From 89e461bad55f7f19c25d9608a32c5e98a44430aa Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Wed, 12 Jul 2023 15:38:53 +0100 Subject: [PATCH] Updates from dependabot (#397) * added dependabot changes --- go.mod | 44 +- go.sum | 104 +- go.work.sum | 25 +- sdk/go.mod | 2 +- sdk/go.sum | 4 +- sdk/vendor/modules.txt | 4 +- test/integration/go.mod | 21 +- test/integration/go.sum | 76 +- .../github.com/docker/distribution/Dockerfile | 4 +- .../distribution/registry/client/errors.go | 2 + .../registry/client/transport/http_reader.go | 1 - .../client_golang/prometheus/counter.go | 37 +- .../client_golang/prometheus/desc.go | 46 +- .../client_golang/prometheus/doc.go | 107 +- .../client_golang/prometheus/gauge.go | 32 +- .../prometheus/go_collector_latest.go | 7 +- .../client_golang/prometheus/histogram.go | 1009 ++++- .../prometheus/internal/almost_equal.go | 60 + .../prometheus/internal/difflib.go | 13 +- .../client_golang/prometheus/labels.go | 75 +- .../client_golang/prometheus/metric.go | 8 +- .../client_golang/prometheus/promhttp/http.go | 19 +- .../prometheus/promhttp/instrument_client.go | 27 +- .../prometheus/promhttp/instrument_server.go | 109 +- .../prometheus/promhttp/option.go | 38 +- .../client_golang/prometheus/registry.go | 51 +- .../client_golang/prometheus/summary.go | 48 +- .../client_golang/prometheus/timer.go | 39 +- .../client_golang/prometheus/value.go | 10 +- .../client_golang/prometheus/vec.go | 79 +- .../client_golang/prometheus/vnext.go | 23 + .../client_golang/prometheus/wrap.go | 8 +- .../prometheus/client_model/go/metrics.pb.go | 1530 +++++--- .../prometheus/common/expfmt/decode.go | 39 +- .../prometheus/common/expfmt/encode.go | 13 +- .../prometheus/common/expfmt/expfmt.go | 26 +- .../prometheus/common/expfmt/fuzz.go | 4 +- .../common/expfmt/openmetrics_create.go | 22 +- .../prometheus/common/expfmt/text_create.go | 3 +- .../prometheus/common/expfmt/text_parse.go | 12 +- .../bitbucket.org/ww/goautoneg/autoneg.go | 22 +- .../prometheus/common/model/time.go | 89 +- .../prometheus/common/model/value.go | 246 +- .../prometheus/common/model/value_float.go | 100 + .../common/model/value_histogram.go | 178 + .../prometheus/common/model/value_type.go | 83 + .../prometheus/procfs/.golangci.yml | 3 + .../prometheus/procfs/Makefile.common | 23 +- .../github.com/prometheus/procfs/README.md | 4 +- .../github.com/prometheus/procfs/arp.go | 6 +- .../github.com/prometheus/procfs/buddyinfo.go | 6 +- .../github.com/prometheus/procfs/cpuinfo.go | 53 +- .../prometheus/procfs/cpuinfo_loong64.go | 19 + .../prometheus/procfs/cpuinfo_others.go | 4 +- .../github.com/prometheus/procfs/crypto.go | 7 +- .../github.com/prometheus/procfs/doc.go | 51 +- .../vendor/github.com/prometheus/procfs/fs.go | 9 +- .../prometheus/procfs/fs_statfs_notype.go | 20 +- .../prometheus/procfs/fs_statfs_type.go | 33 + .../github.com/prometheus/procfs/fscache.go | 6 +- .../prometheus/procfs/internal/util/parse.go | 15 + .../github.com/prometheus/procfs/ipvs.go | 7 +- .../github.com/prometheus/procfs/loadavg.go | 4 +- .../github.com/prometheus/procfs/mdstat.go | 36 +- .../github.com/prometheus/procfs/meminfo.go | 4 +- .../github.com/prometheus/procfs/mountinfo.go | 10 +- .../prometheus/procfs/mountstats.go | 41 +- .../prometheus/procfs/net_conntrackstat.go | 91 +- .../prometheus/procfs/net_ip_socket.go | 32 +- .../prometheus/procfs/net_protocols.go | 4 +- .../github.com/prometheus/procfs/net_route.go | 143 + .../prometheus/procfs/net_sockstat.go | 9 +- .../prometheus/procfs/net_softnet.go | 79 +- .../github.com/prometheus/procfs/net_unix.go | 16 +- .../prometheus/procfs/net_wireless.go | 182 + .../github.com/prometheus/procfs/net_xfrm.go | 2 +- .../github.com/prometheus/procfs/netstat.go | 54 +- .../github.com/prometheus/procfs/proc.go | 37 +- .../prometheus/procfs/proc_cgroup.go | 6 +- .../prometheus/procfs/proc_cgroups.go | 8 +- .../prometheus/procfs/proc_fdinfo.go | 2 +- .../prometheus/procfs/proc_interrupts.go | 98 + .../prometheus/procfs/proc_limits.go | 4 +- .../github.com/prometheus/procfs/proc_maps.go | 8 +- .../prometheus/procfs/proc_netstat.go | 495 +-- .../github.com/prometheus/procfs/proc_ns.go | 6 +- .../github.com/prometheus/procfs/proc_psi.go | 2 +- .../github.com/prometheus/procfs/proc_snmp.go | 322 +- .../prometheus/procfs/proc_snmp6.go | 364 +- .../github.com/prometheus/procfs/proc_stat.go | 12 +- .../prometheus/procfs/proc_status.go | 38 +- .../github.com/prometheus/procfs/proc_sys.go | 2 +- .../github.com/prometheus/procfs/slab.go | 2 +- .../github.com/prometheus/procfs/softirqs.go | 24 +- .../github.com/prometheus/procfs/stat.go | 46 +- .../github.com/prometheus/procfs/swaps.go | 8 +- .../github.com/prometheus/procfs/thread.go | 80 + .../vendor/github.com/prometheus/procfs/vm.go | 6 +- .../github.com/prometheus/procfs/zoneinfo.go | 4 +- .../shirou/gopsutil/v3/common/env.go | 23 + .../shirou/gopsutil/v3/cpu/cpu_darwin.go | 15 +- .../shirou/gopsutil/v3/cpu/cpu_linux.go | 29 +- .../shirou/gopsutil/v3/disk/disk.go | 2 + .../shirou/gopsutil/v3/disk/disk_darwin.go | 3 +- .../shirou/gopsutil/v3/disk/disk_linux.go | 27 +- .../shirou/gopsutil/v3/disk/disk_windows.go | 17 +- .../shirou/gopsutil/v3/host/host.go | 2 + .../shirou/gopsutil/v3/host/host_darwin.go | 3 +- .../shirou/gopsutil/v3/host/host_linux.go | 80 +- .../gopsutil/v3/internal/common/common.go | 55 + .../v3/internal/common/common_linux.go | 30 +- .../gopsutil/v3/internal/common/sleep.go | 3 + .../shirou/gopsutil/v3/mem/mem_darwin.go | 3 +- .../shirou/gopsutil/v3/mem/mem_linux.go | 31 +- .../shirou/gopsutil/v3/net/net_darwin.go | 4 +- .../shirou/gopsutil/v3/net/net_freebsd.go | 2 +- .../shirou/gopsutil/v3/net/net_linux.go | 26 +- .../shirou/gopsutil/v3/net/net_openbsd.go | 2 +- .../shirou/gopsutil/v3/net/net_windows.go | 2 +- .../shirou/gopsutil/v3/process/process.go | 6 +- .../gopsutil/v3/process/process_darwin.go | 5 +- .../gopsutil/v3/process/process_freebsd.go | 8 +- .../gopsutil/v3/process/process_linux.go | 67 +- .../gopsutil/v3/process/process_posix.go | 9 +- .../gopsutil/v3/process/process_solaris.go | 14 +- .../shoenig/go-m1cpu/.golangci.yaml | 12 + .../github.com/shoenig/go-m1cpu/LICENSE | 363 ++ .../github.com/shoenig/go-m1cpu/Makefile | 12 + .../github.com/shoenig/go-m1cpu/README.md | 66 + .../vendor/github.com/shoenig/go-m1cpu/cpu.go | 213 ++ .../shoenig/go-m1cpu/incompatible.go | 53 + .../github.com/yusufpapurcu/wmi/README.md | 7 - .../yusufpapurcu/wmi/swbemservices.go | 1 + .../vendor/github.com/yusufpapurcu/wmi/wmi.go | 13 +- test/integration/vendor/modules.txt | 30 +- test/performance/go.mod | 15 +- test/performance/go.sum | 116 +- .../client_golang/prometheus/counter.go | 37 +- .../client_golang/prometheus/desc.go | 46 +- .../client_golang/prometheus/doc.go | 107 +- .../client_golang/prometheus/gauge.go | 32 +- .../prometheus/go_collector_latest.go | 7 +- .../client_golang/prometheus/histogram.go | 1009 ++++- .../prometheus/internal/almost_equal.go | 60 + .../prometheus/internal/difflib.go | 13 +- .../client_golang/prometheus/labels.go | 75 +- .../client_golang/prometheus/metric.go | 8 +- .../client_golang/prometheus/promauto/auto.go | 170 +- .../client_golang/prometheus/promhttp/http.go | 19 +- .../prometheus/promhttp/instrument_client.go | 27 +- .../prometheus/promhttp/instrument_server.go | 109 +- .../prometheus/promhttp/option.go | 38 +- .../client_golang/prometheus/registry.go | 51 +- .../client_golang/prometheus/summary.go | 48 +- .../client_golang/prometheus/timer.go | 39 +- .../client_golang/prometheus/value.go | 10 +- .../client_golang/prometheus/vec.go | 79 +- .../client_golang/prometheus/vnext.go | 23 + .../client_golang/prometheus/wrap.go | 8 +- .../prometheus/client_model/go/metrics.pb.go | 1530 +++++--- .../prometheus/common/expfmt/decode.go | 39 +- .../prometheus/common/expfmt/encode.go | 13 +- .../prometheus/common/expfmt/expfmt.go | 26 +- .../prometheus/common/expfmt/fuzz.go | 4 +- .../common/expfmt/openmetrics_create.go | 22 +- .../prometheus/common/expfmt/text_create.go | 3 +- .../prometheus/common/expfmt/text_parse.go | 12 +- .../bitbucket.org/ww/goautoneg/autoneg.go | 22 +- .../prometheus/common/model/time.go | 89 +- .../prometheus/common/model/value.go | 246 +- .../prometheus/common/model/value_float.go | 100 + .../common/model/value_histogram.go | 178 + .../prometheus/common/model/value_type.go | 83 + .../prometheus/procfs/.golangci.yml | 3 + .../prometheus/procfs/Makefile.common | 23 +- .../github.com/prometheus/procfs/README.md | 4 +- .../github.com/prometheus/procfs/arp.go | 6 +- .../github.com/prometheus/procfs/buddyinfo.go | 6 +- .../github.com/prometheus/procfs/cpuinfo.go | 53 +- .../prometheus/procfs/cpuinfo_loong64.go | 19 + .../prometheus/procfs/cpuinfo_others.go | 4 +- .../github.com/prometheus/procfs/crypto.go | 7 +- .../github.com/prometheus/procfs/doc.go | 51 +- .../vendor/github.com/prometheus/procfs/fs.go | 9 +- .../prometheus/procfs/fs_statfs_notype.go | 23 + .../prometheus/procfs/fs_statfs_type.go | 33 + .../github.com/prometheus/procfs/fscache.go | 6 +- .../prometheus/procfs/internal/util/parse.go | 15 + .../github.com/prometheus/procfs/ipvs.go | 7 +- .../github.com/prometheus/procfs/loadavg.go | 4 +- .../github.com/prometheus/procfs/mdstat.go | 36 +- .../github.com/prometheus/procfs/meminfo.go | 4 +- .../github.com/prometheus/procfs/mountinfo.go | 10 +- .../prometheus/procfs/mountstats.go | 41 +- .../prometheus/procfs/net_conntrackstat.go | 91 +- .../prometheus/procfs/net_ip_socket.go | 32 +- .../prometheus/procfs/net_protocols.go | 4 +- .../github.com/prometheus/procfs/net_route.go | 143 + .../prometheus/procfs/net_sockstat.go | 9 +- .../prometheus/procfs/net_softnet.go | 79 +- .../github.com/prometheus/procfs/net_unix.go | 16 +- .../prometheus/procfs/net_wireless.go | 182 + .../github.com/prometheus/procfs/net_xfrm.go | 2 +- .../github.com/prometheus/procfs/netstat.go | 54 +- .../github.com/prometheus/procfs/proc.go | 37 +- .../prometheus/procfs/proc_cgroup.go | 6 +- .../prometheus/procfs/proc_cgroups.go | 8 +- .../prometheus/procfs/proc_fdinfo.go | 2 +- .../prometheus/procfs/proc_interrupts.go | 98 + .../prometheus/procfs/proc_limits.go | 4 +- .../github.com/prometheus/procfs/proc_maps.go | 8 +- .../prometheus/procfs/proc_netstat.go | 495 +-- .../github.com/prometheus/procfs/proc_ns.go | 6 +- .../github.com/prometheus/procfs/proc_psi.go | 2 +- .../github.com/prometheus/procfs/proc_snmp.go | 322 +- .../prometheus/procfs/proc_snmp6.go | 364 +- .../github.com/prometheus/procfs/proc_stat.go | 12 +- .../prometheus/procfs/proc_status.go | 38 +- .../github.com/prometheus/procfs/proc_sys.go | 2 +- .../github.com/prometheus/procfs/slab.go | 2 +- .../github.com/prometheus/procfs/softirqs.go | 24 +- .../github.com/prometheus/procfs/stat.go | 46 +- .../github.com/prometheus/procfs/swaps.go | 8 +- .../github.com/prometheus/procfs/thread.go | 80 + .../vendor/github.com/prometheus/procfs/vm.go | 6 +- .../github.com/prometheus/procfs/zoneinfo.go | 4 +- .../shirou/gopsutil/v3/common/env.go | 23 + .../shirou/gopsutil/v3/cpu/cpu_darwin.go | 15 +- .../shirou/gopsutil/v3/cpu/cpu_linux.go | 29 +- .../shirou/gopsutil/v3/disk/disk.go | 2 + .../shirou/gopsutil/v3/disk/disk_darwin.go | 3 +- .../shirou/gopsutil/v3/disk/disk_linux.go | 27 +- .../shirou/gopsutil/v3/disk/disk_windows.go | 17 +- .../shirou/gopsutil/v3/host/host.go | 2 + .../shirou/gopsutil/v3/host/host_darwin.go | 3 +- .../shirou/gopsutil/v3/host/host_linux.go | 80 +- .../gopsutil/v3/internal/common/common.go | 55 + .../v3/internal/common/common_linux.go | 30 +- .../gopsutil/v3/internal/common/sleep.go | 3 + .../shirou/gopsutil/v3/load/load_linux.go | 18 +- .../shirou/gopsutil/v3/mem/mem_darwin.go | 3 +- .../shirou/gopsutil/v3/mem/mem_linux.go | 31 +- .../shirou/gopsutil/v3/net/net_darwin.go | 4 +- .../shirou/gopsutil/v3/net/net_freebsd.go | 2 +- .../shirou/gopsutil/v3/net/net_linux.go | 26 +- .../shirou/gopsutil/v3/net/net_openbsd.go | 2 +- .../shirou/gopsutil/v3/net/net_windows.go | 2 +- .../shirou/gopsutil/v3/process/process.go | 6 +- .../gopsutil/v3/process/process_darwin.go | 5 +- .../gopsutil/v3/process/process_freebsd.go | 8 +- .../gopsutil/v3/process/process_linux.go | 67 +- .../gopsutil/v3/process/process_posix.go | 9 +- .../gopsutil/v3/process/process_solaris.go | 14 +- .../shoenig/go-m1cpu/.golangci.yaml | 12 + .../github.com/shoenig/go-m1cpu/LICENSE | 363 ++ .../github.com/shoenig/go-m1cpu/Makefile | 12 + .../github.com/shoenig/go-m1cpu/README.md | 66 + .../vendor/github.com/shoenig/go-m1cpu/cpu.go | 213 ++ .../shoenig/go-m1cpu/incompatible.go | 53 + .../github.com/yusufpapurcu/wmi/README.md | 7 - .../yusufpapurcu/wmi/swbemservices.go | 1 + .../vendor/github.com/yusufpapurcu/wmi/wmi.go | 13 +- test/performance/vendor/modules.txt | 26 +- .../bufbuild/buf/private/buf/bufcli/bufcli.go | 240 +- .../bufbuild/buf/private/buf/bufcli/errors.go | 22 +- .../buf/private/buf/bufcurl/invoker.go | 41 +- .../private/buf/buffetch/internal/errors.go | 8 + .../buf/buffetch/internal/proto_file_ref.go | 9 +- .../buf/buffetch/internal/ref_parser.go | 4 +- .../buf/private/buf/bufformat/formatter.go | 70 +- .../buf/private/buf/bufprint/bufprint.go | 49 +- .../private/buf/bufprint/plugin_printer.go | 105 - .../buf/bufprint/plugin_version_printer.go | 101 - .../private/buf/bufprint/template_printer.go | 103 - .../buf/bufprint/template_version_printer.go | 105 - .../buf/private/buf/bufsync/bufsync.go | 173 + .../buf/private/buf/bufsync/module_commit.go | 65 + .../private/buf/bufsync/syncable_module.go | 55 + .../buf/private/buf/bufsync/syncer.go | 234 ++ .../filelock => buf/bufsync}/usage.gen.go | 2 +- .../buf/private/buf/bufwire/bufwire.go | 20 +- .../buf/private/buf/bufwire/file_lister.go | 4 +- .../buf/bufwire/image_config_reader.go | 85 +- .../buf/private/buf/bufwire/module_config.go | 16 +- .../buf/bufwire/module_config_reader.go | 187 +- .../bufwire/module_config_set.go} | 24 +- .../buf/bufwire/proto_encoding_writer.go | 2 +- .../buf/private/buf/bufwork/bufwork.go | 16 +- .../private/buf/bufwork/workspace_builder.go | 45 +- .../bufbuild/buf/private/buf/cmd/buf/buf.go | 82 +- .../alpha/package/goversion/goversion.go | 124 + .../package/goversion}/usage.gen.go | 2 +- .../package/mavenversion/mavenversion.go | 124 + .../mavenversion}/usage.gen.go | 2 +- .../alpha/package/npmversion/npmversion.go | 124 + .../package/npmversion}/usage.gen.go | 2 +- .../package/swiftversion/swiftversion.go | 124 + .../package/swiftversion}/usage.gen.go | 2 +- .../alpha/plugin/plugindelete/plugindelete.go | 101 - .../cmd/buf/command/alpha/protoc/protoc.go | 14 +- .../command/alpha/repo/reposync/reposync.go | 448 +++ .../command/alpha/repo/reposync/usage.gen.go | 19 + .../buf/cmd/buf/command/beta/graph/graph.go | 186 + .../cmd/buf/command/beta/graph/usage.gen.go | 19 + .../buf/cmd/buf/command/beta/price/price.go | 11 +- .../plugin/plugincreate/plugincreate.go | 141 - .../plugin/plugindelete/plugindelete.go | 65 +- .../registry/plugin/pluginlist/pluginlist.go | 131 - .../registry}/plugin/pluginpush/pluginpush.go | 14 +- .../registry}/plugin/pluginpush/usage.gen.go | 0 .../pluginversionlist/pluginversionlist.go | 131 - .../template/templatecreate/templatecreate.go | 155 - .../template/templatedelete/templatedelete.go | 110 - .../template/templatedelete/usage.gen.go | 19 - .../template/templatelist/templatelist.go | 131 - .../templateversioncreate.go | 131 - .../templateversioncreate/usage.gen.go | 19 - .../templateversionlist.go | 131 - .../templateversionlist/usage.gen.go | 19 - .../buf/cmd/buf/command/beta/stats/stats.go | 3 +- .../command/beta/studioagent/studioagent.go | 2 +- .../private/buf/cmd/buf/command/curl/curl.go | 24 +- .../buf/cmd/buf/command/export/export.go | 10 +- .../buf/cmd/buf/command/format/format.go | 19 +- .../cmd/buf/command/mod/modprune/modprune.go | 34 +- .../buf/command/mod/modupdate/modupdate.go | 43 +- .../private/buf/cmd/buf/command/push/push.go | 139 +- .../private/bufpkg/bufanalysis/bufanalysis.go | 26 +- .../buf/private/bufpkg/bufanalysis/print.go | 51 + .../bufpkg/bufapimodule/bufapimodule.go | 7 - .../bufpkg/bufapimodule/module_reader.go | 55 +- .../bufpkg/bufapimodule/module_resolver.go | 2 +- .../private/bufpkg/bufconnect/bufconnect.go | 3 + .../private/bufpkg/bufconnect/interceptors.go | 46 +- .../buf/private/bufpkg/bufgraph/bufgraph.go | 88 + .../buf/private/bufpkg/bufgraph/builder.go | 226 ++ .../buf/private/bufpkg/bufgraph/usage.gen.go | 19 + .../buf/private/bufpkg/bufimage/bufimage.go | 95 + .../bufimage/bufimagebuild/bufimagebuild.go | 29 +- .../bufpkg/bufimage/bufimagebuild/builder.go | 190 +- .../bufimage/bufimageutil/bufimageutil.go | 145 +- .../bufimageutil/source_paths_remap.go | 145 + .../bufpkg/bufimage/bufimageutil/tags.go | 39 + .../buf/private/bufpkg/bufimage/image.go | 12 + .../bufimage/image_module_dependency.go | 61 + .../buf/private/bufpkg/bufimage/util.go | 67 + .../buf/private/bufpkg/buflock/buflock.go | 13 +- .../buf/private/bufpkg/bufmodule/bufmodule.go | 48 +- .../bufmodulebuild/bufmodulebuild.go | 33 +- .../bufmodulebuild/module_bucket_builder.go | 52 +- .../bufmodulebuild/module_file_set_builder.go | 90 +- .../bufmodulecache/bufmodulecache.go | 43 +- .../bufmodulecache/cas_module_cacher.go | 12 +- .../bufmodulecache/cas_module_reader.go | 3 +- .../bufmodule/bufmodulecache/module_cacher.go | 173 - .../bufmodule/bufmodulecache/module_reader.go | 142 - .../bufpkg/bufmodule/bufmodulecache/util.go | 7 - .../bufmoduleprotocompile.go | 9 +- .../bufmoduleprotocompile/path_resolver.go | 13 +- .../bufmodule/bufmoduleref/bufmoduleref.go | 9 +- .../buf/private/bufpkg/bufmodule/module.go | 74 +- .../bufpkg/bufmodule/module_file_set.go | 8 +- .../bufpkg/bufmodule/targeting_module.go | 8 +- .../buf/private/bufpkg/bufmodule/workspace.go | 28 +- .../buf/private/bufpkg/bufplugin/bufplugin.go | 18 +- .../bufpluginconfig/bufpluginconfig.go | 4 + .../bufplugin/bufpluginconfig/config.go | 9 +- .../bufplugin/bufplugindocker/docker.go | 6 - .../bufplugin/bufpluginref/bufpluginref.go | 15 + .../bufpkg/bufremoteplugin/bufremoteplugin.go | 209 -- .../bufpkg/buftransport/buftransport.go | 27 - .../registryv1alpha1connect/admin.connect.go | 67 +- .../registryv1alpha1connect/authz.connect.go | 76 - .../display.connect.go | 222 -- .../registryv1alpha1connect/labels.connect.go | 6 +- .../organization.connect.go | 69 +- .../registryv1alpha1connect/plugin.connect.go | 206 +- .../plugin_curation.connect.go | 12 +- .../registryv1alpha1connect/push.connect.go | 14 +- .../recommendation.connect.go | 6 +- .../reference.connect.go | 34 +- .../repository.connect.go | 18 +- .../repository_branch.connect.go | 121 + .../repository_commit.connect.go | 6 +- .../repository_tag.connect.go | 6 +- .../resolve.connect.go | 118 +- .../scim_token.connect.go | 6 +- .../studio_request.connect.go | 6 +- .../registryv1alpha1connect/sync.connect.go | 148 + .../registryv1alpha1connect/token.connect.go | 6 +- .../registryv1alpha1connect/user.connect.go | 18 +- .../webhook.connect.go | 12 +- .../buf/alpha/registry/v1alpha1/admin.pb.go | 790 +++- .../buf/alpha/registry/v1alpha1/authz.pb.go | 840 ++--- .../buf/alpha/registry/v1alpha1/display.pb.go | 1428 ++------ .../go/buf/alpha/registry/v1alpha1/doc.pb.go | 31 +- .../registry/v1alpha1/git_metadata.pb.go | 319 ++ .../buf/alpha/registry/v1alpha1/labels.pb.go | 86 +- .../registry/v1alpha1/organization.pb.go | 1069 +++--- .../buf/alpha/registry/v1alpha1/plugin.pb.go | 3255 +++++------------ .../registry/v1alpha1/plugin_curation.pb.go | 779 ++-- .../go/buf/alpha/registry/v1alpha1/push.pb.go | 61 +- .../registry/v1alpha1/recommendation.pb.go | 44 +- .../alpha/registry/v1alpha1/reference.pb.go | 293 +- .../alpha/registry/v1alpha1/repository.pb.go | 39 +- .../registry/v1alpha1/repository_branch.pb.go | 410 +++ .../registry/v1alpha1/repository_commit.pb.go | 45 +- .../registry/v1alpha1/repository_tag.pb.go | 62 +- .../buf/alpha/registry/v1alpha1/resolve.pb.go | 892 ++++- .../alpha/registry/v1alpha1/scim_token.pb.go | 54 +- .../registry/v1alpha1/studio_request.pb.go | 62 +- .../go/buf/alpha/registry/v1alpha1/sync.pb.go | 633 ++++ .../buf/alpha/registry/v1alpha1/token.pb.go | 42 +- .../go/buf/alpha/registry/v1alpha1/user.pb.go | 174 +- .../buf/alpha/registry/v1alpha1/webhook.pb.go | 69 +- .../go/grpc/reflection/v1/reflection.pb.go | 63 + .../bufbuild/buf/private/pkg/app/app.go | 6 + .../buf/private/pkg/app/appflag/builder.go | 2 +- .../bufbuild/buf/private/pkg/dag/dag.go | 450 +++ .../bufbuild/buf/private/pkg/dag/usage.gen.go | 19 + .../buf/private/pkg/filelock/filelock.go | 95 - .../bufbuild/buf/private/pkg/filelock/lock.go | 93 - .../buf/private/pkg/filelock/locker.go | 76 - .../buf/private/pkg/git/annotated_tag.go | 75 + .../bufbuild/buf/private/pkg/git/commit.go | 91 + .../bufbuild/buf/private/pkg/git/git.go | 184 + .../bufbuild/buf/private/pkg/git/hash.go | 66 + .../bufbuild/buf/private/pkg/git/ident.go | 87 + .../buf/private/pkg/git/object_reader.go | 170 + .../buf/private/pkg/git/packed_refs.go | 106 + .../buf/private/pkg/git/repository.go | 325 ++ .../bufbuild/buf/private/pkg/git/tree.go | 115 + .../bufbuild/buf/private/pkg/git/tree_node.go | 86 + .../buf/private/pkg/manifest/manifest.go | 6 + .../buf/private/pkg/manifest/module.go | 19 +- .../pkg/observabilityzap/zapexporter.go | 2 +- .../pkg/protoencoding/json_marshaler.go | 35 +- .../pkg/protoencoding/protoencoding.go | 36 +- .../buf/private/pkg/protosource/file.go | 25 +- .../private/pkg/protosource/location_store.go | 63 +- .../option_extension_descriptor.go | 60 +- .../buf/private/pkg/protosource/paths.go | 41 + .../private/pkg/protosource/protosource.go | 17 + .../private/pkg/storage/storagegit/bucket.go | 210 ++ .../buf/private/pkg/storage/storagegit/doc.go | 16 + .../pkg/storage/storagegit/provider.go | 58 + .../pkg/storage/storagegit/storagegit.go | 60 + .../pkg/storage/storagegit/usage.gen.go | 19 + .../pkg/storage/storagemem/storagemem.go | 40 +- .../pkg/storage/storageos/storageos.go | 2 +- .../bufbuild/buf/private/pkg/thread/thread.go | 4 +- .../transport/http/httpserver/httpserver.go | 10 +- .../bufbuild/connect-go/.golangci.yml | 17 + .../github.com/bufbuild/connect-go/Makefile | 12 +- .../github.com/bufbuild/connect-go/client.go | 17 +- .../github.com/bufbuild/connect-go/connect.go | 41 +- .../bufbuild/connect-go/duplex_http_call.go | 5 + .../github.com/bufbuild/connect-go/error.go | 11 +- .../github.com/bufbuild/connect-go/handler.go | 6 + .../github.com/bufbuild/connect-go/header.go | 2 +- .../bufbuild/connect-go/maxbytes.go | 32 - .../bufbuild/connect-go/protocol.go | 35 +- .../bufbuild/connect-go/protocol_connect.go | 18 +- .../bufbuild/connect-go/protocol_grpc.go | 6 +- .../connect-opentelemetry-go/.gitignore | 4 + .../connect-opentelemetry-go/.golangci.yml | 67 + .../bufbuild/connect-opentelemetry-go/LICENSE | 201 + .../connect-opentelemetry-go/Makefile | 98 + .../connect-opentelemetry-go/README.md | 139 + .../connect-opentelemetry-go/attributes.go | 137 + .../connect-opentelemetry-go/buf.gen.yaml | 12 + .../connect-opentelemetry-go/buf.work.yaml | 3 + .../bufbuild/connect-opentelemetry-go/doc.go | 22 + .../connect-opentelemetry-go/instruments.go | 94 + .../connect-opentelemetry-go/interceptor.go | 347 ++ .../connect-opentelemetry-go/option.go | 195 + .../connect-opentelemetry-go/otelconnect.go | 58 + .../payloadinterceptor.go | 116 + .../connect-opentelemetry-go/streaming.go | 137 + .../stargz-snapshotter/estargz/LICENSE | 202 + .../stargz-snapshotter/estargz/build.go | 690 ++++ .../estargz/errorutil/errors.go | 40 + .../stargz-snapshotter/estargz/estargz.go | 1223 +++++++ .../stargz-snapshotter/estargz/gzip.go | 237 ++ .../stargz-snapshotter/estargz/testutil.go | 2366 ++++++++++++ .../stargz-snapshotter/estargz/types.go | 342 ++ .../docker/cli/cli/config/configfile/file.go | 1 - vendor/github.com/docker/docker/AUTHORS | 18 + vendor/github.com/docker/docker/api/common.go | 2 +- .../github.com/docker/docker/api/swagger.yaml | 99 +- .../docker/docker/api/types/auth.go | 25 +- .../docker/docker/api/types/client.go | 3 +- .../container/change_response_deprecated.go | 6 + .../docker/api/types/container/change_type.go | 15 + .../api/types/container/change_types.go | 23 + .../api/types/container/container_changes.go | 20 - .../docker/api/types/container/deprecated.go | 16 - .../api/types/container/filesystem_change.go | 19 + .../{host_config.go => hostconfig.go} | 129 +- .../docker/docker/api/types/deprecated.go | 14 - .../docker/docker/api/types/filters/errors.go | 37 + .../docker/docker/api/types/filters/parse.go | 51 +- .../docker/docker/api/types/image/opts.go | 9 + .../docker/docker/api/types/image_summary.go | 13 +- .../docker/api/types/registry/authconfig.go | 99 + .../docker/docker/api/types/time/timestamp.go | 40 +- .../docker/docker/api/types/types.go | 34 +- .../docker/api/types/volume/deprecated.go | 11 - .../docker/docker/client/build_prune.go | 10 +- .../github.com/docker/docker/client/client.go | 23 +- .../docker/docker/client/client_unix.go | 7 +- .../docker/docker/client/client_windows.go | 3 - .../docker/docker/client/container_diff.go | 4 +- .../docker/client/distribution_inspect.go | 8 +- .../github.com/docker/docker/client/errors.go | 25 - .../docker/docker/client/image_create.go | 3 +- .../docker/docker/client/image_push.go | 3 +- .../docker/docker/client/image_search.go | 2 +- .../docker/docker/client/interface.go | 6 +- .../github.com/docker/docker/client/login.go | 3 +- .../github.com/docker/docker/client/ping.go | 6 +- .../docker/docker/client/plugin_install.go | 7 +- .../docker/docker/client/plugin_push.go | 4 +- .../docker/docker/client/plugin_upgrade.go | 3 +- .../docker/docker/client/service_create.go | 3 +- .../docker/docker/client/service_update.go | 3 +- .../docker/docker/client/volume_list.go | 6 +- .../docker/pkg/homedir/homedir_linux.go | 9 +- .../docker/pkg/jsonmessage/jsonmessage.go | 92 +- .../docker/docker/pkg/stringid/README.md | 1 - .../docker/docker/pkg/stringid/stringid.go | 22 +- .../evilmartians/lefthook/.golangci.yml | 1 - .../evilmartians/lefthook/.goreleaser.yml | 10 + .../evilmartians/lefthook/CHANGELOG.md | 30 +- .../evilmartians/lefthook/CONTRIBUTING.md | 2 +- .../github.com/evilmartians/lefthook/Makefile | 9 + .../evilmartians/lefthook/README.md | 2 +- .../evilmartians/lefthook/cmd/dump.go | 31 + .../evilmartians/lefthook/cmd/lefthook.go | 12 +- .../evilmartians/lefthook/cmd/root.go | 1 + .../lefthook/internal/config/command.go | 24 +- .../lefthook/internal/config/config.go | 94 +- .../lefthook/internal/config/hook.go | 20 +- .../lefthook/internal/config/load.go | 3 +- .../lefthook/internal/config/remote.go | 12 +- .../lefthook/internal/config/script.go | 16 +- .../lefthook/internal/lefthook/dump.go | 30 + .../lefthook/internal/lefthook/install.go | 48 +- .../lefthook/internal/lefthook/run.go | 6 +- .../internal/lefthook/runner/execute_unix.go | 2 +- .../lefthook/runner/prepare_command.go | 31 +- .../internal/lefthook/runner/runner.go | 57 +- .../evilmartians/lefthook/internal/log/log.go | 84 +- .../lefthook/internal/log/skip_settings.go | 9 +- .../lefthook/internal/version/version.go | 2 +- .../github.com/evilmartians/lefthook/main.go | 8 +- .../internal/estargz/estargz.go | 54 + .../pkg/authn/keychain.go | 71 +- .../go-containerregistry/pkg/name/registry.go | 6 + .../pkg/v1/empty/README.md | 8 + .../go-containerregistry/pkg/v1/empty/doc.go} | 11 +- .../pkg/v1/empty/image.go | 52 + .../pkg/v1/empty/index.go | 65 + .../pkg/v1/mutate/README.md | 56 + .../go-containerregistry/pkg/v1/mutate/doc.go | 16 + .../pkg/v1/mutate/image.go | 293 ++ .../pkg/v1/mutate/index.go | 232 ++ .../pkg/v1/mutate/mutate.go | 553 +++ .../pkg/v1/mutate/rebase.go | 144 + .../pkg/v1/partial/index.go | 80 + .../pkg/v1/remote/catalog.go | 131 +- .../pkg/v1/remote/delete.go | 37 +- .../pkg/v1/remote/descriptor.go | 393 +- .../pkg/v1/remote/fetcher.go | 311 ++ .../pkg/v1/remote/image.go | 35 +- .../pkg/v1/remote/index.go | 60 +- .../pkg/v1/remote/layer.go | 37 +- .../pkg/v1/remote/list.go | 123 +- .../pkg/v1/remote/multi_write.go | 282 +- .../pkg/v1/remote/options.go | 75 +- .../pkg/v1/remote/progress.go | 7 + .../pkg/v1/remote/puller.go | 222 ++ .../pkg/v1/remote/pusher.go | 559 +++ .../pkg/v1/remote/referrers.go | 90 +- .../pkg/v1/remote/schema1.go | 118 + .../pkg/v1/remote/transport/error.go | 27 +- .../pkg/v1/remote/transport/retry.go | 2 +- .../pkg/v1/remote/write.go | 485 +-- .../pkg/v1/stream/layer.go | 2 + .../pkg/v1/tarball/README.md | 280 ++ .../pkg/v1/tarball/doc.go} | 12 +- .../pkg/v1/tarball/image.go | 429 +++ .../pkg/v1/tarball/layer.go | 354 ++ .../pkg/v1/tarball/write.go | 457 +++ .../pkg/v1/types/types.go | 16 + .../client_golang/prometheus/counter.go | 37 +- .../client_golang/prometheus/desc.go | 46 +- .../client_golang/prometheus/doc.go | 107 +- .../client_golang/prometheus/gauge.go | 32 +- .../prometheus/go_collector_latest.go | 7 +- .../client_golang/prometheus/histogram.go | 1009 ++++- .../prometheus/internal/almost_equal.go | 60 + .../prometheus/internal/difflib.go | 13 +- .../client_golang/prometheus/labels.go | 75 +- .../client_golang/prometheus/metric.go | 8 +- .../client_golang/prometheus/promhttp/http.go | 19 +- .../prometheus/promhttp/instrument_client.go | 27 +- .../prometheus/promhttp/instrument_server.go | 109 +- .../prometheus/promhttp/option.go | 38 +- .../client_golang/prometheus/registry.go | 51 +- .../client_golang/prometheus/summary.go | 48 +- .../prometheus/testutil/promlint/promlint.go | 20 +- .../client_golang/prometheus/timer.go | 39 +- .../client_golang/prometheus/value.go | 10 +- .../client_golang/prometheus/vec.go | 79 +- .../client_golang/prometheus/vnext.go | 23 + .../client_golang/prometheus/wrap.go | 8 +- .../prometheus/client_model/go/metrics.pb.go | 1530 +++++--- .../prometheus/common/expfmt/decode.go | 39 +- .../prometheus/common/expfmt/encode.go | 13 +- .../prometheus/common/expfmt/expfmt.go | 26 +- .../prometheus/common/expfmt/fuzz.go | 4 +- .../common/expfmt/openmetrics_create.go | 22 +- .../prometheus/common/expfmt/text_create.go | 3 +- .../prometheus/common/expfmt/text_parse.go | 12 +- .../bitbucket.org/ww/goautoneg/autoneg.go | 22 +- .../prometheus/common/model/time.go | 89 +- .../prometheus/common/model/value.go | 246 +- .../prometheus/common/model/value_float.go | 100 + .../common/model/value_histogram.go | 178 + .../prometheus/common/model/value_type.go | 83 + .../prometheus/procfs/.golangci.yml | 3 + .../prometheus/procfs/Makefile.common | 23 +- vendor/github.com/prometheus/procfs/README.md | 4 +- vendor/github.com/prometheus/procfs/arp.go | 6 +- .../github.com/prometheus/procfs/buddyinfo.go | 6 +- .../github.com/prometheus/procfs/cpuinfo.go | 53 +- .../prometheus/procfs/cpuinfo_loong64.go | 19 + .../prometheus/procfs/cpuinfo_others.go | 4 +- vendor/github.com/prometheus/procfs/crypto.go | 7 +- vendor/github.com/prometheus/procfs/doc.go | 51 +- vendor/github.com/prometheus/procfs/fs.go | 9 +- .../prometheus/procfs/fs_statfs_notype.go | 23 + .../prometheus/procfs/fs_statfs_type.go | 33 + .../github.com/prometheus/procfs/fscache.go | 6 +- .../prometheus/procfs/internal/util/parse.go | 15 + vendor/github.com/prometheus/procfs/ipvs.go | 7 +- .../github.com/prometheus/procfs/loadavg.go | 4 +- vendor/github.com/prometheus/procfs/mdstat.go | 36 +- .../github.com/prometheus/procfs/meminfo.go | 4 +- .../github.com/prometheus/procfs/mountinfo.go | 10 +- .../prometheus/procfs/mountstats.go | 41 +- .../prometheus/procfs/net_conntrackstat.go | 91 +- .../prometheus/procfs/net_ip_socket.go | 32 +- .../prometheus/procfs/net_protocols.go | 4 +- .../github.com/prometheus/procfs/net_route.go | 143 + .../prometheus/procfs/net_sockstat.go | 9 +- .../prometheus/procfs/net_softnet.go | 79 +- .../github.com/prometheus/procfs/net_unix.go | 16 +- .../prometheus/procfs/net_wireless.go | 182 + .../github.com/prometheus/procfs/net_xfrm.go | 2 +- .../github.com/prometheus/procfs/netstat.go | 54 +- vendor/github.com/prometheus/procfs/proc.go | 37 +- .../prometheus/procfs/proc_cgroup.go | 6 +- .../prometheus/procfs/proc_cgroups.go | 8 +- .../prometheus/procfs/proc_fdinfo.go | 2 +- .../prometheus/procfs/proc_interrupts.go | 98 + .../prometheus/procfs/proc_limits.go | 4 +- .../github.com/prometheus/procfs/proc_maps.go | 8 +- .../prometheus/procfs/proc_netstat.go | 495 +-- .../github.com/prometheus/procfs/proc_ns.go | 6 +- .../github.com/prometheus/procfs/proc_psi.go | 2 +- .../github.com/prometheus/procfs/proc_snmp.go | 322 +- .../prometheus/procfs/proc_snmp6.go | 364 +- .../github.com/prometheus/procfs/proc_stat.go | 12 +- .../prometheus/procfs/proc_status.go | 38 +- .../github.com/prometheus/procfs/proc_sys.go | 2 +- vendor/github.com/prometheus/procfs/slab.go | 2 +- .../github.com/prometheus/procfs/softirqs.go | 24 +- vendor/github.com/prometheus/procfs/stat.go | 46 +- vendor/github.com/prometheus/procfs/swaps.go | 8 +- vendor/github.com/prometheus/procfs/thread.go | 80 + vendor/github.com/prometheus/procfs/vm.go | 6 +- .../github.com/prometheus/procfs/zoneinfo.go | 4 +- .../rogpeppe/go-internal/fmtsort/mapelem.go | 3 - .../go-internal/fmtsort/mapelem_1.11.go | 24 - .../rogpeppe/go-internal/fmtsort/sort.go | 25 +- .../shirou/gopsutil/v3/common/env.go | 23 + .../shirou/gopsutil/v3/cpu/cpu_darwin.go | 15 +- .../shirou/gopsutil/v3/cpu/cpu_linux.go | 29 +- .../shirou/gopsutil/v3/disk/disk.go | 2 + .../shirou/gopsutil/v3/disk/disk_darwin.go | 3 +- .../shirou/gopsutil/v3/disk/disk_linux.go | 27 +- .../shirou/gopsutil/v3/disk/disk_windows.go | 17 +- .../shirou/gopsutil/v3/host/host.go | 2 + .../shirou/gopsutil/v3/host/host_darwin.go | 3 +- .../shirou/gopsutil/v3/host/host_linux.go | 80 +- .../gopsutil/v3/internal/common/common.go | 55 + .../v3/internal/common/common_linux.go | 30 +- .../gopsutil/v3/internal/common/sleep.go | 3 + .../shirou/gopsutil/v3/load/load_linux.go | 18 +- .../shirou/gopsutil/v3/mem/mem_darwin.go | 3 +- .../shirou/gopsutil/v3/mem/mem_linux.go | 31 +- .../shirou/gopsutil/v3/net/net_darwin.go | 4 +- .../shirou/gopsutil/v3/net/net_freebsd.go | 2 +- .../shirou/gopsutil/v3/net/net_linux.go | 26 +- .../shirou/gopsutil/v3/net/net_openbsd.go | 2 +- .../shirou/gopsutil/v3/net/net_windows.go | 2 +- .../shirou/gopsutil/v3/process/process.go | 6 +- .../gopsutil/v3/process/process_darwin.go | 5 +- .../gopsutil/v3/process/process_freebsd.go | 8 +- .../gopsutil/v3/process/process_linux.go | 67 +- .../gopsutil/v3/process/process_posix.go | 9 +- .../gopsutil/v3/process/process_solaris.go | 14 +- .../shoenig/go-m1cpu/.golangci.yaml | 12 + vendor/github.com/shoenig/go-m1cpu/LICENSE | 363 ++ vendor/github.com/shoenig/go-m1cpu/Makefile | 12 + vendor/github.com/shoenig/go-m1cpu/README.md | 66 + vendor/github.com/shoenig/go-m1cpu/cpu.go | 213 ++ .../shoenig/go-m1cpu/incompatible.go | 53 + vendor/github.com/tetratelabs/wazero/Makefile | 26 +- .../github.com/tetratelabs/wazero/builder.go | 2 +- .../github.com/tetratelabs/wazero/config.go | 16 +- .../wazero/examples/basic/testdata/add.wasm | Bin 6039 -> 6093 bytes .../wazero/experimental/experimental.go | 29 +- .../wazero/experimental/gojs/README.md | 4 +- .../wazero/experimental/listener.go | 328 +- .../github.com/tetratelabs/wazero/fsconfig.go | 9 +- .../imports/wasi_snapshot_preview1/fs.go | 651 ++-- .../imports/wasi_snapshot_preview1/poll.go | 32 +- .../imports/wasi_snapshot_preview1/sock.go | 156 +- .../testdata/cargo-wasi/wasi.rs | 38 +- .../testdata/cargo-wasi/wasi.wasm | Bin 97804 -> 94484 bytes .../testdata/gotip/wasi.go | 162 + .../testdata/zig-cc/wasi.c | 120 +- .../testdata/zig-cc/wasi.wasm | Bin 51342 -> 62102 bytes .../wazero/internal/asm/amd64/impl.go | 694 ++-- .../internal/asm/amd64/impl_staticconst.go | 56 +- .../wazero/internal/asm/arm64/consts.go | 4 + .../wazero/internal/asm/arm64/impl.go | 1127 +++--- .../wazero/internal/asm/assembler.go | 14 +- .../tetratelabs/wazero/internal/asm/buffer.go | 235 ++ .../wazero/internal/bitpack/offset_array.go | 224 ++ .../internal/engine/compiler/RATIONALE.md | 35 + .../wazero/internal/engine/compiler/arch.go | 3 +- .../internal/engine/compiler/compiler.go | 4 +- .../wazero/internal/engine/compiler/engine.go | 310 +- .../internal/engine/compiler/engine_cache.go | 19 +- .../internal/engine/compiler/impl_amd64.go | 402 +- .../internal/engine/compiler/impl_arm64.go | 190 +- .../engine/interpreter/interpreter.go | 159 +- .../wazero/internal/fsapi/constants.go | 13 + .../wazero/internal/fsapi/constants_js.go | 8 + .../wazero/internal/fsapi/constants_sun.go | 12 + .../internal/fsapi/constants_windows.go | 24 + .../tetratelabs/wazero/internal/fsapi/dir.go | 99 + .../tetratelabs/wazero/internal/fsapi/file.go | 382 ++ .../tetratelabs/wazero/internal/fsapi/fs.go | 365 ++ .../internal/{platform => fsapi}/stat.go | 58 +- .../wazero/internal/fsapi/unimplemented.go | 205 ++ .../tetratelabs/wazero/internal/gojs/fs.go | 110 +- .../wazero/internal/gojs/runtime.go | 18 +- .../wazero/internal/platform/chown_unix.go | 9 - .../wazero/internal/platform/dir.go | 138 - .../wazero/internal/platform/errno_windows.go | 8 +- .../wazero/internal/platform/error.go | 2 +- .../wazero/internal/platform/file.go | 50 - .../wazero/internal/platform/mmap_linux.go | 76 + .../wazero/internal/platform/mmap_other.go | 18 + .../platform/{mmap.go => mmap_unix.go} | 42 +- .../wazero/internal/platform/mmap_windows.go | 6 +- .../wazero/internal/platform/mremap_other.go | 23 + .../wazero/internal/platform/mremap_unix.go | 21 + .../wazero/internal/platform/open_file.go | 23 - .../wazero/internal/platform/open_file_js.go | 19 - .../wazero/internal/platform/open_file_sun.go | 20 - .../wazero/internal/platform/platform.go | 43 +- .../wazero/internal/platform/rename.go | 12 - .../internal/platform/select_unsupported.go | 12 - .../internal/platform/stat_unsupported.go | 39 - .../wazero/internal/platform/sync.go | 14 - .../wazero/internal/platform/sync_linux.go | 20 - .../internal/platform/sync_unsupported.go | 16 - .../wazero/internal/platform/time_cgo.go | 1 - .../wazero/internal/platform/unlink.go | 13 - .../wazero/internal/platform/wrap_windows.go | 132 - .../tetratelabs/wazero/internal/sock/sock.go | 88 + .../tetratelabs/wazero/internal/sys/fs.go | 680 ++-- .../tetratelabs/wazero/internal/sys/lazy.go | 136 + .../tetratelabs/wazero/internal/sys/stdio.go | 121 + .../tetratelabs/wazero/internal/sys/sys.go | 30 +- .../wazero/internal/sysfs/adapter.go | 76 +- .../internal/{platform => sysfs}/chown.go | 21 +- .../wazero/internal/sysfs/chown_unix.go | 13 + .../{platform => sysfs}/chown_unsupported.go | 2 +- .../wazero/internal/sysfs/datasync_linux.go | 14 + .../internal/sysfs/datasync_unsupported.go | 13 + .../tetratelabs/wazero/internal/sysfs/dir.go | 26 + .../wazero/internal/sysfs/dirfs.go | 62 +- .../tetratelabs/wazero/internal/sysfs/file.go | 434 +++ .../wazero/internal/sysfs/file_test.go | 1061 ++++++ .../wazero/internal/sysfs/file_unix.go | 21 + .../wazero/internal/sysfs/file_unsupported.go | 12 + .../internal/{platform => sysfs}/futimens.go | 36 +- .../{platform => sysfs}/futimens_darwin.go | 2 +- .../{platform => sysfs}/futimens_darwin.s | 0 .../{platform => sysfs}/futimens_linux.go | 2 +- .../futimens_unsupported.go | 2 +- .../{platform => sysfs}/futimens_windows.go | 6 +- .../wazero/internal/sysfs/nonblock_unix.go | 9 + .../wazero/internal/sysfs/nonblock_windows.go | 9 + .../wazero/internal/sysfs/open_file.go | 26 + .../wazero/internal/sysfs/open_file_js.go | 19 + .../wazero/internal/sysfs/open_file_sun.go | 21 + .../{platform => sysfs}/open_file_windows.go | 95 +- .../wazero/internal/sysfs/osfile.go | 268 ++ .../wazero/internal/sysfs/readfs.go | 247 +- .../wazero/internal/sysfs/rename.go | 16 + .../{platform => sysfs}/rename_windows.go | 14 +- .../wazero/internal/sysfs/rootfs.go | 275 +- .../internal/{platform => sysfs}/select.go | 13 +- .../{platform => sysfs}/select_darwin.go | 6 +- .../{platform => sysfs}/select_darwin.s | 0 .../{platform => sysfs}/select_linux.go | 6 +- .../internal/sysfs/select_unsupported.go | 14 + .../{platform => sysfs}/select_windows.go | 22 +- .../tetratelabs/wazero/internal/sysfs/sock.go | 37 + .../wazero/internal/sysfs/sock_unix.go | 155 + .../wazero/internal/sysfs/sock_unsupported.go | 26 + .../wazero/internal/sysfs/sock_windows.go | 192 + .../tetratelabs/wazero/internal/sysfs/stat.go | 32 + .../internal/{platform => sysfs}/stat_bsd.go | 23 +- .../{platform => sysfs}/stat_linux.go | 23 +- .../wazero/internal/sysfs/stat_unsupported.go | 42 + .../{platform => sysfs}/stat_windows.go | 76 +- .../tetratelabs/wazero/internal/sysfs/sync.go | 14 + .../wazero/internal/sysfs/sync_windows.go | 21 + .../{platform => sysfs}/syscall6_darwin.go | 2 +- .../wazero/internal/sysfs/sysfs.go | 428 --- .../wazero/internal/sysfs/unlink.go | 17 + .../{platform => sysfs}/unlink_windows.go | 10 +- .../wazero/internal/sysfs/unsupported.go | 97 - .../wazero/internal/version/version.go | 5 +- .../wazero/internal/wasip1/errno.go | 2 + .../wazero/internal/wasip1/sock.go | 63 + .../wazero/internal/wasm/binary/element.go | 15 + .../wazero/internal/wasm/engine.go | 4 +- .../internal/wasm/function_definition.go | 64 +- .../tetratelabs/wazero/internal/wasm/host.go | 1 - .../wazero/internal/wasm/memory.go | 10 +- .../wazero/internal/wasm/module.go | 40 +- .../wazero/internal/wasm/module_instance.go | 2 +- .../tetratelabs/wazero/internal/wasm/store.go | 33 +- .../wazero/internal/wasm/store_module_list.go | 27 - .../tetratelabs/wazero/internal/wasm/table.go | 49 +- .../wazero/internal/wasmdebug/dwarf.go | 21 +- .../tetratelabs/wazero/netlify.toml | 2 +- .../github.com/tetratelabs/wazero/runtime.go | 19 +- vendor/github.com/vbatts/tar-split/LICENSE | 28 + .../vbatts/tar-split/archive/tar/common.go | 723 ++++ .../vbatts/tar-split/archive/tar/format.go | 303 ++ .../vbatts/tar-split/archive/tar/reader.go | 925 +++++ .../tar-split/archive/tar/stat_actime1.go | 20 + .../tar-split/archive/tar/stat_actime2.go | 20 + .../vbatts/tar-split/archive/tar/stat_unix.go | 96 + .../vbatts/tar-split/archive/tar/strconv.go | 326 ++ .../vbatts/tar-split/archive/tar/writer.go | 653 ++++ vendor/github.com/yusufpapurcu/wmi/README.md | 7 - .../yusufpapurcu/wmi/swbemservices.go | 1 + vendor/github.com/yusufpapurcu/wmi/wmi.go | 13 +- .../otel/metric/noop/noop.go | 264 ++ .../otel/semconv/internal/http.go | 338 ++ .../otel/semconv/v1.12.0/doc.go | 20 + .../otel/semconv/v1.12.0/exception.go | 20 + .../otel/semconv/v1.12.0/http.go | 114 + .../otel/semconv/v1.12.0/resource.go | 1042 ++++++ .../otel/semconv/v1.12.0/schema.go | 20 + .../otel/semconv/v1.12.0/trace.go | 1704 +++++++++ .../otel/semconv/v1.20.0/attribute_group.go | 1209 ++++++ .../otel/semconv/v1.20.0/doc.go | 20 + .../otel/semconv/v1.20.0/event.go | 199 + .../otel/semconv/v1.20.0/exception.go | 20 + .../otel/semconv/v1.20.0/http.go | 21 + .../otel/semconv/v1.20.0/resource.go | 2071 +++++++++++ .../otel/semconv/v1.20.0/schema.go | 20 + .../otel/semconv/v1.20.0/trace.go | 2610 +++++++++++++ vendor/modules.txt | 106 +- vendor/mvdan.cc/gofumpt/CHANGELOG.md | 31 + vendor/mvdan.cc/gofumpt/README.md | 180 +- vendor/mvdan.cc/gofumpt/format/format.go | 25 +- vendor/mvdan.cc/gofumpt/gofmt.go | 31 +- vendor/mvdan.cc/gofumpt/internal.go | 3 +- .../internal/{ => govendor}/diff/diff.go | 0 .../internal/govendor/go/doc/comment/doc.go | 36 + .../internal/govendor/go/doc/comment/html.go | 169 + .../govendor/go/doc/comment/markdown.go | 188 + .../internal/govendor/go/doc/comment/parse.go | 1262 +++++++ .../internal/govendor/go/doc/comment/print.go | 290 ++ .../internal/govendor/go/doc/comment/std.go | 44 + .../internal/govendor/go/doc/comment/text.go | 337 ++ .../internal/govendor/go/format/format.go | 134 + .../internal/govendor/go/format/internal.go | 177 + .../internal/govendor/go/printer/comment.go | 155 + .../internal/govendor/go/printer/gobuild.go | 170 + .../internal/govendor/go/printer/nodes.go | 2001 ++++++++++ .../internal/govendor/go/printer/printer.go | 1427 ++++++++ .../gofumpt/internal/version/version.go | 5 +- 907 files changed, 71105 insertions(+), 22764 deletions(-) create mode 100644 test/integration/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go create mode 100644 test/integration/vendor/github.com/prometheus/client_golang/prometheus/vnext.go create mode 100644 test/integration/vendor/github.com/prometheus/common/model/value_float.go create mode 100644 test/integration/vendor/github.com/prometheus/common/model/value_histogram.go create mode 100644 test/integration/vendor/github.com/prometheus/common/model/value_type.go create mode 100644 test/integration/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go rename vendor/github.com/bufbuild/buf/private/pkg/filelock/nop_unlocker.go => test/integration/vendor/github.com/prometheus/procfs/fs_statfs_notype.go (58%) create mode 100644 test/integration/vendor/github.com/prometheus/procfs/fs_statfs_type.go create mode 100644 test/integration/vendor/github.com/prometheus/procfs/net_route.go create mode 100644 test/integration/vendor/github.com/prometheus/procfs/net_wireless.go create mode 100644 test/integration/vendor/github.com/prometheus/procfs/proc_interrupts.go create mode 100644 test/integration/vendor/github.com/prometheus/procfs/thread.go create mode 100644 test/integration/vendor/github.com/shirou/gopsutil/v3/common/env.go create mode 100644 test/integration/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml create mode 100644 test/integration/vendor/github.com/shoenig/go-m1cpu/LICENSE create mode 100644 test/integration/vendor/github.com/shoenig/go-m1cpu/Makefile create mode 100644 test/integration/vendor/github.com/shoenig/go-m1cpu/README.md create mode 100644 test/integration/vendor/github.com/shoenig/go-m1cpu/cpu.go create mode 100644 test/integration/vendor/github.com/shoenig/go-m1cpu/incompatible.go create mode 100644 test/performance/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go create mode 100644 test/performance/vendor/github.com/prometheus/client_golang/prometheus/vnext.go create mode 100644 test/performance/vendor/github.com/prometheus/common/model/value_float.go create mode 100644 test/performance/vendor/github.com/prometheus/common/model/value_histogram.go create mode 100644 test/performance/vendor/github.com/prometheus/common/model/value_type.go create mode 100644 test/performance/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go create mode 100644 test/performance/vendor/github.com/prometheus/procfs/fs_statfs_notype.go create mode 100644 test/performance/vendor/github.com/prometheus/procfs/fs_statfs_type.go create mode 100644 test/performance/vendor/github.com/prometheus/procfs/net_route.go create mode 100644 test/performance/vendor/github.com/prometheus/procfs/net_wireless.go create mode 100644 test/performance/vendor/github.com/prometheus/procfs/proc_interrupts.go create mode 100644 test/performance/vendor/github.com/prometheus/procfs/thread.go create mode 100644 test/performance/vendor/github.com/shirou/gopsutil/v3/common/env.go create mode 100644 test/performance/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml create mode 100644 test/performance/vendor/github.com/shoenig/go-m1cpu/LICENSE create mode 100644 test/performance/vendor/github.com/shoenig/go-m1cpu/Makefile create mode 100644 test/performance/vendor/github.com/shoenig/go-m1cpu/README.md create mode 100644 test/performance/vendor/github.com/shoenig/go-m1cpu/cpu.go create mode 100644 test/performance/vendor/github.com/shoenig/go-m1cpu/incompatible.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/bufprint/plugin_printer.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/bufprint/plugin_version_printer.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/bufprint/template_printer.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/bufprint/template_version_printer.go create mode 100644 vendor/github.com/bufbuild/buf/private/buf/bufsync/bufsync.go create mode 100644 vendor/github.com/bufbuild/buf/private/buf/bufsync/module_commit.go create mode 100644 vendor/github.com/bufbuild/buf/private/buf/bufsync/syncable_module.go create mode 100644 vendor/github.com/bufbuild/buf/private/buf/bufsync/syncer.go rename vendor/github.com/bufbuild/buf/private/{pkg/filelock => buf/bufsync}/usage.gen.go (97%) rename vendor/github.com/bufbuild/buf/private/{pkg/filelock/nop_locker.go => buf/bufwire/module_config_set.go} (54%) create mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/goversion/goversion.go rename vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/{beta/registry/plugin/pluginlist => alpha/package/goversion}/usage.gen.go (97%) create mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/mavenversion/mavenversion.go rename vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/{plugin/plugindelete => package/mavenversion}/usage.gen.go (97%) create mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/npmversion/npmversion.go rename vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/{beta/registry/plugin/plugincreate => alpha/package/npmversion}/usage.gen.go (97%) create mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/swiftversion/swiftversion.go rename vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/{beta/registry/template/templatelist => alpha/package/swiftversion}/usage.gen.go (97%) delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/plugindelete/plugindelete.go create mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/repo/reposync/reposync.go create mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/repo/reposync/usage.gen.go create mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/graph/graph.go create mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/graph/usage.gen.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugincreate/plugincreate.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginlist/pluginlist.go rename vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/{alpha => beta/registry}/plugin/pluginpush/pluginpush.go (97%) rename vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/{alpha => beta/registry}/plugin/pluginpush/usage.gen.go (100%) delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginversion/pluginversionlist/pluginversionlist.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatecreate/templatecreate.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatedelete/templatedelete.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatedelete/usage.gen.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatelist/templatelist.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversioncreate/templateversioncreate.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversioncreate/usage.gen.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversionlist/templateversionlist.go delete mode 100644 vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversionlist/usage.gen.go create mode 100644 vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/bufgraph.go create mode 100644 vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/builder.go create mode 100644 vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/usage.gen.go create mode 100644 vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/source_paths_remap.go create mode 100644 vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/tags.go create mode 100644 vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/image_module_dependency.go delete mode 100644 vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/module_cacher.go delete mode 100644 vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/module_reader.go create mode 100644 vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_branch.connect.go create mode 100644 vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/sync.connect.go create mode 100644 vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/git_metadata.pb.go create mode 100644 vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_branch.pb.go create mode 100644 vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/sync.pb.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/dag/dag.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/dag/usage.gen.go delete mode 100644 vendor/github.com/bufbuild/buf/private/pkg/filelock/filelock.go delete mode 100644 vendor/github.com/bufbuild/buf/private/pkg/filelock/lock.go delete mode 100644 vendor/github.com/bufbuild/buf/private/pkg/filelock/locker.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/git/annotated_tag.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/git/commit.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/git/hash.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/git/ident.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/git/object_reader.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/git/packed_refs.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/git/repository.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/git/tree.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/git/tree_node.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/bucket.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/doc.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/provider.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/storagegit.go create mode 100644 vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/usage.gen.go delete mode 100644 vendor/github.com/bufbuild/connect-go/maxbytes.go create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/.gitignore create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/.golangci.yml create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/LICENSE create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/Makefile create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/README.md create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/attributes.go create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/buf.gen.yaml create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/buf.work.yaml create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/doc.go create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/instruments.go create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/interceptor.go create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/option.go create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/otelconnect.go create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/payloadinterceptor.go create mode 100644 vendor/github.com/bufbuild/connect-opentelemetry-go/streaming.go create mode 100644 vendor/github.com/containerd/stargz-snapshotter/estargz/LICENSE create mode 100644 vendor/github.com/containerd/stargz-snapshotter/estargz/build.go create mode 100644 vendor/github.com/containerd/stargz-snapshotter/estargz/errorutil/errors.go create mode 100644 vendor/github.com/containerd/stargz-snapshotter/estargz/estargz.go create mode 100644 vendor/github.com/containerd/stargz-snapshotter/estargz/gzip.go create mode 100644 vendor/github.com/containerd/stargz-snapshotter/estargz/testutil.go create mode 100644 vendor/github.com/containerd/stargz-snapshotter/estargz/types.go create mode 100644 vendor/github.com/docker/docker/api/types/container/change_response_deprecated.go create mode 100644 vendor/github.com/docker/docker/api/types/container/change_type.go create mode 100644 vendor/github.com/docker/docker/api/types/container/change_types.go delete mode 100644 vendor/github.com/docker/docker/api/types/container/container_changes.go delete mode 100644 vendor/github.com/docker/docker/api/types/container/deprecated.go create mode 100644 vendor/github.com/docker/docker/api/types/container/filesystem_change.go rename vendor/github.com/docker/docker/api/types/container/{host_config.go => hostconfig.go} (84%) delete mode 100644 vendor/github.com/docker/docker/api/types/deprecated.go create mode 100644 vendor/github.com/docker/docker/api/types/filters/errors.go create mode 100644 vendor/github.com/docker/docker/api/types/image/opts.go create mode 100644 vendor/github.com/docker/docker/api/types/registry/authconfig.go delete mode 100644 vendor/github.com/docker/docker/api/types/volume/deprecated.go delete mode 100644 vendor/github.com/docker/docker/pkg/stringid/README.md create mode 100644 vendor/github.com/evilmartians/lefthook/cmd/dump.go create mode 100644 vendor/github.com/evilmartians/lefthook/internal/lefthook/dump.go create mode 100644 vendor/github.com/google/go-containerregistry/internal/estargz/estargz.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/empty/README.md rename vendor/github.com/{bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatecreate/usage.gen.go => google/go-containerregistry/pkg/v1/empty/doc.go} (71%) create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/empty/image.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/empty/index.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/mutate/README.md create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/mutate/doc.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/mutate/image.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/mutate/index.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/mutate/mutate.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/remote/fetcher.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/remote/puller.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/remote/pusher.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/remote/schema1.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/tarball/README.md rename vendor/github.com/{bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginversion/pluginversionlist/usage.gen.go => google/go-containerregistry/pkg/v1/tarball/doc.go} (70%) create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/tarball/image.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/tarball/layer.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go create mode 100644 vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go create mode 100644 vendor/github.com/prometheus/client_golang/prometheus/vnext.go create mode 100644 vendor/github.com/prometheus/common/model/value_float.go create mode 100644 vendor/github.com/prometheus/common/model/value_histogram.go create mode 100644 vendor/github.com/prometheus/common/model/value_type.go create mode 100644 vendor/github.com/prometheus/procfs/cpuinfo_loong64.go create mode 100644 vendor/github.com/prometheus/procfs/fs_statfs_notype.go create mode 100644 vendor/github.com/prometheus/procfs/fs_statfs_type.go create mode 100644 vendor/github.com/prometheus/procfs/net_route.go create mode 100644 vendor/github.com/prometheus/procfs/net_wireless.go create mode 100644 vendor/github.com/prometheus/procfs/proc_interrupts.go create mode 100644 vendor/github.com/prometheus/procfs/thread.go delete mode 100644 vendor/github.com/rogpeppe/go-internal/fmtsort/mapelem_1.11.go create mode 100644 vendor/github.com/shirou/gopsutil/v3/common/env.go create mode 100644 vendor/github.com/shoenig/go-m1cpu/.golangci.yaml create mode 100644 vendor/github.com/shoenig/go-m1cpu/LICENSE create mode 100644 vendor/github.com/shoenig/go-m1cpu/Makefile create mode 100644 vendor/github.com/shoenig/go-m1cpu/README.md create mode 100644 vendor/github.com/shoenig/go-m1cpu/cpu.go create mode 100644 vendor/github.com/shoenig/go-m1cpu/incompatible.go create mode 100644 vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/gotip/wasi.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/asm/buffer.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/bitpack/offset_array.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/fsapi/constants.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_js.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_sun.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_windows.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/fsapi/dir.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/fsapi/file.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/fsapi/fs.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => fsapi}/stat.go (50%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/fsapi/unimplemented.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/chown_unix.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/dir.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/file.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/mmap_linux.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/mmap_other.go rename vendor/github.com/tetratelabs/wazero/internal/platform/{mmap.go => mmap_unix.go} (52%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/mremap_other.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/mremap_unix.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/open_file.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/open_file_js.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/open_file_sun.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/rename.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/select_unsupported.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/stat_unsupported.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/sync.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/sync_linux.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/sync_unsupported.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/unlink.go delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/platform/wrap_windows.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sock/sock.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sys/lazy.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sys/stdio.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/chown.go (61%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/chown_unix.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/chown_unsupported.go (93%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_linux.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_unsupported.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/dir.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/file.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/file_test.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/file_unix.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/file_unsupported.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/futimens.go (77%) rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/futimens_darwin.go (98%) rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/futimens_darwin.s (100%) rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/futimens_linux.go (98%) rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/futimens_unsupported.go (97%) rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/futimens_windows.go (95%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unix.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_windows.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_js.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_sun.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/open_file_windows.go (69%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/osfile.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/rename.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/rename_windows.go (77%) rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/select.go (79%) rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/select_darwin.go (88%) rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/select_darwin.s (100%) rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/select_linux.go (67%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/select_unsupported.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/select_windows.go (84%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/sock.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unsupported.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_windows.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/stat.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/stat_bsd.go (57%) rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/stat_linux.go (61%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_unsupported.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/stat_windows.go (62%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/sync.go create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/sync_windows.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/syscall6_darwin.go (95%) create mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/unlink.go rename vendor/github.com/tetratelabs/wazero/internal/{platform => sysfs}/unlink_windows.go (62%) delete mode 100644 vendor/github.com/tetratelabs/wazero/internal/sysfs/unsupported.go create mode 100644 vendor/github.com/vbatts/tar-split/LICENSE create mode 100644 vendor/github.com/vbatts/tar-split/archive/tar/common.go create mode 100644 vendor/github.com/vbatts/tar-split/archive/tar/format.go create mode 100644 vendor/github.com/vbatts/tar-split/archive/tar/reader.go create mode 100644 vendor/github.com/vbatts/tar-split/archive/tar/stat_actime1.go create mode 100644 vendor/github.com/vbatts/tar-split/archive/tar/stat_actime2.go create mode 100644 vendor/github.com/vbatts/tar-split/archive/tar/stat_unix.go create mode 100644 vendor/github.com/vbatts/tar-split/archive/tar/strconv.go create mode 100644 vendor/github.com/vbatts/tar-split/archive/tar/writer.go create mode 100644 vendor/go.opentelemetry.io/otel/metric/noop/noop.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/internal/http.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.12.0/doc.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.12.0/exception.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.12.0/http.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.12.0/resource.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.12.0/schema.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.12.0/trace.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.20.0/attribute_group.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.20.0/doc.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.20.0/event.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.20.0/exception.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.20.0/http.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.20.0/resource.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.20.0/schema.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.20.0/trace.go rename vendor/mvdan.cc/gofumpt/internal/{ => govendor}/diff/diff.go (100%) create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/doc.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/html.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/markdown.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/parse.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/print.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/std.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/text.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/format/format.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/format/internal.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/comment.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/gobuild.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/nodes.go create mode 100644 vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/printer.go diff --git a/go.mod b/go.mod index 6d1b25870..a846b09e7 100644 --- a/go.mod +++ b/go.mod @@ -15,11 +15,11 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/mwitkow/go-proto-validators v0.3.2 github.com/nginxinc/nginx-plus-go-client v0.10.0 - github.com/nginxinc/nginx-prometheus-exporter v0.10.0 + github.com/nginxinc/nginx-prometheus-exporter v0.11.0 github.com/nxadm/tail v1.4.8 github.com/orcaman/concurrent-map v1.0.0 github.com/shirou/gopsutil v3.21.11+incompatible - github.com/shirou/gopsutil/v3 v3.23.2 + github.com/shirou/gopsutil/v3 v3.23.6 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 @@ -37,20 +37,20 @@ require ( ) require ( - github.com/bufbuild/buf v1.18.0 - github.com/evilmartians/lefthook v1.3.13 + github.com/bufbuild/buf v1.23.1 + github.com/evilmartians/lefthook v1.4.4 github.com/go-resty/resty/v2 v2.7.0 github.com/go-swagger/go-swagger v0.30.4 github.com/golangci/golangci-lint v1.52.2 github.com/goreleaser/nfpm/v2 v2.31.0 github.com/nginx/agent/sdk/v2 v2.0.0-00010101000000-000000000000 - github.com/prometheus/client_golang v1.13.0 + github.com/prometheus/client_golang v1.16.0 github.com/pseudomuto/protoc-gen-doc v1.5.1 github.com/rs/cors v1.9.0 golang.org/x/sys v0.10.0 golang.org/x/text v0.11.0 gopkg.in/yaml.v2 v2.4.0 - mvdan.cc/gofumpt v0.4.0 + mvdan.cc/gofumpt v0.5.0 ) require ( @@ -88,7 +88,8 @@ require ( github.com/breml/bidichk v0.2.4 // indirect github.com/breml/errchkjson v0.3.1 // indirect github.com/briandowns/spinner v1.23.0 // indirect - github.com/bufbuild/connect-go v1.7.0 // indirect + github.com/bufbuild/connect-go v1.8.0 // indirect + github.com/bufbuild/connect-opentelemetry-go v0.3.0 // indirect github.com/bufbuild/protocompile v0.5.1 // indirect github.com/butuzov/ireturn v0.1.1 // indirect github.com/cavaliergopher/cpio v1.0.1 // indirect @@ -97,15 +98,16 @@ require ( github.com/charmbracelet/lipgloss v0.7.1 // indirect github.com/chavacava/garif v0.0.0-20230227094218-b8c73b2037b8 // indirect github.com/cloudflare/circl v1.3.3 // indirect + github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/creack/pty v1.1.18 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/daixiang0/gci v0.10.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/denis-tingaikin/go-header v0.4.3 // indirect - github.com/docker/cli v23.0.5+incompatible // indirect - github.com/docker/distribution v2.8.2-beta.1+incompatible // indirect - github.com/docker/docker v23.0.5+incompatible // indirect + github.com/docker/cli v24.0.2+incompatible // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect + github.com/docker/docker v24.0.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect @@ -160,8 +162,8 @@ require ( github.com/golangci/misspell v0.4.0 // indirect github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6 // indirect github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect - github.com/google/go-containerregistry v0.14.0 // indirect - github.com/google/pprof v0.0.0-20230502171905-255e3b9b56de // indirect + github.com/google/go-containerregistry v0.15.2 // indirect + github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect github.com/gordonklaus/ineffassign v0.0.0-20230107090616-13ace0543b28 // indirect github.com/goreleaser/chglog v0.5.0 // indirect github.com/goreleaser/fileglob v1.3.0 // indirect @@ -214,7 +216,7 @@ require ( github.com/maratori/testpackage v1.1.1 // indirect github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mbilski/exhaustivestruct v1.2.0 // indirect @@ -249,16 +251,16 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polyfloyd/go-errorlint v1.4.0 // indirect github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.37.0 // indirect - github.com/prometheus/procfs v0.8.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.11.0 // indirect github.com/pseudomuto/protokit v0.2.0 // indirect github.com/quasilyte/go-ruleguard v0.3.19 // indirect github.com/quasilyte/gogrep v0.5.0 // indirect github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect github.com/rivo/uniseg v0.2.0 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/ryancurrah/gomodguard v1.3.0 // indirect github.com/ryanrolds/sqlclosecheck v0.4.0 // indirect @@ -268,6 +270,7 @@ require ( github.com/securego/gosec/v2 v2.15.0 // indirect github.com/sergi/go-diff v1.3.1 // indirect github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/sivchari/containedctx v1.0.2 // indirect github.com/sivchari/nosnakecase v1.7.0 // indirect @@ -285,7 +288,7 @@ require ( github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect github.com/tdakkota/asciicheck v0.2.0 // indirect github.com/tetafro/godot v1.4.11 // indirect - github.com/tetratelabs/wazero v1.1.0 // indirect + github.com/tetratelabs/wazero v1.2.1 // indirect github.com/timakin/bodyclose v0.0.0-20221125081123-e39cf3fc478e // indirect github.com/timonwong/loggercheck v0.9.4 // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect @@ -298,10 +301,11 @@ require ( github.com/ultraware/funlen v0.0.3 // indirect github.com/ultraware/whitespace v0.0.5 // indirect github.com/uudashr/gocognit v1.0.6 // indirect + github.com/vbatts/tar-split v0.11.3 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/yagipy/maintidx v1.0.0 // indirect github.com/yeya24/promlinter v0.2.0 // indirect - github.com/yusufpapurcu/wmi v1.2.2 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect gitlab.com/bosi/decorder v0.2.3 // indirect gitlab.com/digitalxero/go-conventional-commit v1.0.7 // indirect go.mongodb.org/mongo-driver v1.11.3 // indirect @@ -313,7 +317,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/crypto v0.11.0 // indirect - golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 // indirect + golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.12.0 // indirect diff --git a/go.sum b/go.sum index 630a9a16d..4855f4f5b 100644 --- a/go.sum +++ b/go.sum @@ -107,7 +107,7 @@ github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvx github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/benbjohnson/clock v1.3.3 h1:g+rSsSaAzhHJYcIQE78hJ3AhyjjtQvleKDjlhdBnIhc= +github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -126,10 +126,12 @@ github.com/breml/errchkjson v0.3.1 h1:hlIeXuspTyt8Y/UmP5qy1JocGNR00KQHgfaNtRAjox github.com/breml/errchkjson v0.3.1/go.mod h1:XroxrzKjdiutFyW3nWhw34VGg7kiMsDQox73yWCGI2U= github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A= github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yqeBQJSrbXjuE= -github.com/bufbuild/buf v1.18.0 h1:21VUsBACeRLwJ+7XfzCc8z173M4iH8shcKDO7ASwp7A= -github.com/bufbuild/buf v1.18.0/go.mod h1:Wp6mb9HCLDPI1woVCZux154AA0y8aLiPM+fr7Qufmto= -github.com/bufbuild/connect-go v1.7.0 h1:MGp82v7SCza+3RhsVhV7aMikwxvI3ZfD72YiGt8FYJo= -github.com/bufbuild/connect-go v1.7.0/go.mod h1:GmMJYR6orFqD0Y6ZgX8pwQ8j9baizDrIQMm1/a6LnHk= +github.com/bufbuild/buf v1.23.1 h1:BeMkA3+e9XTFEZPDlAI7cydFKlq24wwYiOHp8CvsRzc= +github.com/bufbuild/buf v1.23.1/go.mod h1:ERFRzJiIjAOzUSJ3vz1zoI7XfxlBnCwZEyL+NJm4pko= +github.com/bufbuild/connect-go v1.8.0 h1:srluNkFkZBfSfg9Qb6DrO+5nMaxix//h2ctrHZhMGKc= +github.com/bufbuild/connect-go v1.8.0/go.mod h1:GmMJYR6orFqD0Y6ZgX8pwQ8j9baizDrIQMm1/a6LnHk= +github.com/bufbuild/connect-opentelemetry-go v0.3.0 h1:AuZi3asTDKmjGtd2aqpyP4p5QvBFG/YEaHopViLatnk= +github.com/bufbuild/connect-opentelemetry-go v0.3.0/go.mod h1:r1ppyTtu1EWeRodk4Q/JbyQhIWtO7eR3GoRDzjeEcNU= github.com/bufbuild/protocompile v0.5.1 h1:mixz5lJX4Hiz4FpqFREJHIXLfaLBntfaJv1h+/jS+Qg= github.com/bufbuild/protocompile v0.5.1/go.mod h1:G5iLmavmF4NsYtpZFvE3B/zFch2GIY8+wjsYLR/lc40= github.com/butuzov/ireturn v0.1.1 h1:QvrO2QF2+/Cx1WA/vETCIYBKtRjc30vesdoPUNo1EbY= @@ -163,6 +165,7 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSkDwbkEETK84kQgEeFwDC+62k= +github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -177,12 +180,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denis-tingaikin/go-header v0.4.3 h1:tEaZKAlqql6SKCY++utLmkPLd6K8IBM20Ha7UVm+mtU= github.com/denis-tingaikin/go-header v0.4.3/go.mod h1:0wOCWuN71D5qIgE2nz9KrKmuYBAC2Mra5RassOIQ2/c= -github.com/docker/cli v23.0.5+incompatible h1:ufWmAOuD3Vmr7JP2G5K3cyuNC4YZWiAsuDEvFVVDafE= -github.com/docker/cli v23.0.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/distribution v2.8.2-beta.1+incompatible h1:gILO60VLD2v28ozemv4aAwDb8ds5U2O/vD/sBXbd7Rw= -github.com/docker/distribution v2.8.2-beta.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v23.0.5+incompatible h1:DaxtlTJjFSnLOXVNUBU1+6kXGz2lpDoEAH6QoxaSg8k= -github.com/docker/docker v23.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/cli v24.0.2+incompatible h1:QdqR7znue1mtkXIJ+ruQMGQhpw2JzMJLRXp6zpzF6tM= +github.com/docker/cli v24.0.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v24.0.2+incompatible h1:eATx+oLz9WdNVkQrr0qjQ8HvRJ4bOOxfzEo8R+dA3cg= +github.com/docker/docker v24.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -204,8 +207,8 @@ github.com/esimonov/ifshort v1.0.4 h1:6SID4yGWfRae/M7hkVDVVyppy8q/v9OuxNdmjLQStB github.com/esimonov/ifshort v1.0.4/go.mod h1:Pe8zjlRrJ80+q2CxHLfEOfTwxCZ4O+MuhcHcfgNWTk0= github.com/ettle/strcase v0.1.1 h1:htFueZyVeE1XNnMEfbqp5r67qAN/4r6ya1ysq8Q+Zcw= github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY= -github.com/evilmartians/lefthook v1.3.13 h1:WowytlQPtGLj0ffGJZY2MaLWSfQuqgmVKOjzTzvY46c= -github.com/evilmartians/lefthook v1.3.13/go.mod h1:Ybinyhjf5wdloc78pkBV2K0XZRvdnsIova48LAco5HU= +github.com/evilmartians/lefthook v1.4.4 h1:5EaZvLg7hWJSC54crrDadqmzLF9SI7lfOVWqHuBOjys= +github.com/evilmartians/lefthook v1.4.4/go.mod h1:wGvLhEBXf0YPxuDoMkxy7b6NFM5hr+CK4QCvCgcJEpw= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= @@ -242,11 +245,9 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -419,8 +420,8 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-containerregistry v0.14.0 h1:z58vMqHxuwvAsVwvKEkmVBz2TlgBgH5k6koEXBtlYkw= -github.com/google/go-containerregistry v0.14.0/go.mod h1:aiJ2fp/SXvkWgmYHioXnbMdlgB8eXiiYOY55gfN91Wk= +github.com/google/go-containerregistry v0.15.2 h1:MMkSh+tjSdnmJZO7ljvEqV1DjfekB6VUEAZgy3a+TQE= +github.com/google/go-containerregistry v0.15.2/go.mod h1:wWK+LnOv4jXMM23IT/F1wdYftGWGr47Is8CG+pmHK1Q= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -436,8 +437,8 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= -github.com/google/pprof v0.0.0-20230502171905-255e3b9b56de h1:6bMcLOeKoNo0+mTOb1ee3McF6CCKGixjLR3EDQY1Jik= -github.com/google/pprof v0.0.0-20230502171905-255e3b9b56de/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 h1:hR7/MlvK23p6+lIw9SN1TigNLn9ZnF3W4SYRKq2gAHs= +github.com/google/pprof v0.0.0-20230602150820-91b7bce49751/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -604,8 +605,8 @@ github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwM github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= @@ -667,8 +668,8 @@ github.com/nginxinc/nginx-go-crossplane v0.4.17 h1:kBISwQT36Uv4h57ran0bT4MIWUqao github.com/nginxinc/nginx-go-crossplane v0.4.17/go.mod h1:UzbZnyFv0vPlt1Urbnp/mrFCzBL4tYCReFuNBpFQEfI= github.com/nginxinc/nginx-plus-go-client v0.10.0 h1:3zsMMkPvRDo8D7ZSprXtbAEW/SDmezZWzxdyS+6oAlc= github.com/nginxinc/nginx-plus-go-client v0.10.0/go.mod h1:0v3RsQCvRn/IyrMtW+DK6CNkz+PxEsXDJPjQ3yUMBF0= -github.com/nginxinc/nginx-prometheus-exporter v0.10.0 h1:wFP8mYMtmn8uK1I5tzXb3s4CQq+r3h6Y0Qdc7d+QpyM= -github.com/nginxinc/nginx-prometheus-exporter v0.10.0/go.mod h1:U3BudpuBp/uO++yvnaaI4Dz7oOFJPdM726WEv70k3O4= +github.com/nginxinc/nginx-prometheus-exporter v0.11.0 h1:21xjnqNgxtni2jDgAQ90bl15uDnrTreO9sIlu1YsX/U= +github.com/nginxinc/nginx-prometheus-exporter v0.11.0/go.mod h1:GdyHnWAb8q8OW1Pssrrqbcqra0SH0Vn6UXICMmyWkw8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nishanths/exhaustive v0.9.5 h1:TzssWan6orBiLYVqewCG8faud9qlFntJE30ACpzmGME= github.com/nishanths/exhaustive v0.9.5/go.mod h1:IbwrGdVMizvDcIxPYGVdQn5BqWJaOwpCvg4RGb8r/TA= @@ -704,7 +705,6 @@ github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -725,27 +725,27 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= -github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= -github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= +github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/pseudomuto/protoc-gen-doc v1.5.1 h1:Ah259kcrio7Ix1Rhb6u8FCaOkzf9qRBqXnvAufg061w= github.com/pseudomuto/protoc-gen-doc v1.5.1/go.mod h1:XpMKYg6zkcpgfpCfQ8GcWBDRtRxOmMR5w7pz4Xo+dYM= github.com/pseudomuto/protokit v0.2.0 h1:hlnBDcy3YEDXH7kc9gV+NLaN0cDzhDvD1s7Y6FZ8RpM= @@ -764,8 +764,9 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE= github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= @@ -789,8 +790,12 @@ github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c h1:W65qqJCIOVP4jpqP github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil/v3 v3.23.2 h1:PAWSuiAszn7IhPMBtXsbSCafej7PqUOvY6YywlQUExU= -github.com/shirou/gopsutil/v3 v3.23.2/go.mod h1:gv0aQw33GLo3pG8SiWKiQrbDzbRY1K80RyZJ7V4Th1M= +github.com/shirou/gopsutil/v3 v3.23.6 h1:5y46WPI9QBKBbK7EEccUPNXpJpNrvPuTD0O2zHEHT08= +github.com/shirou/gopsutil/v3 v3.23.6/go.mod h1:j7QX50DrXYggrpN30W0Mo+I4/8U2UUIQrnrhqUeWrAU= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= @@ -802,6 +807,7 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sivchari/containedctx v1.0.2 h1:0hLQKpgC53OVF1VT7CeoFHk9YKstur1XOgfYIc1yrHI= @@ -852,6 +858,7 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= @@ -868,8 +875,8 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpR github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= github.com/tetafro/godot v1.4.11 h1:BVoBIqAf/2QdbFmSwAWnaIqDivZdOV0ZRwEm6jivLKw= github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8= -github.com/tetratelabs/wazero v1.1.0 h1:EByoAhC+QcYpwSZJSs/aV0uokxPwBgKxfiokSUwAknQ= -github.com/tetratelabs/wazero v1.1.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= +github.com/tetratelabs/wazero v1.2.1 h1:J4X2hrGzJvt+wqltuvcSjHQ7ujQxA9gb6PeMs4qlUWs= +github.com/tetratelabs/wazero v1.2.1/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/timakin/bodyclose v0.0.0-20221125081123-e39cf3fc478e h1:MV6KaVu/hzByHP0UvJ4HcMGE/8a6A4Rggc/0wx2AvJo= @@ -896,11 +903,13 @@ github.com/ultraware/funlen v0.0.3 h1:5ylVWm8wsNwH5aWo9438pwvsK0QiqVuUrt9bn7S/iL github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= github.com/ultraware/whitespace v0.0.5 h1:hh+/cpIcopyMYbZNVov9iSxvJU3OYQg78Sfaqzi/CzI= github.com/ultraware/whitespace v0.0.5/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA= +github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8= github.com/uudashr/gocognit v1.0.6 h1:2Cgi6MweCsdB6kpcVQp7EW4U23iBFQWfTXiWlyp842Y= github.com/uudashr/gocognit v1.0.6/go.mod h1:nAIUuVBnYU7pcninia3BHOvQkpQCeO76Uscky5BOwcY= github.com/vardius/message-bus v1.1.5 h1:YSAC2WB4HRlwc4neFPTmT88kzzoiQ+9WRRbej/E/LZc= github.com/vardius/message-bus v1.1.5/go.mod h1:6xladCV2lMkUAE4bzzS85qKOiB5miV7aBVRafiTJGqw= -github.com/vbatts/tar-split v0.11.2 h1:Via6XqJr0hceW4wff3QRzD5gAk/tatMw/4ZA7cTlIME= +github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck= +github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= @@ -921,8 +930,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= -github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= gitlab.com/bosi/decorder v0.2.3 h1:gX4/RgK16ijY8V+BRQHAySfQAb354T7/xQpDB2n10P0= gitlab.com/bosi/decorder v0.2.3/go.mod h1:9K1RB5+VPNQYtXtTDAzd2OEftsZb1oV0IrJrzChSdGE= gitlab.com/digitalxero/go-conventional-commit v1.0.7 h1:8/dO6WWG+98PMhlZowt/YjuiKhqhGlOCwlIV8SqqGh8= @@ -944,6 +953,7 @@ go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26 go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE= go.opentelemetry.io/otel/sdk v1.16.0/go.mod h1:tMsIuKXuuIWPBAOrH+eHtvhTL+SntFtXF9QD68aP6p4= +go.opentelemetry.io/otel/sdk/metric v0.39.0 h1:Kun8i1eYf48kHH83RucG93ffz0zGV1sh46FAScOTuDI= go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -986,8 +996,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4pudlXrR0dCgw51QK9o= -golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2 h1:J74nGeMgeFnYQJN59eFwh06jX/V8g0lB7LWpjSLxtgU= @@ -1063,8 +1073,6 @@ golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= @@ -1084,7 +1092,6 @@ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1161,7 +1168,6 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1169,6 +1175,7 @@ golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1176,6 +1183,7 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1439,8 +1447,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.4.3 h1:o/n5/K5gXqk8Gozvs2cnL0F2S1/g1vcGCAx2vETjITw= honnef.co/go/tools v0.4.3/go.mod h1:36ZgoUOrqOk1GxwHhyryEkq8FQWkUO2xGuSMhUCcdvA= -mvdan.cc/gofumpt v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= -mvdan.cc/gofumpt v0.4.0/go.mod h1:PljLOHDeZqgS8opHRKLzp2It2VBuSdteAgqUfzMTxlQ= +mvdan.cc/gofumpt v0.5.0 h1:0EQ+Z56k8tXjj/6TQD25BFNKQXpCvT0rnansIc7Ug5E= +mvdan.cc/gofumpt v0.5.0/go.mod h1:HBeVDtMKRZpXyxFciAirzdKklDlGu8aAy1wEbH5Y9js= mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed h1:WX1yoOaKQfddO/mLzdV4wptyWgoH/6hwLs7QHTixo0I= mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b h1:DxJ5nJdkhDlLok9K6qO+5290kphDJbHOQO1DFFFTeBo= diff --git a/go.work.sum b/go.work.sum index 3af9a4e19..3a844a4ac 100644 --- a/go.work.sum +++ b/go.work.sum @@ -759,9 +759,11 @@ github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI= github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= +github.com/alecthomas/kingpin/v2 v2.3.2 h1:H0aULhgmSzN8xQ3nX1uxtdlTHYoPLu5AhHxWrKI6ocU= github.com/alecthomas/kingpin/v2 v2.3.2/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= +github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= @@ -833,6 +835,7 @@ github.com/aws/smithy-go v1.11.2 h1:eG/N+CcUMAvsdffgMvjMKwfyDzIkjM6pfxMJ8Mzc6mE= github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.3/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bitly/go-hostpool v0.1.0 h1:XKmsF6k5el6xHG3WPJ8U0Ku/ye7njX7W81Ng7O2ioR0= @@ -863,10 +866,12 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf github.com/checkpoint-restore/go-criu/v5 v5.3.0 h1:wpFFOoomK3389ue2lAb0Boag6XPht5QYpipxmSNL4d8= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= +github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= github.com/chzyer/readline v1.5.0 h1:lSwwFrbNviGePhkewF1az4oLmcwqCZijQ2/Wi3BGHAI= github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI= github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= +github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= github.com/cilium/ebpf v0.7.0 h1:1k/q3ATgxSXRdrmPfH8d7YK0GfqVsEKZAX9dQZvs56k= github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= github.com/cilium/ebpf v0.11.0/go.mod h1:WE7CZAnqOL2RouJ4f1uyNhqr2P4CCvXFIqdRDUgWsVs= @@ -903,7 +908,6 @@ github.com/containerd/nri v0.1.0 h1:6QioHRlThlKh2RkRTR4kIT3PKAcrLo3gIWnjkM4dQmQ= github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= github.com/containerd/stargz-snapshotter v0.12.0 h1:SRKo+YxmypnlyC7eKc9KNW0Ciy1Auo102s8E/aRGWKg= github.com/containerd/stargz-snapshotter v0.12.0/go.mod h1:LYKrfzJBNUs0hP9GA4YXTIudE6pjZ96W0X1Ls7yI7Gs= -github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o= github.com/containerd/zfs v1.0.0 h1:cXLJbx+4Jj7rNsTiqVfm6i+RNLx6FFA2fMmDlEf+Wm8= github.com/containerd/zfs v1.0.0/go.mod h1:m+m51S1DvAP6r3FcmYCp54bQ34pyOwTieQDNRIRHsFY= github.com/containernetworking/cni v1.1.1 h1:ky20T7c0MvKvbMOwS/FrlbNwjEoqJEUUYfsL4b0mc4k= @@ -952,6 +956,7 @@ github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= github.com/docker/cli-docs-tool v0.5.1 h1:jIk/cCZurZERhALPVKhqlNxTQGxn2kcI+56gE57PQXg= github.com/docker/cli-docs-tool v0.5.1/go.mod h1:zMjqTFCU361PRh8apiXzeAZ1Q/xupbIwTusYpzCXS/o= +github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= @@ -996,8 +1001,10 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I= github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk= github.com/go-kit/log v0.2.0 h1:7i2K3eKTos3Vc0enKCfnVcgHh2olr/MyfboYq7cAcFw= +github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= @@ -1058,7 +1065,6 @@ github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdf github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20221203041831-ce31453925ec/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= -github.com/google/pprof v0.0.0-20230602150820-91b7bce49751/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA= github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= github.com/google/s2a-go v0.1.3 h1:FAgZmpLl/SXurPEZyCMPBIiiYeTbqfjlbdnCNTAkbGE= github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= @@ -1173,6 +1179,8 @@ github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47 github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2 h1:rcanfLhLDA8nozr/K289V1zcntHr3V+SHlXwzz1ZI2g= github.com/ianlancetaylor/demangle v0.0.0-20220517205856-0058ec4f073c h1:rwmN+hgiyp8QyBqzdEX43lTjKAxaqCrYHaU5op5P9J8= github.com/ianlancetaylor/demangle v0.0.0-20220517205856-0058ec4f073c/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= +github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab h1:BA4a7pe6ZTd9F8kXETBoijjFJ/ntaa//1wiH9BZu4zU= +github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= @@ -1264,6 +1272,7 @@ github.com/mmcloughlin/avo v0.5.0/go.mod h1:ChHFdoV7ql95Wi7vuq2YT1bwCJqiWdZrQ1im github.com/moby/sys/mount v0.3.0 h1:bXZYMmq7DBQPwHRxH/MG+u9+XF90ZOwoXpHTOznMGp0= github.com/moby/sys/mount v0.3.0/go.mod h1:U2Z3ur2rXPFrFmy4q6WMwWrBOAQGYtYTRVM8BIvzbwk= github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/mozilla/tls-observatory v0.0.0-20210609171429-7bc42856d2e5 h1:0KqC6/sLy7fDpBdybhVkkv4Yz+PmB7c9Dz9z3dLW804= github.com/mozilla/tls-observatory v0.0.0-20210609171429-7bc42856d2e5/go.mod h1:FUqVoUPHSEdDR0MnFM3Dh8AU0pZHLXUD127SAJGER/s= @@ -1274,7 +1283,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/ncw/swift v1.0.47 h1:4DQRPj35Y41WogBxyhOXlrI37nzGlyEcsforeudyYPQ= github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= -github.com/nginxinc/nginx-prometheus-exporter v0.11.0/go.mod h1:GdyHnWAb8q8OW1Pssrrqbcqra0SH0Vn6UXICMmyWkw8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU= github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= @@ -1284,6 +1292,7 @@ github.com/onsi/ginkgo/v2 v2.8.0/go.mod h1:6JsQiECmxCa3V5st74AL/AmsV482EDdVrGaVW github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ= +github.com/opencontainers/image-spec v1.1.0-rc3/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opencontainers/selinux v1.10.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI= github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc= @@ -1298,6 +1307,7 @@ github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d h1:CdDQnGF8Nq9oc github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d/go.mod h1:3OzsM7FXDQlpCiw2j81fOmAwQLnZnLGXVKUzeKQXIAw= github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0= github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pkg/sftp v1.13.1 h1:I2qBYMChEhIjOgazfJmV3/mZM256btk6wkCDRmW7JYs= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -1379,7 +1389,6 @@ github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 h1:lIOOH github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8= github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI= @@ -1395,6 +1404,7 @@ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA= github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli v1.22.12 h1:igJgVw1JdKH+trcLWLeLwZjU9fEfPesQ+9/e4MQ44S8= github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= @@ -1415,6 +1425,9 @@ github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xhit/go-str2duration v1.2.0 h1:BcV5u025cITWxEQKGWr1URRzrcXtu7uk8+luz3Yuhwc= +github.com/xhit/go-str2duration v1.2.0/go.mod h1:3cPSlfZlUHVlneIVfePFWcJZsuwf+P1v2SRTV4cUmp4= +github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= @@ -1478,6 +1491,7 @@ go.opentelemetry.io/otel/metric v0.34.0/go.mod h1:ZFuI4yQGNCupurTXCwkeD/zHBt+C2b go.opentelemetry.io/otel/sdk v1.11.1/go.mod h1:/l3FE4SupHJ12TduVjUkZtlfFqDCQJlOlithYrdktys= go.opentelemetry.io/otel/sdk v1.15.1 h1:5FKR+skgpzvhPQHIEfcwMYjCBr14LWzs3uSqKiQzETI= go.opentelemetry.io/otel/sdk v1.15.1/go.mod h1:8rVtxQfrbmbHKfqzpQkT5EzZMcbMBwTzNAggbEAM0KA= +go.opentelemetry.io/otel/sdk/metric v0.39.0/go.mod h1:piDIRgjcK7u0HCL5pCA4e74qpK/jk3NiUoAHATVAmiI= go.opentelemetry.io/otel/trace v1.11.2/go.mod h1:4N+yC7QEz7TTsG9BSRLNAa63eg5E06ObSbKPmxQ/pKA= go.opentelemetry.io/otel/trace v1.15.1 h1:uXLo6iHJEzDfrNC0L0mNjItIp06SyaBQxu5t3xMlngY= go.opentelemetry.io/otel/trace v1.15.1/go.mod h1:IWdQG/5N1x7f6YUlmdLeJvH9yxtuJAfc4VW5Agv9r/8= @@ -1559,6 +1573,7 @@ golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1572,6 +1587,7 @@ golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= @@ -1669,6 +1685,7 @@ gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76 gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gotest.tools/gotestsum v1.8.2 h1:szU3TaSz8wMx/uG+w/A2+4JUPwH903YYaMI9yOOYAyI= gotest.tools/gotestsum v1.8.2/go.mod h1:6JHCiN6TEjA7Kaz23q1bH0e2Dc3YJjDUZ0DmctFZf+w= +gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= k8s.io/apiserver v0.22.5 h1:71krQxCUz218ecb+nPhfDsNB6QgP1/4EMvi1a2uYBlg= k8s.io/apiserver v0.22.5/go.mod h1:s2WbtgZAkTKt679sYtSudEQrTGWUSQAPe6MupLnlmaQ= diff --git a/sdk/go.mod b/sdk/go.mod index 0a9f5796b..b5006caf0 100644 --- a/sdk/go.mod +++ b/sdk/go.mod @@ -20,7 +20,7 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/maxbrunsfeld/counterfeiter/v6 v6.6.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/stretchr/objx v0.5.0 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.12.0 // indirect diff --git a/sdk/go.sum b/sdk/go.sum index abec85fb5..135e3deb3 100644 --- a/sdk/go.sum +++ b/sdk/go.sum @@ -55,8 +55,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= diff --git a/sdk/vendor/modules.txt b/sdk/vendor/modules.txt index e62effe7f..940f9f45d 100644 --- a/sdk/vendor/modules.txt +++ b/sdk/vendor/modules.txt @@ -47,8 +47,8 @@ github.com/nginxinc/nginx-go-crossplane # github.com/pmezard/go-difflib v1.0.0 ## explicit github.com/pmezard/go-difflib/difflib -# github.com/rogpeppe/go-internal v1.9.0 -## explicit; go 1.17 +# github.com/rogpeppe/go-internal v1.11.0 +## explicit; go 1.19 # github.com/sirupsen/logrus v1.9.3 ## explicit; go 1.13 github.com/sirupsen/logrus diff --git a/test/integration/go.mod b/test/integration/go.mod index 8bd11f63e..5309e1bf7 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -31,10 +31,10 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/distribution/distribution/v3 v3.0.0-20221201083218-92d136e113cf // indirect github.com/docker/buildx v0.9.1 // indirect - github.com/docker/cli v23.0.5+incompatible // indirect + github.com/docker/cli v24.0.2+incompatible // indirect github.com/docker/compose/v2 v2.15.0 // indirect - github.com/docker/distribution v2.8.2-beta.1+incompatible // indirect - github.com/docker/docker v23.0.5+incompatible // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect + github.com/docker/docker v24.0.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect github.com/docker/go-connections v0.4.0 // indirect @@ -78,7 +78,7 @@ require ( github.com/lufia/plan9stats v0.0.0-20220517141722-cf486979b281 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/mattn/go-shellwords v1.0.12 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect @@ -110,13 +110,14 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect - github.com/prometheus/client_golang v1.13.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.37.0 // indirect - github.com/prometheus/procfs v0.8.0 // indirect + github.com/prometheus/client_golang v1.16.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.11.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002 // indirect - github.com/shirou/gopsutil/v3 v3.23.2 // indirect + github.com/shirou/gopsutil/v3 v3.23.6 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/cobra v1.7.0 // indirect @@ -135,7 +136,7 @@ require ( github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect - github.com/yusufpapurcu/wmi v1.2.2 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.29.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.29.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 // indirect diff --git a/test/integration/go.sum b/test/integration/go.sum index 72e7c14da..de5c243b2 100644 --- a/test/integration/go.sum +++ b/test/integration/go.sum @@ -64,10 +64,7 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -91,7 +88,6 @@ github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqy github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -139,8 +135,8 @@ github.com/docker/cli v20.10.3-0.20221013132413-1d6c6e2367e2+incompatible/go.mod github.com/docker/compose/v2 v2.15.0 h1:kdeilqTSrWBcek4MGTlRUZ8GgXgzJZDtMoeVNiFxdpU= github.com/docker/compose/v2 v2.15.0/go.mod h1:YcXtjGuMqyzWiDLIZ1/Jl9o3LV8hQyj1/znCFMhyBb4= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/distribution v2.8.2-beta.1+incompatible h1:gILO60VLD2v28ozemv4aAwDb8ds5U2O/vD/sBXbd7Rw= -github.com/docker/distribution v2.8.2-beta.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v20.10.3-0.20221013203545-33ab36d6b304+incompatible h1:ieHXawdo9MXKnRkKuVWEfEN3PDQUqIjz/T8vMfIaHkM= github.com/docker/docker v20.10.3-0.20221013203545-33ab36d6b304+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= @@ -191,13 +187,10 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -352,10 +345,8 @@ github.com/jinzhu/inflection v0.0.0-20170102125226-1c35d901db3d/go.mod h1:h+uFLl github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= @@ -365,7 +356,6 @@ github.com/jstemmer/go-junit-report v1.0.0 h1:8X1gzZpR+nVQLAht+L/foqOeX2l9DTZoaI github.com/jstemmer/go-junit-report v1.0.0/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= @@ -377,7 +367,6 @@ github.com/klauspost/cpuid/v2 v2.1.0 h1:eyi1Ad2aNJMW95zcSbmGg7Cg6cq3ADwLpMAP96d8 github.com/klauspost/cpuid/v2 v2.1.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -402,8 +391,8 @@ github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxec github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk= @@ -451,7 +440,6 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nginx/agent/v2 v2.22.0 h1:MRDg67kRKtaXqVmNO9yWcllj7oD1d6iuz3xAUyJVWC0= github.com/nginx/agent/v2 v2.22.0/go.mod h1:qyc0p+kuv+sC9xJYd3S1JbxIej9v+E+X0rrh3x9V5hg= @@ -506,53 +494,47 @@ github.com/prometheus/client_golang v0.9.0-pre1.0.20180209125602-c332b6f63c06/go github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= -github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.0.0-20180110214958-89604d197083/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= -github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= +github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002 h1:ka9QPuQg2u4LGipiZGsgkg3rJCo4iIUCy75FddM0GRQ= github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002/go.mod h1:/yeG0My1xr/u+HZrFQ1tOQQQQrOawfyMUH13ai5brBc= -github.com/shirou/gopsutil/v3 v3.23.2 h1:PAWSuiAszn7IhPMBtXsbSCafej7PqUOvY6YywlQUExU= -github.com/shirou/gopsutil/v3 v3.23.2/go.mod h1:gv0aQw33GLo3pG8SiWKiQrbDzbRY1K80RyZJ7V4Th1M= +github.com/shirou/gopsutil/v3 v3.23.6 h1:5y46WPI9QBKBbK7EEccUPNXpJpNrvPuTD0O2zHEHT08= +github.com/shirou/gopsutil/v3 v3.23.6/go.mod h1:j7QX50DrXYggrpN30W0Mo+I4/8U2UUIQrnrhqUeWrAU= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= @@ -590,7 +572,6 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -627,8 +608,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= -github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zmap/zcrypto v0.0.0-20220605182715-4dfcec6e9a8c h1:ufDm/IlBYZYLuiqvQuhpTKwrcAS2OlXEzWbDvTVGbSQ= github.com/zmap/zlint v1.1.0 h1:Vyh2GmprXw5TLmKmkTa2BgFvvYAFBValBFesqkKsszM= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -766,11 +747,8 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -782,8 +760,6 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -822,7 +798,6 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -836,8 +811,6 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -853,27 +826,23 @@ golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1082,7 +1051,6 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/test/integration/vendor/github.com/docker/distribution/Dockerfile b/test/integration/vendor/github.com/docker/distribution/Dockerfile index 40fd4dcc1..fb54b6813 100644 --- a/test/integration/vendor/github.com/docker/distribution/Dockerfile +++ b/test/integration/vendor/github.com/docker/distribution/Dockerfile @@ -44,8 +44,8 @@ RUN --mount=from=binary,target=/build \ VERSION=$(cat /tmp/.version) \ && mkdir -p /out \ && cp /build/registry /src/README.md /src/LICENSE . \ - && tar -czvf "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.tgz" * \ - && sha256sum -z "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.tgz" | awk '{ print $1 }' > "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.tgz.sha256" + && tar -czvf "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.gz" * \ + && sha256sum -z "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.gz" | awk '{ print $1 }' > "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.gz.sha256" FROM scratch AS artifact COPY --from=releaser /out / diff --git a/test/integration/vendor/github.com/docker/distribution/registry/client/errors.go b/test/integration/vendor/github.com/docker/distribution/registry/client/errors.go index 52d49d5d2..024df43dd 100644 --- a/test/integration/vendor/github.com/docker/distribution/registry/client/errors.go +++ b/test/integration/vendor/github.com/docker/distribution/registry/client/errors.go @@ -55,6 +55,8 @@ func parseHTTPErrorResponse(statusCode int, r io.Reader) error { switch statusCode { case http.StatusUnauthorized: return errcode.ErrorCodeUnauthorized.WithMessage(detailsErr.Details) + case http.StatusForbidden: + return errcode.ErrorCodeDenied.WithMessage(detailsErr.Details) case http.StatusTooManyRequests: return errcode.ErrorCodeTooManyRequests.WithMessage(detailsErr.Details) default: diff --git a/test/integration/vendor/github.com/docker/distribution/registry/client/transport/http_reader.go b/test/integration/vendor/github.com/docker/distribution/registry/client/transport/http_reader.go index 1d0b382fb..9120dbed6 100644 --- a/test/integration/vendor/github.com/docker/distribution/registry/client/transport/http_reader.go +++ b/test/integration/vendor/github.com/docker/distribution/registry/client/transport/http_reader.go @@ -180,7 +180,6 @@ func (hrs *httpReadSeeker) reader() (io.Reader, error) { // context.GetLogger(hrs.context).Infof("Range: %s", req.Header.Get("Range")) } - req.Header.Add("Accept-Encoding", "identity") resp, err := hrs.client.Do(req) if err != nil { return nil, err diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/counter.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/counter.go index de30de6da..62de4dc59 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/counter.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/counter.go @@ -59,6 +59,18 @@ type ExemplarAdder interface { // CounterOpts is an alias for Opts. See there for doc comments. type CounterOpts Opts +// CounterVecOpts bundles the options to create a CounterVec metric. +// It is mandatory to set CounterOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type CounterVecOpts struct { + CounterOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels +} + // NewCounter creates a new Counter based on the provided CounterOpts. // // The returned implementation also implements ExemplarAdder. It is safe to @@ -140,12 +152,13 @@ func (c *counter) get() float64 { } func (c *counter) Write(out *dto.Metric) error { - val := c.get() - + // Read the Exemplar first and the value second. This is to avoid a race condition + // where users see an exemplar for a not-yet-existing observation. var exemplar *dto.Exemplar if e := c.exemplar.Load(); e != nil { exemplar = e.(*dto.Exemplar) } + val := c.get() return populateMetric(CounterValue, val, c.labelPairs, exemplar, out) } @@ -173,16 +186,24 @@ type CounterVec struct { // NewCounterVec creates a new CounterVec based on the provided CounterOpts and // partitioned by the given label names. func NewCounterVec(opts CounterOpts, labelNames []string) *CounterVec { - desc := NewDesc( + return V2.NewCounterVec(CounterVecOpts{ + CounterOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewCounterVec creates a new CounterVec based on the provided CounterVecOpts. +func (v2) NewCounterVec(opts CounterVecOpts) *CounterVec { + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &CounterVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { if len(lvs) != len(desc.variableLabels) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, lvs)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), lvs)) } result := &counter{desc: desc, labelPairs: MakeLabelPairs(desc, lvs), now: time.Now} result.init(result) // Init self-collection. @@ -245,7 +266,8 @@ func (v *CounterVec) GetMetricWith(labels Labels) (Counter, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Add(42) +// +// myVec.WithLabelValues("404", "GET").Add(42) func (v *CounterVec) WithLabelValues(lvs ...string) Counter { c, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -256,7 +278,8 @@ func (v *CounterVec) WithLabelValues(lvs ...string) Counter { // With works as GetMetricWith, but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) func (v *CounterVec) With(labels Labels) Counter { c, err := v.GetMetricWith(labels) if err != nil { diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/desc.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/desc.go index 8bc5e44e2..deedc2dfb 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/desc.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/desc.go @@ -14,20 +14,16 @@ package prometheus import ( - "errors" "fmt" "sort" "strings" "github.com/cespare/xxhash/v2" - - "github.com/prometheus/client_golang/prometheus/internal" - - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" + dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/model" + "google.golang.org/protobuf/proto" - dto "github.com/prometheus/client_model/go" + "github.com/prometheus/client_golang/prometheus/internal" ) // Desc is the descriptor used by every Prometheus Metric. It is essentially @@ -54,9 +50,9 @@ type Desc struct { // constLabelPairs contains precalculated DTO label pairs based on // the constant labels. constLabelPairs []*dto.LabelPair - // variableLabels contains names of labels for which the metric - // maintains variable values. - variableLabels []string + // variableLabels contains names of labels and normalization function for + // which the metric maintains variable values. + variableLabels ConstrainedLabels // id is a hash of the values of the ConstLabels and fqName. This // must be unique among all registered descriptors and can therefore be // used as an identifier of the descriptor. @@ -80,10 +76,24 @@ type Desc struct { // For constLabels, the label values are constant. Therefore, they are fully // specified in the Desc. See the Collector example for a usage pattern. func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *Desc { + return V2.NewDesc(fqName, help, UnconstrainedLabels(variableLabels), constLabels) +} + +// NewDesc allocates and initializes a new Desc. Errors are recorded in the Desc +// and will be reported on registration time. variableLabels and constLabels can +// be nil if no such labels should be set. fqName must not be empty. +// +// variableLabels only contain the label names and normalization functions. Their +// label values are variable and therefore not part of the Desc. (They are managed +// within the Metric.) +// +// For constLabels, the label values are constant. Therefore, they are fully +// specified in the Desc. See the Collector example for a usage pattern. +func (v2) NewDesc(fqName, help string, variableLabels ConstrainableLabels, constLabels Labels) *Desc { d := &Desc{ fqName: fqName, help: help, - variableLabels: variableLabels, + variableLabels: variableLabels.constrainedLabels(), } if !model.IsValidMetricName(model.LabelValue(fqName)) { d.err = fmt.Errorf("%q is not a valid metric name", fqName) @@ -93,7 +103,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) * // their sorted label names) plus the fqName (at position 0). labelValues := make([]string, 1, len(constLabels)+1) labelValues[0] = fqName - labelNames := make([]string, 0, len(constLabels)+len(variableLabels)) + labelNames := make([]string, 0, len(constLabels)+len(d.variableLabels)) labelNameSet := map[string]struct{}{} // First add only the const label names and sort them... for labelName := range constLabels { @@ -118,16 +128,16 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) * // Now add the variable label names, but prefix them with something that // cannot be in a regular label name. That prevents matching the label // dimension with a different mix between preset and variable labels. - for _, labelName := range variableLabels { - if !checkLabelName(labelName) { - d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName) + for _, label := range d.variableLabels { + if !checkLabelName(label.Name) { + d.err = fmt.Errorf("%q is not a valid label name for metric %q", label.Name, fqName) return d } - labelNames = append(labelNames, "$"+labelName) - labelNameSet[labelName] = struct{}{} + labelNames = append(labelNames, "$"+label.Name) + labelNameSet[label.Name] = struct{}{} } if len(labelNames) != len(labelNameSet) { - d.err = errors.New("duplicate label names") + d.err = fmt.Errorf("duplicate label names in constant and variable labels for metric %q", fqName) return d } diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/doc.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/doc.go index 98450125d..962608f02 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/doc.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/doc.go @@ -21,55 +21,66 @@ // All exported functions and methods are safe to be used concurrently unless // specified otherwise. // -// A Basic Example +// # A Basic Example // // As a starting point, a very basic usage example: // -// package main -// -// import ( -// "log" -// "net/http" -// -// "github.com/prometheus/client_golang/prometheus" -// "github.com/prometheus/client_golang/prometheus/promhttp" -// ) -// -// var ( -// cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{ -// Name: "cpu_temperature_celsius", -// Help: "Current temperature of the CPU.", -// }) -// hdFailures = prometheus.NewCounterVec( -// prometheus.CounterOpts{ -// Name: "hd_errors_total", -// Help: "Number of hard-disk errors.", -// }, -// []string{"device"}, -// ) -// ) -// -// func init() { -// // Metrics have to be registered to be exposed: -// prometheus.MustRegister(cpuTemp) -// prometheus.MustRegister(hdFailures) -// } -// -// func main() { -// cpuTemp.Set(65.3) -// hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc() -// -// // The Handler function provides a default handler to expose metrics -// // via an HTTP server. "/metrics" is the usual endpoint for that. -// http.Handle("/metrics", promhttp.Handler()) -// log.Fatal(http.ListenAndServe(":8080", nil)) -// } -// +// package main +// +// import ( +// "log" +// "net/http" +// +// "github.com/prometheus/client_golang/prometheus" +// "github.com/prometheus/client_golang/prometheus/promhttp" +// ) +// +// type metrics struct { +// cpuTemp prometheus.Gauge +// hdFailures *prometheus.CounterVec +// } +// +// func NewMetrics(reg prometheus.Registerer) *metrics { +// m := &metrics{ +// cpuTemp: prometheus.NewGauge(prometheus.GaugeOpts{ +// Name: "cpu_temperature_celsius", +// Help: "Current temperature of the CPU.", +// }), +// hdFailures: prometheus.NewCounterVec( +// prometheus.CounterOpts{ +// Name: "hd_errors_total", +// Help: "Number of hard-disk errors.", +// }, +// []string{"device"}, +// ), +// } +// reg.MustRegister(m.cpuTemp) +// reg.MustRegister(m.hdFailures) +// return m +// } +// +// func main() { +// // Create a non-global registry. +// reg := prometheus.NewRegistry() +// +// // Create new metrics and register them using the custom registry. +// m := NewMetrics(reg) +// // Set values for the new created metrics. +// m.cpuTemp.Set(65.3) +// m.hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc() +// +// // Expose metrics and custom registry via an HTTP server +// // using the HandleFor function. "/metrics" is the usual endpoint for that. +// http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: reg})) +// log.Fatal(http.ListenAndServe(":8080", nil)) +// } // // This is a complete program that exports two metrics, a Gauge and a Counter, // the latter with a label attached to turn it into a (one-dimensional) vector. +// It register the metrics using a custom registry and exposes them via an HTTP server +// on the /metrics endpoint. // -// Metrics +// # Metrics // // The number of exported identifiers in this package might appear a bit // overwhelming. However, in addition to the basic plumbing shown in the example @@ -100,7 +111,7 @@ // To create instances of Metrics and their vector versions, you need a suitable // …Opts struct, i.e. GaugeOpts, CounterOpts, SummaryOpts, or HistogramOpts. // -// Custom Collectors and constant Metrics +// # Custom Collectors and constant Metrics // // While you could create your own implementations of Metric, most likely you // will only ever implement the Collector interface on your own. At a first @@ -141,7 +152,7 @@ // a metric, GaugeFunc, CounterFunc, or UntypedFunc might be interesting // shortcuts. // -// Advanced Uses of the Registry +// # Advanced Uses of the Registry // // While MustRegister is the by far most common way of registering a Collector, // sometimes you might want to handle the errors the registration might cause. @@ -176,23 +187,23 @@ // NewProcessCollector). With a custom registry, you are in control and decide // yourself about the Collectors to register. // -// HTTP Exposition +// # HTTP Exposition // // The Registry implements the Gatherer interface. The caller of the Gather // method can then expose the gathered metrics in some way. Usually, the metrics // are served via HTTP on the /metrics endpoint. That's happening in the example // above. The tools to expose metrics via HTTP are in the promhttp sub-package. // -// Pushing to the Pushgateway +// # Pushing to the Pushgateway // // Function for pushing to the Pushgateway can be found in the push sub-package. // -// Graphite Bridge +// # Graphite Bridge // // Functions and examples to push metrics from a Gatherer to Graphite can be // found in the graphite sub-package. // -// Other Means of Exposition +// # Other Means of Exposition // // More ways of exposing metrics can easily be added by following the approaches // of the existing implementations. diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/gauge.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/gauge.go index bd0733d6a..f1ea6c76f 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/gauge.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/gauge.go @@ -55,6 +55,18 @@ type Gauge interface { // GaugeOpts is an alias for Opts. See there for doc comments. type GaugeOpts Opts +// GaugeVecOpts bundles the options to create a GaugeVec metric. +// It is mandatory to set GaugeOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type GaugeVecOpts struct { + GaugeOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels +} + // NewGauge creates a new Gauge based on the provided GaugeOpts. // // The returned implementation is optimized for a fast Set method. If you have a @@ -138,16 +150,24 @@ type GaugeVec struct { // NewGaugeVec creates a new GaugeVec based on the provided GaugeOpts and // partitioned by the given label names. func NewGaugeVec(opts GaugeOpts, labelNames []string) *GaugeVec { - desc := NewDesc( + return V2.NewGaugeVec(GaugeVecOpts{ + GaugeOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewGaugeVec creates a new GaugeVec based on the provided GaugeVecOpts. +func (v2) NewGaugeVec(opts GaugeVecOpts) *GaugeVec { + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &GaugeVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { if len(lvs) != len(desc.variableLabels) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, lvs)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), lvs)) } result := &gauge{desc: desc, labelPairs: MakeLabelPairs(desc, lvs)} result.init(result) // Init self-collection. @@ -210,7 +230,8 @@ func (v *GaugeVec) GetMetricWith(labels Labels) (Gauge, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Add(42) +// +// myVec.WithLabelValues("404", "GET").Add(42) func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge { g, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -221,7 +242,8 @@ func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge { // With works as GetMetricWith, but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) func (v *GaugeVec) With(labels Labels) Gauge { g, err := v.GetMetricWith(labels) if err != nil { diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go index 3a2d55e84..2d8d9f64f 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go @@ -23,11 +23,10 @@ import ( "strings" "sync" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - dto "github.com/prometheus/client_model/go" - "github.com/prometheus/client_golang/prometheus/internal" + + dto "github.com/prometheus/client_model/go" + "google.golang.org/protobuf/proto" ) const ( diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/histogram.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/histogram.go index 0d47fecdc..8d818afe9 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/histogram.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/histogram.go @@ -22,25 +22,221 @@ import ( "sync/atomic" "time" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - dto "github.com/prometheus/client_model/go" + + "google.golang.org/protobuf/proto" ) +// nativeHistogramBounds for the frac of observed values. Only relevant for +// schema > 0. The position in the slice is the schema. (0 is never used, just +// here for convenience of using the schema directly as the index.) +// +// TODO(beorn7): Currently, we do a binary search into these slices. There are +// ways to turn it into a small number of simple array lookups. It probably only +// matters for schema 5 and beyond, but should be investigated. See this comment +// as a starting point: +// https://github.com/open-telemetry/opentelemetry-specification/issues/1776#issuecomment-870164310 +var nativeHistogramBounds = [][]float64{ + // Schema "0": + {0.5}, + // Schema 1: + {0.5, 0.7071067811865475}, + // Schema 2: + {0.5, 0.5946035575013605, 0.7071067811865475, 0.8408964152537144}, + // Schema 3: + { + 0.5, 0.5452538663326288, 0.5946035575013605, 0.6484197773255048, + 0.7071067811865475, 0.7711054127039704, 0.8408964152537144, 0.9170040432046711, + }, + // Schema 4: + { + 0.5, 0.5221368912137069, 0.5452538663326288, 0.5693943173783458, + 0.5946035575013605, 0.620928906036742, 0.6484197773255048, 0.6771277734684463, + 0.7071067811865475, 0.7384130729697496, 0.7711054127039704, 0.805245165974627, + 0.8408964152537144, 0.8781260801866495, 0.9170040432046711, 0.9576032806985735, + }, + // Schema 5: + { + 0.5, 0.5109485743270583, 0.5221368912137069, 0.5335702003384117, + 0.5452538663326288, 0.5571933712979462, 0.5693943173783458, 0.5818624293887887, + 0.5946035575013605, 0.6076236799902344, 0.620928906036742, 0.6345254785958666, + 0.6484197773255048, 0.6626183215798706, 0.6771277734684463, 0.6919549409819159, + 0.7071067811865475, 0.7225904034885232, 0.7384130729697496, 0.7545822137967112, + 0.7711054127039704, 0.7879904225539431, 0.805245165974627, 0.8228777390769823, + 0.8408964152537144, 0.8593096490612387, 0.8781260801866495, 0.8973545375015533, + 0.9170040432046711, 0.9370838170551498, 0.9576032806985735, 0.9785720620876999, + }, + // Schema 6: + { + 0.5, 0.5054446430258502, 0.5109485743270583, 0.5165124395106142, + 0.5221368912137069, 0.5278225891802786, 0.5335702003384117, 0.5393803988785598, + 0.5452538663326288, 0.5511912916539204, 0.5571933712979462, 0.5632608093041209, + 0.5693943173783458, 0.5755946149764913, 0.5818624293887887, 0.5881984958251406, + 0.5946035575013605, 0.6010783657263515, 0.6076236799902344, 0.6142402680534349, + 0.620928906036742, 0.6276903785123455, 0.6345254785958666, 0.6414350080393891, + 0.6484197773255048, 0.6554806057623822, 0.6626183215798706, 0.6698337620266515, + 0.6771277734684463, 0.6845012114872953, 0.6919549409819159, 0.6994898362691555, + 0.7071067811865475, 0.7148066691959849, 0.7225904034885232, 0.7304588970903234, + 0.7384130729697496, 0.7464538641456323, 0.7545822137967112, 0.762799075372269, + 0.7711054127039704, 0.7795022001189185, 0.7879904225539431, 0.7965710756711334, + 0.805245165974627, 0.8140137109286738, 0.8228777390769823, 0.8318382901633681, + 0.8408964152537144, 0.8500531768592616, 0.8593096490612387, 0.8686669176368529, + 0.8781260801866495, 0.8876882462632604, 0.8973545375015533, 0.9071260877501991, + 0.9170040432046711, 0.9269895625416926, 0.9370838170551498, 0.9472879907934827, + 0.9576032806985735, 0.9680308967461471, 0.9785720620876999, 0.9892280131939752, + }, + // Schema 7: + { + 0.5, 0.5027149505564014, 0.5054446430258502, 0.5081891574554764, + 0.5109485743270583, 0.5137229745593818, 0.5165124395106142, 0.5193170509806894, + 0.5221368912137069, 0.5249720429003435, 0.5278225891802786, 0.5306886136446309, + 0.5335702003384117, 0.5364674337629877, 0.5393803988785598, 0.5423091811066545, + 0.5452538663326288, 0.5482145409081883, 0.5511912916539204, 0.5541842058618393, + 0.5571933712979462, 0.5602188762048033, 0.5632608093041209, 0.5663192597993595, + 0.5693943173783458, 0.572486072215902, 0.5755946149764913, 0.5787200368168754, + 0.5818624293887887, 0.585021884841625, 0.5881984958251406, 0.5913923554921704, + 0.5946035575013605, 0.5978321960199137, 0.6010783657263515, 0.6043421618132907, + 0.6076236799902344, 0.6109230164863786, 0.6142402680534349, 0.6175755319684665, + 0.620928906036742, 0.6243004885946023, 0.6276903785123455, 0.6310986751971253, + 0.6345254785958666, 0.637970889198196, 0.6414350080393891, 0.6449179367033329, + 0.6484197773255048, 0.6519406325959679, 0.6554806057623822, 0.659039800633032, + 0.6626183215798706, 0.6662162735415805, 0.6698337620266515, 0.6734708931164728, + 0.6771277734684463, 0.6808045103191123, 0.6845012114872953, 0.688217985377265, + 0.6919549409819159, 0.6957121878859629, 0.6994898362691555, 0.7032879969095076, + 0.7071067811865475, 0.7109463010845827, 0.7148066691959849, 0.718687998724491, + 0.7225904034885232, 0.7265139979245261, 0.7304588970903234, 0.7344252166684908, + 0.7384130729697496, 0.7424225829363761, 0.7464538641456323, 0.7505070348132126, + 0.7545822137967112, 0.7586795205991071, 0.762799075372269, 0.7669409989204777, + 0.7711054127039704, 0.7752924388424999, 0.7795022001189185, 0.7837348199827764, + 0.7879904225539431, 0.7922691326262467, 0.7965710756711334, 0.8008963778413465, + 0.805245165974627, 0.8096175675974316, 0.8140137109286738, 0.8184337248834821, + 0.8228777390769823, 0.8273458838280969, 0.8318382901633681, 0.8363550898207981, + 0.8408964152537144, 0.8454623996346523, 0.8500531768592616, 0.8546688815502312, + 0.8593096490612387, 0.8639756154809185, 0.8686669176368529, 0.8733836930995842, + 0.8781260801866495, 0.8828942179666361, 0.8876882462632604, 0.8925083056594671, + 0.8973545375015533, 0.9022270839033115, 0.9071260877501991, 0.9120516927035263, + 0.9170040432046711, 0.9219832844793128, 0.9269895625416926, 0.9320230241988943, + 0.9370838170551498, 0.9421720895161669, 0.9472879907934827, 0.9524316709088368, + 0.9576032806985735, 0.9628029718180622, 0.9680308967461471, 0.9732872087896164, + 0.9785720620876999, 0.9838856116165875, 0.9892280131939752, 0.9945994234836328, + }, + // Schema 8: + { + 0.5, 0.5013556375251013, 0.5027149505564014, 0.5040779490592088, + 0.5054446430258502, 0.5068150424757447, 0.5081891574554764, 0.509566998038869, + 0.5109485743270583, 0.5123338964485679, 0.5137229745593818, 0.5151158188430205, + 0.5165124395106142, 0.5179128468009786, 0.5193170509806894, 0.520725062344158, + 0.5221368912137069, 0.5235525479396449, 0.5249720429003435, 0.526395386502313, + 0.5278225891802786, 0.5292536613972564, 0.5306886136446309, 0.5321274564422321, + 0.5335702003384117, 0.5350168559101208, 0.5364674337629877, 0.5379219445313954, + 0.5393803988785598, 0.5408428074966075, 0.5423091811066545, 0.5437795304588847, + 0.5452538663326288, 0.5467321995364429, 0.5482145409081883, 0.549700901315111, + 0.5511912916539204, 0.5526857228508706, 0.5541842058618393, 0.5556867516724088, + 0.5571933712979462, 0.5587040757836845, 0.5602188762048033, 0.5617377836665098, + 0.5632608093041209, 0.564787964283144, 0.5663192597993595, 0.5678547070789026, + 0.5693943173783458, 0.5709381019847808, 0.572486072215902, 0.5740382394200894, + 0.5755946149764913, 0.5771552102951081, 0.5787200368168754, 0.5802891060137493, + 0.5818624293887887, 0.5834400184762408, 0.585021884841625, 0.5866080400818185, + 0.5881984958251406, 0.5897932637314379, 0.5913923554921704, 0.5929957828304968, + 0.5946035575013605, 0.5962156912915756, 0.5978321960199137, 0.5994530835371903, + 0.6010783657263515, 0.6027080545025619, 0.6043421618132907, 0.6059806996384005, + 0.6076236799902344, 0.6092711149137041, 0.6109230164863786, 0.6125793968185725, + 0.6142402680534349, 0.6159056423670379, 0.6175755319684665, 0.6192499490999082, + 0.620928906036742, 0.622612415087629, 0.6243004885946023, 0.6259931389331581, + 0.6276903785123455, 0.6293922197748583, 0.6310986751971253, 0.6328097572894031, + 0.6345254785958666, 0.6362458516947014, 0.637970889198196, 0.6397006037528346, + 0.6414350080393891, 0.6431741147730128, 0.6449179367033329, 0.6466664866145447, + 0.6484197773255048, 0.6501778216898253, 0.6519406325959679, 0.6537082229673385, + 0.6554806057623822, 0.6572577939746774, 0.659039800633032, 0.6608266388015788, + 0.6626183215798706, 0.6644148621029772, 0.6662162735415805, 0.6680225691020727, + 0.6698337620266515, 0.6716498655934177, 0.6734708931164728, 0.6752968579460171, + 0.6771277734684463, 0.6789636531064505, 0.6808045103191123, 0.6826503586020058, + 0.6845012114872953, 0.6863570825438342, 0.688217985377265, 0.690083933630119, + 0.6919549409819159, 0.6938310211492645, 0.6957121878859629, 0.6975984549830999, + 0.6994898362691555, 0.7013863456101023, 0.7032879969095076, 0.7051948041086352, + 0.7071067811865475, 0.7090239421602076, 0.7109463010845827, 0.7128738720527471, + 0.7148066691959849, 0.7167447066838943, 0.718687998724491, 0.7206365595643126, + 0.7225904034885232, 0.7245495448210174, 0.7265139979245261, 0.7284837772007218, + 0.7304588970903234, 0.7324393720732029, 0.7344252166684908, 0.7364164454346837, + 0.7384130729697496, 0.7404151139112358, 0.7424225829363761, 0.7444354947621984, + 0.7464538641456323, 0.7484777058836176, 0.7505070348132126, 0.7525418658117031, + 0.7545822137967112, 0.7566280937263048, 0.7586795205991071, 0.7607365094544071, + 0.762799075372269, 0.7648672334736434, 0.7669409989204777, 0.7690203869158282, + 0.7711054127039704, 0.7731960915705107, 0.7752924388424999, 0.7773944698885442, + 0.7795022001189185, 0.7816156449856788, 0.7837348199827764, 0.7858597406461707, + 0.7879904225539431, 0.7901268813264122, 0.7922691326262467, 0.7944171921585818, + 0.7965710756711334, 0.7987307989543135, 0.8008963778413465, 0.8030678282083853, + 0.805245165974627, 0.8074284071024302, 0.8096175675974316, 0.8118126635086642, + 0.8140137109286738, 0.8162207259936375, 0.8184337248834821, 0.820652723822003, + 0.8228777390769823, 0.8251087869603088, 0.8273458838280969, 0.8295890460808079, + 0.8318382901633681, 0.8340936325652911, 0.8363550898207981, 0.8386226785089391, + 0.8408964152537144, 0.8431763167241966, 0.8454623996346523, 0.8477546807446661, + 0.8500531768592616, 0.8523579048290255, 0.8546688815502312, 0.8569861239649629, + 0.8593096490612387, 0.8616394738731368, 0.8639756154809185, 0.8663180910111553, + 0.8686669176368529, 0.871022112577578, 0.8733836930995842, 0.8757516765159389, + 0.8781260801866495, 0.8805069215187917, 0.8828942179666361, 0.8852879870317771, + 0.8876882462632604, 0.890095013257712, 0.8925083056594671, 0.8949281411607002, + 0.8973545375015533, 0.8997875124702672, 0.9022270839033115, 0.9046732696855155, + 0.9071260877501991, 0.909585556079304, 0.9120516927035263, 0.9145245157024483, + 0.9170040432046711, 0.9194902933879467, 0.9219832844793128, 0.9244830347552253, + 0.9269895625416926, 0.92950288621441, 0.9320230241988943, 0.9345499949706191, + 0.9370838170551498, 0.93962450902828, 0.9421720895161669, 0.9447265771954693, + 0.9472879907934827, 0.9498563490882775, 0.9524316709088368, 0.9550139751351947, + 0.9576032806985735, 0.9601996065815236, 0.9628029718180622, 0.9654133954938133, + 0.9680308967461471, 0.9706554947643201, 0.9732872087896164, 0.9759260581154889, + 0.9785720620876999, 0.9812252401044634, 0.9838856116165875, 0.9865531961276168, + 0.9892280131939752, 0.9919100824251095, 0.9945994234836328, 0.9972960560854698, + }, +} + +// The nativeHistogramBounds above can be generated with the code below. +// +// TODO(beorn7): It's tempting to actually use `go generate` to generate the +// code above. However, this could lead to slightly different numbers on +// different architectures. We still need to come to terms if we are fine with +// that, or if we might prefer to specify precise numbers in the standard. +// +// var nativeHistogramBounds [][]float64 = make([][]float64, 9) +// +// func init() { +// // Populate nativeHistogramBounds. +// numBuckets := 1 +// for i := range nativeHistogramBounds { +// bounds := []float64{0.5} +// factor := math.Exp2(math.Exp2(float64(-i))) +// for j := 0; j < numBuckets-1; j++ { +// var bound float64 +// if (j+1)%2 == 0 { +// // Use previously calculated value for increased precision. +// bound = nativeHistogramBounds[i-1][j/2+1] +// } else { +// bound = bounds[j] * factor +// } +// bounds = append(bounds, bound) +// } +// numBuckets *= 2 +// nativeHistogramBounds[i] = bounds +// } +// } + // A Histogram counts individual observations from an event or sample stream in -// configurable buckets. Similar to a summary, it also provides a sum of -// observations and an observation count. +// configurable static buckets (or in dynamic sparse buckets as part of the +// experimental Native Histograms, see below for more details). Similar to a +// Summary, it also provides a sum of observations and an observation count. // // On the Prometheus server, quantiles can be calculated from a Histogram using -// the histogram_quantile function in the query language. +// the histogram_quantile PromQL function. // -// Note that Histograms, in contrast to Summaries, can be aggregated with the -// Prometheus query language (see the documentation for detailed -// procedures). However, Histograms require the user to pre-define suitable -// buckets, and they are in general less accurate. The Observe method of a -// Histogram has a very low performance overhead in comparison with the Observe -// method of a Summary. +// Note that Histograms, in contrast to Summaries, can be aggregated in PromQL +// (see the documentation for detailed procedures). However, Histograms require +// the user to pre-define suitable buckets, and they are in general less +// accurate. (Both problems are addressed by the experimental Native +// Histograms. To use them, configure a NativeHistogramBucketFactor in the +// HistogramOpts. They also require a Prometheus server v2.40+ with the +// corresponding feature flag enabled.) +// +// The Observe method of a Histogram has a very low performance overhead in +// comparison with the Observe method of a Summary. // // To create Histogram instances, use NewHistogram. type Histogram interface { @@ -50,7 +246,8 @@ type Histogram interface { // Observe adds a single observation to the histogram. Observations are // usually positive or zero. Negative observations are accepted but // prevent current versions of Prometheus from properly detecting - // counter resets in the sum of observations. See + // counter resets in the sum of observations. (The experimental Native + // Histograms handle negative observations properly.) See // https://prometheus.io/docs/practices/histograms/#count-and-sum-of-observations // for details. Observe(float64) @@ -64,18 +261,28 @@ const bucketLabel = "le" // tailored to broadly measure the response time (in seconds) of a network // service. Most likely, however, you will be required to define buckets // customized to your use case. -var ( - DefBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10} +var DefBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10} - errBucketLabelNotAllowed = fmt.Errorf( - "%q is not allowed as label name in histograms", bucketLabel, - ) +// DefNativeHistogramZeroThreshold is the default value for +// NativeHistogramZeroThreshold in the HistogramOpts. +// +// The value is 2^-128 (or 0.5*2^-127 in the actual IEEE 754 representation), +// which is a bucket boundary at all possible resolutions. +const DefNativeHistogramZeroThreshold = 2.938735877055719e-39 + +// NativeHistogramZeroThresholdZero can be used as NativeHistogramZeroThreshold +// in the HistogramOpts to create a zero bucket of width zero, i.e. a zero +// bucket that only receives observations of precisely zero. +const NativeHistogramZeroThresholdZero = -1 + +var errBucketLabelNotAllowed = fmt.Errorf( + "%q is not allowed as label name in histograms", bucketLabel, ) -// LinearBuckets creates 'count' buckets, each 'width' wide, where the lowest -// bucket has an upper bound of 'start'. The final +Inf bucket is not counted -// and not included in the returned slice. The returned slice is meant to be -// used for the Buckets field of HistogramOpts. +// LinearBuckets creates 'count' regular buckets, each 'width' wide, where the +// lowest bucket has an upper bound of 'start'. The final +Inf bucket is not +// counted and not included in the returned slice. The returned slice is meant +// to be used for the Buckets field of HistogramOpts. // // The function panics if 'count' is zero or negative. func LinearBuckets(start, width float64, count int) []float64 { @@ -90,11 +297,11 @@ func LinearBuckets(start, width float64, count int) []float64 { return buckets } -// ExponentialBuckets creates 'count' buckets, where the lowest bucket has an -// upper bound of 'start' and each following bucket's upper bound is 'factor' -// times the previous bucket's upper bound. The final +Inf bucket is not counted -// and not included in the returned slice. The returned slice is meant to be -// used for the Buckets field of HistogramOpts. +// ExponentialBuckets creates 'count' regular buckets, where the lowest bucket +// has an upper bound of 'start' and each following bucket's upper bound is +// 'factor' times the previous bucket's upper bound. The final +Inf bucket is +// not counted and not included in the returned slice. The returned slice is +// meant to be used for the Buckets field of HistogramOpts. // // The function panics if 'count' is 0 or negative, if 'start' is 0 or negative, // or if 'factor' is less than or equal 1. @@ -180,8 +387,97 @@ type HistogramOpts struct { // element in the slice is the upper inclusive bound of a bucket. The // values must be sorted in strictly increasing order. There is no need // to add a highest bucket with +Inf bound, it will be added - // implicitly. The default value is DefBuckets. + // implicitly. If Buckets is left as nil or set to a slice of length + // zero, it is replaced by default buckets. The default buckets are + // DefBuckets if no buckets for a native histogram (see below) are used, + // otherwise the default is no buckets. (In other words, if you want to + // use both reguler buckets and buckets for a native histogram, you have + // to define the regular buckets here explicitly.) Buckets []float64 + + // If NativeHistogramBucketFactor is greater than one, so-called sparse + // buckets are used (in addition to the regular buckets, if defined + // above). A Histogram with sparse buckets will be ingested as a Native + // Histogram by a Prometheus server with that feature enabled (requires + // Prometheus v2.40+). Sparse buckets are exponential buckets covering + // the whole float64 range (with the exception of the “zero” bucket, see + // NativeHistogramZeroThreshold below). From any one bucket to the next, + // the width of the bucket grows by a constant + // factor. NativeHistogramBucketFactor provides an upper bound for this + // factor (exception see below). The smaller + // NativeHistogramBucketFactor, the more buckets will be used and thus + // the more costly the histogram will become. A generally good trade-off + // between cost and accuracy is a value of 1.1 (each bucket is at most + // 10% wider than the previous one), which will result in each power of + // two divided into 8 buckets (e.g. there will be 8 buckets between 1 + // and 2, same as between 2 and 4, and 4 and 8, etc.). + // + // Details about the actually used factor: The factor is calculated as + // 2^(2^n), where n is an integer number between (and including) -8 and + // 4. n is chosen so that the resulting factor is the largest that is + // still smaller or equal to NativeHistogramBucketFactor. Note that the + // smallest possible factor is therefore approx. 1.00271 (i.e. 2^(2^-8) + // ). If NativeHistogramBucketFactor is greater than 1 but smaller than + // 2^(2^-8), then the actually used factor is still 2^(2^-8) even though + // it is larger than the provided NativeHistogramBucketFactor. + // + // NOTE: Native Histograms are still an experimental feature. Their + // behavior might still change without a major version + // bump. Subsequently, all NativeHistogram... options here might still + // change their behavior or name (or might completely disappear) without + // a major version bump. + NativeHistogramBucketFactor float64 + // All observations with an absolute value of less or equal + // NativeHistogramZeroThreshold are accumulated into a “zero” + // bucket. For best results, this should be close to a bucket + // boundary. This is usually the case if picking a power of two. If + // NativeHistogramZeroThreshold is left at zero, + // DefNativeHistogramZeroThreshold is used as the threshold. To configure + // a zero bucket with an actual threshold of zero (i.e. only + // observations of precisely zero will go into the zero bucket), set + // NativeHistogramZeroThreshold to the NativeHistogramZeroThresholdZero + // constant (or any negative float value). + NativeHistogramZeroThreshold float64 + + // The remaining fields define a strategy to limit the number of + // populated sparse buckets. If NativeHistogramMaxBucketNumber is left + // at zero, the number of buckets is not limited. (Note that this might + // lead to unbounded memory consumption if the values observed by the + // Histogram are sufficiently wide-spread. In particular, this could be + // used as a DoS attack vector. Where the observed values depend on + // external inputs, it is highly recommended to set a + // NativeHistogramMaxBucketNumber.) Once the set + // NativeHistogramMaxBucketNumber is exceeded, the following strategy is + // enacted: First, if the last reset (or the creation) of the histogram + // is at least NativeHistogramMinResetDuration ago, then the whole + // histogram is reset to its initial state (including regular + // buckets). If less time has passed, or if + // NativeHistogramMinResetDuration is zero, no reset is + // performed. Instead, the zero threshold is increased sufficiently to + // reduce the number of buckets to or below + // NativeHistogramMaxBucketNumber, but not to more than + // NativeHistogramMaxZeroThreshold. Thus, if + // NativeHistogramMaxZeroThreshold is already at or below the current + // zero threshold, nothing happens at this step. After that, if the + // number of buckets still exceeds NativeHistogramMaxBucketNumber, the + // resolution of the histogram is reduced by doubling the width of the + // sparse buckets (up to a growth factor between one bucket to the next + // of 2^(2^4) = 65536, see above). + NativeHistogramMaxBucketNumber uint32 + NativeHistogramMinResetDuration time.Duration + NativeHistogramMaxZeroThreshold float64 +} + +// HistogramVecOpts bundles the options to create a HistogramVec metric. +// It is mandatory to set HistogramOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type HistogramVecOpts struct { + HistogramOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels } // NewHistogram creates a new Histogram based on the provided HistogramOpts. It @@ -204,11 +500,11 @@ func NewHistogram(opts HistogramOpts) Histogram { func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogram { if len(desc.variableLabels) != len(labelValues) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, labelValues)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), labelValues)) } for _, n := range desc.variableLabels { - if n == bucketLabel { + if n.Name == bucketLabel { panic(errBucketLabelNotAllowed) } } @@ -218,16 +514,29 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr } } - if len(opts.Buckets) == 0 { - opts.Buckets = DefBuckets - } - h := &histogram{ - desc: desc, - upperBounds: opts.Buckets, - labelPairs: MakeLabelPairs(desc, labelValues), - counts: [2]*histogramCounts{{}, {}}, - now: time.Now, + desc: desc, + upperBounds: opts.Buckets, + labelPairs: MakeLabelPairs(desc, labelValues), + nativeHistogramMaxBuckets: opts.NativeHistogramMaxBucketNumber, + nativeHistogramMaxZeroThreshold: opts.NativeHistogramMaxZeroThreshold, + nativeHistogramMinResetDuration: opts.NativeHistogramMinResetDuration, + lastResetTime: time.Now(), + now: time.Now, + } + if len(h.upperBounds) == 0 && opts.NativeHistogramBucketFactor <= 1 { + h.upperBounds = DefBuckets + } + if opts.NativeHistogramBucketFactor <= 1 { + h.nativeHistogramSchema = math.MinInt32 // To mark that there are no sparse buckets. + } else { + switch { + case opts.NativeHistogramZeroThreshold > 0: + h.nativeHistogramZeroThreshold = opts.NativeHistogramZeroThreshold + case opts.NativeHistogramZeroThreshold == 0: + h.nativeHistogramZeroThreshold = DefNativeHistogramZeroThreshold + } // Leave h.nativeHistogramZeroThreshold at 0 otherwise. + h.nativeHistogramSchema = pickSchema(opts.NativeHistogramBucketFactor) } for i, upperBound := range h.upperBounds { if i < len(h.upperBounds)-1 { @@ -246,8 +555,12 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr } // Finally we know the final length of h.upperBounds and can make buckets // for both counts as well as exemplars: - h.counts[0].buckets = make([]uint64, len(h.upperBounds)) - h.counts[1].buckets = make([]uint64, len(h.upperBounds)) + h.counts[0] = &histogramCounts{buckets: make([]uint64, len(h.upperBounds))} + atomic.StoreUint64(&h.counts[0].nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold)) + atomic.StoreInt32(&h.counts[0].nativeHistogramSchema, h.nativeHistogramSchema) + h.counts[1] = &histogramCounts{buckets: make([]uint64, len(h.upperBounds))} + atomic.StoreUint64(&h.counts[1].nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold)) + atomic.StoreInt32(&h.counts[1].nativeHistogramSchema, h.nativeHistogramSchema) h.exemplars = make([]atomic.Value, len(h.upperBounds)+1) h.init(h) // Init self-collection. @@ -255,13 +568,98 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr } type histogramCounts struct { + // Order in this struct matters for the alignment required by atomic + // operations, see http://golang.org/pkg/sync/atomic/#pkg-note-BUG + // sumBits contains the bits of the float64 representing the sum of all - // observations. sumBits and count have to go first in the struct to - // guarantee alignment for atomic operations. - // http://golang.org/pkg/sync/atomic/#pkg-note-BUG + // observations. sumBits uint64 count uint64 + + // nativeHistogramZeroBucket counts all (positive and negative) + // observations in the zero bucket (with an absolute value less or equal + // the current threshold, see next field. + nativeHistogramZeroBucket uint64 + // nativeHistogramZeroThresholdBits is the bit pattern of the current + // threshold for the zero bucket. It's initially equal to + // nativeHistogramZeroThreshold but may change according to the bucket + // count limitation strategy. + nativeHistogramZeroThresholdBits uint64 + // nativeHistogramSchema may change over time according to the bucket + // count limitation strategy and therefore has to be saved here. + nativeHistogramSchema int32 + // Number of (positive and negative) sparse buckets. + nativeHistogramBucketsNumber uint32 + + // Regular buckets. buckets []uint64 + + // The sparse buckets for native histograms are implemented with a + // sync.Map for now. A dedicated data structure will likely be more + // efficient. There are separate maps for negative and positive + // observations. The map's value is an *int64, counting observations in + // that bucket. (Note that we don't use uint64 as an int64 won't + // overflow in practice, and working with signed numbers from the + // beginning simplifies the handling of deltas.) The map's key is the + // index of the bucket according to the used + // nativeHistogramSchema. Index 0 is for an upper bound of 1. + nativeHistogramBucketsPositive, nativeHistogramBucketsNegative sync.Map +} + +// observe manages the parts of observe that only affects +// histogramCounts. doSparse is true if sparse buckets should be done, +// too. +func (hc *histogramCounts) observe(v float64, bucket int, doSparse bool) { + if bucket < len(hc.buckets) { + atomic.AddUint64(&hc.buckets[bucket], 1) + } + atomicAddFloat(&hc.sumBits, v) + if doSparse && !math.IsNaN(v) { + var ( + key int + schema = atomic.LoadInt32(&hc.nativeHistogramSchema) + zeroThreshold = math.Float64frombits(atomic.LoadUint64(&hc.nativeHistogramZeroThresholdBits)) + bucketCreated, isInf bool + ) + if math.IsInf(v, 0) { + // Pretend v is MaxFloat64 but later increment key by one. + if math.IsInf(v, +1) { + v = math.MaxFloat64 + } else { + v = -math.MaxFloat64 + } + isInf = true + } + frac, exp := math.Frexp(math.Abs(v)) + if schema > 0 { + bounds := nativeHistogramBounds[schema] + key = sort.SearchFloat64s(bounds, frac) + (exp-1)*len(bounds) + } else { + key = exp + if frac == 0.5 { + key-- + } + offset := (1 << -schema) - 1 + key = (key + offset) >> -schema + } + if isInf { + key++ + } + switch { + case v > zeroThreshold: + bucketCreated = addToBucket(&hc.nativeHistogramBucketsPositive, key, 1) + case v < -zeroThreshold: + bucketCreated = addToBucket(&hc.nativeHistogramBucketsNegative, key, 1) + default: + atomic.AddUint64(&hc.nativeHistogramZeroBucket, 1) + } + if bucketCreated { + atomic.AddUint32(&hc.nativeHistogramBucketsNumber, 1) + } + } + // Increment count last as we take it as a signal that the observation + // is complete. + atomic.AddUint64(&hc.count, 1) } type histogram struct { @@ -276,7 +674,7 @@ type histogram struct { // perspective of the histogram) swap the hot–cold under the writeMtx // lock. A cooldown is awaited (while locked) by comparing the number of // observations with the initiation count. Once they match, then the - // last observation on the now cool one has completed. All cool fields must + // last observation on the now cool one has completed. All cold fields must // be merged into the new hot before releasing writeMtx. // // Fields with atomic access first! See alignment constraint: @@ -284,8 +682,10 @@ type histogram struct { countAndHotIdx uint64 selfCollector - desc *Desc - writeMtx sync.Mutex // Only used in the Write method. + desc *Desc + + // Only used in the Write method and for sparse bucket management. + mtx sync.Mutex // Two counts, one is "hot" for lock-free observations, the other is // "cold" for writing out a dto.Metric. It has to be an array of @@ -293,9 +693,15 @@ type histogram struct { // http://golang.org/pkg/sync/atomic/#pkg-note-BUG. counts [2]*histogramCounts - upperBounds []float64 - labelPairs []*dto.LabelPair - exemplars []atomic.Value // One more than buckets (to include +Inf), each a *dto.Exemplar. + upperBounds []float64 + labelPairs []*dto.LabelPair + exemplars []atomic.Value // One more than buckets (to include +Inf), each a *dto.Exemplar. + nativeHistogramSchema int32 // The initial schema. Set to math.MinInt32 if no sparse buckets are used. + nativeHistogramZeroThreshold float64 // The initial zero threshold. + nativeHistogramMaxZeroThreshold float64 + nativeHistogramMaxBuckets uint32 + nativeHistogramMinResetDuration time.Duration + lastResetTime time.Time // Protected by mtx. now func() time.Time // To mock out time.Now() for testing. } @@ -319,8 +725,8 @@ func (h *histogram) Write(out *dto.Metric) error { // the hot path, i.e. Observe is called much more often than Write. The // complication of making Write lock-free isn't worth it, if possible at // all. - h.writeMtx.Lock() - defer h.writeMtx.Unlock() + h.mtx.Lock() + defer h.mtx.Unlock() // Adding 1<<63 switches the hot index (from 0 to 1 or from 1 to 0) // without touching the count bits. See the struct comments for a full @@ -333,16 +739,16 @@ func (h *histogram) Write(out *dto.Metric) error { hotCounts := h.counts[n>>63] coldCounts := h.counts[(^n)>>63] - // Await cooldown. - for count != atomic.LoadUint64(&coldCounts.count) { - runtime.Gosched() // Let observations get work done. - } + waitForCooldown(count, coldCounts) his := &dto.Histogram{ Bucket: make([]*dto.Bucket, len(h.upperBounds)), SampleCount: proto.Uint64(count), SampleSum: proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.sumBits))), } + out.Histogram = his + out.Label = h.labelPairs + var cumCount uint64 for i, upperBound := range h.upperBounds { cumCount += atomic.LoadUint64(&coldCounts.buckets[i]) @@ -363,25 +769,21 @@ func (h *histogram) Write(out *dto.Metric) error { } his.Bucket = append(his.Bucket, b) } - - out.Histogram = his - out.Label = h.labelPairs - - // Finally add all the cold counts to the new hot counts and reset the cold counts. - atomic.AddUint64(&hotCounts.count, count) - atomic.StoreUint64(&coldCounts.count, 0) - for { - oldBits := atomic.LoadUint64(&hotCounts.sumBits) - newBits := math.Float64bits(math.Float64frombits(oldBits) + his.GetSampleSum()) - if atomic.CompareAndSwapUint64(&hotCounts.sumBits, oldBits, newBits) { - atomic.StoreUint64(&coldCounts.sumBits, 0) - break - } - } - for i := range h.upperBounds { - atomic.AddUint64(&hotCounts.buckets[i], atomic.LoadUint64(&coldCounts.buckets[i])) - atomic.StoreUint64(&coldCounts.buckets[i], 0) + if h.nativeHistogramSchema > math.MinInt32 { + his.ZeroThreshold = proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.nativeHistogramZeroThresholdBits))) + his.Schema = proto.Int32(atomic.LoadInt32(&coldCounts.nativeHistogramSchema)) + zeroBucket := atomic.LoadUint64(&coldCounts.nativeHistogramZeroBucket) + + defer func() { + coldCounts.nativeHistogramBucketsPositive.Range(addAndReset(&hotCounts.nativeHistogramBucketsPositive, &hotCounts.nativeHistogramBucketsNumber)) + coldCounts.nativeHistogramBucketsNegative.Range(addAndReset(&hotCounts.nativeHistogramBucketsNegative, &hotCounts.nativeHistogramBucketsNumber)) + }() + + his.ZeroCount = proto.Uint64(zeroBucket) + his.NegativeSpan, his.NegativeDelta = makeBuckets(&coldCounts.nativeHistogramBucketsNegative) + his.PositiveSpan, his.PositiveDelta = makeBuckets(&coldCounts.nativeHistogramBucketsPositive) } + addAndResetCounts(hotCounts, coldCounts) return nil } @@ -402,25 +804,216 @@ func (h *histogram) findBucket(v float64) int { // observe is the implementation for Observe without the findBucket part. func (h *histogram) observe(v float64, bucket int) { + // Do not add to sparse buckets for NaN observations. + doSparse := h.nativeHistogramSchema > math.MinInt32 && !math.IsNaN(v) // We increment h.countAndHotIdx so that the counter in the lower // 63 bits gets incremented. At the same time, we get the new value // back, which we can use to find the currently-hot counts. n := atomic.AddUint64(&h.countAndHotIdx, 1) hotCounts := h.counts[n>>63] + hotCounts.observe(v, bucket, doSparse) + if doSparse { + h.limitBuckets(hotCounts, v, bucket) + } +} - if bucket < len(h.upperBounds) { - atomic.AddUint64(&hotCounts.buckets[bucket], 1) +// limitBuckets applies a strategy to limit the number of populated sparse +// buckets. It's generally best effort, and there are situations where the +// number can go higher (if even the lowest resolution isn't enough to reduce +// the number sufficiently, or if the provided counts aren't fully updated yet +// by a concurrently happening Write call). +func (h *histogram) limitBuckets(counts *histogramCounts, value float64, bucket int) { + if h.nativeHistogramMaxBuckets == 0 { + return // No limit configured. } - for { - oldBits := atomic.LoadUint64(&hotCounts.sumBits) - newBits := math.Float64bits(math.Float64frombits(oldBits) + v) - if atomic.CompareAndSwapUint64(&hotCounts.sumBits, oldBits, newBits) { - break + if h.nativeHistogramMaxBuckets >= atomic.LoadUint32(&counts.nativeHistogramBucketsNumber) { + return // Bucket limit not exceeded yet. + } + + h.mtx.Lock() + defer h.mtx.Unlock() + + // The hot counts might have been swapped just before we acquired the + // lock. Re-fetch the hot counts first... + n := atomic.LoadUint64(&h.countAndHotIdx) + hotIdx := n >> 63 + coldIdx := (^n) >> 63 + hotCounts := h.counts[hotIdx] + coldCounts := h.counts[coldIdx] + // ...and then check again if we really have to reduce the bucket count. + if h.nativeHistogramMaxBuckets >= atomic.LoadUint32(&hotCounts.nativeHistogramBucketsNumber) { + return // Bucket limit not exceeded after all. + } + // Try the various strategies in order. + if h.maybeReset(hotCounts, coldCounts, coldIdx, value, bucket) { + return + } + if h.maybeWidenZeroBucket(hotCounts, coldCounts) { + return + } + h.doubleBucketWidth(hotCounts, coldCounts) +} + +// maybeReset resests the whole histogram if at least h.nativeHistogramMinResetDuration +// has been passed. It returns true if the histogram has been reset. The caller +// must have locked h.mtx. +func (h *histogram) maybeReset(hot, cold *histogramCounts, coldIdx uint64, value float64, bucket int) bool { + // We are using the possibly mocked h.now() rather than + // time.Since(h.lastResetTime) to enable testing. + if h.nativeHistogramMinResetDuration == 0 || h.now().Sub(h.lastResetTime) < h.nativeHistogramMinResetDuration { + return false + } + // Completely reset coldCounts. + h.resetCounts(cold) + // Repeat the latest observation to not lose it completely. + cold.observe(value, bucket, true) + // Make coldCounts the new hot counts while ressetting countAndHotIdx. + n := atomic.SwapUint64(&h.countAndHotIdx, (coldIdx<<63)+1) + count := n & ((1 << 63) - 1) + waitForCooldown(count, hot) + // Finally, reset the formerly hot counts, too. + h.resetCounts(hot) + h.lastResetTime = h.now() + return true +} + +// maybeWidenZeroBucket widens the zero bucket until it includes the existing +// buckets closest to the zero bucket (which could be two, if an equidistant +// negative and a positive bucket exists, but usually it's only one bucket to be +// merged into the new wider zero bucket). h.nativeHistogramMaxZeroThreshold +// limits how far the zero bucket can be extended, and if that's not enough to +// include an existing bucket, the method returns false. The caller must have +// locked h.mtx. +func (h *histogram) maybeWidenZeroBucket(hot, cold *histogramCounts) bool { + currentZeroThreshold := math.Float64frombits(atomic.LoadUint64(&hot.nativeHistogramZeroThresholdBits)) + if currentZeroThreshold >= h.nativeHistogramMaxZeroThreshold { + return false + } + // Find the key of the bucket closest to zero. + smallestKey := findSmallestKey(&hot.nativeHistogramBucketsPositive) + smallestNegativeKey := findSmallestKey(&hot.nativeHistogramBucketsNegative) + if smallestNegativeKey < smallestKey { + smallestKey = smallestNegativeKey + } + if smallestKey == math.MaxInt32 { + return false + } + newZeroThreshold := getLe(smallestKey, atomic.LoadInt32(&hot.nativeHistogramSchema)) + if newZeroThreshold > h.nativeHistogramMaxZeroThreshold { + return false // New threshold would exceed the max threshold. + } + atomic.StoreUint64(&cold.nativeHistogramZeroThresholdBits, math.Float64bits(newZeroThreshold)) + // Remove applicable buckets. + if _, loaded := cold.nativeHistogramBucketsNegative.LoadAndDelete(smallestKey); loaded { + atomicDecUint32(&cold.nativeHistogramBucketsNumber) + } + if _, loaded := cold.nativeHistogramBucketsPositive.LoadAndDelete(smallestKey); loaded { + atomicDecUint32(&cold.nativeHistogramBucketsNumber) + } + // Make cold counts the new hot counts. + n := atomic.AddUint64(&h.countAndHotIdx, 1<<63) + count := n & ((1 << 63) - 1) + // Swap the pointer names to represent the new roles and make + // the rest less confusing. + hot, cold = cold, hot + waitForCooldown(count, cold) + // Add all the now cold counts to the new hot counts... + addAndResetCounts(hot, cold) + // ...adjust the new zero threshold in the cold counts, too... + atomic.StoreUint64(&cold.nativeHistogramZeroThresholdBits, math.Float64bits(newZeroThreshold)) + // ...and then merge the newly deleted buckets into the wider zero + // bucket. + mergeAndDeleteOrAddAndReset := func(hotBuckets, coldBuckets *sync.Map) func(k, v interface{}) bool { + return func(k, v interface{}) bool { + key := k.(int) + bucket := v.(*int64) + if key == smallestKey { + // Merge into hot zero bucket... + atomic.AddUint64(&hot.nativeHistogramZeroBucket, uint64(atomic.LoadInt64(bucket))) + // ...and delete from cold counts. + coldBuckets.Delete(key) + atomicDecUint32(&cold.nativeHistogramBucketsNumber) + } else { + // Add to corresponding hot bucket... + if addToBucket(hotBuckets, key, atomic.LoadInt64(bucket)) { + atomic.AddUint32(&hot.nativeHistogramBucketsNumber, 1) + } + // ...and reset cold bucket. + atomic.StoreInt64(bucket, 0) + } + return true } } - // Increment count last as we take it as a signal that the observation - // is complete. - atomic.AddUint64(&hotCounts.count, 1) + + cold.nativeHistogramBucketsPositive.Range(mergeAndDeleteOrAddAndReset(&hot.nativeHistogramBucketsPositive, &cold.nativeHistogramBucketsPositive)) + cold.nativeHistogramBucketsNegative.Range(mergeAndDeleteOrAddAndReset(&hot.nativeHistogramBucketsNegative, &cold.nativeHistogramBucketsNegative)) + return true +} + +// doubleBucketWidth doubles the bucket width (by decrementing the schema +// number). Note that very sparse buckets could lead to a low reduction of the +// bucket count (or even no reduction at all). The method does nothing if the +// schema is already -4. +func (h *histogram) doubleBucketWidth(hot, cold *histogramCounts) { + coldSchema := atomic.LoadInt32(&cold.nativeHistogramSchema) + if coldSchema == -4 { + return // Already at lowest resolution. + } + coldSchema-- + atomic.StoreInt32(&cold.nativeHistogramSchema, coldSchema) + // Play it simple and just delete all cold buckets. + atomic.StoreUint32(&cold.nativeHistogramBucketsNumber, 0) + deleteSyncMap(&cold.nativeHistogramBucketsNegative) + deleteSyncMap(&cold.nativeHistogramBucketsPositive) + // Make coldCounts the new hot counts. + n := atomic.AddUint64(&h.countAndHotIdx, 1<<63) + count := n & ((1 << 63) - 1) + // Swap the pointer names to represent the new roles and make + // the rest less confusing. + hot, cold = cold, hot + waitForCooldown(count, cold) + // Add all the now cold counts to the new hot counts... + addAndResetCounts(hot, cold) + // ...adjust the schema in the cold counts, too... + atomic.StoreInt32(&cold.nativeHistogramSchema, coldSchema) + // ...and then merge the cold buckets into the wider hot buckets. + merge := func(hotBuckets *sync.Map) func(k, v interface{}) bool { + return func(k, v interface{}) bool { + key := k.(int) + bucket := v.(*int64) + // Adjust key to match the bucket to merge into. + if key > 0 { + key++ + } + key /= 2 + // Add to corresponding hot bucket. + if addToBucket(hotBuckets, key, atomic.LoadInt64(bucket)) { + atomic.AddUint32(&hot.nativeHistogramBucketsNumber, 1) + } + return true + } + } + + cold.nativeHistogramBucketsPositive.Range(merge(&hot.nativeHistogramBucketsPositive)) + cold.nativeHistogramBucketsNegative.Range(merge(&hot.nativeHistogramBucketsNegative)) + // Play it simple again and just delete all cold buckets. + atomic.StoreUint32(&cold.nativeHistogramBucketsNumber, 0) + deleteSyncMap(&cold.nativeHistogramBucketsNegative) + deleteSyncMap(&cold.nativeHistogramBucketsPositive) +} + +func (h *histogram) resetCounts(counts *histogramCounts) { + atomic.StoreUint64(&counts.sumBits, 0) + atomic.StoreUint64(&counts.count, 0) + atomic.StoreUint64(&counts.nativeHistogramZeroBucket, 0) + atomic.StoreUint64(&counts.nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold)) + atomic.StoreInt32(&counts.nativeHistogramSchema, h.nativeHistogramSchema) + atomic.StoreUint32(&counts.nativeHistogramBucketsNumber, 0) + for i := range h.upperBounds { + atomic.StoreUint64(&counts.buckets[i], 0) + } + deleteSyncMap(&counts.nativeHistogramBucketsNegative) + deleteSyncMap(&counts.nativeHistogramBucketsPositive) } // updateExemplar replaces the exemplar for the provided bucket. With empty @@ -448,15 +1041,23 @@ type HistogramVec struct { // NewHistogramVec creates a new HistogramVec based on the provided HistogramOpts and // partitioned by the given label names. func NewHistogramVec(opts HistogramOpts, labelNames []string) *HistogramVec { - desc := NewDesc( + return V2.NewHistogramVec(HistogramVecOpts{ + HistogramOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewHistogramVec creates a new HistogramVec based on the provided HistogramVecOpts. +func (v2) NewHistogramVec(opts HistogramVecOpts) *HistogramVec { + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &HistogramVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { - return newHistogram(desc, opts, lvs...) + return newHistogram(desc, opts.HistogramOpts, lvs...) }), } } @@ -516,7 +1117,8 @@ func (v *HistogramVec) GetMetricWith(labels Labels) (Observer, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Observe(42.21) +// +// myVec.WithLabelValues("404", "GET").Observe(42.21) func (v *HistogramVec) WithLabelValues(lvs ...string) Observer { h, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -527,7 +1129,8 @@ func (v *HistogramVec) WithLabelValues(lvs ...string) Observer { // With works as GetMetricWith but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) func (v *HistogramVec) With(labels Labels) Observer { h, err := v.GetMetricWith(labels) if err != nil { @@ -613,7 +1216,7 @@ func (h *constHistogram) Write(out *dto.Metric) error { // to send it to Prometheus in the Collect method. // // buckets is a map of upper bounds to cumulative counts, excluding the +Inf -// bucket. +// bucket. The +Inf bucket is implicit, and its value is equal to the provided count. // // NewConstHistogram returns an error if the length of labelValues is not // consistent with the variable labels in Desc or if Desc is invalid. @@ -668,3 +1271,229 @@ func (s buckSort) Swap(i, j int) { func (s buckSort) Less(i, j int) bool { return s[i].GetUpperBound() < s[j].GetUpperBound() } + +// pickSchema returns the largest number n between -4 and 8 such that +// 2^(2^-n) is less or equal the provided bucketFactor. +// +// Special cases: +// - bucketFactor <= 1: panics. +// - bucketFactor < 2^(2^-8) (but > 1): still returns 8. +func pickSchema(bucketFactor float64) int32 { + if bucketFactor <= 1 { + panic(fmt.Errorf("bucketFactor %f is <=1", bucketFactor)) + } + floor := math.Floor(math.Log2(math.Log2(bucketFactor))) + switch { + case floor <= -8: + return 8 + case floor >= 4: + return -4 + default: + return -int32(floor) + } +} + +func makeBuckets(buckets *sync.Map) ([]*dto.BucketSpan, []int64) { + var ii []int + buckets.Range(func(k, v interface{}) bool { + ii = append(ii, k.(int)) + return true + }) + sort.Ints(ii) + + if len(ii) == 0 { + return nil, nil + } + + var ( + spans []*dto.BucketSpan + deltas []int64 + prevCount int64 + nextI int + ) + + appendDelta := func(count int64) { + *spans[len(spans)-1].Length++ + deltas = append(deltas, count-prevCount) + prevCount = count + } + + for n, i := range ii { + v, _ := buckets.Load(i) + count := atomic.LoadInt64(v.(*int64)) + // Multiple spans with only small gaps in between are probably + // encoded more efficiently as one larger span with a few empty + // buckets. Needs some research to find the sweet spot. For now, + // we assume that gaps of one ore two buckets should not create + // a new span. + iDelta := int32(i - nextI) + if n == 0 || iDelta > 2 { + // We have to create a new span, either because we are + // at the very beginning, or because we have found a gap + // of more than two buckets. + spans = append(spans, &dto.BucketSpan{ + Offset: proto.Int32(iDelta), + Length: proto.Uint32(0), + }) + } else { + // We have found a small gap (or no gap at all). + // Insert empty buckets as needed. + for j := int32(0); j < iDelta; j++ { + appendDelta(0) + } + } + appendDelta(count) + nextI = i + 1 + } + return spans, deltas +} + +// addToBucket increments the sparse bucket at key by the provided amount. It +// returns true if a new sparse bucket had to be created for that. +func addToBucket(buckets *sync.Map, key int, increment int64) bool { + if existingBucket, ok := buckets.Load(key); ok { + // Fast path without allocation. + atomic.AddInt64(existingBucket.(*int64), increment) + return false + } + // Bucket doesn't exist yet. Slow path allocating new counter. + newBucket := increment // TODO(beorn7): Check if this is sufficient to not let increment escape. + if actualBucket, loaded := buckets.LoadOrStore(key, &newBucket); loaded { + // The bucket was created concurrently in another goroutine. + // Have to increment after all. + atomic.AddInt64(actualBucket.(*int64), increment) + return false + } + return true +} + +// addAndReset returns a function to be used with sync.Map.Range of spare +// buckets in coldCounts. It increments the buckets in the provided hotBuckets +// according to the buckets ranged through. It then resets all buckets ranged +// through to 0 (but leaves them in place so that they don't need to get +// recreated on the next scrape). +func addAndReset(hotBuckets *sync.Map, bucketNumber *uint32) func(k, v interface{}) bool { + return func(k, v interface{}) bool { + bucket := v.(*int64) + if addToBucket(hotBuckets, k.(int), atomic.LoadInt64(bucket)) { + atomic.AddUint32(bucketNumber, 1) + } + atomic.StoreInt64(bucket, 0) + return true + } +} + +func deleteSyncMap(m *sync.Map) { + m.Range(func(k, v interface{}) bool { + m.Delete(k) + return true + }) +} + +func findSmallestKey(m *sync.Map) int { + result := math.MaxInt32 + m.Range(func(k, v interface{}) bool { + key := k.(int) + if key < result { + result = key + } + return true + }) + return result +} + +func getLe(key int, schema int32) float64 { + // Here a bit of context about the behavior for the last bucket counting + // regular numbers (called simply "last bucket" below) and the bucket + // counting observations of ±Inf (called "inf bucket" below, with a key + // one higher than that of the "last bucket"): + // + // If we apply the usual formula to the last bucket, its upper bound + // would be calculated as +Inf. The reason is that the max possible + // regular float64 number (math.MaxFloat64) doesn't coincide with one of + // the calculated bucket boundaries. So the calculated boundary has to + // be larger than math.MaxFloat64, and the only float64 larger than + // math.MaxFloat64 is +Inf. However, we want to count actual + // observations of ±Inf in the inf bucket. Therefore, we have to treat + // the upper bound of the last bucket specially and set it to + // math.MaxFloat64. (The upper bound of the inf bucket, with its key + // being one higher than that of the last bucket, naturally comes out as + // +Inf by the usual formula. So that's fine.) + // + // math.MaxFloat64 has a frac of 0.9999999999999999 and an exp of + // 1024. If there were a float64 number following math.MaxFloat64, it + // would have a frac of 1.0 and an exp of 1024, or equivalently a frac + // of 0.5 and an exp of 1025. However, since frac must be smaller than + // 1, and exp must be smaller than 1025, either representation overflows + // a float64. (Which, in turn, is the reason that math.MaxFloat64 is the + // largest possible float64. Q.E.D.) However, the formula for + // calculating the upper bound from the idx and schema of the last + // bucket results in precisely that. It is either frac=1.0 & exp=1024 + // (for schema < 0) or frac=0.5 & exp=1025 (for schema >=0). (This is, + // by the way, a power of two where the exponent itself is a power of + // two, 2¹⁰ in fact, which coinicides with a bucket boundary in all + // schemas.) So these are the special cases we have to catch below. + if schema < 0 { + exp := key << -schema + if exp == 1024 { + // This is the last bucket before the overflow bucket + // (for ±Inf observations). Return math.MaxFloat64 as + // explained above. + return math.MaxFloat64 + } + return math.Ldexp(1, exp) + } + + fracIdx := key & ((1 << schema) - 1) + frac := nativeHistogramBounds[schema][fracIdx] + exp := (key >> schema) + 1 + if frac == 0.5 && exp == 1025 { + // This is the last bucket before the overflow bucket (for ±Inf + // observations). Return math.MaxFloat64 as explained above. + return math.MaxFloat64 + } + return math.Ldexp(frac, exp) +} + +// waitForCooldown returns after the count field in the provided histogramCounts +// has reached the provided count value. +func waitForCooldown(count uint64, counts *histogramCounts) { + for count != atomic.LoadUint64(&counts.count) { + runtime.Gosched() // Let observations get work done. + } +} + +// atomicAddFloat adds the provided float atomically to another float +// represented by the bit pattern the bits pointer is pointing to. +func atomicAddFloat(bits *uint64, v float64) { + for { + loadedBits := atomic.LoadUint64(bits) + newBits := math.Float64bits(math.Float64frombits(loadedBits) + v) + if atomic.CompareAndSwapUint64(bits, loadedBits, newBits) { + break + } + } +} + +// atomicDecUint32 atomically decrements the uint32 p points to. See +// https://pkg.go.dev/sync/atomic#AddUint32 to understand how this is done. +func atomicDecUint32(p *uint32) { + atomic.AddUint32(p, ^uint32(0)) +} + +// addAndResetCounts adds certain fields (count, sum, conventional buckets, zero +// bucket) from the cold counts to the corresponding fields in the hot +// counts. Those fields are then reset to 0 in the cold counts. +func addAndResetCounts(hot, cold *histogramCounts) { + atomic.AddUint64(&hot.count, atomic.LoadUint64(&cold.count)) + atomic.StoreUint64(&cold.count, 0) + coldSum := math.Float64frombits(atomic.LoadUint64(&cold.sumBits)) + atomicAddFloat(&hot.sumBits, coldSum) + atomic.StoreUint64(&cold.sumBits, 0) + for i := range hot.buckets { + atomic.AddUint64(&hot.buckets[i], atomic.LoadUint64(&cold.buckets[i])) + atomic.StoreUint64(&cold.buckets[i], 0) + } + atomic.AddUint64(&hot.nativeHistogramZeroBucket, atomic.LoadUint64(&cold.nativeHistogramZeroBucket)) + atomic.StoreUint64(&cold.nativeHistogramZeroBucket, 0) +} diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go new file mode 100644 index 000000000..1ed5abe74 --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go @@ -0,0 +1,60 @@ +// Copyright (c) 2015 Björn Rabenstein +// +// 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. +// +// The code in this package is copy/paste to avoid a dependency. Hence this file +// carries the copyright of the original repo. +// https://github.com/beorn7/floats +package internal + +import ( + "math" +) + +// minNormalFloat64 is the smallest positive normal value of type float64. +var minNormalFloat64 = math.Float64frombits(0x0010000000000000) + +// AlmostEqualFloat64 returns true if a and b are equal within a relative error +// of epsilon. See http://floating-point-gui.de/errors/comparison/ for the +// details of the applied method. +func AlmostEqualFloat64(a, b, epsilon float64) bool { + if a == b { + return true + } + absA := math.Abs(a) + absB := math.Abs(b) + diff := math.Abs(a - b) + if a == 0 || b == 0 || absA+absB < minNormalFloat64 { + return diff < epsilon*minNormalFloat64 + } + return diff/math.Min(absA+absB, math.MaxFloat64) < epsilon +} + +// AlmostEqualFloat64s is the slice form of AlmostEqualFloat64. +func AlmostEqualFloat64s(a, b []float64, epsilon float64) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if !AlmostEqualFloat64(a[i], b[i], epsilon) { + return false + } + } + return true +} diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go index fd45cadc0..fd0750f2c 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go @@ -201,12 +201,15 @@ func (m *SequenceMatcher) isBJunk(s string) bool { // If IsJunk is not defined: // // Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where -// alo <= i <= i+k <= ahi -// blo <= j <= j+k <= bhi +// +// alo <= i <= i+k <= ahi +// blo <= j <= j+k <= bhi +// // and for all (i',j',k') meeting those conditions, -// k >= k' -// i <= i' -// and if i == i', j <= j' +// +// k >= k' +// i <= i' +// and if i == i', j <= j' // // In other words, of all maximal matching blocks, return one that // starts earliest in a, and of all those maximal matching blocks that diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/labels.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/labels.go index 6eee198fe..63ff8683c 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/labels.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/labels.go @@ -25,12 +25,85 @@ import ( // Labels represents a collection of label name -> value mappings. This type is // commonly used with the With(Labels) and GetMetricWith(Labels) methods of // metric vector Collectors, e.g.: -// myVec.With(Labels{"code": "404", "method": "GET"}).Add(42) +// +// myVec.With(Labels{"code": "404", "method": "GET"}).Add(42) // // The other use-case is the specification of constant label pairs in Opts or to // create a Desc. type Labels map[string]string +// ConstrainedLabels represents a label name and its constrain function +// to normalize label values. This type is commonly used when constructing +// metric vector Collectors. +type ConstrainedLabel struct { + Name string + Constraint func(string) string +} + +func (cl ConstrainedLabel) Constrain(v string) string { + if cl.Constraint == nil { + return v + } + return cl.Constraint(v) +} + +// ConstrainableLabels is an interface that allows creating of labels that can +// be optionally constrained. +// +// prometheus.V2().NewCounterVec(CounterVecOpts{ +// CounterOpts: {...}, // Usual CounterOpts fields +// VariableLabels: []ConstrainedLabels{ +// {Name: "A"}, +// {Name: "B", Constraint: func(v string) string { ... }}, +// }, +// }) +type ConstrainableLabels interface { + constrainedLabels() ConstrainedLabels + labelNames() []string +} + +// ConstrainedLabels represents a collection of label name -> constrain function +// to normalize label values. This type is commonly used when constructing +// metric vector Collectors. +type ConstrainedLabels []ConstrainedLabel + +func (cls ConstrainedLabels) constrainedLabels() ConstrainedLabels { + return cls +} + +func (cls ConstrainedLabels) labelNames() []string { + names := make([]string, len(cls)) + for i, label := range cls { + names[i] = label.Name + } + return names +} + +// UnconstrainedLabels represents collection of label without any constraint on +// their value. Thus, it is simply a collection of label names. +// +// UnconstrainedLabels([]string{ "A", "B" }) +// +// is equivalent to +// +// ConstrainedLabels { +// { Name: "A" }, +// { Name: "B" }, +// } +type UnconstrainedLabels []string + +func (uls UnconstrainedLabels) constrainedLabels() ConstrainedLabels { + constrainedLabels := make([]ConstrainedLabel, len(uls)) + for i, l := range uls { + constrainedLabels[i] = ConstrainedLabel{Name: l} + } + return constrainedLabels +} + +func (uls UnconstrainedLabels) labelNames() []string { + return uls +} + // reservedLabelPrefix is a prefix which is not legal in user-supplied // label names. const reservedLabelPrefix = "__" diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/metric.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/metric.go index f0941f6f0..07bbc9d76 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/metric.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/metric.go @@ -20,11 +20,9 @@ import ( "strings" "time" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - "github.com/prometheus/common/model" - dto "github.com/prometheus/client_model/go" + "github.com/prometheus/common/model" + "google.golang.org/protobuf/proto" ) var separatorByteSlice = []byte{model.SeparatorByte} // For convenient use with xxhash. @@ -187,7 +185,7 @@ func (m *withExemplarsMetric) Write(pb *dto.Metric) error { } else { // The +Inf bucket should be explicitly added if there is an exemplar for it, similar to non-const histogram logic in https://github.com/prometheus/client_golang/blob/main/prometheus/histogram.go#L357-L365. b := &dto.Bucket{ - CumulativeCount: proto.Uint64(pb.Histogram.Bucket[len(pb.Histogram.GetBucket())-1].GetCumulativeCount()), + CumulativeCount: proto.Uint64(pb.Histogram.GetSampleCount()), UpperBound: proto.Float64(math.Inf(1)), Exemplar: e, } diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go index a4cc9810b..09b8d2fbe 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go @@ -37,6 +37,7 @@ import ( "fmt" "io" "net/http" + "strconv" "strings" "sync" "time" @@ -47,9 +48,10 @@ import ( ) const ( - contentTypeHeader = "Content-Type" - contentEncodingHeader = "Content-Encoding" - acceptEncodingHeader = "Accept-Encoding" + contentTypeHeader = "Content-Type" + contentEncodingHeader = "Content-Encoding" + acceptEncodingHeader = "Accept-Encoding" + processStartTimeHeader = "Process-Start-Time-Unix" ) var gzipPool = sync.Pool{ @@ -121,6 +123,9 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO } h := http.HandlerFunc(func(rsp http.ResponseWriter, req *http.Request) { + if !opts.ProcessStartTime.IsZero() { + rsp.Header().Set(processStartTimeHeader, strconv.FormatInt(opts.ProcessStartTime.Unix(), 10)) + } if inFlightSem != nil { select { case inFlightSem <- struct{}{}: // All good, carry on. @@ -366,6 +371,14 @@ type HandlerOpts struct { // (which changes the identity of the resulting series on the Prometheus // server). EnableOpenMetrics bool + // ProcessStartTime allows setting process start timevalue that will be exposed + // with "Process-Start-Time-Unix" response header along with the metrics + // payload. This allow callers to have efficient transformations to cumulative + // counters (e.g. OpenTelemetry) or generally _created timestamp estimation per + // scrape target. + // NOTE: This feature is experimental and not covered by OpenMetrics or Prometheus + // exposition format. + ProcessStartTime time.Time } // gzipAccepted returns whether the client will accept gzip-encoded content. diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go index 097aff2df..d3482c40c 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go @@ -68,17 +68,17 @@ func InstrumentRoundTripperCounter(counter *prometheus.CounterVec, next http.Rou o.apply(rtOpts) } - code, method := checkLabels(counter) + // Curry the counter with dynamic labels before checking the remaining labels. + code, method := checkLabels(counter.MustCurryWith(rtOpts.emptyDynamicLabels())) return func(r *http.Request) (*http.Response, error) { resp, err := next.RoundTrip(r) if err == nil { - exemplarAdd( - counter.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)), - 1, - rtOpts.getExemplarFn(r.Context()), - ) - counter.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)).Inc() + l := labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...) + for label, resolve := range rtOpts.extraLabelsFromCtx { + l[label] = resolve(resp.Request.Context()) + } + addWithExemplar(counter.With(l), 1, rtOpts.getExemplarFn(r.Context())) } return resp, err } @@ -111,17 +111,18 @@ func InstrumentRoundTripperDuration(obs prometheus.ObserverVec, next http.RoundT o.apply(rtOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(rtOpts.emptyDynamicLabels())) return func(r *http.Request) (*http.Response, error) { start := time.Now() resp, err := next.RoundTrip(r) if err == nil { - exemplarObserve( - obs.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)), - time.Since(start).Seconds(), - rtOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...) + for label, resolve := range rtOpts.extraLabelsFromCtx { + l[label] = resolve(resp.Request.Context()) + } + observeWithExemplar(obs.With(l), time.Since(start).Seconds(), rtOpts.getExemplarFn(r.Context())) } return resp, err } diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go index bfe500987..3793036ad 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go @@ -28,7 +28,9 @@ import ( // magicString is used for the hacky label test in checkLabels. Remove once fixed. const magicString = "zZgWfBxLqvG8kc8IMv3POi2Bb0tZI3vAnBx+gBaFi9FyPzB/CzKUer1yufDa" -func exemplarObserve(obs prometheus.Observer, val float64, labels map[string]string) { +// observeWithExemplar is a wrapper for [prometheus.ExemplarAdder.ExemplarObserver], +// which falls back to [prometheus.Observer.Observe] if no labels are provided. +func observeWithExemplar(obs prometheus.Observer, val float64, labels map[string]string) { if labels == nil { obs.Observe(val) return @@ -36,7 +38,9 @@ func exemplarObserve(obs prometheus.Observer, val float64, labels map[string]str obs.(prometheus.ExemplarObserver).ObserveWithExemplar(val, labels) } -func exemplarAdd(obs prometheus.Counter, val float64, labels map[string]string) { +// addWithExemplar is a wrapper for [prometheus.ExemplarAdder.AddWithExemplar], +// which falls back to [prometheus.Counter.Add] if no labels are provided. +func addWithExemplar(obs prometheus.Counter, val float64, labels map[string]string) { if labels == nil { obs.Add(val) return @@ -83,7 +87,8 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler, op o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) if code { return func(w http.ResponseWriter, r *http.Request) { @@ -91,23 +96,22 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler, op d := newDelegator(w, nil) next.ServeHTTP(d, r) - exemplarObserve( - obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - time.Since(now).Seconds(), - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) } } return func(w http.ResponseWriter, r *http.Request) { now := time.Now() next.ServeHTTP(w, r) - - exemplarObserve( - obs.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)), - time.Since(now).Seconds(), - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, 0, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) } } @@ -134,28 +138,30 @@ func InstrumentHandlerCounter(counter *prometheus.CounterVec, next http.Handler, o.apply(hOpts) } - code, method := checkLabels(counter) + // Curry the counter with dynamic labels before checking the remaining labels. + code, method := checkLabels(counter.MustCurryWith(hOpts.emptyDynamicLabels())) if code { return func(w http.ResponseWriter, r *http.Request) { d := newDelegator(w, nil) next.ServeHTTP(d, r) - exemplarAdd( - counter.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - 1, - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r.Context())) } } return func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) - exemplarAdd( - counter.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)), - 1, - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, 0, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r.Context())) } } @@ -187,16 +193,17 @@ func InstrumentHandlerTimeToWriteHeader(obs prometheus.ObserverVec, next http.Ha o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) return func(w http.ResponseWriter, r *http.Request) { now := time.Now() d := newDelegator(w, func(status int) { - exemplarObserve( - obs.With(labels(code, method, r.Method, status, hOpts.extraMethods...)), - time.Since(now).Seconds(), - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, status, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) }) next.ServeHTTP(d, r) } @@ -227,28 +234,32 @@ func InstrumentHandlerRequestSize(obs prometheus.ObserverVec, next http.Handler, o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) + if code { return func(w http.ResponseWriter, r *http.Request) { d := newDelegator(w, nil) next.ServeHTTP(d, r) size := computeApproximateRequestSize(r) - exemplarObserve( - obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - float64(size), - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r.Context())) } } return func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) size := computeApproximateRequestSize(r) - exemplarObserve( - obs.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)), - float64(size), - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, 0, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r.Context())) } } @@ -277,16 +288,18 @@ func InstrumentHandlerResponseSize(obs prometheus.ObserverVec, next http.Handler o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { d := newDelegator(w, nil) next.ServeHTTP(d, r) - exemplarObserve( - obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - float64(d.Written()), - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), float64(d.Written()), hOpts.getExemplarFn(r.Context())) }) } diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go index c590d912c..5d4383aa1 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go @@ -24,14 +24,32 @@ type Option interface { apply(*options) } +// LabelValueFromCtx are used to compute the label value from request context. +// Context can be filled with values from request through middleware. +type LabelValueFromCtx func(ctx context.Context) string + // options store options for both a handler or round tripper. type options struct { - extraMethods []string - getExemplarFn func(requestCtx context.Context) prometheus.Labels + extraMethods []string + getExemplarFn func(requestCtx context.Context) prometheus.Labels + extraLabelsFromCtx map[string]LabelValueFromCtx } func defaultOptions() *options { - return &options{getExemplarFn: func(ctx context.Context) prometheus.Labels { return nil }} + return &options{ + getExemplarFn: func(ctx context.Context) prometheus.Labels { return nil }, + extraLabelsFromCtx: map[string]LabelValueFromCtx{}, + } +} + +func (o *options) emptyDynamicLabels() prometheus.Labels { + labels := prometheus.Labels{} + + for label := range o.extraLabelsFromCtx { + labels[label] = "" + } + + return labels } type optionApplyFunc func(*options) @@ -48,11 +66,19 @@ func WithExtraMethods(methods ...string) Option { }) } -// WithExemplarFromContext adds allows to put a hook to all counter and histogram metrics. -// If the hook function returns non-nil labels, exemplars will be added for that request, otherwise metric -// will get instrumented without exemplar. +// WithExemplarFromContext allows to inject function that will get exemplar from context that will be put to counter and histogram metrics. +// If the function returns nil labels or the metric does not support exemplars, no exemplar will be added (noop), but +// metric will continue to observe/increment. func WithExemplarFromContext(getExemplarFn func(requestCtx context.Context) prometheus.Labels) Option { return optionApplyFunc(func(o *options) { o.getExemplarFn = getExemplarFn }) } + +// WithLabelFromCtx registers a label for dynamic resolution with access to context. +// See the example for ExampleInstrumentHandlerWithLabelResolver for example usage +func WithLabelFromCtx(name string, valueFn LabelValueFromCtx) Option { + return optionApplyFunc(func(o *options) { + o.extraLabelsFromCtx[name] = valueFn + }) +} diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/registry.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/registry.go index 325f665ff..44da9433b 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/registry.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/registry.go @@ -21,18 +21,17 @@ import ( "path/filepath" "runtime" "sort" + "strconv" "strings" "sync" "unicode/utf8" - "github.com/cespare/xxhash/v2" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - "github.com/prometheus/common/expfmt" + "github.com/prometheus/client_golang/prometheus/internal" + "github.com/cespare/xxhash/v2" dto "github.com/prometheus/client_model/go" - - "github.com/prometheus/client_golang/prometheus/internal" + "github.com/prometheus/common/expfmt" + "google.golang.org/protobuf/proto" ) const ( @@ -252,9 +251,12 @@ func (errs MultiError) MaybeUnwrap() error { } // Registry registers Prometheus collectors, collects their metrics, and gathers -// them into MetricFamilies for exposition. It implements both Registerer and -// Gatherer. The zero value is not usable. Create instances with NewRegistry or -// NewPedanticRegistry. +// them into MetricFamilies for exposition. It implements Registerer, Gatherer, +// and Collector. The zero value is not usable. Create instances with +// NewRegistry or NewPedanticRegistry. +// +// Registry implements Collector to allow it to be used for creating groups of +// metrics. See the Grouping example for how this can be done. type Registry struct { mtx sync.RWMutex collectorsByID map[uint64]Collector // ID is a hash of the descIDs. @@ -556,6 +558,31 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { return internal.NormalizeMetricFamilies(metricFamiliesByName), errs.MaybeUnwrap() } +// Describe implements Collector. +func (r *Registry) Describe(ch chan<- *Desc) { + r.mtx.RLock() + defer r.mtx.RUnlock() + + // Only report the checked Collectors; unchecked collectors don't report any + // Desc. + for _, c := range r.collectorsByID { + c.Describe(ch) + } +} + +// Collect implements Collector. +func (r *Registry) Collect(ch chan<- Metric) { + r.mtx.RLock() + defer r.mtx.RUnlock() + + for _, c := range r.collectorsByID { + c.Collect(ch) + } + for _, c := range r.uncheckedCollectors { + c.Collect(ch) + } +} + // WriteToTextfile calls Gather on the provided Gatherer, encodes the result in the // Prometheus text format, and writes it to a temporary file. Upon success, the // temporary file is renamed to the provided filename. @@ -905,6 +932,10 @@ func checkMetricConsistency( h.WriteString(lp.GetValue()) h.Write(separatorByteSlice) } + if dtoMetric.TimestampMs != nil { + h.WriteString(strconv.FormatInt(*(dtoMetric.TimestampMs), 10)) + h.Write(separatorByteSlice) + } hSum := h.Sum64() if _, exists := metricHashes[hSum]; exists { return fmt.Errorf( @@ -934,7 +965,7 @@ func checkDescConsistency( copy(lpsFromDesc, desc.constLabelPairs) for _, l := range desc.variableLabels { lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{ - Name: proto.String(l), + Name: proto.String(l.Name), }) } if len(lpsFromDesc) != len(dtoMetric.Label) { diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/summary.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/summary.go index c5fa8ed7c..dd359264e 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/summary.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/summary.go @@ -22,11 +22,10 @@ import ( "sync/atomic" "time" - "github.com/beorn7/perks/quantile" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - dto "github.com/prometheus/client_model/go" + + "github.com/beorn7/perks/quantile" + "google.golang.org/protobuf/proto" ) // quantileLabel is used for the label that defines the quantile in a @@ -148,6 +147,18 @@ type SummaryOpts struct { BufCap uint32 } +// SummaryVecOpts bundles the options to create a SummaryVec metric. +// It is mandatory to set SummaryOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type SummaryVecOpts struct { + SummaryOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels +} + // Problem with the sliding-window decay algorithm... The Merge method of // perk/quantile is actually not working as advertised - and it might be // unfixable, as the underlying algorithm is apparently not capable of merging @@ -178,11 +189,11 @@ func NewSummary(opts SummaryOpts) Summary { func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary { if len(desc.variableLabels) != len(labelValues) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, labelValues)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), labelValues)) } for _, n := range desc.variableLabels { - if n == quantileLabel { + if n.Name == quantileLabel { panic(errQuantileLabelNotAllowed) } } @@ -530,20 +541,28 @@ type SummaryVec struct { // it is handled by the Prometheus server internally, “quantile” is an illegal // label name. NewSummaryVec will panic if this label name is used. func NewSummaryVec(opts SummaryOpts, labelNames []string) *SummaryVec { - for _, ln := range labelNames { + return V2.NewSummaryVec(SummaryVecOpts{ + SummaryOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewSummaryVec creates a new SummaryVec based on the provided SummaryVecOpts. +func (v2) NewSummaryVec(opts SummaryVecOpts) *SummaryVec { + for _, ln := range opts.VariableLabels.labelNames() { if ln == quantileLabel { panic(errQuantileLabelNotAllowed) } } - desc := NewDesc( + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &SummaryVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { - return newSummary(desc, opts, lvs...) + return newSummary(desc, opts.SummaryOpts, lvs...) }), } } @@ -603,7 +622,8 @@ func (v *SummaryVec) GetMetricWith(labels Labels) (Observer, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Observe(42.21) +// +// myVec.WithLabelValues("404", "GET").Observe(42.21) func (v *SummaryVec) WithLabelValues(lvs ...string) Observer { s, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -614,7 +634,8 @@ func (v *SummaryVec) WithLabelValues(lvs ...string) Observer { // With works as GetMetricWith, but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) func (v *SummaryVec) With(labels Labels) Observer { s, err := v.GetMetricWith(labels) if err != nil { @@ -701,7 +722,8 @@ func (s *constSummary) Write(out *dto.Metric) error { // // quantiles maps ranks to quantile values. For example, a median latency of // 0.23s and a 99th percentile latency of 0.56s would be expressed as: -// map[float64]float64{0.5: 0.23, 0.99: 0.56} +// +// map[float64]float64{0.5: 0.23, 0.99: 0.56} // // NewConstSummary returns an error if the length of labelValues is not // consistent with the variable labels in Desc or if Desc is invalid. diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/timer.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/timer.go index 8d5f10523..52344fef5 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/timer.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/timer.go @@ -23,13 +23,24 @@ type Timer struct { } // NewTimer creates a new Timer. The provided Observer is used to observe a -// duration in seconds. Timer is usually used to time a function call in the +// duration in seconds. If the Observer implements ExemplarObserver, passing exemplar +// later on will be also supported. +// Timer is usually used to time a function call in the // following way: -// func TimeMe() { -// timer := NewTimer(myHistogram) -// defer timer.ObserveDuration() -// // Do actual work. -// } +// +// func TimeMe() { +// timer := NewTimer(myHistogram) +// defer timer.ObserveDuration() +// // Do actual work. +// } +// +// or +// +// func TimeMeWithExemplar() { +// timer := NewTimer(myHistogram) +// defer timer.ObserveDurationWithExemplar(exemplar) +// // Do actual work. +// } func NewTimer(o Observer) *Timer { return &Timer{ begin: time.Now(), @@ -52,3 +63,19 @@ func (t *Timer) ObserveDuration() time.Duration { } return d } + +// ObserveDurationWithExemplar is like ObserveDuration, but it will also +// observe exemplar with the duration unless exemplar is nil or provided Observer can't +// be casted to ExemplarObserver. +func (t *Timer) ObserveDurationWithExemplar(exemplar Labels) time.Duration { + d := time.Since(t.begin) + eo, ok := t.observer.(ExemplarObserver) + if ok && exemplar != nil { + eo.ObserveWithExemplar(d.Seconds(), exemplar) + return d + } + if t.observer != nil { + t.observer.Observe(d.Seconds()) + } + return d +} diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/value.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/value.go index 2d3abc1cb..5f6bb8001 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/value.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/value.go @@ -19,13 +19,11 @@ import ( "time" "unicode/utf8" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - "google.golang.org/protobuf/types/known/timestamppb" - "github.com/prometheus/client_golang/prometheus/internal" dto "github.com/prometheus/client_model/go" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/timestamppb" ) // ValueType is an enumeration of metric types that represent a simple value. @@ -188,9 +186,9 @@ func MakeLabelPairs(desc *Desc, labelValues []string) []*dto.LabelPair { return desc.constLabelPairs } labelPairs := make([]*dto.LabelPair, 0, totalLen) - for i, n := range desc.variableLabels { + for i, l := range desc.variableLabels { labelPairs = append(labelPairs, &dto.LabelPair{ - Name: proto.String(n), + Name: proto.String(l.Name), Value: proto.String(labelValues[i]), }) } diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/vec.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/vec.go index 7ae322590..f0d0015a0 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/vec.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/vec.go @@ -20,6 +20,24 @@ import ( "github.com/prometheus/common/model" ) +var labelsPool = &sync.Pool{ + New: func() interface{} { + return make(Labels) + }, +} + +func getLabelsFromPool() Labels { + return labelsPool.Get().(Labels) +} + +func putLabelsToPool(labels Labels) { + for k := range labels { + delete(labels, k) + } + + labelsPool.Put(labels) +} + // MetricVec is a Collector to bundle metrics of the same name that differ in // their label values. MetricVec is not used directly but as a building block // for implementations of vectors of a given metric type, like GaugeVec, @@ -72,6 +90,7 @@ func NewMetricVec(desc *Desc, newMetric func(lvs ...string) Metric) *MetricVec { // with a performance overhead (for creating and processing the Labels map). // See also the CounterVec example. func (m *MetricVec) DeleteLabelValues(lvs ...string) bool { + lvs = constrainLabelValues(m.desc, lvs, m.curry) h, err := m.hashLabelValues(lvs) if err != nil { return false @@ -91,6 +110,9 @@ func (m *MetricVec) DeleteLabelValues(lvs ...string) bool { // This method is used for the same purpose as DeleteLabelValues(...string). See // there for pros and cons of the two methods. func (m *MetricVec) Delete(labels Labels) bool { + labels = constrainLabels(m.desc, labels) + defer putLabelsToPool(labels) + h, err := m.hashLabels(labels) if err != nil { return false @@ -106,6 +128,9 @@ func (m *MetricVec) Delete(labels Labels) bool { // Note that curried labels will never be matched if deleting from the curried vector. // To match curried labels with DeletePartialMatch, it must be called on the base vector. func (m *MetricVec) DeletePartialMatch(labels Labels) int { + labels = constrainLabels(m.desc, labels) + defer putLabelsToPool(labels) + return m.metricMap.deleteByLabels(labels, m.curry) } @@ -145,10 +170,10 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) { iCurry int ) for i, label := range m.desc.variableLabels { - val, ok := labels[label] + val, ok := labels[label.Name] if iCurry < len(oldCurry) && oldCurry[iCurry].index == i { if ok { - return nil, fmt.Errorf("label name %q is already curried", label) + return nil, fmt.Errorf("label name %q is already curried", label.Name) } newCurry = append(newCurry, oldCurry[iCurry]) iCurry++ @@ -156,7 +181,7 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) { if !ok { continue // Label stays uncurried. } - newCurry = append(newCurry, curriedLabelValue{i, val}) + newCurry = append(newCurry, curriedLabelValue{i, label.Constrain(val)}) } } if l := len(oldCurry) + len(labels) - len(newCurry); l > 0 { @@ -199,6 +224,7 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) { // a wrapper around MetricVec, implementing a vector for a specific Metric // implementation, for example GaugeVec. func (m *MetricVec) GetMetricWithLabelValues(lvs ...string) (Metric, error) { + lvs = constrainLabelValues(m.desc, lvs, m.curry) h, err := m.hashLabelValues(lvs) if err != nil { return nil, err @@ -224,6 +250,9 @@ func (m *MetricVec) GetMetricWithLabelValues(lvs ...string) (Metric, error) { // around MetricVec, implementing a vector for a specific Metric implementation, // for example GaugeVec. func (m *MetricVec) GetMetricWith(labels Labels) (Metric, error) { + labels = constrainLabels(m.desc, labels) + defer putLabelsToPool(labels) + h, err := m.hashLabels(labels) if err != nil { return nil, err @@ -266,16 +295,16 @@ func (m *MetricVec) hashLabels(labels Labels) (uint64, error) { iCurry int ) for i, label := range m.desc.variableLabels { - val, ok := labels[label] + val, ok := labels[label.Name] if iCurry < len(curry) && curry[iCurry].index == i { if ok { - return 0, fmt.Errorf("label name %q is already curried", label) + return 0, fmt.Errorf("label name %q is already curried", label.Name) } h = m.hashAdd(h, curry[iCurry].value) iCurry++ } else { if !ok { - return 0, fmt.Errorf("label name %q missing in label map", label) + return 0, fmt.Errorf("label name %q missing in label map", label.Name) } h = m.hashAdd(h, val) } @@ -453,7 +482,7 @@ func valueMatchesVariableOrCurriedValue(targetValue string, index int, values [] func matchPartialLabels(desc *Desc, values []string, labels Labels, curry []curriedLabelValue) bool { for l, v := range labels { // Check if the target label exists in our metrics and get the index. - varLabelIndex, validLabel := indexOf(l, desc.variableLabels) + varLabelIndex, validLabel := indexOf(l, desc.variableLabels.labelNames()) if validLabel { // Check the value of that label against the target value. // We don't consider curried values in partial matches. @@ -605,7 +634,7 @@ func matchLabels(desc *Desc, values []string, labels Labels, curry []curriedLabe iCurry++ continue } - if values[i] != labels[k] { + if values[i] != labels[k.Name] { return false } } @@ -621,7 +650,7 @@ func extractLabelValues(desc *Desc, labels Labels, curry []curriedLabelValue) [] iCurry++ continue } - labelValues[i] = labels[k] + labelValues[i] = labels[k.Name] } return labelValues } @@ -640,3 +669,35 @@ func inlineLabelValues(lvs []string, curry []curriedLabelValue) []string { } return labelValues } + +func constrainLabels(desc *Desc, labels Labels) Labels { + constrainedLabels := getLabelsFromPool() + for l, v := range labels { + if i, ok := indexOf(l, desc.variableLabels.labelNames()); ok { + v = desc.variableLabels[i].Constrain(v) + } + + constrainedLabels[l] = v + } + + return constrainedLabels +} + +func constrainLabelValues(desc *Desc, lvs []string, curry []curriedLabelValue) []string { + constrainedValues := make([]string, len(lvs)) + var iCurry, iLVs int + for i := 0; i < len(lvs)+len(curry); i++ { + if iCurry < len(curry) && curry[iCurry].index == i { + iCurry++ + continue + } + + if i < len(desc.variableLabels) { + constrainedValues[iLVs] = desc.variableLabels[i].Constrain(lvs[iLVs]) + } else { + constrainedValues[iLVs] = lvs[iLVs] + } + iLVs++ + } + return constrainedValues +} diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/vnext.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/vnext.go new file mode 100644 index 000000000..42bc3a8f0 --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/vnext.go @@ -0,0 +1,23 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package prometheus + +type v2 struct{} + +// V2 is a struct that can be referenced to access experimental API that might +// be present in v2 of client golang someday. It offers extended functionality +// of v1 with slightly changed API. It is acceptable to use some pieces from v1 +// and e.g `prometheus.NewGauge` and some from v2 e.g. `prometheus.V2.NewDesc` +// in the same codebase. +var V2 = v2{} diff --git a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/wrap.go b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/wrap.go index 1498ee144..25da157f1 100644 --- a/test/integration/vendor/github.com/prometheus/client_golang/prometheus/wrap.go +++ b/test/integration/vendor/github.com/prometheus/client_golang/prometheus/wrap.go @@ -17,12 +17,10 @@ import ( "fmt" "sort" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" + "github.com/prometheus/client_golang/prometheus/internal" dto "github.com/prometheus/client_model/go" - - "github.com/prometheus/client_golang/prometheus/internal" + "google.golang.org/protobuf/proto" ) // WrapRegistererWith returns a Registerer wrapping the provided @@ -206,7 +204,7 @@ func wrapDesc(desc *Desc, prefix string, labels Labels) *Desc { constLabels[ln] = lv } // NewDesc will do remaining validations. - newDesc := NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels) + newDesc := V2.NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels) // Propagate errors if there was any. This will override any errer // created by NewDesc above, i.e. earlier errors get precedence. if desc.err != nil { diff --git a/test/integration/vendor/github.com/prometheus/client_model/go/metrics.pb.go b/test/integration/vendor/github.com/prometheus/client_model/go/metrics.pb.go index 35904ea19..2b5bca4b9 100644 --- a/test/integration/vendor/github.com/prometheus/client_model/go/metrics.pb.go +++ b/test/integration/vendor/github.com/prometheus/client_model/go/metrics.pb.go @@ -1,25 +1,38 @@ +// Copyright 2013 Prometheus Team +// 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. + // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.20.3 // source: io/prometheus/client/metrics.proto package io_prometheus_client import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" ) -// 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.ProtoPackageIsVersion3 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type MetricType int32 @@ -38,23 +51,25 @@ const ( MetricType_GAUGE_HISTOGRAM MetricType = 5 ) -var MetricType_name = map[int32]string{ - 0: "COUNTER", - 1: "GAUGE", - 2: "SUMMARY", - 3: "UNTYPED", - 4: "HISTOGRAM", - 5: "GAUGE_HISTOGRAM", -} - -var MetricType_value = map[string]int32{ - "COUNTER": 0, - "GAUGE": 1, - "SUMMARY": 2, - "UNTYPED": 3, - "HISTOGRAM": 4, - "GAUGE_HISTOGRAM": 5, -} +// Enum value maps for MetricType. +var ( + MetricType_name = map[int32]string{ + 0: "COUNTER", + 1: "GAUGE", + 2: "SUMMARY", + 3: "UNTYPED", + 4: "HISTOGRAM", + 5: "GAUGE_HISTOGRAM", + } + MetricType_value = map[string]int32{ + "COUNTER": 0, + "GAUGE": 1, + "SUMMARY": 2, + "UNTYPED": 3, + "HISTOGRAM": 4, + "GAUGE_HISTOGRAM": 5, + } +) func (x MetricType) Enum() *MetricType { p := new(MetricType) @@ -63,449 +78,519 @@ func (x MetricType) Enum() *MetricType { } func (x MetricType) String() string { - return proto.EnumName(MetricType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (x *MetricType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(MetricType_value, data, "MetricType") +func (MetricType) Descriptor() protoreflect.EnumDescriptor { + return file_io_prometheus_client_metrics_proto_enumTypes[0].Descriptor() +} + +func (MetricType) Type() protoreflect.EnumType { + return &file_io_prometheus_client_metrics_proto_enumTypes[0] +} + +func (x MetricType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *MetricType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = MetricType(value) + *x = MetricType(num) return nil } +// Deprecated: Use MetricType.Descriptor instead. func (MetricType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{0} + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{0} } type LabelPair struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *LabelPair) Reset() { *m = LabelPair{} } -func (m *LabelPair) String() string { return proto.CompactTextString(m) } -func (*LabelPair) ProtoMessage() {} -func (*LabelPair) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{0} + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` } -func (m *LabelPair) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LabelPair.Unmarshal(m, b) -} -func (m *LabelPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LabelPair.Marshal(b, m, deterministic) -} -func (m *LabelPair) XXX_Merge(src proto.Message) { - xxx_messageInfo_LabelPair.Merge(m, src) +func (x *LabelPair) Reset() { + *x = LabelPair{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *LabelPair) XXX_Size() int { - return xxx_messageInfo_LabelPair.Size(m) + +func (x *LabelPair) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *LabelPair) XXX_DiscardUnknown() { - xxx_messageInfo_LabelPair.DiscardUnknown(m) + +func (*LabelPair) ProtoMessage() {} + +func (x *LabelPair) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_LabelPair proto.InternalMessageInfo +// Deprecated: Use LabelPair.ProtoReflect.Descriptor instead. +func (*LabelPair) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{0} +} -func (m *LabelPair) GetName() string { - if m != nil && m.Name != nil { - return *m.Name +func (x *LabelPair) GetName() string { + if x != nil && x.Name != nil { + return *x.Name } return "" } -func (m *LabelPair) GetValue() string { - if m != nil && m.Value != nil { - return *m.Value +func (x *LabelPair) GetValue() string { + if x != nil && x.Value != nil { + return *x.Value } return "" } type Gauge struct { - Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Gauge) Reset() { *m = Gauge{} } -func (m *Gauge) String() string { return proto.CompactTextString(m) } -func (*Gauge) ProtoMessage() {} -func (*Gauge) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{1} + Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` } -func (m *Gauge) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Gauge.Unmarshal(m, b) -} -func (m *Gauge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Gauge.Marshal(b, m, deterministic) -} -func (m *Gauge) XXX_Merge(src proto.Message) { - xxx_messageInfo_Gauge.Merge(m, src) +func (x *Gauge) Reset() { + *x = Gauge{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Gauge) XXX_Size() int { - return xxx_messageInfo_Gauge.Size(m) + +func (x *Gauge) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Gauge) XXX_DiscardUnknown() { - xxx_messageInfo_Gauge.DiscardUnknown(m) + +func (*Gauge) ProtoMessage() {} + +func (x *Gauge) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Gauge proto.InternalMessageInfo +// Deprecated: Use Gauge.ProtoReflect.Descriptor instead. +func (*Gauge) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{1} +} -func (m *Gauge) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Gauge) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } type Counter struct { - Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` - Exemplar *Exemplar `protobuf:"bytes,2,opt,name=exemplar" json:"exemplar,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Counter) Reset() { *m = Counter{} } -func (m *Counter) String() string { return proto.CompactTextString(m) } -func (*Counter) ProtoMessage() {} -func (*Counter) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{2} + Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` + Exemplar *Exemplar `protobuf:"bytes,2,opt,name=exemplar" json:"exemplar,omitempty"` } -func (m *Counter) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Counter.Unmarshal(m, b) -} -func (m *Counter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Counter.Marshal(b, m, deterministic) -} -func (m *Counter) XXX_Merge(src proto.Message) { - xxx_messageInfo_Counter.Merge(m, src) +func (x *Counter) Reset() { + *x = Counter{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Counter) XXX_Size() int { - return xxx_messageInfo_Counter.Size(m) + +func (x *Counter) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Counter) XXX_DiscardUnknown() { - xxx_messageInfo_Counter.DiscardUnknown(m) + +func (*Counter) ProtoMessage() {} + +func (x *Counter) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Counter proto.InternalMessageInfo +// Deprecated: Use Counter.ProtoReflect.Descriptor instead. +func (*Counter) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{2} +} -func (m *Counter) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Counter) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } -func (m *Counter) GetExemplar() *Exemplar { - if m != nil { - return m.Exemplar +func (x *Counter) GetExemplar() *Exemplar { + if x != nil { + return x.Exemplar } return nil } type Quantile struct { - Quantile *float64 `protobuf:"fixed64,1,opt,name=quantile" json:"quantile,omitempty"` - Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Quantile) Reset() { *m = Quantile{} } -func (m *Quantile) String() string { return proto.CompactTextString(m) } -func (*Quantile) ProtoMessage() {} -func (*Quantile) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{3} + Quantile *float64 `protobuf:"fixed64,1,opt,name=quantile" json:"quantile,omitempty"` + Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` } -func (m *Quantile) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Quantile.Unmarshal(m, b) -} -func (m *Quantile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Quantile.Marshal(b, m, deterministic) -} -func (m *Quantile) XXX_Merge(src proto.Message) { - xxx_messageInfo_Quantile.Merge(m, src) +func (x *Quantile) Reset() { + *x = Quantile{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Quantile) XXX_Size() int { - return xxx_messageInfo_Quantile.Size(m) + +func (x *Quantile) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Quantile) XXX_DiscardUnknown() { - xxx_messageInfo_Quantile.DiscardUnknown(m) + +func (*Quantile) ProtoMessage() {} + +func (x *Quantile) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Quantile proto.InternalMessageInfo +// Deprecated: Use Quantile.ProtoReflect.Descriptor instead. +func (*Quantile) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{3} +} -func (m *Quantile) GetQuantile() float64 { - if m != nil && m.Quantile != nil { - return *m.Quantile +func (x *Quantile) GetQuantile() float64 { + if x != nil && x.Quantile != nil { + return *x.Quantile } return 0 } -func (m *Quantile) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Quantile) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } type Summary struct { - SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"` - SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"` - Quantile []*Quantile `protobuf:"bytes,3,rep,name=quantile" json:"quantile,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Summary) Reset() { *m = Summary{} } -func (m *Summary) String() string { return proto.CompactTextString(m) } -func (*Summary) ProtoMessage() {} -func (*Summary) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{4} + SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"` + SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"` + Quantile []*Quantile `protobuf:"bytes,3,rep,name=quantile" json:"quantile,omitempty"` } -func (m *Summary) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Summary.Unmarshal(m, b) -} -func (m *Summary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Summary.Marshal(b, m, deterministic) -} -func (m *Summary) XXX_Merge(src proto.Message) { - xxx_messageInfo_Summary.Merge(m, src) +func (x *Summary) Reset() { + *x = Summary{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Summary) XXX_Size() int { - return xxx_messageInfo_Summary.Size(m) + +func (x *Summary) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Summary) XXX_DiscardUnknown() { - xxx_messageInfo_Summary.DiscardUnknown(m) + +func (*Summary) ProtoMessage() {} + +func (x *Summary) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Summary proto.InternalMessageInfo +// Deprecated: Use Summary.ProtoReflect.Descriptor instead. +func (*Summary) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{4} +} -func (m *Summary) GetSampleCount() uint64 { - if m != nil && m.SampleCount != nil { - return *m.SampleCount +func (x *Summary) GetSampleCount() uint64 { + if x != nil && x.SampleCount != nil { + return *x.SampleCount } return 0 } -func (m *Summary) GetSampleSum() float64 { - if m != nil && m.SampleSum != nil { - return *m.SampleSum +func (x *Summary) GetSampleSum() float64 { + if x != nil && x.SampleSum != nil { + return *x.SampleSum } return 0 } -func (m *Summary) GetQuantile() []*Quantile { - if m != nil { - return m.Quantile +func (x *Summary) GetQuantile() []*Quantile { + if x != nil { + return x.Quantile } return nil } type Untyped struct { - Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Untyped) Reset() { *m = Untyped{} } -func (m *Untyped) String() string { return proto.CompactTextString(m) } -func (*Untyped) ProtoMessage() {} -func (*Untyped) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{5} + Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` } -func (m *Untyped) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Untyped.Unmarshal(m, b) -} -func (m *Untyped) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Untyped.Marshal(b, m, deterministic) -} -func (m *Untyped) XXX_Merge(src proto.Message) { - xxx_messageInfo_Untyped.Merge(m, src) +func (x *Untyped) Reset() { + *x = Untyped{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Untyped) XXX_Size() int { - return xxx_messageInfo_Untyped.Size(m) + +func (x *Untyped) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Untyped) XXX_DiscardUnknown() { - xxx_messageInfo_Untyped.DiscardUnknown(m) + +func (*Untyped) ProtoMessage() {} + +func (x *Untyped) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Untyped proto.InternalMessageInfo +// Deprecated: Use Untyped.ProtoReflect.Descriptor instead. +func (*Untyped) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{5} +} -func (m *Untyped) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Untyped) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } type Histogram struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"` - SampleCountFloat *float64 `protobuf:"fixed64,4,opt,name=sample_count_float,json=sampleCountFloat" json:"sample_count_float,omitempty"` + SampleCountFloat *float64 `protobuf:"fixed64,4,opt,name=sample_count_float,json=sampleCountFloat" json:"sample_count_float,omitempty"` // Overrides sample_count if > 0. SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"` // Buckets for the conventional histogram. - Bucket []*Bucket `protobuf:"bytes,3,rep,name=bucket" json:"bucket,omitempty"` + Bucket []*Bucket `protobuf:"bytes,3,rep,name=bucket" json:"bucket,omitempty"` // Ordered in increasing order of upper_bound, +Inf bucket is optional. // schema defines the bucket schema. Currently, valid numbers are -4 <= n <= 8. // They are all for base-2 bucket schemas, where 1 is a bucket boundary in each case, and // then each power of two is divided into 2^n logarithmic buckets. // Or in other words, each bucket boundary is the previous boundary times 2^(2^-n). // In the future, more bucket schemas may be added using numbers < -4 or > 8. Schema *int32 `protobuf:"zigzag32,5,opt,name=schema" json:"schema,omitempty"` - ZeroThreshold *float64 `protobuf:"fixed64,6,opt,name=zero_threshold,json=zeroThreshold" json:"zero_threshold,omitempty"` - ZeroCount *uint64 `protobuf:"varint,7,opt,name=zero_count,json=zeroCount" json:"zero_count,omitempty"` - ZeroCountFloat *float64 `protobuf:"fixed64,8,opt,name=zero_count_float,json=zeroCountFloat" json:"zero_count_float,omitempty"` + ZeroThreshold *float64 `protobuf:"fixed64,6,opt,name=zero_threshold,json=zeroThreshold" json:"zero_threshold,omitempty"` // Breadth of the zero bucket. + ZeroCount *uint64 `protobuf:"varint,7,opt,name=zero_count,json=zeroCount" json:"zero_count,omitempty"` // Count in zero bucket. + ZeroCountFloat *float64 `protobuf:"fixed64,8,opt,name=zero_count_float,json=zeroCountFloat" json:"zero_count_float,omitempty"` // Overrides sb_zero_count if > 0. // Negative buckets for the native histogram. NegativeSpan []*BucketSpan `protobuf:"bytes,9,rep,name=negative_span,json=negativeSpan" json:"negative_span,omitempty"` // Use either "negative_delta" or "negative_count", the former for // regular histograms with integer counts, the latter for float // histograms. - NegativeDelta []int64 `protobuf:"zigzag64,10,rep,name=negative_delta,json=negativeDelta" json:"negative_delta,omitempty"` - NegativeCount []float64 `protobuf:"fixed64,11,rep,name=negative_count,json=negativeCount" json:"negative_count,omitempty"` + NegativeDelta []int64 `protobuf:"zigzag64,10,rep,name=negative_delta,json=negativeDelta" json:"negative_delta,omitempty"` // Count delta of each bucket compared to previous one (or to zero for 1st bucket). + NegativeCount []float64 `protobuf:"fixed64,11,rep,name=negative_count,json=negativeCount" json:"negative_count,omitempty"` // Absolute count of each bucket. // Positive buckets for the native histogram. PositiveSpan []*BucketSpan `protobuf:"bytes,12,rep,name=positive_span,json=positiveSpan" json:"positive_span,omitempty"` // Use either "positive_delta" or "positive_count", the former for // regular histograms with integer counts, the latter for float // histograms. - PositiveDelta []int64 `protobuf:"zigzag64,13,rep,name=positive_delta,json=positiveDelta" json:"positive_delta,omitempty"` - PositiveCount []float64 `protobuf:"fixed64,14,rep,name=positive_count,json=positiveCount" json:"positive_count,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + PositiveDelta []int64 `protobuf:"zigzag64,13,rep,name=positive_delta,json=positiveDelta" json:"positive_delta,omitempty"` // Count delta of each bucket compared to previous one (or to zero for 1st bucket). + PositiveCount []float64 `protobuf:"fixed64,14,rep,name=positive_count,json=positiveCount" json:"positive_count,omitempty"` // Absolute count of each bucket. } -func (m *Histogram) Reset() { *m = Histogram{} } -func (m *Histogram) String() string { return proto.CompactTextString(m) } -func (*Histogram) ProtoMessage() {} -func (*Histogram) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{6} +func (x *Histogram) Reset() { + *x = Histogram{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Histogram) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Histogram.Unmarshal(m, b) +func (x *Histogram) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Histogram) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Histogram.Marshal(b, m, deterministic) -} -func (m *Histogram) XXX_Merge(src proto.Message) { - xxx_messageInfo_Histogram.Merge(m, src) -} -func (m *Histogram) XXX_Size() int { - return xxx_messageInfo_Histogram.Size(m) -} -func (m *Histogram) XXX_DiscardUnknown() { - xxx_messageInfo_Histogram.DiscardUnknown(m) + +func (*Histogram) ProtoMessage() {} + +func (x *Histogram) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Histogram proto.InternalMessageInfo +// Deprecated: Use Histogram.ProtoReflect.Descriptor instead. +func (*Histogram) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{6} +} -func (m *Histogram) GetSampleCount() uint64 { - if m != nil && m.SampleCount != nil { - return *m.SampleCount +func (x *Histogram) GetSampleCount() uint64 { + if x != nil && x.SampleCount != nil { + return *x.SampleCount } return 0 } -func (m *Histogram) GetSampleCountFloat() float64 { - if m != nil && m.SampleCountFloat != nil { - return *m.SampleCountFloat +func (x *Histogram) GetSampleCountFloat() float64 { + if x != nil && x.SampleCountFloat != nil { + return *x.SampleCountFloat } return 0 } -func (m *Histogram) GetSampleSum() float64 { - if m != nil && m.SampleSum != nil { - return *m.SampleSum +func (x *Histogram) GetSampleSum() float64 { + if x != nil && x.SampleSum != nil { + return *x.SampleSum } return 0 } -func (m *Histogram) GetBucket() []*Bucket { - if m != nil { - return m.Bucket +func (x *Histogram) GetBucket() []*Bucket { + if x != nil { + return x.Bucket } return nil } -func (m *Histogram) GetSchema() int32 { - if m != nil && m.Schema != nil { - return *m.Schema +func (x *Histogram) GetSchema() int32 { + if x != nil && x.Schema != nil { + return *x.Schema } return 0 } -func (m *Histogram) GetZeroThreshold() float64 { - if m != nil && m.ZeroThreshold != nil { - return *m.ZeroThreshold +func (x *Histogram) GetZeroThreshold() float64 { + if x != nil && x.ZeroThreshold != nil { + return *x.ZeroThreshold } return 0 } -func (m *Histogram) GetZeroCount() uint64 { - if m != nil && m.ZeroCount != nil { - return *m.ZeroCount +func (x *Histogram) GetZeroCount() uint64 { + if x != nil && x.ZeroCount != nil { + return *x.ZeroCount } return 0 } -func (m *Histogram) GetZeroCountFloat() float64 { - if m != nil && m.ZeroCountFloat != nil { - return *m.ZeroCountFloat +func (x *Histogram) GetZeroCountFloat() float64 { + if x != nil && x.ZeroCountFloat != nil { + return *x.ZeroCountFloat } return 0 } -func (m *Histogram) GetNegativeSpan() []*BucketSpan { - if m != nil { - return m.NegativeSpan +func (x *Histogram) GetNegativeSpan() []*BucketSpan { + if x != nil { + return x.NegativeSpan } return nil } -func (m *Histogram) GetNegativeDelta() []int64 { - if m != nil { - return m.NegativeDelta +func (x *Histogram) GetNegativeDelta() []int64 { + if x != nil { + return x.NegativeDelta } return nil } -func (m *Histogram) GetNegativeCount() []float64 { - if m != nil { - return m.NegativeCount +func (x *Histogram) GetNegativeCount() []float64 { + if x != nil { + return x.NegativeCount } return nil } -func (m *Histogram) GetPositiveSpan() []*BucketSpan { - if m != nil { - return m.PositiveSpan +func (x *Histogram) GetPositiveSpan() []*BucketSpan { + if x != nil { + return x.PositiveSpan } return nil } -func (m *Histogram) GetPositiveDelta() []int64 { - if m != nil { - return m.PositiveDelta +func (x *Histogram) GetPositiveDelta() []int64 { + if x != nil { + return x.PositiveDelta } return nil } -func (m *Histogram) GetPositiveCount() []float64 { - if m != nil { - return m.PositiveCount +func (x *Histogram) GetPositiveCount() []float64 { + if x != nil { + return x.PositiveCount } return nil } @@ -513,64 +598,72 @@ func (m *Histogram) GetPositiveCount() []float64 { // A Bucket of a conventional histogram, each of which is treated as // an individual counter-like time series by Prometheus. type Bucket struct { - CumulativeCount *uint64 `protobuf:"varint,1,opt,name=cumulative_count,json=cumulativeCount" json:"cumulative_count,omitempty"` - CumulativeCountFloat *float64 `protobuf:"fixed64,4,opt,name=cumulative_count_float,json=cumulativeCountFloat" json:"cumulative_count_float,omitempty"` - UpperBound *float64 `protobuf:"fixed64,2,opt,name=upper_bound,json=upperBound" json:"upper_bound,omitempty"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CumulativeCount *uint64 `protobuf:"varint,1,opt,name=cumulative_count,json=cumulativeCount" json:"cumulative_count,omitempty"` // Cumulative in increasing order. + CumulativeCountFloat *float64 `protobuf:"fixed64,4,opt,name=cumulative_count_float,json=cumulativeCountFloat" json:"cumulative_count_float,omitempty"` // Overrides cumulative_count if > 0. + UpperBound *float64 `protobuf:"fixed64,2,opt,name=upper_bound,json=upperBound" json:"upper_bound,omitempty"` // Inclusive. Exemplar *Exemplar `protobuf:"bytes,3,opt,name=exemplar" json:"exemplar,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` } -func (m *Bucket) Reset() { *m = Bucket{} } -func (m *Bucket) String() string { return proto.CompactTextString(m) } -func (*Bucket) ProtoMessage() {} -func (*Bucket) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{7} +func (x *Bucket) Reset() { + *x = Bucket{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Bucket) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Bucket.Unmarshal(m, b) -} -func (m *Bucket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Bucket.Marshal(b, m, deterministic) -} -func (m *Bucket) XXX_Merge(src proto.Message) { - xxx_messageInfo_Bucket.Merge(m, src) -} -func (m *Bucket) XXX_Size() int { - return xxx_messageInfo_Bucket.Size(m) +func (x *Bucket) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Bucket) XXX_DiscardUnknown() { - xxx_messageInfo_Bucket.DiscardUnknown(m) + +func (*Bucket) ProtoMessage() {} + +func (x *Bucket) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Bucket proto.InternalMessageInfo +// Deprecated: Use Bucket.ProtoReflect.Descriptor instead. +func (*Bucket) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{7} +} -func (m *Bucket) GetCumulativeCount() uint64 { - if m != nil && m.CumulativeCount != nil { - return *m.CumulativeCount +func (x *Bucket) GetCumulativeCount() uint64 { + if x != nil && x.CumulativeCount != nil { + return *x.CumulativeCount } return 0 } -func (m *Bucket) GetCumulativeCountFloat() float64 { - if m != nil && m.CumulativeCountFloat != nil { - return *m.CumulativeCountFloat +func (x *Bucket) GetCumulativeCountFloat() float64 { + if x != nil && x.CumulativeCountFloat != nil { + return *x.CumulativeCountFloat } return 0 } -func (m *Bucket) GetUpperBound() float64 { - if m != nil && m.UpperBound != nil { - return *m.UpperBound +func (x *Bucket) GetUpperBound() float64 { + if x != nil && x.UpperBound != nil { + return *x.UpperBound } return 0 } -func (m *Bucket) GetExemplar() *Exemplar { - if m != nil { - return m.Exemplar +func (x *Bucket) GetExemplar() *Exemplar { + if x != nil { + return x.Exemplar } return nil } @@ -582,333 +675,658 @@ func (m *Bucket) GetExemplar() *Exemplar { // structured here (with all the buckets in a single array separate // from the Spans). type BucketSpan struct { - Offset *int32 `protobuf:"zigzag32,1,opt,name=offset" json:"offset,omitempty"` - Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *BucketSpan) Reset() { *m = BucketSpan{} } -func (m *BucketSpan) String() string { return proto.CompactTextString(m) } -func (*BucketSpan) ProtoMessage() {} -func (*BucketSpan) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{8} + Offset *int32 `protobuf:"zigzag32,1,opt,name=offset" json:"offset,omitempty"` // Gap to previous span, or starting point for 1st span (which can be negative). + Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` // Length of consecutive buckets. } -func (m *BucketSpan) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_BucketSpan.Unmarshal(m, b) -} -func (m *BucketSpan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_BucketSpan.Marshal(b, m, deterministic) -} -func (m *BucketSpan) XXX_Merge(src proto.Message) { - xxx_messageInfo_BucketSpan.Merge(m, src) +func (x *BucketSpan) Reset() { + *x = BucketSpan{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *BucketSpan) XXX_Size() int { - return xxx_messageInfo_BucketSpan.Size(m) + +func (x *BucketSpan) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *BucketSpan) XXX_DiscardUnknown() { - xxx_messageInfo_BucketSpan.DiscardUnknown(m) + +func (*BucketSpan) ProtoMessage() {} + +func (x *BucketSpan) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_BucketSpan proto.InternalMessageInfo +// Deprecated: Use BucketSpan.ProtoReflect.Descriptor instead. +func (*BucketSpan) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{8} +} -func (m *BucketSpan) GetOffset() int32 { - if m != nil && m.Offset != nil { - return *m.Offset +func (x *BucketSpan) GetOffset() int32 { + if x != nil && x.Offset != nil { + return *x.Offset } return 0 } -func (m *BucketSpan) GetLength() uint32 { - if m != nil && m.Length != nil { - return *m.Length +func (x *BucketSpan) GetLength() uint32 { + if x != nil && x.Length != nil { + return *x.Length } return 0 } type Exemplar struct { - Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` - Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` - Timestamp *timestamp.Timestamp `protobuf:"bytes,3,opt,name=timestamp" json:"timestamp,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Exemplar) Reset() { *m = Exemplar{} } -func (m *Exemplar) String() string { return proto.CompactTextString(m) } -func (*Exemplar) ProtoMessage() {} -func (*Exemplar) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{9} + Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` + Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=timestamp" json:"timestamp,omitempty"` // OpenMetrics-style. } -func (m *Exemplar) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Exemplar.Unmarshal(m, b) -} -func (m *Exemplar) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Exemplar.Marshal(b, m, deterministic) -} -func (m *Exemplar) XXX_Merge(src proto.Message) { - xxx_messageInfo_Exemplar.Merge(m, src) +func (x *Exemplar) Reset() { + *x = Exemplar{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Exemplar) XXX_Size() int { - return xxx_messageInfo_Exemplar.Size(m) + +func (x *Exemplar) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Exemplar) XXX_DiscardUnknown() { - xxx_messageInfo_Exemplar.DiscardUnknown(m) + +func (*Exemplar) ProtoMessage() {} + +func (x *Exemplar) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Exemplar proto.InternalMessageInfo +// Deprecated: Use Exemplar.ProtoReflect.Descriptor instead. +func (*Exemplar) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{9} +} -func (m *Exemplar) GetLabel() []*LabelPair { - if m != nil { - return m.Label +func (x *Exemplar) GetLabel() []*LabelPair { + if x != nil { + return x.Label } return nil } -func (m *Exemplar) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Exemplar) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } -func (m *Exemplar) GetTimestamp() *timestamp.Timestamp { - if m != nil { - return m.Timestamp +func (x *Exemplar) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp } return nil } type Metric struct { - Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` - Gauge *Gauge `protobuf:"bytes,2,opt,name=gauge" json:"gauge,omitempty"` - Counter *Counter `protobuf:"bytes,3,opt,name=counter" json:"counter,omitempty"` - Summary *Summary `protobuf:"bytes,4,opt,name=summary" json:"summary,omitempty"` - Untyped *Untyped `protobuf:"bytes,5,opt,name=untyped" json:"untyped,omitempty"` - Histogram *Histogram `protobuf:"bytes,7,opt,name=histogram" json:"histogram,omitempty"` - TimestampMs *int64 `protobuf:"varint,6,opt,name=timestamp_ms,json=timestampMs" json:"timestamp_ms,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Metric) Reset() { *m = Metric{} } -func (m *Metric) String() string { return proto.CompactTextString(m) } -func (*Metric) ProtoMessage() {} -func (*Metric) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{10} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` + Gauge *Gauge `protobuf:"bytes,2,opt,name=gauge" json:"gauge,omitempty"` + Counter *Counter `protobuf:"bytes,3,opt,name=counter" json:"counter,omitempty"` + Summary *Summary `protobuf:"bytes,4,opt,name=summary" json:"summary,omitempty"` + Untyped *Untyped `protobuf:"bytes,5,opt,name=untyped" json:"untyped,omitempty"` + Histogram *Histogram `protobuf:"bytes,7,opt,name=histogram" json:"histogram,omitempty"` + TimestampMs *int64 `protobuf:"varint,6,opt,name=timestamp_ms,json=timestampMs" json:"timestamp_ms,omitempty"` +} + +func (x *Metric) Reset() { + *x = Metric{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Metric) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Metric.Unmarshal(m, b) +func (x *Metric) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Metric) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Metric.Marshal(b, m, deterministic) -} -func (m *Metric) XXX_Merge(src proto.Message) { - xxx_messageInfo_Metric.Merge(m, src) -} -func (m *Metric) XXX_Size() int { - return xxx_messageInfo_Metric.Size(m) -} -func (m *Metric) XXX_DiscardUnknown() { - xxx_messageInfo_Metric.DiscardUnknown(m) + +func (*Metric) ProtoMessage() {} + +func (x *Metric) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Metric proto.InternalMessageInfo +// Deprecated: Use Metric.ProtoReflect.Descriptor instead. +func (*Metric) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{10} +} -func (m *Metric) GetLabel() []*LabelPair { - if m != nil { - return m.Label +func (x *Metric) GetLabel() []*LabelPair { + if x != nil { + return x.Label } return nil } -func (m *Metric) GetGauge() *Gauge { - if m != nil { - return m.Gauge +func (x *Metric) GetGauge() *Gauge { + if x != nil { + return x.Gauge } return nil } -func (m *Metric) GetCounter() *Counter { - if m != nil { - return m.Counter +func (x *Metric) GetCounter() *Counter { + if x != nil { + return x.Counter } return nil } -func (m *Metric) GetSummary() *Summary { - if m != nil { - return m.Summary +func (x *Metric) GetSummary() *Summary { + if x != nil { + return x.Summary } return nil } -func (m *Metric) GetUntyped() *Untyped { - if m != nil { - return m.Untyped +func (x *Metric) GetUntyped() *Untyped { + if x != nil { + return x.Untyped } return nil } -func (m *Metric) GetHistogram() *Histogram { - if m != nil { - return m.Histogram +func (x *Metric) GetHistogram() *Histogram { + if x != nil { + return x.Histogram } return nil } -func (m *Metric) GetTimestampMs() int64 { - if m != nil && m.TimestampMs != nil { - return *m.TimestampMs +func (x *Metric) GetTimestampMs() int64 { + if x != nil && x.TimestampMs != nil { + return *x.TimestampMs } return 0 } type MetricFamily struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Help *string `protobuf:"bytes,2,opt,name=help" json:"help,omitempty"` - Type *MetricType `protobuf:"varint,3,opt,name=type,enum=io.prometheus.client.MetricType" json:"type,omitempty"` - Metric []*Metric `protobuf:"bytes,4,rep,name=metric" json:"metric,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *MetricFamily) Reset() { *m = MetricFamily{} } -func (m *MetricFamily) String() string { return proto.CompactTextString(m) } -func (*MetricFamily) ProtoMessage() {} -func (*MetricFamily) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{11} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Help *string `protobuf:"bytes,2,opt,name=help" json:"help,omitempty"` + Type *MetricType `protobuf:"varint,3,opt,name=type,enum=io.prometheus.client.MetricType" json:"type,omitempty"` + Metric []*Metric `protobuf:"bytes,4,rep,name=metric" json:"metric,omitempty"` +} + +func (x *MetricFamily) Reset() { + *x = MetricFamily{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *MetricFamily) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_MetricFamily.Unmarshal(m, b) -} -func (m *MetricFamily) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_MetricFamily.Marshal(b, m, deterministic) -} -func (m *MetricFamily) XXX_Merge(src proto.Message) { - xxx_messageInfo_MetricFamily.Merge(m, src) -} -func (m *MetricFamily) XXX_Size() int { - return xxx_messageInfo_MetricFamily.Size(m) +func (x *MetricFamily) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *MetricFamily) XXX_DiscardUnknown() { - xxx_messageInfo_MetricFamily.DiscardUnknown(m) + +func (*MetricFamily) ProtoMessage() {} + +func (x *MetricFamily) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_MetricFamily proto.InternalMessageInfo +// Deprecated: Use MetricFamily.ProtoReflect.Descriptor instead. +func (*MetricFamily) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{11} +} -func (m *MetricFamily) GetName() string { - if m != nil && m.Name != nil { - return *m.Name +func (x *MetricFamily) GetName() string { + if x != nil && x.Name != nil { + return *x.Name } return "" } -func (m *MetricFamily) GetHelp() string { - if m != nil && m.Help != nil { - return *m.Help +func (x *MetricFamily) GetHelp() string { + if x != nil && x.Help != nil { + return *x.Help } return "" } -func (m *MetricFamily) GetType() MetricType { - if m != nil && m.Type != nil { - return *m.Type +func (x *MetricFamily) GetType() MetricType { + if x != nil && x.Type != nil { + return *x.Type } return MetricType_COUNTER } -func (m *MetricFamily) GetMetric() []*Metric { - if m != nil { - return m.Metric +func (x *MetricFamily) GetMetric() []*Metric { + if x != nil { + return x.Metric } return nil } -func init() { - proto.RegisterEnum("io.prometheus.client.MetricType", MetricType_name, MetricType_value) - proto.RegisterType((*LabelPair)(nil), "io.prometheus.client.LabelPair") - proto.RegisterType((*Gauge)(nil), "io.prometheus.client.Gauge") - proto.RegisterType((*Counter)(nil), "io.prometheus.client.Counter") - proto.RegisterType((*Quantile)(nil), "io.prometheus.client.Quantile") - proto.RegisterType((*Summary)(nil), "io.prometheus.client.Summary") - proto.RegisterType((*Untyped)(nil), "io.prometheus.client.Untyped") - proto.RegisterType((*Histogram)(nil), "io.prometheus.client.Histogram") - proto.RegisterType((*Bucket)(nil), "io.prometheus.client.Bucket") - proto.RegisterType((*BucketSpan)(nil), "io.prometheus.client.BucketSpan") - proto.RegisterType((*Exemplar)(nil), "io.prometheus.client.Exemplar") - proto.RegisterType((*Metric)(nil), "io.prometheus.client.Metric") - proto.RegisterType((*MetricFamily)(nil), "io.prometheus.client.MetricFamily") -} - -func init() { - proto.RegisterFile("io/prometheus/client/metrics.proto", fileDescriptor_d1e5ddb18987a258) -} - -var fileDescriptor_d1e5ddb18987a258 = []byte{ - // 896 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xdd, 0x8e, 0xdb, 0x44, - 0x18, 0xc5, 0x9b, 0x5f, 0x7f, 0xd9, 0x6c, 0xd3, 0x61, 0x55, 0x59, 0x0b, 0xcb, 0x06, 0x4b, 0x48, - 0x0b, 0x42, 0x8e, 0x40, 0x5b, 0x81, 0x0a, 0x5c, 0xec, 0xb6, 0xe9, 0x16, 0x89, 0xb4, 0x65, 0x92, - 0x5c, 0x14, 0x2e, 0xac, 0x49, 0x32, 0xeb, 0x58, 0x78, 0x3c, 0xc6, 0x1e, 0x57, 0x2c, 0x2f, 0xc0, - 0x35, 0xaf, 0xc0, 0xc3, 0xf0, 0x22, 0x3c, 0x08, 0x68, 0xfe, 0xec, 0xdd, 0xe2, 0x94, 0xd2, 0x3b, - 0x7f, 0x67, 0xce, 0xf7, 0xcd, 0x39, 0xe3, 0xc9, 0x71, 0xc0, 0x8f, 0xf9, 0x24, 0xcb, 0x39, 0xa3, - 0x62, 0x4b, 0xcb, 0x62, 0xb2, 0x4e, 0x62, 0x9a, 0x8a, 0x09, 0xa3, 0x22, 0x8f, 0xd7, 0x45, 0x90, - 0xe5, 0x5c, 0x70, 0x74, 0x18, 0xf3, 0xa0, 0xe6, 0x04, 0x9a, 0x73, 0x74, 0x12, 0x71, 0x1e, 0x25, - 0x74, 0xa2, 0x38, 0xab, 0xf2, 0x6a, 0x22, 0x62, 0x46, 0x0b, 0x41, 0x58, 0xa6, 0xdb, 0xfc, 0xfb, - 0xe0, 0x7e, 0x47, 0x56, 0x34, 0x79, 0x4e, 0xe2, 0x1c, 0x21, 0x68, 0xa7, 0x84, 0x51, 0xcf, 0x19, - 0x3b, 0xa7, 0x2e, 0x56, 0xcf, 0xe8, 0x10, 0x3a, 0x2f, 0x49, 0x52, 0x52, 0x6f, 0x4f, 0x81, 0xba, - 0xf0, 0x8f, 0xa1, 0x73, 0x49, 0xca, 0xe8, 0xc6, 0xb2, 0xec, 0x71, 0xec, 0xf2, 0x8f, 0xd0, 0x7b, - 0xc8, 0xcb, 0x54, 0xd0, 0xbc, 0x99, 0x80, 0x1e, 0x40, 0x9f, 0xfe, 0x42, 0x59, 0x96, 0x90, 0x5c, - 0x0d, 0x1e, 0x7c, 0xfe, 0x41, 0xd0, 0x64, 0x20, 0x98, 0x1a, 0x16, 0xae, 0xf8, 0xfe, 0xd7, 0xd0, - 0xff, 0xbe, 0x24, 0xa9, 0x88, 0x13, 0x8a, 0x8e, 0xa0, 0xff, 0xb3, 0x79, 0x36, 0x1b, 0x54, 0xf5, - 0x6d, 0xe5, 0x95, 0xb4, 0xdf, 0x1c, 0xe8, 0xcd, 0x4b, 0xc6, 0x48, 0x7e, 0x8d, 0x3e, 0x84, 0xfd, - 0x82, 0xb0, 0x2c, 0xa1, 0xe1, 0x5a, 0xaa, 0x55, 0x13, 0xda, 0x78, 0xa0, 0x31, 0x65, 0x00, 0x1d, - 0x03, 0x18, 0x4a, 0x51, 0x32, 0x33, 0xc9, 0xd5, 0xc8, 0xbc, 0x64, 0xd2, 0x47, 0xb5, 0x7f, 0x6b, - 0xdc, 0xda, 0xed, 0xc3, 0x2a, 0xae, 0xf5, 0xf9, 0x27, 0xd0, 0x5b, 0xa6, 0xe2, 0x3a, 0xa3, 0x9b, - 0x1d, 0xa7, 0xf8, 0x57, 0x1b, 0xdc, 0x27, 0x71, 0x21, 0x78, 0x94, 0x13, 0xf6, 0x26, 0x62, 0x3f, - 0x05, 0x74, 0x93, 0x12, 0x5e, 0x25, 0x9c, 0x08, 0xaf, 0xad, 0x66, 0x8e, 0x6e, 0x10, 0x1f, 0x4b, - 0xfc, 0xbf, 0xac, 0x9d, 0x41, 0x77, 0x55, 0xae, 0x7f, 0xa2, 0xc2, 0x18, 0x7b, 0xbf, 0xd9, 0xd8, - 0x85, 0xe2, 0x60, 0xc3, 0x45, 0xf7, 0xa0, 0x5b, 0xac, 0xb7, 0x94, 0x11, 0xaf, 0x33, 0x76, 0x4e, - 0xef, 0x62, 0x53, 0xa1, 0x8f, 0xe0, 0xe0, 0x57, 0x9a, 0xf3, 0x50, 0x6c, 0x73, 0x5a, 0x6c, 0x79, - 0xb2, 0xf1, 0xba, 0x6a, 0xc3, 0xa1, 0x44, 0x17, 0x16, 0x94, 0x9a, 0x14, 0x4d, 0x5b, 0xec, 0x29, - 0x8b, 0xae, 0x44, 0xb4, 0xc1, 0x53, 0x18, 0xd5, 0xcb, 0xc6, 0x5e, 0x5f, 0xcd, 0x39, 0xa8, 0x48, - 0xda, 0xdc, 0x14, 0x86, 0x29, 0x8d, 0x88, 0x88, 0x5f, 0xd2, 0xb0, 0xc8, 0x48, 0xea, 0xb9, 0xca, - 0xc4, 0xf8, 0x75, 0x26, 0xe6, 0x19, 0x49, 0xf1, 0xbe, 0x6d, 0x93, 0x95, 0x94, 0x5d, 0x8d, 0xd9, - 0xd0, 0x44, 0x10, 0x0f, 0xc6, 0xad, 0x53, 0x84, 0xab, 0xe1, 0x8f, 0x24, 0x78, 0x8b, 0xa6, 0xa5, - 0x0f, 0xc6, 0x2d, 0xe9, 0xce, 0xa2, 0x5a, 0xfe, 0x14, 0x86, 0x19, 0x2f, 0xe2, 0x5a, 0xd4, 0xfe, - 0x9b, 0x8a, 0xb2, 0x6d, 0x56, 0x54, 0x35, 0x46, 0x8b, 0x1a, 0x6a, 0x51, 0x16, 0xad, 0x44, 0x55, - 0x34, 0x2d, 0xea, 0x40, 0x8b, 0xb2, 0xa8, 0x12, 0xe5, 0xff, 0xe9, 0x40, 0x57, 0x6f, 0x85, 0x3e, - 0x86, 0xd1, 0xba, 0x64, 0x65, 0x72, 0xd3, 0x88, 0xbe, 0x66, 0x77, 0x6a, 0x5c, 0x5b, 0x39, 0x83, - 0x7b, 0xaf, 0x52, 0x6f, 0x5d, 0xb7, 0xc3, 0x57, 0x1a, 0xf4, 0x5b, 0x39, 0x81, 0x41, 0x99, 0x65, - 0x34, 0x0f, 0x57, 0xbc, 0x4c, 0x37, 0xe6, 0xce, 0x81, 0x82, 0x2e, 0x24, 0x72, 0x2b, 0x17, 0x5a, - 0xff, 0x3b, 0x17, 0xa0, 0x3e, 0x32, 0x79, 0x11, 0xf9, 0xd5, 0x55, 0x41, 0xb5, 0x83, 0xbb, 0xd8, - 0x54, 0x12, 0x4f, 0x68, 0x1a, 0x89, 0xad, 0xda, 0x7d, 0x88, 0x4d, 0xe5, 0xff, 0xee, 0x40, 0xdf, - 0x0e, 0x45, 0xf7, 0xa1, 0x93, 0xc8, 0x54, 0xf4, 0x1c, 0xf5, 0x82, 0x4e, 0x9a, 0x35, 0x54, 0xc1, - 0x89, 0x35, 0xbb, 0x39, 0x71, 0xd0, 0x97, 0xe0, 0x56, 0xa9, 0x6b, 0x4c, 0x1d, 0x05, 0x3a, 0x97, - 0x03, 0x9b, 0xcb, 0xc1, 0xc2, 0x32, 0x70, 0x4d, 0xf6, 0xff, 0xde, 0x83, 0xee, 0x4c, 0xa5, 0xfc, - 0xdb, 0x2a, 0xfa, 0x0c, 0x3a, 0x91, 0xcc, 0x69, 0x13, 0xb2, 0xef, 0x35, 0xb7, 0xa9, 0x28, 0xc7, - 0x9a, 0x89, 0xbe, 0x80, 0xde, 0x5a, 0x67, 0xb7, 0x11, 0x7b, 0xdc, 0xdc, 0x64, 0x02, 0x1e, 0x5b, - 0xb6, 0x6c, 0x2c, 0x74, 0xb0, 0xaa, 0x3b, 0xb0, 0xb3, 0xd1, 0xa4, 0x2f, 0xb6, 0x6c, 0xd9, 0x58, - 0xea, 0x20, 0x54, 0xa1, 0xb1, 0xb3, 0xd1, 0xa4, 0x25, 0xb6, 0x6c, 0xf4, 0x0d, 0xb8, 0x5b, 0x9b, - 0x8f, 0x2a, 0x2c, 0x76, 0x1e, 0x4c, 0x15, 0xa3, 0xb8, 0xee, 0x90, 0x89, 0x5a, 0x9d, 0x75, 0xc8, - 0x0a, 0x95, 0x48, 0x2d, 0x3c, 0xa8, 0xb0, 0x59, 0xe1, 0xff, 0xe1, 0xc0, 0xbe, 0x7e, 0x03, 0x8f, - 0x09, 0x8b, 0x93, 0xeb, 0xc6, 0x4f, 0x24, 0x82, 0xf6, 0x96, 0x26, 0x99, 0xf9, 0x42, 0xaa, 0x67, - 0x74, 0x06, 0x6d, 0xa9, 0x51, 0x1d, 0xe1, 0xc1, 0xae, 0x5f, 0xb8, 0x9e, 0xbc, 0xb8, 0xce, 0x28, - 0x56, 0x6c, 0x99, 0xb9, 0xfa, 0xab, 0xee, 0xb5, 0x5f, 0x97, 0xb9, 0xba, 0x0f, 0x1b, 0xee, 0x27, - 0x2b, 0x80, 0x7a, 0x12, 0x1a, 0x40, 0xef, 0xe1, 0xb3, 0xe5, 0xd3, 0xc5, 0x14, 0x8f, 0xde, 0x41, - 0x2e, 0x74, 0x2e, 0xcf, 0x97, 0x97, 0xd3, 0x91, 0x23, 0xf1, 0xf9, 0x72, 0x36, 0x3b, 0xc7, 0x2f, - 0x46, 0x7b, 0xb2, 0x58, 0x3e, 0x5d, 0xbc, 0x78, 0x3e, 0x7d, 0x34, 0x6a, 0xa1, 0x21, 0xb8, 0x4f, - 0xbe, 0x9d, 0x2f, 0x9e, 0x5d, 0xe2, 0xf3, 0xd9, 0xa8, 0x8d, 0xde, 0x85, 0x3b, 0xaa, 0x27, 0xac, - 0xc1, 0xce, 0x05, 0x86, 0xc6, 0x3f, 0x18, 0x3f, 0x3c, 0x88, 0x62, 0xb1, 0x2d, 0x57, 0xc1, 0x9a, - 0xb3, 0x7f, 0xff, 0x45, 0x09, 0x19, 0xdf, 0xd0, 0x64, 0x12, 0xf1, 0xaf, 0x62, 0x1e, 0xd6, 0xab, - 0xa1, 0x5e, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0x16, 0x77, 0x81, 0x98, 0xd7, 0x08, 0x00, 0x00, +var File_io_prometheus_client_metrics_proto protoreflect.FileDescriptor + +var file_io_prometheus_client_metrics_proto_rawDesc = []byte{ + 0x0a, 0x22, 0x69, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2f, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, + 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x35, 0x0a, 0x09, 0x4c, + 0x61, 0x62, 0x65, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x22, 0x1d, 0x0a, 0x05, 0x47, 0x61, 0x75, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x22, 0x5b, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x12, 0x3a, 0x0a, 0x08, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, + 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x78, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x72, 0x52, 0x08, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x22, 0x3c, + 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x87, 0x01, 0x0a, + 0x07, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, + 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, + 0x09, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x53, 0x75, 0x6d, 0x12, 0x3a, 0x0a, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, + 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x2e, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x52, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x22, 0x1f, 0x0a, 0x07, 0x55, 0x6e, 0x74, 0x79, 0x70, 0x65, + 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xe3, 0x04, 0x0a, 0x09, 0x48, 0x69, 0x73, 0x74, + 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x73, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x01, 0x52, 0x10, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x5f, 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x53, 0x75, 0x6d, 0x12, 0x34, 0x0a, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, + 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x42, 0x75, 0x63, + 0x6b, 0x65, 0x74, 0x52, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x11, 0x52, 0x06, 0x73, 0x63, 0x68, + 0x65, 0x6d, 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x7a, 0x65, 0x72, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, + 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0d, 0x7a, 0x65, 0x72, + 0x6f, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x7a, 0x65, + 0x72, 0x6f, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, + 0x7a, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x7a, 0x65, 0x72, + 0x6f, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x0e, 0x7a, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x6c, + 0x6f, 0x61, 0x74, 0x12, 0x45, 0x0a, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, + 0x73, 0x70, 0x61, 0x6e, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x6f, 0x2e, + 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x52, 0x0c, 0x6e, 0x65, + 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6e, 0x65, + 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x74, 0x61, 0x18, 0x0a, 0x20, 0x03, + 0x28, 0x12, 0x52, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x44, 0x65, 0x6c, 0x74, + 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x01, 0x52, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, + 0x69, 0x76, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x45, 0x0a, 0x0d, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x76, 0x65, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x20, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x70, 0x61, + 0x6e, 0x52, 0x0c, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x12, + 0x25, 0x0a, 0x0e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x74, + 0x61, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x12, 0x52, 0x0d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, + 0x65, 0x44, 0x65, 0x6c, 0x74, 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x01, 0x52, 0x0d, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xc6, 0x01, + 0x0a, 0x06, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x75, 0x6d, 0x75, + 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0f, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x12, 0x34, 0x0a, 0x16, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, + 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x14, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x70, 0x70, + 0x65, 0x72, 0x5f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0a, + 0x75, 0x70, 0x70, 0x65, 0x72, 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x3a, 0x0a, 0x08, 0x65, 0x78, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, + 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x52, 0x08, 0x65, 0x78, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x22, 0x3c, 0x0a, 0x0a, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, + 0x53, 0x70, 0x61, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x11, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, + 0x6e, 0x67, 0x74, 0x68, 0x22, 0x91, 0x01, 0x0a, 0x08, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x72, 0x12, 0x35, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, + 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x50, 0x61, 0x69, + 0x72, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x38, + 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xff, 0x02, 0x0a, 0x06, 0x4d, 0x65, 0x74, + 0x72, 0x69, 0x63, 0x12, 0x35, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, + 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x50, + 0x61, 0x69, 0x72, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x31, 0x0a, 0x05, 0x67, 0x61, + 0x75, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x69, 0x6f, 0x2e, 0x70, + 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x2e, 0x47, 0x61, 0x75, 0x67, 0x65, 0x52, 0x05, 0x67, 0x61, 0x75, 0x67, 0x65, 0x12, 0x37, 0x0a, + 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, + 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x07, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, + 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x53, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, + 0x37, 0x0a, 0x07, 0x75, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1d, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, + 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x55, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x64, 0x52, + 0x07, 0x75, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x64, 0x12, 0x3d, 0x0a, 0x09, 0x68, 0x69, 0x73, 0x74, + 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6f, + 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x52, 0x09, 0x68, 0x69, + 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x6d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x4d, 0x73, 0x22, 0xa2, 0x01, 0x0a, 0x0c, 0x4d, + 0x65, 0x74, 0x72, 0x69, 0x63, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x68, 0x65, 0x6c, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, + 0x65, 0x6c, 0x70, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x20, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, + 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x54, + 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x34, 0x0a, 0x06, 0x6d, 0x65, 0x74, + 0x72, 0x69, 0x63, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x69, 0x6f, 0x2e, 0x70, + 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x2a, + 0x62, 0x0a, 0x0a, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, + 0x07, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x47, 0x41, + 0x55, 0x47, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x4d, 0x4d, 0x41, 0x52, 0x59, + 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x54, 0x59, 0x50, 0x45, 0x44, 0x10, 0x03, 0x12, + 0x0d, 0x0a, 0x09, 0x48, 0x49, 0x53, 0x54, 0x4f, 0x47, 0x52, 0x41, 0x4d, 0x10, 0x04, 0x12, 0x13, + 0x0a, 0x0f, 0x47, 0x41, 0x55, 0x47, 0x45, 0x5f, 0x48, 0x49, 0x53, 0x54, 0x4f, 0x47, 0x52, 0x41, + 0x4d, 0x10, 0x05, 0x42, 0x52, 0x0a, 0x14, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, + 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5a, 0x3a, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, + 0x75, 0x73, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, + 0x67, 0x6f, 0x3b, 0x69, 0x6f, 0x5f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, + 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, +} + +var ( + file_io_prometheus_client_metrics_proto_rawDescOnce sync.Once + file_io_prometheus_client_metrics_proto_rawDescData = file_io_prometheus_client_metrics_proto_rawDesc +) + +func file_io_prometheus_client_metrics_proto_rawDescGZIP() []byte { + file_io_prometheus_client_metrics_proto_rawDescOnce.Do(func() { + file_io_prometheus_client_metrics_proto_rawDescData = protoimpl.X.CompressGZIP(file_io_prometheus_client_metrics_proto_rawDescData) + }) + return file_io_prometheus_client_metrics_proto_rawDescData +} + +var file_io_prometheus_client_metrics_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_io_prometheus_client_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_io_prometheus_client_metrics_proto_goTypes = []interface{}{ + (MetricType)(0), // 0: io.prometheus.client.MetricType + (*LabelPair)(nil), // 1: io.prometheus.client.LabelPair + (*Gauge)(nil), // 2: io.prometheus.client.Gauge + (*Counter)(nil), // 3: io.prometheus.client.Counter + (*Quantile)(nil), // 4: io.prometheus.client.Quantile + (*Summary)(nil), // 5: io.prometheus.client.Summary + (*Untyped)(nil), // 6: io.prometheus.client.Untyped + (*Histogram)(nil), // 7: io.prometheus.client.Histogram + (*Bucket)(nil), // 8: io.prometheus.client.Bucket + (*BucketSpan)(nil), // 9: io.prometheus.client.BucketSpan + (*Exemplar)(nil), // 10: io.prometheus.client.Exemplar + (*Metric)(nil), // 11: io.prometheus.client.Metric + (*MetricFamily)(nil), // 12: io.prometheus.client.MetricFamily + (*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp +} +var file_io_prometheus_client_metrics_proto_depIdxs = []int32{ + 10, // 0: io.prometheus.client.Counter.exemplar:type_name -> io.prometheus.client.Exemplar + 4, // 1: io.prometheus.client.Summary.quantile:type_name -> io.prometheus.client.Quantile + 8, // 2: io.prometheus.client.Histogram.bucket:type_name -> io.prometheus.client.Bucket + 9, // 3: io.prometheus.client.Histogram.negative_span:type_name -> io.prometheus.client.BucketSpan + 9, // 4: io.prometheus.client.Histogram.positive_span:type_name -> io.prometheus.client.BucketSpan + 10, // 5: io.prometheus.client.Bucket.exemplar:type_name -> io.prometheus.client.Exemplar + 1, // 6: io.prometheus.client.Exemplar.label:type_name -> io.prometheus.client.LabelPair + 13, // 7: io.prometheus.client.Exemplar.timestamp:type_name -> google.protobuf.Timestamp + 1, // 8: io.prometheus.client.Metric.label:type_name -> io.prometheus.client.LabelPair + 2, // 9: io.prometheus.client.Metric.gauge:type_name -> io.prometheus.client.Gauge + 3, // 10: io.prometheus.client.Metric.counter:type_name -> io.prometheus.client.Counter + 5, // 11: io.prometheus.client.Metric.summary:type_name -> io.prometheus.client.Summary + 6, // 12: io.prometheus.client.Metric.untyped:type_name -> io.prometheus.client.Untyped + 7, // 13: io.prometheus.client.Metric.histogram:type_name -> io.prometheus.client.Histogram + 0, // 14: io.prometheus.client.MetricFamily.type:type_name -> io.prometheus.client.MetricType + 11, // 15: io.prometheus.client.MetricFamily.metric:type_name -> io.prometheus.client.Metric + 16, // [16:16] is the sub-list for method output_type + 16, // [16:16] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name +} + +func init() { file_io_prometheus_client_metrics_proto_init() } +func file_io_prometheus_client_metrics_proto_init() { + if File_io_prometheus_client_metrics_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_io_prometheus_client_metrics_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LabelPair); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Gauge); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Counter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Quantile); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Summary); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Untyped); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Histogram); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Bucket); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BucketSpan); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Exemplar); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Metric); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MetricFamily); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_io_prometheus_client_metrics_proto_rawDesc, + NumEnums: 1, + NumMessages: 12, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_io_prometheus_client_metrics_proto_goTypes, + DependencyIndexes: file_io_prometheus_client_metrics_proto_depIdxs, + EnumInfos: file_io_prometheus_client_metrics_proto_enumTypes, + MessageInfos: file_io_prometheus_client_metrics_proto_msgTypes, + }.Build() + File_io_prometheus_client_metrics_proto = out.File + file_io_prometheus_client_metrics_proto_rawDesc = nil + file_io_prometheus_client_metrics_proto_goTypes = nil + file_io_prometheus_client_metrics_proto_depIdxs = nil } diff --git a/test/integration/vendor/github.com/prometheus/common/expfmt/decode.go b/test/integration/vendor/github.com/prometheus/common/expfmt/decode.go index 7657f841d..906397815 100644 --- a/test/integration/vendor/github.com/prometheus/common/expfmt/decode.go +++ b/test/integration/vendor/github.com/prometheus/common/expfmt/decode.go @@ -115,32 +115,31 @@ func (d *protoDecoder) Decode(v *dto.MetricFamily) error { // textDecoder implements the Decoder interface for the text protocol. type textDecoder struct { r io.Reader - p TextParser - fams []*dto.MetricFamily + fams map[string]*dto.MetricFamily + err error } // Decode implements the Decoder interface. func (d *textDecoder) Decode(v *dto.MetricFamily) error { - // TODO(fabxc): Wrap this as a line reader to make streaming safer. - if len(d.fams) == 0 { - // No cached metric families, read everything and parse metrics. - fams, err := d.p.TextToMetricFamilies(d.r) - if err != nil { - return err - } - if len(fams) == 0 { - return io.EOF - } - d.fams = make([]*dto.MetricFamily, 0, len(fams)) - for _, f := range fams { - d.fams = append(d.fams, f) + if d.err == nil { + // Read all metrics in one shot. + var p TextParser + d.fams, d.err = p.TextToMetricFamilies(d.r) + // If we don't get an error, store io.EOF for the end. + if d.err == nil { + d.err = io.EOF } } - - *v = *d.fams[0] - d.fams = d.fams[1:] - - return nil + // Pick off one MetricFamily per Decode until there's nothing left. + for key, fam := range d.fams { + v.Name = fam.Name + v.Help = fam.Help + v.Type = fam.Type + v.Metric = fam.Metric + delete(d.fams, key) + return nil + } + return d.err } // SampleDecoder wraps a Decoder to extract samples from the metric families diff --git a/test/integration/vendor/github.com/prometheus/common/expfmt/encode.go b/test/integration/vendor/github.com/prometheus/common/expfmt/encode.go index 64dc0eb40..7f611ffaa 100644 --- a/test/integration/vendor/github.com/prometheus/common/expfmt/encode.go +++ b/test/integration/vendor/github.com/prometheus/common/expfmt/encode.go @@ -18,9 +18,9 @@ import ( "io" "net/http" - "github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. "github.com/matttproud/golang_protobuf_extensions/pbutil" "github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg" + "google.golang.org/protobuf/encoding/prototext" dto "github.com/prometheus/client_model/go" ) @@ -99,8 +99,11 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format { if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") { return FmtText } - if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion || ver == "") { - return FmtOpenMetrics + if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion_0_0_1 || ver == OpenMetricsVersion_1_0_0 || ver == "") { + if ver == OpenMetricsVersion_1_0_0 { + return FmtOpenMetrics_1_0_0 + } + return FmtOpenMetrics_0_0_1 } } return FmtText @@ -133,7 +136,7 @@ func NewEncoder(w io.Writer, format Format) Encoder { case FmtProtoText: return encoderCloser{ encode: func(v *dto.MetricFamily) error { - _, err := fmt.Fprintln(w, proto.MarshalTextString(v)) + _, err := fmt.Fprintln(w, prototext.Format(v)) return err }, close: func() error { return nil }, @@ -146,7 +149,7 @@ func NewEncoder(w io.Writer, format Format) Encoder { }, close: func() error { return nil }, } - case FmtOpenMetrics: + case FmtOpenMetrics_0_0_1, FmtOpenMetrics_1_0_0: return encoderCloser{ encode: func(v *dto.MetricFamily) error { _, err := MetricFamilyToOpenMetrics(w, v) diff --git a/test/integration/vendor/github.com/prometheus/common/expfmt/expfmt.go b/test/integration/vendor/github.com/prometheus/common/expfmt/expfmt.go index 0f176fa64..c4cb20f0d 100644 --- a/test/integration/vendor/github.com/prometheus/common/expfmt/expfmt.go +++ b/test/integration/vendor/github.com/prometheus/common/expfmt/expfmt.go @@ -19,20 +19,22 @@ type Format string // Constants to assemble the Content-Type values for the different wire protocols. const ( - TextVersion = "0.0.4" - ProtoType = `application/vnd.google.protobuf` - ProtoProtocol = `io.prometheus.client.MetricFamily` - ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";" - OpenMetricsType = `application/openmetrics-text` - OpenMetricsVersion = "0.0.1" + TextVersion = "0.0.4" + ProtoType = `application/vnd.google.protobuf` + ProtoProtocol = `io.prometheus.client.MetricFamily` + ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";" + OpenMetricsType = `application/openmetrics-text` + OpenMetricsVersion_0_0_1 = "0.0.1" + OpenMetricsVersion_1_0_0 = "1.0.0" // The Content-Type values for the different wire protocols. - FmtUnknown Format = `` - FmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8` - FmtProtoDelim Format = ProtoFmt + ` encoding=delimited` - FmtProtoText Format = ProtoFmt + ` encoding=text` - FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text` - FmtOpenMetrics Format = OpenMetricsType + `; version=` + OpenMetricsVersion + `; charset=utf-8` + FmtUnknown Format = `` + FmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8` + FmtProtoDelim Format = ProtoFmt + ` encoding=delimited` + FmtProtoText Format = ProtoFmt + ` encoding=text` + FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text` + FmtOpenMetrics_1_0_0 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_1_0_0 + `; charset=utf-8` + FmtOpenMetrics_0_0_1 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_0_0_1 + `; charset=utf-8` ) const ( diff --git a/test/integration/vendor/github.com/prometheus/common/expfmt/fuzz.go b/test/integration/vendor/github.com/prometheus/common/expfmt/fuzz.go index f819e4f8b..dfac962a4 100644 --- a/test/integration/vendor/github.com/prometheus/common/expfmt/fuzz.go +++ b/test/integration/vendor/github.com/prometheus/common/expfmt/fuzz.go @@ -21,8 +21,8 @@ import "bytes" // Fuzz text metric parser with with github.com/dvyukov/go-fuzz: // -// go-fuzz-build github.com/prometheus/common/expfmt -// go-fuzz -bin expfmt-fuzz.zip -workdir fuzz +// go-fuzz-build github.com/prometheus/common/expfmt +// go-fuzz -bin expfmt-fuzz.zip -workdir fuzz // // Further input samples should go in the folder fuzz/corpus. func Fuzz(in []byte) int { diff --git a/test/integration/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go b/test/integration/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go index 9d94ae9ef..21cdddcf0 100644 --- a/test/integration/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go +++ b/test/integration/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go @@ -46,20 +46,20 @@ import ( // missing features and peculiarities to avoid complications when switching from // Prometheus to OpenMetrics or vice versa: // -// - Counters are expected to have the `_total` suffix in their metric name. In -// the output, the suffix will be truncated from the `# TYPE` and `# HELP` -// line. A counter with a missing `_total` suffix is not an error. However, -// its type will be set to `unknown` in that case to avoid invalid OpenMetrics -// output. +// - Counters are expected to have the `_total` suffix in their metric name. In +// the output, the suffix will be truncated from the `# TYPE` and `# HELP` +// line. A counter with a missing `_total` suffix is not an error. However, +// its type will be set to `unknown` in that case to avoid invalid OpenMetrics +// output. // -// - No support for the following (optional) features: `# UNIT` line, `_created` -// line, info type, stateset type, gaugehistogram type. +// - No support for the following (optional) features: `# UNIT` line, `_created` +// line, info type, stateset type, gaugehistogram type. // -// - The size of exemplar labels is not checked (i.e. it's possible to create -// exemplars that are larger than allowed by the OpenMetrics specification). +// - The size of exemplar labels is not checked (i.e. it's possible to create +// exemplars that are larger than allowed by the OpenMetrics specification). // -// - The value of Counters is not checked. (OpenMetrics doesn't allow counters -// with a `NaN` value.) +// - The value of Counters is not checked. (OpenMetrics doesn't allow counters +// with a `NaN` value.) func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily) (written int, err error) { name := in.GetName() if name == "" { diff --git a/test/integration/vendor/github.com/prometheus/common/expfmt/text_create.go b/test/integration/vendor/github.com/prometheus/common/expfmt/text_create.go index 5ba503b06..2946b8f1a 100644 --- a/test/integration/vendor/github.com/prometheus/common/expfmt/text_create.go +++ b/test/integration/vendor/github.com/prometheus/common/expfmt/text_create.go @@ -17,7 +17,6 @@ import ( "bufio" "fmt" "io" - "io/ioutil" "math" "strconv" "strings" @@ -44,7 +43,7 @@ const ( var ( bufPool = sync.Pool{ New: func() interface{} { - return bufio.NewWriter(ioutil.Discard) + return bufio.NewWriter(io.Discard) }, } numBufPool = sync.Pool{ diff --git a/test/integration/vendor/github.com/prometheus/common/expfmt/text_parse.go b/test/integration/vendor/github.com/prometheus/common/expfmt/text_parse.go index 84be0643e..35db1cc9d 100644 --- a/test/integration/vendor/github.com/prometheus/common/expfmt/text_parse.go +++ b/test/integration/vendor/github.com/prometheus/common/expfmt/text_parse.go @@ -24,8 +24,8 @@ import ( dto "github.com/prometheus/client_model/go" - "github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. "github.com/prometheus/common/model" + "google.golang.org/protobuf/proto" ) // A stateFn is a function that represents a state in a state machine. By @@ -142,9 +142,13 @@ func (p *TextParser) reset(in io.Reader) { func (p *TextParser) startOfLine() stateFn { p.lineCount++ if p.skipBlankTab(); p.err != nil { - // End of input reached. This is the only case where - // that is not an error but a signal that we are done. - p.err = nil + // This is the only place that we expect to see io.EOF, + // which is not an error but the signal that we are done. + // Any other error that happens to align with the start of + // a line is still an error. + if p.err == io.EOF { + p.err = nil + } return nil } switch p.currentByte { diff --git a/test/integration/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go b/test/integration/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go index 26e92288c..a21b9d15d 100644 --- a/test/integration/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go +++ b/test/integration/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go @@ -11,18 +11,18 @@ 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 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. + 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 the Open Knowledge Foundation Ltd. nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. + Neither the name of the Open Knowledge Foundation Ltd. 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 @@ -35,8 +35,6 @@ 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 goautoneg diff --git a/test/integration/vendor/github.com/prometheus/common/model/time.go b/test/integration/vendor/github.com/prometheus/common/model/time.go index c909b8aa8..5727452c1 100644 --- a/test/integration/vendor/github.com/prometheus/common/model/time.go +++ b/test/integration/vendor/github.com/prometheus/common/model/time.go @@ -18,7 +18,6 @@ import ( "errors" "fmt" "math" - "regexp" "strconv" "strings" "time" @@ -183,54 +182,78 @@ func (d *Duration) Type() string { return "duration" } -var durationRE = regexp.MustCompile("^(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?$") +func isdigit(c byte) bool { return c >= '0' && c <= '9' } + +// Units are required to go in order from biggest to smallest. +// This guards against confusion from "1m1d" being 1 minute + 1 day, not 1 month + 1 day. +var unitMap = map[string]struct { + pos int + mult uint64 +}{ + "ms": {7, uint64(time.Millisecond)}, + "s": {6, uint64(time.Second)}, + "m": {5, uint64(time.Minute)}, + "h": {4, uint64(time.Hour)}, + "d": {3, uint64(24 * time.Hour)}, + "w": {2, uint64(7 * 24 * time.Hour)}, + "y": {1, uint64(365 * 24 * time.Hour)}, +} // ParseDuration parses a string into a time.Duration, assuming that a year // always has 365d, a week always has 7d, and a day always has 24h. -func ParseDuration(durationStr string) (Duration, error) { - switch durationStr { +func ParseDuration(s string) (Duration, error) { + switch s { case "0": // Allow 0 without a unit. return 0, nil case "": return 0, errors.New("empty duration string") } - matches := durationRE.FindStringSubmatch(durationStr) - if matches == nil { - return 0, fmt.Errorf("not a valid duration string: %q", durationStr) - } - var dur time.Duration - // Parse the match at pos `pos` in the regex and use `mult` to turn that - // into ms, then add that value to the total parsed duration. - var overflowErr error - m := func(pos int, mult time.Duration) { - if matches[pos] == "" { - return + orig := s + var dur uint64 + lastUnitPos := 0 + + for s != "" { + if !isdigit(s[0]) { + return 0, fmt.Errorf("not a valid duration string: %q", orig) + } + // Consume [0-9]* + i := 0 + for ; i < len(s) && isdigit(s[i]); i++ { + } + v, err := strconv.ParseUint(s[:i], 10, 0) + if err != nil { + return 0, fmt.Errorf("not a valid duration string: %q", orig) } - n, _ := strconv.Atoi(matches[pos]) + s = s[i:] + // Consume unit. + for i = 0; i < len(s) && !isdigit(s[i]); i++ { + } + if i == 0 { + return 0, fmt.Errorf("not a valid duration string: %q", orig) + } + u := s[:i] + s = s[i:] + unit, ok := unitMap[u] + if !ok { + return 0, fmt.Errorf("unknown unit %q in duration %q", u, orig) + } + if unit.pos <= lastUnitPos { // Units must go in order from biggest to smallest. + return 0, fmt.Errorf("not a valid duration string: %q", orig) + } + lastUnitPos = unit.pos // Check if the provided duration overflows time.Duration (> ~ 290years). - if n > int((1<<63-1)/mult/time.Millisecond) { - overflowErr = errors.New("duration out of range") + if v > 1<<63/unit.mult { + return 0, errors.New("duration out of range") } - d := time.Duration(n) * time.Millisecond - dur += d * mult - - if dur < 0 { - overflowErr = errors.New("duration out of range") + dur += v * unit.mult + if dur > 1<<63-1 { + return 0, errors.New("duration out of range") } } - - m(2, 1000*60*60*24*365) // y - m(4, 1000*60*60*24*7) // w - m(6, 1000*60*60*24) // d - m(8, 1000*60*60) // h - m(10, 1000*60) // m - m(12, 1000) // s - m(14, 1) // ms - - return Duration(dur), overflowErr + return Duration(dur), nil } func (d Duration) String() string { diff --git a/test/integration/vendor/github.com/prometheus/common/model/value.go b/test/integration/vendor/github.com/prometheus/common/model/value.go index c9d8fb1a2..9eb440413 100644 --- a/test/integration/vendor/github.com/prometheus/common/model/value.go +++ b/test/integration/vendor/github.com/prometheus/common/model/value.go @@ -16,20 +16,12 @@ package model import ( "encoding/json" "fmt" - "math" "sort" "strconv" "strings" ) var ( - // ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a - // non-existing sample pair. It is a SamplePair with timestamp Earliest and - // value 0.0. Note that the natural zero value of SamplePair has a timestamp - // of 0, which is possible to appear in a real SamplePair and thus not - // suitable to signal a non-existing SamplePair. - ZeroSamplePair = SamplePair{Timestamp: Earliest} - // ZeroSample is the pseudo zero-value of Sample used to signal a // non-existing sample. It is a Sample with timestamp Earliest, value 0.0, // and metric nil. Note that the natural zero value of Sample has a timestamp @@ -38,82 +30,14 @@ var ( ZeroSample = Sample{Timestamp: Earliest} ) -// A SampleValue is a representation of a value for a given sample at a given -// time. -type SampleValue float64 - -// MarshalJSON implements json.Marshaler. -func (v SampleValue) MarshalJSON() ([]byte, error) { - return json.Marshal(v.String()) -} - -// UnmarshalJSON implements json.Unmarshaler. -func (v *SampleValue) UnmarshalJSON(b []byte) error { - if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { - return fmt.Errorf("sample value must be a quoted string") - } - f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) - if err != nil { - return err - } - *v = SampleValue(f) - return nil -} - -// Equal returns true if the value of v and o is equal or if both are NaN. Note -// that v==o is false if both are NaN. If you want the conventional float -// behavior, use == to compare two SampleValues. -func (v SampleValue) Equal(o SampleValue) bool { - if v == o { - return true - } - return math.IsNaN(float64(v)) && math.IsNaN(float64(o)) -} - -func (v SampleValue) String() string { - return strconv.FormatFloat(float64(v), 'f', -1, 64) -} - -// SamplePair pairs a SampleValue with a Timestamp. -type SamplePair struct { - Timestamp Time - Value SampleValue -} - -// MarshalJSON implements json.Marshaler. -func (s SamplePair) MarshalJSON() ([]byte, error) { - t, err := json.Marshal(s.Timestamp) - if err != nil { - return nil, err - } - v, err := json.Marshal(s.Value) - if err != nil { - return nil, err - } - return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (s *SamplePair) UnmarshalJSON(b []byte) error { - v := [...]json.Unmarshaler{&s.Timestamp, &s.Value} - return json.Unmarshal(b, &v) -} - -// Equal returns true if this SamplePair and o have equal Values and equal -// Timestamps. The semantics of Value equality is defined by SampleValue.Equal. -func (s *SamplePair) Equal(o *SamplePair) bool { - return s == o || (s.Value.Equal(o.Value) && s.Timestamp.Equal(o.Timestamp)) -} - -func (s SamplePair) String() string { - return fmt.Sprintf("%s @[%s]", s.Value, s.Timestamp) -} - -// Sample is a sample pair associated with a metric. +// Sample is a sample pair associated with a metric. A single sample must either +// define Value or Histogram but not both. Histogram == nil implies the Value +// field is used, otherwise it should be ignored. type Sample struct { - Metric Metric `json:"metric"` - Value SampleValue `json:"value"` - Timestamp Time `json:"timestamp"` + Metric Metric `json:"metric"` + Value SampleValue `json:"value"` + Timestamp Time `json:"timestamp"` + Histogram *SampleHistogram `json:"histogram"` } // Equal compares first the metrics, then the timestamp, then the value. The @@ -129,11 +53,19 @@ func (s *Sample) Equal(o *Sample) bool { if !s.Timestamp.Equal(o.Timestamp) { return false } - + if s.Histogram != nil { + return s.Histogram.Equal(o.Histogram) + } return s.Value.Equal(o.Value) } func (s Sample) String() string { + if s.Histogram != nil { + return fmt.Sprintf("%s => %s", s.Metric, SampleHistogramPair{ + Timestamp: s.Timestamp, + Histogram: s.Histogram, + }) + } return fmt.Sprintf("%s => %s", s.Metric, SamplePair{ Timestamp: s.Timestamp, Value: s.Value, @@ -142,6 +74,19 @@ func (s Sample) String() string { // MarshalJSON implements json.Marshaler. func (s Sample) MarshalJSON() ([]byte, error) { + if s.Histogram != nil { + v := struct { + Metric Metric `json:"metric"` + Histogram SampleHistogramPair `json:"histogram"` + }{ + Metric: s.Metric, + Histogram: SampleHistogramPair{ + Timestamp: s.Timestamp, + Histogram: s.Histogram, + }, + } + return json.Marshal(&v) + } v := struct { Metric Metric `json:"metric"` Value SamplePair `json:"value"` @@ -152,21 +97,25 @@ func (s Sample) MarshalJSON() ([]byte, error) { Value: s.Value, }, } - return json.Marshal(&v) } // UnmarshalJSON implements json.Unmarshaler. func (s *Sample) UnmarshalJSON(b []byte) error { v := struct { - Metric Metric `json:"metric"` - Value SamplePair `json:"value"` + Metric Metric `json:"metric"` + Value SamplePair `json:"value"` + Histogram SampleHistogramPair `json:"histogram"` }{ Metric: s.Metric, Value: SamplePair{ Timestamp: s.Timestamp, Value: s.Value, }, + Histogram: SampleHistogramPair{ + Timestamp: s.Timestamp, + Histogram: s.Histogram, + }, } if err := json.Unmarshal(b, &v); err != nil { @@ -174,8 +123,13 @@ func (s *Sample) UnmarshalJSON(b []byte) error { } s.Metric = v.Metric - s.Timestamp = v.Value.Timestamp - s.Value = v.Value.Value + if v.Histogram.Histogram != nil { + s.Timestamp = v.Histogram.Timestamp + s.Histogram = v.Histogram.Histogram + } else { + s.Timestamp = v.Value.Timestamp + s.Value = v.Value.Value + } return nil } @@ -221,80 +175,76 @@ func (s Samples) Equal(o Samples) bool { // SampleStream is a stream of Values belonging to an attached COWMetric. type SampleStream struct { - Metric Metric `json:"metric"` - Values []SamplePair `json:"values"` + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + Histograms []SampleHistogramPair `json:"histograms"` } func (ss SampleStream) String() string { - vals := make([]string, len(ss.Values)) + valuesLength := len(ss.Values) + vals := make([]string, valuesLength+len(ss.Histograms)) for i, v := range ss.Values { vals[i] = v.String() } + for i, v := range ss.Histograms { + vals[i+valuesLength] = v.String() + } return fmt.Sprintf("%s =>\n%s", ss.Metric, strings.Join(vals, "\n")) } -// Value is a generic interface for values resulting from a query evaluation. -type Value interface { - Type() ValueType - String() string +func (ss SampleStream) MarshalJSON() ([]byte, error) { + if len(ss.Histograms) > 0 && len(ss.Values) > 0 { + v := struct { + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + Histograms []SampleHistogramPair `json:"histograms"` + }{ + Metric: ss.Metric, + Values: ss.Values, + Histograms: ss.Histograms, + } + return json.Marshal(&v) + } else if len(ss.Histograms) > 0 { + v := struct { + Metric Metric `json:"metric"` + Histograms []SampleHistogramPair `json:"histograms"` + }{ + Metric: ss.Metric, + Histograms: ss.Histograms, + } + return json.Marshal(&v) + } else { + v := struct { + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + }{ + Metric: ss.Metric, + Values: ss.Values, + } + return json.Marshal(&v) + } } -func (Matrix) Type() ValueType { return ValMatrix } -func (Vector) Type() ValueType { return ValVector } -func (*Scalar) Type() ValueType { return ValScalar } -func (*String) Type() ValueType { return ValString } - -type ValueType int - -const ( - ValNone ValueType = iota - ValScalar - ValVector - ValMatrix - ValString -) - -// MarshalJSON implements json.Marshaler. -func (et ValueType) MarshalJSON() ([]byte, error) { - return json.Marshal(et.String()) -} +func (ss *SampleStream) UnmarshalJSON(b []byte) error { + v := struct { + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + Histograms []SampleHistogramPair `json:"histograms"` + }{ + Metric: ss.Metric, + Values: ss.Values, + Histograms: ss.Histograms, + } -func (et *ValueType) UnmarshalJSON(b []byte) error { - var s string - if err := json.Unmarshal(b, &s); err != nil { + if err := json.Unmarshal(b, &v); err != nil { return err } - switch s { - case "": - *et = ValNone - case "scalar": - *et = ValScalar - case "vector": - *et = ValVector - case "matrix": - *et = ValMatrix - case "string": - *et = ValString - default: - return fmt.Errorf("unknown value type %q", s) - } - return nil -} -func (e ValueType) String() string { - switch e { - case ValNone: - return "" - case ValScalar: - return "scalar" - case ValVector: - return "vector" - case ValMatrix: - return "matrix" - case ValString: - return "string" - } - panic("ValueType.String: unhandled value type") + ss.Metric = v.Metric + ss.Values = v.Values + ss.Histograms = v.Histograms + + return nil } // Scalar is a scalar value evaluated at the set timestamp. diff --git a/test/integration/vendor/github.com/prometheus/common/model/value_float.go b/test/integration/vendor/github.com/prometheus/common/model/value_float.go new file mode 100644 index 000000000..0f615a705 --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/common/model/value_float.go @@ -0,0 +1,100 @@ +// Copyright 2013 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package model + +import ( + "encoding/json" + "fmt" + "math" + "strconv" +) + +var ( + // ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a + // non-existing sample pair. It is a SamplePair with timestamp Earliest and + // value 0.0. Note that the natural zero value of SamplePair has a timestamp + // of 0, which is possible to appear in a real SamplePair and thus not + // suitable to signal a non-existing SamplePair. + ZeroSamplePair = SamplePair{Timestamp: Earliest} +) + +// A SampleValue is a representation of a value for a given sample at a given +// time. +type SampleValue float64 + +// MarshalJSON implements json.Marshaler. +func (v SampleValue) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +// UnmarshalJSON implements json.Unmarshaler. +func (v *SampleValue) UnmarshalJSON(b []byte) error { + if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { + return fmt.Errorf("sample value must be a quoted string") + } + f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) + if err != nil { + return err + } + *v = SampleValue(f) + return nil +} + +// Equal returns true if the value of v and o is equal or if both are NaN. Note +// that v==o is false if both are NaN. If you want the conventional float +// behavior, use == to compare two SampleValues. +func (v SampleValue) Equal(o SampleValue) bool { + if v == o { + return true + } + return math.IsNaN(float64(v)) && math.IsNaN(float64(o)) +} + +func (v SampleValue) String() string { + return strconv.FormatFloat(float64(v), 'f', -1, 64) +} + +// SamplePair pairs a SampleValue with a Timestamp. +type SamplePair struct { + Timestamp Time + Value SampleValue +} + +func (s SamplePair) MarshalJSON() ([]byte, error) { + t, err := json.Marshal(s.Timestamp) + if err != nil { + return nil, err + } + v, err := json.Marshal(s.Value) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (s *SamplePair) UnmarshalJSON(b []byte) error { + v := [...]json.Unmarshaler{&s.Timestamp, &s.Value} + return json.Unmarshal(b, &v) +} + +// Equal returns true if this SamplePair and o have equal Values and equal +// Timestamps. The semantics of Value equality is defined by SampleValue.Equal. +func (s *SamplePair) Equal(o *SamplePair) bool { + return s == o || (s.Value.Equal(o.Value) && s.Timestamp.Equal(o.Timestamp)) +} + +func (s SamplePair) String() string { + return fmt.Sprintf("%s @[%s]", s.Value, s.Timestamp) +} diff --git a/test/integration/vendor/github.com/prometheus/common/model/value_histogram.go b/test/integration/vendor/github.com/prometheus/common/model/value_histogram.go new file mode 100644 index 000000000..54bb038cf --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/common/model/value_histogram.go @@ -0,0 +1,178 @@ +// Copyright 2013 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package model + +import ( + "encoding/json" + "fmt" + "strconv" + "strings" +) + +type FloatString float64 + +func (v FloatString) String() string { + return strconv.FormatFloat(float64(v), 'f', -1, 64) +} + +func (v FloatString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +func (v *FloatString) UnmarshalJSON(b []byte) error { + if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { + return fmt.Errorf("float value must be a quoted string") + } + f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) + if err != nil { + return err + } + *v = FloatString(f) + return nil +} + +type HistogramBucket struct { + Boundaries int32 + Lower FloatString + Upper FloatString + Count FloatString +} + +func (s HistogramBucket) MarshalJSON() ([]byte, error) { + b, err := json.Marshal(s.Boundaries) + if err != nil { + return nil, err + } + l, err := json.Marshal(s.Lower) + if err != nil { + return nil, err + } + u, err := json.Marshal(s.Upper) + if err != nil { + return nil, err + } + c, err := json.Marshal(s.Count) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf("[%s,%s,%s,%s]", b, l, u, c)), nil +} + +func (s *HistogramBucket) UnmarshalJSON(buf []byte) error { + tmp := []interface{}{&s.Boundaries, &s.Lower, &s.Upper, &s.Count} + wantLen := len(tmp) + if err := json.Unmarshal(buf, &tmp); err != nil { + return err + } + if gotLen := len(tmp); gotLen != wantLen { + return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen) + } + return nil +} + +func (s *HistogramBucket) Equal(o *HistogramBucket) bool { + return s == o || (s.Boundaries == o.Boundaries && s.Lower == o.Lower && s.Upper == o.Upper && s.Count == o.Count) +} + +func (b HistogramBucket) String() string { + var sb strings.Builder + lowerInclusive := b.Boundaries == 1 || b.Boundaries == 3 + upperInclusive := b.Boundaries == 0 || b.Boundaries == 3 + if lowerInclusive { + sb.WriteRune('[') + } else { + sb.WriteRune('(') + } + fmt.Fprintf(&sb, "%g,%g", b.Lower, b.Upper) + if upperInclusive { + sb.WriteRune(']') + } else { + sb.WriteRune(')') + } + fmt.Fprintf(&sb, ":%v", b.Count) + return sb.String() +} + +type HistogramBuckets []*HistogramBucket + +func (s HistogramBuckets) Equal(o HistogramBuckets) bool { + if len(s) != len(o) { + return false + } + + for i, bucket := range s { + if !bucket.Equal(o[i]) { + return false + } + } + return true +} + +type SampleHistogram struct { + Count FloatString `json:"count"` + Sum FloatString `json:"sum"` + Buckets HistogramBuckets `json:"buckets"` +} + +func (s SampleHistogram) String() string { + return fmt.Sprintf("Count: %f, Sum: %f, Buckets: %v", s.Count, s.Sum, s.Buckets) +} + +func (s *SampleHistogram) Equal(o *SampleHistogram) bool { + return s == o || (s.Count == o.Count && s.Sum == o.Sum && s.Buckets.Equal(o.Buckets)) +} + +type SampleHistogramPair struct { + Timestamp Time + // Histogram should never be nil, it's only stored as pointer for efficiency. + Histogram *SampleHistogram +} + +func (s SampleHistogramPair) MarshalJSON() ([]byte, error) { + if s.Histogram == nil { + return nil, fmt.Errorf("histogram is nil") + } + t, err := json.Marshal(s.Timestamp) + if err != nil { + return nil, err + } + v, err := json.Marshal(s.Histogram) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil +} + +func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error { + tmp := []interface{}{&s.Timestamp, &s.Histogram} + wantLen := len(tmp) + if err := json.Unmarshal(buf, &tmp); err != nil { + return err + } + if gotLen := len(tmp); gotLen != wantLen { + return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen) + } + if s.Histogram == nil { + return fmt.Errorf("histogram is null") + } + return nil +} + +func (s SampleHistogramPair) String() string { + return fmt.Sprintf("%s @[%s]", s.Histogram, s.Timestamp) +} + +func (s *SampleHistogramPair) Equal(o *SampleHistogramPair) bool { + return s == o || (s.Histogram.Equal(o.Histogram) && s.Timestamp.Equal(o.Timestamp)) +} diff --git a/test/integration/vendor/github.com/prometheus/common/model/value_type.go b/test/integration/vendor/github.com/prometheus/common/model/value_type.go new file mode 100644 index 000000000..726c50ee6 --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/common/model/value_type.go @@ -0,0 +1,83 @@ +// Copyright 2013 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package model + +import ( + "encoding/json" + "fmt" +) + +// Value is a generic interface for values resulting from a query evaluation. +type Value interface { + Type() ValueType + String() string +} + +func (Matrix) Type() ValueType { return ValMatrix } +func (Vector) Type() ValueType { return ValVector } +func (*Scalar) Type() ValueType { return ValScalar } +func (*String) Type() ValueType { return ValString } + +type ValueType int + +const ( + ValNone ValueType = iota + ValScalar + ValVector + ValMatrix + ValString +) + +// MarshalJSON implements json.Marshaler. +func (et ValueType) MarshalJSON() ([]byte, error) { + return json.Marshal(et.String()) +} + +func (et *ValueType) UnmarshalJSON(b []byte) error { + var s string + if err := json.Unmarshal(b, &s); err != nil { + return err + } + switch s { + case "": + *et = ValNone + case "scalar": + *et = ValScalar + case "vector": + *et = ValVector + case "matrix": + *et = ValMatrix + case "string": + *et = ValString + default: + return fmt.Errorf("unknown value type %q", s) + } + return nil +} + +func (e ValueType) String() string { + switch e { + case ValNone: + return "" + case ValScalar: + return "scalar" + case ValVector: + return "vector" + case ValMatrix: + return "matrix" + case ValString: + return "string" + } + panic("ValueType.String: unhandled value type") +} diff --git a/test/integration/vendor/github.com/prometheus/procfs/.golangci.yml b/test/integration/vendor/github.com/prometheus/procfs/.golangci.yml index a197699a1..c24864a92 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/.golangci.yml +++ b/test/integration/vendor/github.com/prometheus/procfs/.golangci.yml @@ -2,6 +2,7 @@ linters: enable: - godot + - misspell - revive linter-settings: @@ -10,3 +11,5 @@ linter-settings: exclude: # Ignore "See: URL" - 'See:' + misspell: + locale: US diff --git a/test/integration/vendor/github.com/prometheus/procfs/Makefile.common b/test/integration/vendor/github.com/prometheus/procfs/Makefile.common index 6c8e3e219..b111d2562 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/Makefile.common +++ b/test/integration/vendor/github.com/prometheus/procfs/Makefile.common @@ -55,19 +55,22 @@ ifneq ($(shell which gotestsum),) endif endif -PROMU_VERSION ?= 0.13.0 +PROMU_VERSION ?= 0.14.0 PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz +SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v1.45.2 +GOLANGCI_LINT_VERSION ?= v1.51.2 # golangci-lint only supports linux, darwin and windows platforms on i386/amd64. # windows isn't included here because of the path separator being different. ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386)) # If we're in CI and there is an Actions file, that means the linter # is being run in Actions, so we don't need to run it here. - ifeq (,$(CIRCLE_JOB)) + ifneq (,$(SKIP_GOLANGCI_LINT)) + GOLANGCI_LINT := + else ifeq (,$(CIRCLE_JOB)) GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint else ifeq (,$(wildcard .github/workflows/golangci-lint.yml)) GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint @@ -88,6 +91,8 @@ BUILD_DOCKER_ARCHS = $(addprefix common-docker-,$(DOCKER_ARCHS)) PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS)) TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS)) +SANITIZED_DOCKER_IMAGE_TAG := $(subst +,-,$(DOCKER_IMAGE_TAG)) + ifeq ($(GOHOSTARCH),amd64) ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin windows)) # Only supported on amd64 @@ -202,7 +207,7 @@ common-tarball: promu .PHONY: common-docker $(BUILD_DOCKER_ARCHS) common-docker: $(BUILD_DOCKER_ARCHS) $(BUILD_DOCKER_ARCHS): common-docker-%: - docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" \ + docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" \ -f $(DOCKERFILE_PATH) \ --build-arg ARCH="$*" \ --build-arg OS="linux" \ @@ -211,19 +216,19 @@ $(BUILD_DOCKER_ARCHS): common-docker-%: .PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS) common-docker-publish: $(PUBLISH_DOCKER_ARCHS) $(PUBLISH_DOCKER_ARCHS): common-docker-publish-%: - docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" + docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" DOCKER_MAJOR_VERSION_TAG = $(firstword $(subst ., ,$(shell cat VERSION))) .PHONY: common-docker-tag-latest $(TAG_DOCKER_ARCHS) common-docker-tag-latest: $(TAG_DOCKER_ARCHS) $(TAG_DOCKER_ARCHS): common-docker-tag-latest-%: - docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest" - docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)" + docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest" + docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)" .PHONY: common-docker-manifest common-docker-manifest: - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(DOCKER_IMAGE_TAG)) - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" + DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(SANITIZED_DOCKER_IMAGE_TAG)) + DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)" .PHONY: promu promu: $(PROMU) diff --git a/test/integration/vendor/github.com/prometheus/procfs/README.md b/test/integration/vendor/github.com/prometheus/procfs/README.md index 43c37735a..1224816c2 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/README.md +++ b/test/integration/vendor/github.com/prometheus/procfs/README.md @@ -51,11 +51,11 @@ ensure the `fixtures` directory is up to date by removing the existing directory extracting the ttar file using `make fixtures/.unpacked` or just `make test`. ```bash -rm -rf fixtures +rm -rf testdata/fixtures make test ``` Next, make the required changes to the extracted files in the `fixtures` directory. When the changes are complete, run `make update_fixtures` to create a new `fixtures.ttar` file based on the updated `fixtures` directory. And finally, verify the changes using -`git diff fixtures.ttar`. +`git diff testdata/fixtures.ttar`. diff --git a/test/integration/vendor/github.com/prometheus/procfs/arp.go b/test/integration/vendor/github.com/prometheus/procfs/arp.go index 68f36e888..28783e2dd 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/arp.go +++ b/test/integration/vendor/github.com/prometheus/procfs/arp.go @@ -55,7 +55,7 @@ type ARPEntry struct { func (fs FS) GatherARPEntries() ([]ARPEntry, error) { data, err := os.ReadFile(fs.proc.Path("net/arp")) if err != nil { - return nil, fmt.Errorf("error reading arp %q: %w", fs.proc.Path("net/arp"), err) + return nil, fmt.Errorf("%s: error reading arp %s: %w", ErrFileRead, fs.proc.Path("net/arp"), err) } return parseARPEntries(data) @@ -78,11 +78,11 @@ func parseARPEntries(data []byte) ([]ARPEntry, error) { } else if width == expectedDataWidth { entry, err := parseARPEntry(columns) if err != nil { - return []ARPEntry{}, fmt.Errorf("failed to parse ARP entry: %w", err) + return []ARPEntry{}, fmt.Errorf("%s: Failed to parse ARP entry: %v: %w", ErrFileParse, entry, err) } entries = append(entries, entry) } else { - return []ARPEntry{}, fmt.Errorf("%d columns were detected, but %d were expected", width, expectedDataWidth) + return []ARPEntry{}, fmt.Errorf("%s: %d columns found, but expected %d: %w", ErrFileParse, width, expectedDataWidth, err) } } diff --git a/test/integration/vendor/github.com/prometheus/procfs/buddyinfo.go b/test/integration/vendor/github.com/prometheus/procfs/buddyinfo.go index f5b7939b2..4a173636c 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/buddyinfo.go +++ b/test/integration/vendor/github.com/prometheus/procfs/buddyinfo.go @@ -55,7 +55,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { parts := strings.Fields(line) if len(parts) < 4 { - return nil, fmt.Errorf("invalid number of fields when parsing buddyinfo") + return nil, fmt.Errorf("%w: Invalid number of fields, found: %v", ErrFileParse, parts) } node := strings.TrimRight(parts[1], ",") @@ -66,7 +66,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { bucketCount = arraySize } else { if bucketCount != arraySize { - return nil, fmt.Errorf("mismatch in number of buddyinfo buckets, previous count %d, new count %d", bucketCount, arraySize) + return nil, fmt.Errorf("%w: mismatch in number of buddyinfo buckets, previous count %d, new count %d", ErrFileParse, bucketCount, arraySize) } } @@ -74,7 +74,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { for i := 0; i < arraySize; i++ { sizes[i], err = strconv.ParseFloat(parts[i+4], 64) if err != nil { - return nil, fmt.Errorf("invalid value in buddyinfo: %w", err) + return nil, fmt.Errorf("%s: Invalid valid in buddyinfo: %f: %w", ErrFileParse, sizes[i], err) } } diff --git a/test/integration/vendor/github.com/prometheus/procfs/cpuinfo.go b/test/integration/vendor/github.com/prometheus/procfs/cpuinfo.go index ff6b927da..f4f5501c6 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/cpuinfo.go +++ b/test/integration/vendor/github.com/prometheus/procfs/cpuinfo.go @@ -79,7 +79,7 @@ func parseCPUInfoX86(info []byte) ([]CPUInfo, error) { // find the first "processor" line firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) v, err := strconv.ParseUint(field[1], 0, 32) @@ -192,9 +192,10 @@ func parseCPUInfoARM(info []byte) ([]CPUInfo, error) { scanner := bufio.NewScanner(bytes.NewReader(info)) firstLine := firstNonEmptyLine(scanner) - match, _ := regexp.MatchString("^[Pp]rocessor", firstLine) + match, err := regexp.MatchString("^[Pp]rocessor", firstLine) if !match || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%s: Cannot parse line: %q: %w", ErrFileParse, firstLine, err) + } field := strings.SplitN(firstLine, ": ", 2) cpuinfo := []CPUInfo{} @@ -258,7 +259,7 @@ func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) { firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "vendor_id") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) cpuinfo := []CPUInfo{} @@ -283,7 +284,7 @@ func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) { if strings.HasPrefix(line, "processor") { match := cpuinfoS390XProcessorRegexp.FindStringSubmatch(line) if len(match) < 2 { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } cpu := commonCPUInfo v, err := strconv.ParseUint(match[1], 0, 32) @@ -343,7 +344,7 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) { // find the first "processor" line firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) cpuinfo := []CPUInfo{} @@ -380,12 +381,48 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) { return cpuinfo, nil } +func parseCPUInfoLoong(info []byte) ([]CPUInfo, error) { + scanner := bufio.NewScanner(bytes.NewReader(info)) + // find the first "processor" line + firstLine := firstNonEmptyLine(scanner) + if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") { + return nil, errors.New("invalid cpuinfo file: " + firstLine) + } + field := strings.SplitN(firstLine, ": ", 2) + cpuinfo := []CPUInfo{} + systemType := field[1] + i := 0 + for scanner.Scan() { + line := scanner.Text() + if !strings.Contains(line, ":") { + continue + } + field := strings.SplitN(line, ": ", 2) + switch strings.TrimSpace(field[0]) { + case "processor": + v, err := strconv.ParseUint(field[1], 0, 32) + if err != nil { + return nil, err + } + i = int(v) + cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor + cpuinfo[i].Processor = uint(v) + cpuinfo[i].VendorID = systemType + case "CPU Family": + cpuinfo[i].CPUFamily = field[1] + case "Model Name": + cpuinfo[i].ModelName = field[1] + } + } + return cpuinfo, nil +} + func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) { scanner := bufio.NewScanner(bytes.NewReader(info)) firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) v, err := strconv.ParseUint(field[1], 0, 32) @@ -430,7 +467,7 @@ func parseCPUInfoRISCV(info []byte) ([]CPUInfo, error) { firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) v, err := strconv.ParseUint(field[1], 0, 32) diff --git a/test/integration/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go b/test/integration/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go new file mode 100644 index 000000000..d88442f0e --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go @@ -0,0 +1,19 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build linux +// +build linux + +package procfs + +var parseCPUInfo = parseCPUInfoLoong diff --git a/test/integration/vendor/github.com/prometheus/procfs/cpuinfo_others.go b/test/integration/vendor/github.com/prometheus/procfs/cpuinfo_others.go index ea41bf2ca..a6b2b3127 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/cpuinfo_others.go +++ b/test/integration/vendor/github.com/prometheus/procfs/cpuinfo_others.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build linux && !386 && !amd64 && !arm && !arm64 && !mips && !mips64 && !mips64le && !mipsle && !ppc64 && !ppc64le && !riscv64 && !s390x -// +build linux,!386,!amd64,!arm,!arm64,!mips,!mips64,!mips64le,!mipsle,!ppc64,!ppc64le,!riscv64,!s390x +//go:build linux && !386 && !amd64 && !arm && !arm64 && !loong64 && !mips && !mips64 && !mips64le && !mipsle && !ppc64 && !ppc64le && !riscv64 && !s390x +// +build linux,!386,!amd64,!arm,!arm64,!loong64,!mips,!mips64,!mips64le,!mipsle,!ppc64,!ppc64le,!riscv64,!s390x package procfs diff --git a/test/integration/vendor/github.com/prometheus/procfs/crypto.go b/test/integration/vendor/github.com/prometheus/procfs/crypto.go index 5048ad1f2..9a73e2639 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/crypto.go +++ b/test/integration/vendor/github.com/prometheus/procfs/crypto.go @@ -55,12 +55,13 @@ func (fs FS) Crypto() ([]Crypto, error) { path := fs.proc.Path("crypto") b, err := util.ReadFileNoStat(path) if err != nil { - return nil, fmt.Errorf("error reading crypto %q: %w", path, err) + return nil, fmt.Errorf("%s: Cannot read file %v: %w", ErrFileRead, b, err) + } crypto, err := parseCrypto(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("error parsing crypto %q: %w", path, err) + return nil, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, crypto, err) } return crypto, nil @@ -83,7 +84,7 @@ func parseCrypto(r io.Reader) ([]Crypto, error) { kv := strings.Split(text, ":") if len(kv) != 2 { - return nil, fmt.Errorf("malformed crypto line: %q", text) + return nil, fmt.Errorf("%w: Cannot parae line: %q", ErrFileParse, text) } k := strings.TrimSpace(kv[0]) diff --git a/test/integration/vendor/github.com/prometheus/procfs/doc.go b/test/integration/vendor/github.com/prometheus/procfs/doc.go index d31a82600..f9d961e44 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/doc.go +++ b/test/integration/vendor/github.com/prometheus/procfs/doc.go @@ -16,30 +16,29 @@ // // Example: // -// package main -// -// import ( -// "fmt" -// "log" -// -// "github.com/prometheus/procfs" -// ) -// -// func main() { -// p, err := procfs.Self() -// if err != nil { -// log.Fatalf("could not get process: %s", err) -// } -// -// stat, err := p.Stat() -// if err != nil { -// log.Fatalf("could not get process stat: %s", err) -// } -// -// fmt.Printf("command: %s\n", stat.Comm) -// fmt.Printf("cpu time: %fs\n", stat.CPUTime()) -// fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) -// fmt.Printf("rss: %dB\n", stat.ResidentMemory()) -// } -// +// package main +// +// import ( +// "fmt" +// "log" +// +// "github.com/prometheus/procfs" +// ) +// +// func main() { +// p, err := procfs.Self() +// if err != nil { +// log.Fatalf("could not get process: %s", err) +// } +// +// stat, err := p.Stat() +// if err != nil { +// log.Fatalf("could not get process stat: %s", err) +// } +// +// fmt.Printf("command: %s\n", stat.Comm) +// fmt.Printf("cpu time: %fs\n", stat.CPUTime()) +// fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) +// fmt.Printf("rss: %dB\n", stat.ResidentMemory()) +// } package procfs diff --git a/test/integration/vendor/github.com/prometheus/procfs/fs.go b/test/integration/vendor/github.com/prometheus/procfs/fs.go index 0102ab0fd..60c551e02 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/fs.go +++ b/test/integration/vendor/github.com/prometheus/procfs/fs.go @@ -21,6 +21,7 @@ import ( // kernel data structures. type FS struct { proc fs.FS + real bool } // DefaultMountPoint is the common mount point of the proc filesystem. @@ -39,5 +40,11 @@ func NewFS(mountPoint string) (FS, error) { if err != nil { return FS{}, err } - return FS{fs}, nil + + real, err := isRealProc(mountPoint) + if err != nil { + return FS{}, err + } + + return FS{fs, real}, nil } diff --git a/vendor/github.com/bufbuild/buf/private/pkg/filelock/nop_unlocker.go b/test/integration/vendor/github.com/prometheus/procfs/fs_statfs_notype.go similarity index 58% rename from vendor/github.com/bufbuild/buf/private/pkg/filelock/nop_unlocker.go rename to test/integration/vendor/github.com/prometheus/procfs/fs_statfs_notype.go index bfff51ea3..800576968 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/filelock/nop_unlocker.go +++ b/test/integration/vendor/github.com/prometheus/procfs/fs_statfs_notype.go @@ -1,10 +1,9 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// +// Copyright 2018 The Prometheus Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// 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, @@ -12,14 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -package filelock - -type nopUnlocker struct{} +//go:build netbsd || openbsd || solaris || windows +// +build netbsd openbsd solaris windows -func newNopUnlocker() *nopUnlocker { - return &nopUnlocker{} -} +package procfs -func (l *nopUnlocker) Unlock() error { - return nil +// isRealProc returns true on architectures that don't have a Type argument +// in their Statfs_t struct +func isRealProc(mountPoint string) (bool, error) { + return true, nil } diff --git a/test/integration/vendor/github.com/prometheus/procfs/fs_statfs_type.go b/test/integration/vendor/github.com/prometheus/procfs/fs_statfs_type.go new file mode 100644 index 000000000..6233217ad --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/procfs/fs_statfs_type.go @@ -0,0 +1,33 @@ +// Copyright 2018 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !netbsd && !openbsd && !solaris && !windows +// +build !netbsd,!openbsd,!solaris,!windows + +package procfs + +import ( + "syscall" +) + +// isRealProc determines whether supplied mountpoint is really a proc filesystem. +func isRealProc(mountPoint string) (bool, error) { + stat := syscall.Statfs_t{} + err := syscall.Statfs(mountPoint, &stat) + if err != nil { + return false, err + } + + // 0x9fa0 is PROC_SUPER_MAGIC: https://elixir.bootlin.com/linux/v6.1/source/include/uapi/linux/magic.h#L87 + return stat.Type == 0x9fa0, nil +} diff --git a/test/integration/vendor/github.com/prometheus/procfs/fscache.go b/test/integration/vendor/github.com/prometheus/procfs/fscache.go index f8070e6e2..f560a8db3 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/fscache.go +++ b/test/integration/vendor/github.com/prometheus/procfs/fscache.go @@ -236,7 +236,7 @@ func (fs FS) Fscacheinfo() (Fscacheinfo, error) { m, err := parseFscacheinfo(bytes.NewReader(b)) if err != nil { - return Fscacheinfo{}, fmt.Errorf("failed to parse Fscacheinfo: %w", err) + return Fscacheinfo{}, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, m, err) } return *m, nil @@ -245,7 +245,7 @@ func (fs FS) Fscacheinfo() (Fscacheinfo, error) { func setFSCacheFields(fields []string, setFields ...*uint64) error { var err error if len(fields) < len(setFields) { - return fmt.Errorf("Insufficient number of fields, expected %v, got %v", len(setFields), len(fields)) + return fmt.Errorf("%s: Expected %d, but got %d: %w", ErrFileParse, len(setFields), len(fields), err) } for i := range setFields { @@ -263,7 +263,7 @@ func parseFscacheinfo(r io.Reader) (*Fscacheinfo, error) { for s.Scan() { fields := strings.Fields(s.Text()) if len(fields) < 2 { - return nil, fmt.Errorf("malformed Fscacheinfo line: %q", s.Text()) + return nil, fmt.Errorf("%w: malformed Fscacheinfo line: %q", ErrFileParse, s.Text()) } switch fields[0] { diff --git a/test/integration/vendor/github.com/prometheus/procfs/internal/util/parse.go b/test/integration/vendor/github.com/prometheus/procfs/internal/util/parse.go index b030951fa..14272dc78 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/internal/util/parse.go +++ b/test/integration/vendor/github.com/prometheus/procfs/internal/util/parse.go @@ -64,6 +64,21 @@ func ParsePInt64s(ss []string) ([]*int64, error) { return us, nil } +// Parses a uint64 from given hex in string. +func ParseHexUint64s(ss []string) ([]*uint64, error) { + us := make([]*uint64, 0, len(ss)) + for _, s := range ss { + u, err := strconv.ParseUint(s, 16, 64) + if err != nil { + return nil, err + } + + us = append(us, &u) + } + + return us, nil +} + // ReadUintFromFile reads a file and attempts to parse a uint64 from it. func ReadUintFromFile(path string) (uint64, error) { data, err := os.ReadFile(path) diff --git a/test/integration/vendor/github.com/prometheus/procfs/ipvs.go b/test/integration/vendor/github.com/prometheus/procfs/ipvs.go index 391c07957..5a145bbfe 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/ipvs.go +++ b/test/integration/vendor/github.com/prometheus/procfs/ipvs.go @@ -221,15 +221,16 @@ func parseIPPort(s string) (net.IP, uint16, error) { case 46: ip = net.ParseIP(s[1:40]) if ip == nil { - return nil, 0, fmt.Errorf("invalid IPv6 address: %s", s[1:40]) + return nil, 0, fmt.Errorf("%s: Invalid IPv6 addr %s: %w", ErrFileParse, s[1:40], err) } default: - return nil, 0, fmt.Errorf("unexpected IP:Port: %s", s) + return nil, 0, fmt.Errorf("%s: Unexpected IP:Port %s: %w", ErrFileParse, s, err) } portString := s[len(s)-4:] if len(portString) != 4 { - return nil, 0, fmt.Errorf("unexpected port string format: %s", portString) + return nil, 0, + fmt.Errorf("%s: Unexpected port string format %s: %w", ErrFileParse, portString, err) } port, err := strconv.ParseUint(portString, 16, 16) if err != nil { diff --git a/test/integration/vendor/github.com/prometheus/procfs/loadavg.go b/test/integration/vendor/github.com/prometheus/procfs/loadavg.go index 0096cafbd..59465c5bb 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/loadavg.go +++ b/test/integration/vendor/github.com/prometheus/procfs/loadavg.go @@ -44,14 +44,14 @@ func parseLoad(loadavgBytes []byte) (*LoadAvg, error) { loads := make([]float64, 3) parts := strings.Fields(string(loadavgBytes)) if len(parts) < 3 { - return nil, fmt.Errorf("malformed loadavg line: too few fields in loadavg string: %q", string(loadavgBytes)) + return nil, fmt.Errorf("%w: Malformed line %q", ErrFileParse, string(loadavgBytes)) } var err error for i, load := range parts[0:3] { loads[i], err = strconv.ParseFloat(load, 64) if err != nil { - return nil, fmt.Errorf("could not parse load %q: %w", load, err) + return nil, fmt.Errorf("%s: Cannot parse load: %f: %w", ErrFileParse, loads[i], err) } } return &LoadAvg{ diff --git a/test/integration/vendor/github.com/prometheus/procfs/mdstat.go b/test/integration/vendor/github.com/prometheus/procfs/mdstat.go index a95c889cb..fdd4b9544 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/mdstat.go +++ b/test/integration/vendor/github.com/prometheus/procfs/mdstat.go @@ -70,7 +70,7 @@ func (fs FS) MDStat() ([]MDStat, error) { } mdstat, err := parseMDStat(data) if err != nil { - return nil, fmt.Errorf("error parsing mdstat %q: %w", fs.proc.Path("mdstat"), err) + return nil, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, fs.proc.Path("mdstat"), err) } return mdstat, nil } @@ -90,13 +90,13 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { deviceFields := strings.Fields(line) if len(deviceFields) < 3 { - return nil, fmt.Errorf("not enough fields in mdline (expected at least 3): %s", line) + return nil, fmt.Errorf("%s: Expected 3+ lines, got %q", ErrFileParse, line) } mdName := deviceFields[0] // mdx state := deviceFields[2] // active or inactive if len(lines) <= i+3 { - return nil, fmt.Errorf("error parsing %q: too few lines for md device", mdName) + return nil, fmt.Errorf("%w: Too few lines for md device: %q", ErrFileParse, mdName) } // Failed disks have the suffix (F) & Spare disks have the suffix (S). @@ -105,7 +105,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { active, total, down, size, err := evalStatusLine(lines[i], lines[i+1]) if err != nil { - return nil, fmt.Errorf("error parsing md device lines: %w", err) + return nil, fmt.Errorf("%s: Cannot parse md device lines: %v: %w", ErrFileParse, active, err) } syncLineIdx := i + 2 @@ -140,7 +140,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { } else { syncedBlocks, pct, finish, speed, err = evalRecoveryLine(lines[syncLineIdx]) if err != nil { - return nil, fmt.Errorf("error parsing sync line in md device %q: %w", mdName, err) + return nil, fmt.Errorf("%s: Cannot parse sync line in md device: %q: %w", ErrFileParse, mdName, err) } } } @@ -168,13 +168,13 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { func evalStatusLine(deviceLine, statusLine string) (active, total, down, size int64, err error) { statusFields := strings.Fields(statusLine) if len(statusFields) < 1 { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q", statusLine) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err) } sizeStr := statusFields[0] size, err = strconv.ParseInt(sizeStr, 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err) } if strings.Contains(deviceLine, "raid0") || strings.Contains(deviceLine, "linear") { @@ -189,17 +189,17 @@ func evalStatusLine(deviceLine, statusLine string) (active, total, down, size in matches := statusLineRE.FindStringSubmatch(statusLine) if len(matches) != 5 { - return 0, 0, 0, 0, fmt.Errorf("couldn't find all the substring matches: %s", statusLine) + return 0, 0, 0, 0, fmt.Errorf("%s: Could not fild all substring matches %s: %w", ErrFileParse, statusLine, err) } total, err = strconv.ParseInt(matches[2], 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err) } active, err = strconv.ParseInt(matches[3], 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected active %d: %w", ErrFileParse, active, err) } down = int64(strings.Count(matches[4], "_")) @@ -209,42 +209,42 @@ func evalStatusLine(deviceLine, statusLine string) (active, total, down, size in func evalRecoveryLine(recoveryLine string) (syncedBlocks int64, pct float64, finish float64, speed float64, err error) { matches := recoveryLineBlocksRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return 0, 0, 0, 0, fmt.Errorf("unexpected recoveryLine: %s", recoveryLine) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected recoveryLine %s: %w", ErrFileParse, recoveryLine, err) } syncedBlocks, err = strconv.ParseInt(matches[1], 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("error parsing int from recoveryLine %q: %w", recoveryLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected parsing of recoveryLine %q: %w", ErrFileParse, recoveryLine, err) } // Get percentage complete matches = recoveryLinePctRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return syncedBlocks, 0, 0, 0, fmt.Errorf("unexpected recoveryLine matching percentage: %s", recoveryLine) + return syncedBlocks, 0, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching percentage %s", ErrFileParse, recoveryLine) } pct, err = strconv.ParseFloat(strings.TrimSpace(matches[1]), 64) if err != nil { - return syncedBlocks, 0, 0, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err) + return syncedBlocks, 0, 0, 0, fmt.Errorf("%w: Error parsing float from recoveryLine %q", ErrFileParse, recoveryLine) } // Get time expected left to complete matches = recoveryLineFinishRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return syncedBlocks, pct, 0, 0, fmt.Errorf("unexpected recoveryLine matching est. finish time: %s", recoveryLine) + return syncedBlocks, pct, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching est. finish time: %s", ErrFileParse, recoveryLine) } finish, err = strconv.ParseFloat(matches[1], 64) if err != nil { - return syncedBlocks, pct, 0, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err) + return syncedBlocks, pct, 0, 0, fmt.Errorf("%w: Unable to parse float from recoveryLine: %q", ErrFileParse, recoveryLine) } // Get recovery speed matches = recoveryLineSpeedRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return syncedBlocks, pct, finish, 0, fmt.Errorf("unexpected recoveryLine matching speed: %s", recoveryLine) + return syncedBlocks, pct, finish, 0, fmt.Errorf("%w: Unexpected recoveryLine value: %s", ErrFileParse, recoveryLine) } speed, err = strconv.ParseFloat(matches[1], 64) if err != nil { - return syncedBlocks, pct, finish, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err) + return syncedBlocks, pct, finish, 0, fmt.Errorf("%s: Error parsing float from recoveryLine: %q: %w", ErrFileParse, recoveryLine, err) } return syncedBlocks, pct, finish, speed, nil diff --git a/test/integration/vendor/github.com/prometheus/procfs/meminfo.go b/test/integration/vendor/github.com/prometheus/procfs/meminfo.go index f65e174e5..eaf00e224 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/meminfo.go +++ b/test/integration/vendor/github.com/prometheus/procfs/meminfo.go @@ -152,7 +152,7 @@ func (fs FS) Meminfo() (Meminfo, error) { m, err := parseMemInfo(bytes.NewReader(b)) if err != nil { - return Meminfo{}, fmt.Errorf("failed to parse meminfo: %w", err) + return Meminfo{}, fmt.Errorf("%s: %w", ErrFileParse, err) } return *m, nil @@ -165,7 +165,7 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) { // Each line has at least a name and value; we ignore the unit. fields := strings.Fields(s.Text()) if len(fields) < 2 { - return nil, fmt.Errorf("malformed meminfo line: %q", s.Text()) + return nil, fmt.Errorf("%w: Malformed line %q", ErrFileParse, s.Text()) } v, err := strconv.ParseUint(fields[1], 0, 64) diff --git a/test/integration/vendor/github.com/prometheus/procfs/mountinfo.go b/test/integration/vendor/github.com/prometheus/procfs/mountinfo.go index 59f4d5055..388ebf396 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/mountinfo.go +++ b/test/integration/vendor/github.com/prometheus/procfs/mountinfo.go @@ -78,11 +78,11 @@ func parseMountInfoString(mountString string) (*MountInfo, error) { mountInfo := strings.Split(mountString, " ") mountInfoLength := len(mountInfo) if mountInfoLength < 10 { - return nil, fmt.Errorf("couldn't find enough fields in mount string: %s", mountString) + return nil, fmt.Errorf("%w: Too few fields in mount string: %s", ErrFileParse, mountString) } if mountInfo[mountInfoLength-4] != "-" { - return nil, fmt.Errorf("couldn't find separator in expected field: %s", mountInfo[mountInfoLength-4]) + return nil, fmt.Errorf("%w: couldn't find separator in expected field: %s", ErrFileParse, mountInfo[mountInfoLength-4]) } mount := &MountInfo{ @@ -98,18 +98,18 @@ func parseMountInfoString(mountString string) (*MountInfo, error) { mount.MountID, err = strconv.Atoi(mountInfo[0]) if err != nil { - return nil, fmt.Errorf("failed to parse mount ID") + return nil, fmt.Errorf("%w: mount ID: %q", ErrFileParse, mount.MountID) } mount.ParentID, err = strconv.Atoi(mountInfo[1]) if err != nil { - return nil, fmt.Errorf("failed to parse parent ID") + return nil, fmt.Errorf("%w: parent ID: %q", ErrFileParse, mount.ParentID) } // Has optional fields, which is a space separated list of values. // Example: shared:2 master:7 if mountInfo[6] != "" { mount.OptionalFields, err = mountOptionsParseOptionalFields(mountInfo[6 : mountInfoLength-4]) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: %w", ErrFileParse, err) } } return mount, nil diff --git a/test/integration/vendor/github.com/prometheus/procfs/mountstats.go b/test/integration/vendor/github.com/prometheus/procfs/mountstats.go index f7a828bb1..852c8c4a0 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/mountstats.go +++ b/test/integration/vendor/github.com/prometheus/procfs/mountstats.go @@ -186,6 +186,8 @@ type NFSOperationStats struct { CumulativeTotalResponseMilliseconds uint64 // Duration from when a request was enqueued to when it was completely handled. CumulativeTotalRequestMilliseconds uint64 + // The average time from the point the client sends RPC requests until it receives the response. + AverageRTTMilliseconds float64 // The count of operations that complete with tk_status < 0. These statuses usually indicate error conditions. Errors uint64 } @@ -264,7 +266,7 @@ func parseMountStats(r io.Reader) ([]*Mount, error) { if len(ss) > deviceEntryLen { // Only NFSv3 and v4 are supported for parsing statistics if m.Type != nfs3Type && m.Type != nfs4Type { - return nil, fmt.Errorf("cannot parse MountStats for fstype %q", m.Type) + return nil, fmt.Errorf("%w: Cannot parse MountStats for %q", ErrFileParse, m.Type) } statVersion := strings.TrimPrefix(ss[8], statVersionPrefix) @@ -284,10 +286,11 @@ func parseMountStats(r io.Reader) ([]*Mount, error) { } // parseMount parses an entry in /proc/[pid]/mountstats in the format: -// device [device] mounted on [mount] with fstype [type] +// +// device [device] mounted on [mount] with fstype [type] func parseMount(ss []string) (*Mount, error) { if len(ss) < deviceEntryLen { - return nil, fmt.Errorf("invalid device entry: %v", ss) + return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss) } // Check for specific words appearing at specific indices to ensure @@ -305,7 +308,7 @@ func parseMount(ss []string) (*Mount, error) { for _, f := range format { if ss[f.i] != f.s { - return nil, fmt.Errorf("invalid device entry: %v", ss) + return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss) } } @@ -342,7 +345,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e switch ss[0] { case fieldOpts: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss) } if stats.Opts == nil { stats.Opts = map[string]string{} @@ -357,7 +360,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e } case fieldAge: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss) } // Age integer is in seconds d, err := time.ParseDuration(ss[1] + "s") @@ -368,7 +371,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e stats.Age = d case fieldBytes: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss) } bstats, err := parseNFSBytesStats(ss[1:]) if err != nil { @@ -378,7 +381,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e stats.Bytes = *bstats case fieldEvents: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS events: %v", ErrFileParse, ss) } estats, err := parseNFSEventsStats(ss[1:]) if err != nil { @@ -388,7 +391,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e stats.Events = *estats case fieldTransport: if len(ss) < 3 { - return nil, fmt.Errorf("not enough information for NFS transport stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS transport stats: %v", ErrFileParse, ss) } tstats, err := parseNFSTransportStats(ss[1:], statVersion) @@ -427,7 +430,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e // integer fields. func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) { if len(ss) != fieldBytesLen { - return nil, fmt.Errorf("invalid NFS bytes stats: %v", ss) + return nil, fmt.Errorf("%w: Invalid NFS bytes stats: %v", ErrFileParse, ss) } ns := make([]uint64, 0, fieldBytesLen) @@ -456,7 +459,7 @@ func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) { // integer fields. func parseNFSEventsStats(ss []string) (*NFSEventsStats, error) { if len(ss) != fieldEventsLen { - return nil, fmt.Errorf("invalid NFS events stats: %v", ss) + return nil, fmt.Errorf("%w: invalid NFS events stats: %v", ErrFileParse, ss) } ns := make([]uint64, 0, fieldEventsLen) @@ -520,7 +523,7 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { } if len(ss) < minFields { - return nil, fmt.Errorf("invalid NFS per-operations stats: %v", ss) + return nil, fmt.Errorf("%w: invalid NFS per-operations stats: %v", ErrFileParse, ss) } // Skip string operation name for integers @@ -533,7 +536,6 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { ns = append(ns, n) } - opStats := NFSOperationStats{ Operation: strings.TrimSuffix(ss[0], ":"), Requests: ns[0], @@ -545,6 +547,9 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { CumulativeTotalResponseMilliseconds: ns[6], CumulativeTotalRequestMilliseconds: ns[7], } + if ns[0] != 0 { + opStats.AverageRTTMilliseconds = float64(ns[6]) / float64(ns[0]) + } if len(ns) > 8 { opStats.Errors = ns[8] @@ -571,10 +576,10 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats } else if protocol == "udp" { expectedLength = fieldTransport10UDPLen } else { - return nil, fmt.Errorf("invalid NFS protocol \"%s\" in stats 1.0 statement: %v", protocol, ss) + return nil, fmt.Errorf("%w: Invalid NFS protocol \"%s\" in stats 1.0 statement: %v", ErrFileParse, protocol, ss) } if len(ss) != expectedLength { - return nil, fmt.Errorf("invalid NFS transport stats 1.0 statement: %v", ss) + return nil, fmt.Errorf("%w: Invalid NFS transport stats 1.0 statement: %v", ErrFileParse, ss) } case statVersion11: var expectedLength int @@ -583,13 +588,13 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats } else if protocol == "udp" { expectedLength = fieldTransport11UDPLen } else { - return nil, fmt.Errorf("invalid NFS protocol \"%s\" in stats 1.1 statement: %v", protocol, ss) + return nil, fmt.Errorf("%w: invalid NFS protocol \"%s\" in stats 1.1 statement: %v", ErrFileParse, protocol, ss) } if len(ss) != expectedLength { - return nil, fmt.Errorf("invalid NFS transport stats 1.1 statement: %v", ss) + return nil, fmt.Errorf("%w: invalid NFS transport stats 1.1 statement: %v", ErrFileParse, ss) } default: - return nil, fmt.Errorf("unrecognized NFS transport stats version: %q", statVersion) + return nil, fmt.Errorf("%s: Unrecognized NFS transport stats version: %q", ErrFileParse, statVersion) } // Allocate enough for v1.1 stats since zero value for v1.1 stats will be okay diff --git a/test/integration/vendor/github.com/prometheus/procfs/net_conntrackstat.go b/test/integration/vendor/github.com/prometheus/procfs/net_conntrackstat.go index 8300daca0..fdfa45611 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/net_conntrackstat.go +++ b/test/integration/vendor/github.com/prometheus/procfs/net_conntrackstat.go @@ -18,7 +18,6 @@ import ( "bytes" "fmt" "io" - "strconv" "strings" "github.com/prometheus/procfs/internal/util" @@ -28,9 +27,13 @@ import ( // and contains netfilter conntrack statistics at one CPU core. type ConntrackStatEntry struct { Entries uint64 + Searched uint64 Found uint64 + New uint64 Invalid uint64 Ignore uint64 + Delete uint64 + DeleteList uint64 Insert uint64 InsertFailed uint64 Drop uint64 @@ -55,7 +58,7 @@ func readConntrackStat(path string) ([]ConntrackStatEntry, error) { stat, err := parseConntrackStat(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("failed to read conntrack stats from %q: %w", path, err) + return nil, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, path, err) } return stat, nil @@ -81,73 +84,35 @@ func parseConntrackStat(r io.Reader) ([]ConntrackStatEntry, error) { // Parses a ConntrackStatEntry from given array of fields. func parseConntrackStatEntry(fields []string) (*ConntrackStatEntry, error) { - if len(fields) != 17 { - return nil, fmt.Errorf("invalid conntrackstat entry, missing fields") - } - entry := &ConntrackStatEntry{} - - entries, err := parseConntrackStatField(fields[0]) - if err != nil { - return nil, err - } - entry.Entries = entries - - found, err := parseConntrackStatField(fields[2]) - if err != nil { - return nil, err - } - entry.Found = found - - invalid, err := parseConntrackStatField(fields[4]) - if err != nil { - return nil, err - } - entry.Invalid = invalid - - ignore, err := parseConntrackStatField(fields[5]) - if err != nil { - return nil, err - } - entry.Ignore = ignore - - insert, err := parseConntrackStatField(fields[8]) + entries, err := util.ParseHexUint64s(fields) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: Cannot parse entry: %d: %w", ErrFileParse, entries, err) } - entry.Insert = insert - - insertFailed, err := parseConntrackStatField(fields[9]) - if err != nil { - return nil, err + numEntries := len(entries) + if numEntries < 16 || numEntries > 17 { + return nil, + fmt.Errorf("%w: invalid conntrackstat entry, invalid number of fields: %d", ErrFileParse, numEntries) } - entry.InsertFailed = insertFailed - drop, err := parseConntrackStatField(fields[10]) - if err != nil { - return nil, err + stats := &ConntrackStatEntry{ + Entries: *entries[0], + Searched: *entries[1], + Found: *entries[2], + New: *entries[3], + Invalid: *entries[4], + Ignore: *entries[5], + Delete: *entries[6], + DeleteList: *entries[7], + Insert: *entries[8], + InsertFailed: *entries[9], + Drop: *entries[10], + EarlyDrop: *entries[11], } - entry.Drop = drop - earlyDrop, err := parseConntrackStatField(fields[11]) - if err != nil { - return nil, err + // Ignore missing search_restart on Linux < 2.6.35. + if numEntries == 17 { + stats.SearchRestart = *entries[16] } - entry.EarlyDrop = earlyDrop - searchRestart, err := parseConntrackStatField(fields[16]) - if err != nil { - return nil, err - } - entry.SearchRestart = searchRestart - - return entry, nil -} - -// Parses a uint64 from given hex in string. -func parseConntrackStatField(field string) (uint64, error) { - val, err := strconv.ParseUint(field, 16, 64) - if err != nil { - return 0, fmt.Errorf("couldn't parse %q field: %w", field, err) - } - return val, err + return stats, nil } diff --git a/test/integration/vendor/github.com/prometheus/procfs/net_ip_socket.go b/test/integration/vendor/github.com/prometheus/procfs/net_ip_socket.go index 7fd57d7f4..4da81ea57 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/net_ip_socket.go +++ b/test/integration/vendor/github.com/prometheus/procfs/net_ip_socket.go @@ -130,7 +130,7 @@ func parseIP(hexIP string) (net.IP, error) { var byteIP []byte byteIP, err := hex.DecodeString(hexIP) if err != nil { - return nil, fmt.Errorf("cannot parse address field in socket line %q", hexIP) + return nil, fmt.Errorf("%s: Cannot parse socket field in %q: %w", ErrFileParse, hexIP, err) } switch len(byteIP) { case 4: @@ -144,7 +144,7 @@ func parseIP(hexIP string) (net.IP, error) { } return i, nil default: - return nil, fmt.Errorf("Unable to parse IP %s", hexIP) + return nil, fmt.Errorf("%s: Unable to parse IP %s: %w", ErrFileParse, hexIP, nil) } } @@ -153,7 +153,8 @@ func parseNetIPSocketLine(fields []string) (*netIPSocketLine, error) { line := &netIPSocketLine{} if len(fields) < 10 { return nil, fmt.Errorf( - "cannot parse net socket line as it has less then 10 columns %q", + "%w: Less than 10 columns found %q", + ErrFileParse, strings.Join(fields, " "), ) } @@ -162,64 +163,65 @@ func parseNetIPSocketLine(fields []string) (*netIPSocketLine, error) { // sl s := strings.Split(fields[0], ":") if len(s) != 2 { - return nil, fmt.Errorf("cannot parse sl field in socket line %q", fields[0]) + return nil, fmt.Errorf("%w: Unable to parse sl field in line %q", ErrFileParse, fields[0]) } if line.Sl, err = strconv.ParseUint(s[0], 0, 64); err != nil { - return nil, fmt.Errorf("cannot parse sl value in socket line: %w", err) + return nil, fmt.Errorf("%s: Unable to parse sl field in %q: %w", ErrFileParse, line.Sl, err) } // local_address l := strings.Split(fields[1], ":") if len(l) != 2 { - return nil, fmt.Errorf("cannot parse local_address field in socket line %q", fields[1]) + return nil, fmt.Errorf("%w: Unable to parse local_address field in %q", ErrFileParse, fields[1]) } if line.LocalAddr, err = parseIP(l[0]); err != nil { return nil, err } if line.LocalPort, err = strconv.ParseUint(l[1], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse local_address port value in socket line: %w", err) + return nil, fmt.Errorf("%s: Unable to parse local_address port value line %q: %w", ErrFileParse, line.LocalPort, err) } // remote_address r := strings.Split(fields[2], ":") if len(r) != 2 { - return nil, fmt.Errorf("cannot parse rem_address field in socket line %q", fields[1]) + return nil, fmt.Errorf("%w: Unable to parse rem_address field in %q", ErrFileParse, fields[1]) } if line.RemAddr, err = parseIP(r[0]); err != nil { return nil, err } if line.RemPort, err = strconv.ParseUint(r[1], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse rem_address port value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse rem_address port value in %q: %w", ErrFileParse, line.RemPort, err) } // st if line.St, err = strconv.ParseUint(fields[3], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse st value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse st value in %q: %w", ErrFileParse, line.St, err) } // tx_queue and rx_queue q := strings.Split(fields[4], ":") if len(q) != 2 { return nil, fmt.Errorf( - "cannot parse tx/rx queues in socket line as it has a missing colon %q", + "%w: Missing colon for tx/rx queues in socket line %q", + ErrFileParse, fields[4], ) } if line.TxQueue, err = strconv.ParseUint(q[0], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse tx_queue value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse tx_queue value in %q: %w", ErrFileParse, line.TxQueue, err) } if line.RxQueue, err = strconv.ParseUint(q[1], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse rx_queue value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse trx_queue value in %q: %w", ErrFileParse, line.RxQueue, err) } // uid if line.UID, err = strconv.ParseUint(fields[7], 0, 64); err != nil { - return nil, fmt.Errorf("cannot parse uid value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse UID value in %q: %w", ErrFileParse, line.UID, err) } // inode if line.Inode, err = strconv.ParseUint(fields[9], 0, 64); err != nil { - return nil, fmt.Errorf("cannot parse inode value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse inode value in %q: %w", ErrFileParse, line.Inode, err) } return line, nil diff --git a/test/integration/vendor/github.com/prometheus/procfs/net_protocols.go b/test/integration/vendor/github.com/prometheus/procfs/net_protocols.go index 374b6f73f..b6c77b709 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/net_protocols.go +++ b/test/integration/vendor/github.com/prometheus/procfs/net_protocols.go @@ -131,7 +131,7 @@ func (ps NetProtocolStats) parseLine(rawLine string) (*NetProtocolStatLine, erro } else if fields[6] == disabled { line.Slab = false } else { - return nil, fmt.Errorf("unable to parse capability for protocol: %s", line.Name) + return nil, fmt.Errorf("%w: capability for protocol: %s", ErrFileParse, line.Name) } line.ModuleName = fields[7] @@ -173,7 +173,7 @@ func (pc *NetProtocolCapabilities) parseCapabilities(capabilities []string) erro } else if capabilities[i] == "n" { *capabilityFields[i] = false } else { - return fmt.Errorf("unable to parse capability block for protocol: position %d", i) + return fmt.Errorf("%w: capability block for protocol: position %d", ErrFileParse, i) } } return nil diff --git a/test/integration/vendor/github.com/prometheus/procfs/net_route.go b/test/integration/vendor/github.com/prometheus/procfs/net_route.go new file mode 100644 index 000000000..deb7029fe --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/procfs/net_route.go @@ -0,0 +1,143 @@ +// Copyright 2023 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strconv" + "strings" + + "github.com/prometheus/procfs/internal/util" +) + +const ( + blackholeRepresentation string = "*" + blackholeIfaceName string = "blackhole" + routeLineColumns int = 11 +) + +// A NetRouteLine represents one line from net/route. +type NetRouteLine struct { + Iface string + Destination uint32 + Gateway uint32 + Flags uint32 + RefCnt uint32 + Use uint32 + Metric uint32 + Mask uint32 + MTU uint32 + Window uint32 + IRTT uint32 +} + +func (fs FS) NetRoute() ([]NetRouteLine, error) { + return readNetRoute(fs.proc.Path("net", "route")) +} + +func readNetRoute(path string) ([]NetRouteLine, error) { + b, err := util.ReadFileNoStat(path) + if err != nil { + return nil, err + } + + routelines, err := parseNetRoute(bytes.NewReader(b)) + if err != nil { + return nil, fmt.Errorf("failed to read net route from %s: %w", path, err) + } + return routelines, nil +} + +func parseNetRoute(r io.Reader) ([]NetRouteLine, error) { + var routelines []NetRouteLine + + scanner := bufio.NewScanner(r) + scanner.Scan() + for scanner.Scan() { + fields := strings.Fields(scanner.Text()) + routeline, err := parseNetRouteLine(fields) + if err != nil { + return nil, err + } + routelines = append(routelines, *routeline) + } + return routelines, nil +} + +func parseNetRouteLine(fields []string) (*NetRouteLine, error) { + if len(fields) != routeLineColumns { + return nil, fmt.Errorf("invalid routeline, num of digits: %d", len(fields)) + } + iface := fields[0] + if iface == blackholeRepresentation { + iface = blackholeIfaceName + } + destination, err := strconv.ParseUint(fields[1], 16, 32) + if err != nil { + return nil, err + } + gateway, err := strconv.ParseUint(fields[2], 16, 32) + if err != nil { + return nil, err + } + flags, err := strconv.ParseUint(fields[3], 10, 32) + if err != nil { + return nil, err + } + refcnt, err := strconv.ParseUint(fields[4], 10, 32) + if err != nil { + return nil, err + } + use, err := strconv.ParseUint(fields[5], 10, 32) + if err != nil { + return nil, err + } + metric, err := strconv.ParseUint(fields[6], 10, 32) + if err != nil { + return nil, err + } + mask, err := strconv.ParseUint(fields[7], 16, 32) + if err != nil { + return nil, err + } + mtu, err := strconv.ParseUint(fields[8], 10, 32) + if err != nil { + return nil, err + } + window, err := strconv.ParseUint(fields[9], 10, 32) + if err != nil { + return nil, err + } + irtt, err := strconv.ParseUint(fields[10], 10, 32) + if err != nil { + return nil, err + } + routeline := &NetRouteLine{ + Iface: iface, + Destination: uint32(destination), + Gateway: uint32(gateway), + Flags: uint32(flags), + RefCnt: uint32(refcnt), + Use: uint32(use), + Metric: uint32(metric), + Mask: uint32(mask), + MTU: uint32(mtu), + Window: uint32(window), + IRTT: uint32(irtt), + } + return routeline, nil +} diff --git a/test/integration/vendor/github.com/prometheus/procfs/net_sockstat.go b/test/integration/vendor/github.com/prometheus/procfs/net_sockstat.go index e36f4872d..360e36af7 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/net_sockstat.go +++ b/test/integration/vendor/github.com/prometheus/procfs/net_sockstat.go @@ -16,7 +16,6 @@ package procfs import ( "bufio" "bytes" - "errors" "fmt" "io" "strings" @@ -70,7 +69,7 @@ func readSockstat(name string) (*NetSockstat, error) { stat, err := parseSockstat(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("failed to read sockstats from %q: %w", name, err) + return nil, fmt.Errorf("%s: sockstats from %q: %w", ErrFileRead, name, err) } return stat, nil @@ -84,13 +83,13 @@ func parseSockstat(r io.Reader) (*NetSockstat, error) { // Expect a minimum of a protocol and one key/value pair. fields := strings.Split(s.Text(), " ") if len(fields) < 3 { - return nil, fmt.Errorf("malformed sockstat line: %q", s.Text()) + return nil, fmt.Errorf("%w: Malformed sockstat line: %q", ErrFileParse, s.Text()) } // The remaining fields are key/value pairs. kvs, err := parseSockstatKVs(fields[1:]) if err != nil { - return nil, fmt.Errorf("error parsing sockstat key/value pairs from %q: %w", s.Text(), err) + return nil, fmt.Errorf("%s: sockstat key/value pairs from %q: %w", ErrFileParse, s.Text(), err) } // The first field is the protocol. We must trim its colon suffix. @@ -119,7 +118,7 @@ func parseSockstat(r io.Reader) (*NetSockstat, error) { // parseSockstatKVs parses a string slice into a map of key/value pairs. func parseSockstatKVs(kvs []string) (map[string]int, error) { if len(kvs)%2 != 0 { - return nil, errors.New("odd number of fields in key/value pairs") + return nil, fmt.Errorf("%w:: Odd number of fields in key/value pairs %q", ErrFileParse, kvs) } // Iterate two values at a time to gather key/value pairs. diff --git a/test/integration/vendor/github.com/prometheus/procfs/net_softnet.go b/test/integration/vendor/github.com/prometheus/procfs/net_softnet.go index a94f86dc4..c77085291 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/net_softnet.go +++ b/test/integration/vendor/github.com/prometheus/procfs/net_softnet.go @@ -27,8 +27,9 @@ import ( // For the proc file format details, // See: // * Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2343 -// * Linux 4.17 https://elixir.bootlin.com/linux/v4.17/source/net/core/net-procfs.c#L162 -// and https://elixir.bootlin.com/linux/v4.17/source/include/linux/netdevice.h#L2810. +// * Linux 2.6.39 https://elixir.bootlin.com/linux/v2.6.39/source/net/core/dev.c#L4086 +// * Linux 4.18 https://elixir.bootlin.com/linux/v4.18/source/net/core/net-procfs.c#L162 +// * Linux 5.14 https://elixir.bootlin.com/linux/v5.14/source/net/core/net-procfs.c#L169 // SoftnetStat contains a single row of data from /proc/net/softnet_stat. type SoftnetStat struct { @@ -38,6 +39,18 @@ type SoftnetStat struct { Dropped uint32 // Number of times processing packets ran out of quota. TimeSqueezed uint32 + // Number of collision occur while obtaining device lock while transmitting. + CPUCollision uint32 + // Number of times cpu woken up received_rps. + ReceivedRps uint32 + // number of times flow limit has been reached. + FlowLimitCount uint32 + // Softnet backlog status. + SoftnetBacklogLen uint32 + // CPU id owning this softnet_data. + Index uint32 + // softnet_data's Width. + Width int } var softNetProcFile = "net/softnet_stat" @@ -51,7 +64,7 @@ func (fs FS) NetSoftnetStat() ([]SoftnetStat, error) { entries, err := parseSoftnet(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("failed to parse /proc/net/softnet_stat: %w", err) + return nil, fmt.Errorf("%s: /proc/net/softnet_stat: %w", ErrFileParse, err) } return entries, nil @@ -63,25 +76,65 @@ func parseSoftnet(r io.Reader) ([]SoftnetStat, error) { s := bufio.NewScanner(r) var stats []SoftnetStat + cpuIndex := 0 for s.Scan() { columns := strings.Fields(s.Text()) width := len(columns) + softnetStat := SoftnetStat{} if width < minColumns { - return nil, fmt.Errorf("%d columns were detected, but at least %d were expected", width, minColumns) + return nil, fmt.Errorf("%w: detected %d columns, but expected at least %d", ErrFileParse, width, minColumns) } - // We only parse the first three columns at the moment. - us, err := parseHexUint32s(columns[0:3]) - if err != nil { - return nil, err + // Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2347 + if width >= minColumns { + us, err := parseHexUint32s(columns[0:9]) + if err != nil { + return nil, err + } + + softnetStat.Processed = us[0] + softnetStat.Dropped = us[1] + softnetStat.TimeSqueezed = us[2] + softnetStat.CPUCollision = us[8] + } + + // Linux 2.6.39 https://elixir.bootlin.com/linux/v2.6.39/source/net/core/dev.c#L4086 + if width >= 10 { + us, err := parseHexUint32s(columns[9:10]) + if err != nil { + return nil, err + } + + softnetStat.ReceivedRps = us[0] } - stats = append(stats, SoftnetStat{ - Processed: us[0], - Dropped: us[1], - TimeSqueezed: us[2], - }) + // Linux 4.18 https://elixir.bootlin.com/linux/v4.18/source/net/core/net-procfs.c#L162 + if width >= 11 { + us, err := parseHexUint32s(columns[10:11]) + if err != nil { + return nil, err + } + + softnetStat.FlowLimitCount = us[0] + } + + // Linux 5.14 https://elixir.bootlin.com/linux/v5.14/source/net/core/net-procfs.c#L169 + if width >= 13 { + us, err := parseHexUint32s(columns[11:13]) + if err != nil { + return nil, err + } + + softnetStat.SoftnetBacklogLen = us[0] + softnetStat.Index = us[1] + } else { + // For older kernels, create the Index based on the scan line number. + softnetStat.Index = uint32(cpuIndex) + } + softnetStat.Width = width + stats = append(stats, softnetStat) + cpuIndex++ } return stats, nil diff --git a/test/integration/vendor/github.com/prometheus/procfs/net_unix.go b/test/integration/vendor/github.com/prometheus/procfs/net_unix.go index 98aa8e1c3..acbbc57ea 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/net_unix.go +++ b/test/integration/vendor/github.com/prometheus/procfs/net_unix.go @@ -108,14 +108,14 @@ func parseNetUNIX(r io.Reader) (*NetUNIX, error) { line := s.Text() item, err := nu.parseLine(line, hasInode, minFields) if err != nil { - return nil, fmt.Errorf("failed to parse /proc/net/unix data %q: %w", line, err) + return nil, fmt.Errorf("%s: /proc/net/unix encountered data %q: %w", ErrFileParse, line, err) } nu.Rows = append(nu.Rows, item) } if err := s.Err(); err != nil { - return nil, fmt.Errorf("failed to scan /proc/net/unix data: %w", err) + return nil, fmt.Errorf("%s: /proc/net/unix encountered data: %w", ErrFileParse, err) } return &nu, nil @@ -126,7 +126,7 @@ func (u *NetUNIX) parseLine(line string, hasInode bool, min int) (*NetUNIXLine, l := len(fields) if l < min { - return nil, fmt.Errorf("expected at least %d fields but got %d", min, l) + return nil, fmt.Errorf("%w: expected at least %d fields but got %d", ErrFileParse, min, l) } // Field offsets are as follows: @@ -136,29 +136,29 @@ func (u *NetUNIX) parseLine(line string, hasInode bool, min int) (*NetUNIXLine, users, err := u.parseUsers(fields[1]) if err != nil { - return nil, fmt.Errorf("failed to parse ref count %q: %w", fields[1], err) + return nil, fmt.Errorf("%s: ref count %q: %w", ErrFileParse, fields[1], err) } flags, err := u.parseFlags(fields[3]) if err != nil { - return nil, fmt.Errorf("failed to parse flags %q: %w", fields[3], err) + return nil, fmt.Errorf("%s: Unable to parse flags %q: %w", ErrFileParse, fields[3], err) } typ, err := u.parseType(fields[4]) if err != nil { - return nil, fmt.Errorf("failed to parse type %q: %w", fields[4], err) + return nil, fmt.Errorf("%s: Failed to parse type %q: %w", ErrFileParse, fields[4], err) } state, err := u.parseState(fields[5]) if err != nil { - return nil, fmt.Errorf("failed to parse state %q: %w", fields[5], err) + return nil, fmt.Errorf("%s: Failed to parse state %q: %w", ErrFileParse, fields[5], err) } var inode uint64 if hasInode { inode, err = u.parseInode(fields[6]) if err != nil { - return nil, fmt.Errorf("failed to parse inode %q: %w", fields[6], err) + return nil, fmt.Errorf("%s failed to parse inode %q: %w", ErrFileParse, fields[6], err) } } diff --git a/test/integration/vendor/github.com/prometheus/procfs/net_wireless.go b/test/integration/vendor/github.com/prometheus/procfs/net_wireless.go new file mode 100644 index 000000000..7443edca9 --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/procfs/net_wireless.go @@ -0,0 +1,182 @@ +// Copyright 2023 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strconv" + "strings" + + "github.com/prometheus/procfs/internal/util" +) + +// Wireless models the content of /proc/net/wireless. +type Wireless struct { + Name string + + // Status is the current 4-digit hex value status of the interface. + Status uint64 + + // QualityLink is the link quality. + QualityLink int + + // QualityLevel is the signal gain (dBm). + QualityLevel int + + // QualityNoise is the signal noise baseline (dBm). + QualityNoise int + + // DiscardedNwid is the number of discarded packets with wrong nwid/essid. + DiscardedNwid int + + // DiscardedCrypt is the number of discarded packets with wrong code/decode (WEP). + DiscardedCrypt int + + // DiscardedFrag is the number of discarded packets that can't perform MAC reassembly. + DiscardedFrag int + + // DiscardedRetry is the number of discarded packets that reached max MAC retries. + DiscardedRetry int + + // DiscardedMisc is the number of discarded packets for other reasons. + DiscardedMisc int + + // MissedBeacon is the number of missed beacons/superframe. + MissedBeacon int +} + +// Wireless returns kernel wireless statistics. +func (fs FS) Wireless() ([]*Wireless, error) { + b, err := util.ReadFileNoStat(fs.proc.Path("net/wireless")) + if err != nil { + return nil, err + } + + m, err := parseWireless(bytes.NewReader(b)) + if err != nil { + return nil, fmt.Errorf("%s: wireless: %w", ErrFileParse, err) + } + + return m, nil +} + +// parseWireless parses the contents of /proc/net/wireless. +/* +Inter-| sta-| Quality | Discarded packets | Missed | WE +face | tus | link level noise | nwid crypt frag retry misc | beacon | 22 + eth1: 0000 5. -256. -10. 0 1 0 3 0 0 + eth2: 0000 5. -256. -20. 0 2 0 4 0 0 +*/ +func parseWireless(r io.Reader) ([]*Wireless, error) { + var ( + interfaces []*Wireless + scanner = bufio.NewScanner(r) + ) + + for n := 0; scanner.Scan(); n++ { + // Skip the 2 header lines. + if n < 2 { + continue + } + + line := scanner.Text() + + parts := strings.Split(line, ":") + if len(parts) != 2 { + return nil, fmt.Errorf("%w: expected 2 parts after splitting line by ':', got %d for line %q", ErrFileParse, len(parts), line) + } + + name := strings.TrimSpace(parts[0]) + stats := strings.Fields(parts[1]) + + if len(stats) < 10 { + return nil, fmt.Errorf("%w: invalid number of fields in line %d, expected 10+, got %d: %q", ErrFileParse, n, len(stats), line) + } + + status, err := strconv.ParseUint(stats[0], 16, 16) + if err != nil { + return nil, fmt.Errorf("%w: invalid status in line %d: %q", ErrFileParse, n, line) + } + + qlink, err := strconv.Atoi(strings.TrimSuffix(stats[1], ".")) + if err != nil { + return nil, fmt.Errorf("%s: parse Quality:link as integer %q: %w", ErrFileParse, qlink, err) + } + + qlevel, err := strconv.Atoi(strings.TrimSuffix(stats[2], ".")) + if err != nil { + return nil, fmt.Errorf("%s: Quality:level as integer %q: %w", ErrFileParse, qlevel, err) + } + + qnoise, err := strconv.Atoi(strings.TrimSuffix(stats[3], ".")) + if err != nil { + return nil, fmt.Errorf("%s: Quality:noise as integer %q: %w", ErrFileParse, qnoise, err) + } + + dnwid, err := strconv.Atoi(stats[4]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:nwid as integer %q: %w", ErrFileParse, dnwid, err) + } + + dcrypt, err := strconv.Atoi(stats[5]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:crypt as integer %q: %w", ErrFileParse, dcrypt, err) + } + + dfrag, err := strconv.Atoi(stats[6]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:frag as integer %q: %w", ErrFileParse, dfrag, err) + } + + dretry, err := strconv.Atoi(stats[7]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:retry as integer %q: %w", ErrFileParse, dretry, err) + } + + dmisc, err := strconv.Atoi(stats[8]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:misc as integer %q: %w", ErrFileParse, dmisc, err) + } + + mbeacon, err := strconv.Atoi(stats[9]) + if err != nil { + return nil, fmt.Errorf("%s: Missed:beacon as integer %q: %w", ErrFileParse, mbeacon, err) + } + + w := &Wireless{ + Name: name, + Status: status, + QualityLink: qlink, + QualityLevel: qlevel, + QualityNoise: qnoise, + DiscardedNwid: dnwid, + DiscardedCrypt: dcrypt, + DiscardedFrag: dfrag, + DiscardedRetry: dretry, + DiscardedMisc: dmisc, + MissedBeacon: mbeacon, + } + + interfaces = append(interfaces, w) + } + + if err := scanner.Err(); err != nil { + return nil, fmt.Errorf("%s: Failed to scan /proc/net/wireless: %w", ErrFileRead, err) + } + + return interfaces, nil +} diff --git a/test/integration/vendor/github.com/prometheus/procfs/net_xfrm.go b/test/integration/vendor/github.com/prometheus/procfs/net_xfrm.go index f9d9d243d..932ef2046 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/net_xfrm.go +++ b/test/integration/vendor/github.com/prometheus/procfs/net_xfrm.go @@ -115,7 +115,7 @@ func (fs FS) NewXfrmStat() (XfrmStat, error) { fields := strings.Fields(s.Text()) if len(fields) != 2 { - return XfrmStat{}, fmt.Errorf("couldn't parse %q line %q", file.Name(), s.Text()) + return XfrmStat{}, fmt.Errorf("%w: %q line %q", ErrFileParse, file.Name(), s.Text()) } name := fields[0] diff --git a/test/integration/vendor/github.com/prometheus/procfs/netstat.go b/test/integration/vendor/github.com/prometheus/procfs/netstat.go index dcea9c5a6..742dff453 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/netstat.go +++ b/test/integration/vendor/github.com/prometheus/procfs/netstat.go @@ -37,32 +37,46 @@ func (fs FS) NetStat() ([]NetStat, error) { var netStatsTotal []NetStat for _, filePath := range statFiles { - file, err := os.Open(filePath) + procNetstat, err := parseNetstat(filePath) if err != nil { return nil, err } + procNetstat.Filename = filepath.Base(filePath) - netStatFile := NetStat{ - Filename: filepath.Base(filePath), - Stats: make(map[string][]uint64), - } - scanner := bufio.NewScanner(file) - scanner.Scan() - // First string is always a header for stats - var headers []string - headers = append(headers, strings.Fields(scanner.Text())...) + netStatsTotal = append(netStatsTotal, procNetstat) + } + return netStatsTotal, nil +} + +// parseNetstat parses the metrics from `/proc/net/stat/` file +// and returns a NetStat structure. +func parseNetstat(filePath string) (NetStat, error) { + netStat := NetStat{ + Stats: make(map[string][]uint64), + } + file, err := os.Open(filePath) + if err != nil { + return netStat, err + } + defer file.Close() + + scanner := bufio.NewScanner(file) + scanner.Scan() - // Other strings represent per-CPU counters - for scanner.Scan() { - for num, counter := range strings.Fields(scanner.Text()) { - value, err := strconv.ParseUint(counter, 16, 64) - if err != nil { - return nil, err - } - netStatFile.Stats[headers[num]] = append(netStatFile.Stats[headers[num]], value) + // First string is always a header for stats + var headers []string + headers = append(headers, strings.Fields(scanner.Text())...) + + // Other strings represent per-CPU counters + for scanner.Scan() { + for num, counter := range strings.Fields(scanner.Text()) { + value, err := strconv.ParseUint(counter, 16, 64) + if err != nil { + return NetStat{}, err } + netStat.Stats[headers[num]] = append(netStat.Stats[headers[num]], value) } - netStatsTotal = append(netStatsTotal, netStatFile) } - return netStatsTotal, nil + + return netStat, nil } diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc.go b/test/integration/vendor/github.com/prometheus/procfs/proc.go index c30223af7..e1599961f 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc.go @@ -15,13 +15,13 @@ package procfs import ( "bytes" + "errors" "fmt" "io" "os" "strconv" "strings" - "github.com/prometheus/procfs/internal/fs" "github.com/prometheus/procfs/internal/util" ) @@ -30,12 +30,18 @@ type Proc struct { // The process ID. PID int - fs fs.FS + fs FS } // Procs represents a list of Proc structs. type Procs []Proc +var ( + ErrFileParse = errors.New("Error Parsing File") + ErrFileRead = errors.New("Error Reading File") + ErrMountPoint = errors.New("Error Accessing Mount point") +) + func (p Procs) Len() int { return len(p) } func (p Procs) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p Procs) Less(i, j int) bool { return p[i].PID < p[j].PID } @@ -43,7 +49,7 @@ func (p Procs) Less(i, j int) bool { return p[i].PID < p[j].PID } // Self returns a process for the current process read via /proc/self. func Self() (Proc, error) { fs, err := NewFS(DefaultMountPoint) - if err != nil { + if err != nil || errors.Unwrap(err) == ErrMountPoint { return Proc{}, err } return fs.Self() @@ -92,7 +98,7 @@ func (fs FS) Proc(pid int) (Proc, error) { if _, err := os.Stat(fs.proc.Path(strconv.Itoa(pid))); err != nil { return Proc{}, err } - return Proc{PID: pid, fs: fs.proc}, nil + return Proc{PID: pid, fs: fs}, nil } // AllProcs returns a list of all currently available processes. @@ -105,7 +111,7 @@ func (fs FS) AllProcs() (Procs, error) { names, err := d.Readdirnames(-1) if err != nil { - return Procs{}, fmt.Errorf("could not read %q: %w", d.Name(), err) + return Procs{}, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, names, err) } p := Procs{} @@ -114,7 +120,7 @@ func (fs FS) AllProcs() (Procs, error) { if err != nil { continue } - p = append(p, Proc{PID: int(pid), fs: fs.proc}) + p = append(p, Proc{PID: int(pid), fs: fs}) } return p, nil @@ -206,7 +212,7 @@ func (p Proc) FileDescriptors() ([]uintptr, error) { for i, n := range names { fd, err := strconv.ParseInt(n, 10, 32) if err != nil { - return nil, fmt.Errorf("could not parse fd %q: %w", n, err) + return nil, fmt.Errorf("%s: Cannot parse line: %v: %w", ErrFileParse, i, err) } fds[i] = uintptr(fd) } @@ -237,6 +243,19 @@ func (p Proc) FileDescriptorTargets() ([]string, error) { // FileDescriptorsLen returns the number of currently open file descriptors of // a process. func (p Proc) FileDescriptorsLen() (int, error) { + // Use fast path if available (Linux v6.2): https://github.com/torvalds/linux/commit/f1f1f2569901 + if p.fs.real { + stat, err := os.Stat(p.path("fd")) + if err != nil { + return 0, err + } + + size := stat.Size() + if size > 0 { + return int(size), nil + } + } + fds, err := p.fileDescriptors() if err != nil { return 0, err @@ -278,14 +297,14 @@ func (p Proc) fileDescriptors() ([]string, error) { names, err := d.Readdirnames(-1) if err != nil { - return nil, fmt.Errorf("could not read %q: %w", d.Name(), err) + return nil, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, names, err) } return names, nil } func (p Proc) path(pa ...string) string { - return p.fs.Path(append([]string{strconv.Itoa(p.PID)}, pa...)...) + return p.fs.proc.Path(append([]string{strconv.Itoa(p.PID)}, pa...)...) } // FileDescriptorsInfo retrieves information about all file descriptors of diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_cgroup.go b/test/integration/vendor/github.com/prometheus/procfs/proc_cgroup.go index cca03327c..daeed7f57 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_cgroup.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_cgroup.go @@ -23,7 +23,7 @@ import ( "github.com/prometheus/procfs/internal/util" ) -// Cgroup models one line from /proc/[pid]/cgroup. Each Cgroup struct describes the the placement of a PID inside a +// Cgroup models one line from /proc/[pid]/cgroup. Each Cgroup struct describes the placement of a PID inside a // specific control hierarchy. The kernel has two cgroup APIs, v1 and v2. v1 has one hierarchy per available resource // controller, while v2 has one unified hierarchy shared by all controllers. Regardless of v1 or v2, all hierarchies // contain all running processes, so the question answerable with a Cgroup struct is 'where is this process in @@ -51,7 +51,7 @@ func parseCgroupString(cgroupStr string) (*Cgroup, error) { fields := strings.SplitN(cgroupStr, ":", 3) if len(fields) < 3 { - return nil, fmt.Errorf("at least 3 fields required, found %d fields in cgroup string: %s", len(fields), cgroupStr) + return nil, fmt.Errorf("%w: 3+ fields required, found %d fields in cgroup string: %s", ErrFileParse, len(fields), cgroupStr) } cgroup := &Cgroup{ @@ -60,7 +60,7 @@ func parseCgroupString(cgroupStr string) (*Cgroup, error) { } cgroup.HierarchyID, err = strconv.Atoi(fields[0]) if err != nil { - return nil, fmt.Errorf("failed to parse hierarchy ID") + return nil, fmt.Errorf("%w: hierarchy ID: %q", ErrFileParse, cgroup.HierarchyID) } if fields[1] != "" { ssNames := strings.Split(fields[1], ",") diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_cgroups.go b/test/integration/vendor/github.com/prometheus/procfs/proc_cgroups.go index 24d4dce9c..5dd493899 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_cgroups.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_cgroups.go @@ -46,7 +46,7 @@ func parseCgroupSummaryString(CgroupSummaryStr string) (*CgroupSummary, error) { fields := strings.Fields(CgroupSummaryStr) // require at least 4 fields if len(fields) < 4 { - return nil, fmt.Errorf("at least 4 fields required, found %d fields in cgroup info string: %s", len(fields), CgroupSummaryStr) + return nil, fmt.Errorf("%w: 4+ fields required, found %d fields in cgroup info string: %s", ErrFileParse, len(fields), CgroupSummaryStr) } CgroupSummary := &CgroupSummary{ @@ -54,15 +54,15 @@ func parseCgroupSummaryString(CgroupSummaryStr string) (*CgroupSummary, error) { } CgroupSummary.Hierarchy, err = strconv.Atoi(fields[1]) if err != nil { - return nil, fmt.Errorf("failed to parse hierarchy ID") + return nil, fmt.Errorf("%w: Unable to parse hierarchy ID from %q", ErrFileParse, fields[1]) } CgroupSummary.Cgroups, err = strconv.Atoi(fields[2]) if err != nil { - return nil, fmt.Errorf("failed to parse Cgroup Num") + return nil, fmt.Errorf("%w: Unable to parse Cgroup Num from %q", ErrFileParse, fields[2]) } CgroupSummary.Enabled, err = strconv.Atoi(fields[3]) if err != nil { - return nil, fmt.Errorf("failed to parse Enabled") + return nil, fmt.Errorf("%w: Unable to parse Enabled from %q", ErrFileParse, fields[3]) } return CgroupSummary, nil } diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_fdinfo.go b/test/integration/vendor/github.com/prometheus/procfs/proc_fdinfo.go index 1bbdd4a8e..4b7933e4f 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_fdinfo.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_fdinfo.go @@ -111,7 +111,7 @@ func parseInotifyInfo(line string) (*InotifyInfo, error) { } return i, nil } - return nil, fmt.Errorf("invalid inode entry: %q", line) + return nil, fmt.Errorf("%w: invalid inode entry: %q", ErrFileParse, line) } // ProcFDInfos represents a list of ProcFDInfo structs. diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_interrupts.go b/test/integration/vendor/github.com/prometheus/procfs/proc_interrupts.go new file mode 100644 index 000000000..86b4b4524 --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_interrupts.go @@ -0,0 +1,98 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "bufio" + "bytes" + "errors" + "fmt" + "io" + "strconv" + "strings" + + "github.com/prometheus/procfs/internal/util" +) + +// Interrupt represents a single interrupt line. +type Interrupt struct { + // Info is the type of interrupt. + Info string + // Devices is the name of the device that is located at that IRQ + Devices string + // Values is the number of interrupts per CPU. + Values []string +} + +// Interrupts models the content of /proc/interrupts. Key is the IRQ number. +// - https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s2-proc-interrupts +// - https://raspberrypi.stackexchange.com/questions/105802/explanation-of-proc-interrupts-output +type Interrupts map[string]Interrupt + +// Interrupts creates a new instance from a given Proc instance. +func (p Proc) Interrupts() (Interrupts, error) { + data, err := util.ReadFileNoStat(p.path("interrupts")) + if err != nil { + return nil, err + } + return parseInterrupts(bytes.NewReader(data)) +} + +func parseInterrupts(r io.Reader) (Interrupts, error) { + var ( + interrupts = Interrupts{} + scanner = bufio.NewScanner(r) + ) + + if !scanner.Scan() { + return nil, errors.New("interrupts empty") + } + cpuNum := len(strings.Fields(scanner.Text())) // one header per cpu + + for scanner.Scan() { + parts := strings.Fields(scanner.Text()) + if len(parts) == 0 { // skip empty lines + continue + } + if len(parts) < 2 { + return nil, fmt.Errorf("%w: Not enough fields in interrupts (expected 2+ fields but got %d): %s", ErrFileParse, len(parts), parts) + } + intName := parts[0][:len(parts[0])-1] // remove trailing : + + if len(parts) == 2 { + interrupts[intName] = Interrupt{ + Info: "", + Devices: "", + Values: []string{ + parts[1], + }, + } + continue + } + + intr := Interrupt{ + Values: parts[1 : cpuNum+1], + } + + if _, err := strconv.Atoi(intName); err == nil { // numeral interrupt + intr.Info = parts[cpuNum+1] + intr.Devices = strings.Join(parts[cpuNum+2:], " ") + } else { + intr.Info = strings.Join(parts[cpuNum+1:], " ") + } + interrupts[intName] = intr + } + + return interrupts, scanner.Err() +} diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_limits.go b/test/integration/vendor/github.com/prometheus/procfs/proc_limits.go index 7a1388185..c86d815d7 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_limits.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_limits.go @@ -103,7 +103,7 @@ func (p Proc) Limits() (ProcLimits, error) { //fields := limitsMatch.Split(s.Text(), limitsFields) fields := limitsMatch.FindStringSubmatch(s.Text()) if len(fields) != limitsFields { - return ProcLimits{}, fmt.Errorf("couldn't parse %q line %q", f.Name(), s.Text()) + return ProcLimits{}, fmt.Errorf("%w: couldn't parse %q line %q", ErrFileParse, f.Name(), s.Text()) } switch fields[1] { @@ -154,7 +154,7 @@ func parseUint(s string) (uint64, error) { } i, err := strconv.ParseUint(s, 10, 64) if err != nil { - return 0, fmt.Errorf("couldn't parse value %q: %w", s, err) + return 0, fmt.Errorf("%s: couldn't parse value %q: %w", ErrFileParse, s, err) } return i, nil } diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_maps.go b/test/integration/vendor/github.com/prometheus/procfs/proc_maps.go index f1bcbf32b..727549a13 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_maps.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_maps.go @@ -65,7 +65,7 @@ type ProcMap struct { func parseDevice(s string) (uint64, error) { toks := strings.Split(s, ":") if len(toks) < 2 { - return 0, fmt.Errorf("unexpected number of fields") + return 0, fmt.Errorf("%w: unexpected number of fields, expected: 2, got: %q", ErrFileParse, len(toks)) } major, err := strconv.ParseUint(toks[0], 16, 0) @@ -95,7 +95,7 @@ func parseAddress(s string) (uintptr, error) { func parseAddresses(s string) (uintptr, uintptr, error) { toks := strings.Split(s, "-") if len(toks) < 2 { - return 0, 0, fmt.Errorf("invalid address") + return 0, 0, fmt.Errorf("%w: invalid address", ErrFileParse) } saddr, err := parseAddress(toks[0]) @@ -114,7 +114,7 @@ func parseAddresses(s string) (uintptr, uintptr, error) { // parsePermissions parses a token and returns any that are set. func parsePermissions(s string) (*ProcMapPermissions, error) { if len(s) < 4 { - return nil, fmt.Errorf("invalid permissions token") + return nil, fmt.Errorf("%w: invalid permissions token", ErrFileParse) } perms := ProcMapPermissions{} @@ -141,7 +141,7 @@ func parsePermissions(s string) (*ProcMapPermissions, error) { func parseProcMap(text string) (*ProcMap, error) { fields := strings.Fields(text) if len(fields) < 5 { - return nil, fmt.Errorf("truncated procmap entry") + return nil, fmt.Errorf("%w: truncated procmap entry", ErrFileParse) } saddr, eaddr, err := parseAddresses(fields[0]) diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_netstat.go b/test/integration/vendor/github.com/prometheus/procfs/proc_netstat.go index 48b523819..8e3ff4d79 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_netstat.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_netstat.go @@ -33,139 +33,140 @@ type ProcNetstat struct { } type TcpExt struct { // nolint:revive - SyncookiesSent float64 - SyncookiesRecv float64 - SyncookiesFailed float64 - EmbryonicRsts float64 - PruneCalled float64 - RcvPruned float64 - OfoPruned float64 - OutOfWindowIcmps float64 - LockDroppedIcmps float64 - ArpFilter float64 - TW float64 - TWRecycled float64 - TWKilled float64 - PAWSActive float64 - PAWSEstab float64 - DelayedACKs float64 - DelayedACKLocked float64 - DelayedACKLost float64 - ListenOverflows float64 - ListenDrops float64 - TCPHPHits float64 - TCPPureAcks float64 - TCPHPAcks float64 - TCPRenoRecovery float64 - TCPSackRecovery float64 - TCPSACKReneging float64 - TCPSACKReorder float64 - TCPRenoReorder float64 - TCPTSReorder float64 - TCPFullUndo float64 - TCPPartialUndo float64 - TCPDSACKUndo float64 - TCPLossUndo float64 - TCPLostRetransmit float64 - TCPRenoFailures float64 - TCPSackFailures float64 - TCPLossFailures float64 - TCPFastRetrans float64 - TCPSlowStartRetrans float64 - TCPTimeouts float64 - TCPLossProbes float64 - TCPLossProbeRecovery float64 - TCPRenoRecoveryFail float64 - TCPSackRecoveryFail float64 - TCPRcvCollapsed float64 - TCPDSACKOldSent float64 - TCPDSACKOfoSent float64 - TCPDSACKRecv float64 - TCPDSACKOfoRecv float64 - TCPAbortOnData float64 - TCPAbortOnClose float64 - TCPAbortOnMemory float64 - TCPAbortOnTimeout float64 - TCPAbortOnLinger float64 - TCPAbortFailed float64 - TCPMemoryPressures float64 - TCPMemoryPressuresChrono float64 - TCPSACKDiscard float64 - TCPDSACKIgnoredOld float64 - TCPDSACKIgnoredNoUndo float64 - TCPSpuriousRTOs float64 - TCPMD5NotFound float64 - TCPMD5Unexpected float64 - TCPMD5Failure float64 - TCPSackShifted float64 - TCPSackMerged float64 - TCPSackShiftFallback float64 - TCPBacklogDrop float64 - PFMemallocDrop float64 - TCPMinTTLDrop float64 - TCPDeferAcceptDrop float64 - IPReversePathFilter float64 - TCPTimeWaitOverflow float64 - TCPReqQFullDoCookies float64 - TCPReqQFullDrop float64 - TCPRetransFail float64 - TCPRcvCoalesce float64 - TCPOFOQueue float64 - TCPOFODrop float64 - TCPOFOMerge float64 - TCPChallengeACK float64 - TCPSYNChallenge float64 - TCPFastOpenActive float64 - TCPFastOpenActiveFail float64 - TCPFastOpenPassive float64 - TCPFastOpenPassiveFail float64 - TCPFastOpenListenOverflow float64 - TCPFastOpenCookieReqd float64 - TCPFastOpenBlackhole float64 - TCPSpuriousRtxHostQueues float64 - BusyPollRxPackets float64 - TCPAutoCorking float64 - TCPFromZeroWindowAdv float64 - TCPToZeroWindowAdv float64 - TCPWantZeroWindowAdv float64 - TCPSynRetrans float64 - TCPOrigDataSent float64 - TCPHystartTrainDetect float64 - TCPHystartTrainCwnd float64 - TCPHystartDelayDetect float64 - TCPHystartDelayCwnd float64 - TCPACKSkippedSynRecv float64 - TCPACKSkippedPAWS float64 - TCPACKSkippedSeq float64 - TCPACKSkippedFinWait2 float64 - TCPACKSkippedTimeWait float64 - TCPACKSkippedChallenge float64 - TCPWinProbe float64 - TCPKeepAlive float64 - TCPMTUPFail float64 - TCPMTUPSuccess float64 - TCPWqueueTooBig float64 + SyncookiesSent *float64 + SyncookiesRecv *float64 + SyncookiesFailed *float64 + EmbryonicRsts *float64 + PruneCalled *float64 + RcvPruned *float64 + OfoPruned *float64 + OutOfWindowIcmps *float64 + LockDroppedIcmps *float64 + ArpFilter *float64 + TW *float64 + TWRecycled *float64 + TWKilled *float64 + PAWSActive *float64 + PAWSEstab *float64 + DelayedACKs *float64 + DelayedACKLocked *float64 + DelayedACKLost *float64 + ListenOverflows *float64 + ListenDrops *float64 + TCPHPHits *float64 + TCPPureAcks *float64 + TCPHPAcks *float64 + TCPRenoRecovery *float64 + TCPSackRecovery *float64 + TCPSACKReneging *float64 + TCPSACKReorder *float64 + TCPRenoReorder *float64 + TCPTSReorder *float64 + TCPFullUndo *float64 + TCPPartialUndo *float64 + TCPDSACKUndo *float64 + TCPLossUndo *float64 + TCPLostRetransmit *float64 + TCPRenoFailures *float64 + TCPSackFailures *float64 + TCPLossFailures *float64 + TCPFastRetrans *float64 + TCPSlowStartRetrans *float64 + TCPTimeouts *float64 + TCPLossProbes *float64 + TCPLossProbeRecovery *float64 + TCPRenoRecoveryFail *float64 + TCPSackRecoveryFail *float64 + TCPRcvCollapsed *float64 + TCPDSACKOldSent *float64 + TCPDSACKOfoSent *float64 + TCPDSACKRecv *float64 + TCPDSACKOfoRecv *float64 + TCPAbortOnData *float64 + TCPAbortOnClose *float64 + TCPAbortOnMemory *float64 + TCPAbortOnTimeout *float64 + TCPAbortOnLinger *float64 + TCPAbortFailed *float64 + TCPMemoryPressures *float64 + TCPMemoryPressuresChrono *float64 + TCPSACKDiscard *float64 + TCPDSACKIgnoredOld *float64 + TCPDSACKIgnoredNoUndo *float64 + TCPSpuriousRTOs *float64 + TCPMD5NotFound *float64 + TCPMD5Unexpected *float64 + TCPMD5Failure *float64 + TCPSackShifted *float64 + TCPSackMerged *float64 + TCPSackShiftFallback *float64 + TCPBacklogDrop *float64 + PFMemallocDrop *float64 + TCPMinTTLDrop *float64 + TCPDeferAcceptDrop *float64 + IPReversePathFilter *float64 + TCPTimeWaitOverflow *float64 + TCPReqQFullDoCookies *float64 + TCPReqQFullDrop *float64 + TCPRetransFail *float64 + TCPRcvCoalesce *float64 + TCPRcvQDrop *float64 + TCPOFOQueue *float64 + TCPOFODrop *float64 + TCPOFOMerge *float64 + TCPChallengeACK *float64 + TCPSYNChallenge *float64 + TCPFastOpenActive *float64 + TCPFastOpenActiveFail *float64 + TCPFastOpenPassive *float64 + TCPFastOpenPassiveFail *float64 + TCPFastOpenListenOverflow *float64 + TCPFastOpenCookieReqd *float64 + TCPFastOpenBlackhole *float64 + TCPSpuriousRtxHostQueues *float64 + BusyPollRxPackets *float64 + TCPAutoCorking *float64 + TCPFromZeroWindowAdv *float64 + TCPToZeroWindowAdv *float64 + TCPWantZeroWindowAdv *float64 + TCPSynRetrans *float64 + TCPOrigDataSent *float64 + TCPHystartTrainDetect *float64 + TCPHystartTrainCwnd *float64 + TCPHystartDelayDetect *float64 + TCPHystartDelayCwnd *float64 + TCPACKSkippedSynRecv *float64 + TCPACKSkippedPAWS *float64 + TCPACKSkippedSeq *float64 + TCPACKSkippedFinWait2 *float64 + TCPACKSkippedTimeWait *float64 + TCPACKSkippedChallenge *float64 + TCPWinProbe *float64 + TCPKeepAlive *float64 + TCPMTUPFail *float64 + TCPMTUPSuccess *float64 + TCPWqueueTooBig *float64 } type IpExt struct { // nolint:revive - InNoRoutes float64 - InTruncatedPkts float64 - InMcastPkts float64 - OutMcastPkts float64 - InBcastPkts float64 - OutBcastPkts float64 - InOctets float64 - OutOctets float64 - InMcastOctets float64 - OutMcastOctets float64 - InBcastOctets float64 - OutBcastOctets float64 - InCsumErrors float64 - InNoECTPkts float64 - InECT1Pkts float64 - InECT0Pkts float64 - InCEPkts float64 - ReasmOverlaps float64 + InNoRoutes *float64 + InTruncatedPkts *float64 + InMcastPkts *float64 + OutMcastPkts *float64 + InBcastPkts *float64 + OutBcastPkts *float64 + InOctets *float64 + OutOctets *float64 + InMcastOctets *float64 + OutMcastOctets *float64 + InBcastOctets *float64 + OutBcastOctets *float64 + InCsumErrors *float64 + InNoECTPkts *float64 + InECT1Pkts *float64 + InECT0Pkts *float64 + InCEPkts *float64 + ReasmOverlaps *float64 } func (p Proc) Netstat() (ProcNetstat, error) { @@ -174,14 +175,14 @@ func (p Proc) Netstat() (ProcNetstat, error) { if err != nil { return ProcNetstat{PID: p.PID}, err } - procNetstat, err := parseNetstat(bytes.NewReader(data), filename) + procNetstat, err := parseProcNetstat(bytes.NewReader(data), filename) procNetstat.PID = p.PID return procNetstat, err } -// parseNetstat parses the metrics from proc//net/netstat file +// parseProcNetstat parses the metrics from proc//net/netstat file // and returns a ProcNetstat structure. -func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) { +func parseProcNetstat(r io.Reader, fileName string) (ProcNetstat, error) { var ( scanner = bufio.NewScanner(r) procNetstat = ProcNetstat{} @@ -194,8 +195,8 @@ func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) { // Remove trailing :. protocol := strings.TrimSuffix(nameParts[0], ":") if len(nameParts) != len(valueParts) { - return procNetstat, fmt.Errorf("mismatch field count mismatch in %s: %s", - fileName, protocol) + return procNetstat, fmt.Errorf("%w: mismatch field count mismatch in %s: %s", + ErrFileParse, fileName, protocol) } for i := 1; i < len(nameParts); i++ { value, err := strconv.ParseFloat(valueParts[i], 64) @@ -208,230 +209,232 @@ func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) { case "TcpExt": switch key { case "SyncookiesSent": - procNetstat.TcpExt.SyncookiesSent = value + procNetstat.TcpExt.SyncookiesSent = &value case "SyncookiesRecv": - procNetstat.TcpExt.SyncookiesRecv = value + procNetstat.TcpExt.SyncookiesRecv = &value case "SyncookiesFailed": - procNetstat.TcpExt.SyncookiesFailed = value + procNetstat.TcpExt.SyncookiesFailed = &value case "EmbryonicRsts": - procNetstat.TcpExt.EmbryonicRsts = value + procNetstat.TcpExt.EmbryonicRsts = &value case "PruneCalled": - procNetstat.TcpExt.PruneCalled = value + procNetstat.TcpExt.PruneCalled = &value case "RcvPruned": - procNetstat.TcpExt.RcvPruned = value + procNetstat.TcpExt.RcvPruned = &value case "OfoPruned": - procNetstat.TcpExt.OfoPruned = value + procNetstat.TcpExt.OfoPruned = &value case "OutOfWindowIcmps": - procNetstat.TcpExt.OutOfWindowIcmps = value + procNetstat.TcpExt.OutOfWindowIcmps = &value case "LockDroppedIcmps": - procNetstat.TcpExt.LockDroppedIcmps = value + procNetstat.TcpExt.LockDroppedIcmps = &value case "ArpFilter": - procNetstat.TcpExt.ArpFilter = value + procNetstat.TcpExt.ArpFilter = &value case "TW": - procNetstat.TcpExt.TW = value + procNetstat.TcpExt.TW = &value case "TWRecycled": - procNetstat.TcpExt.TWRecycled = value + procNetstat.TcpExt.TWRecycled = &value case "TWKilled": - procNetstat.TcpExt.TWKilled = value + procNetstat.TcpExt.TWKilled = &value case "PAWSActive": - procNetstat.TcpExt.PAWSActive = value + procNetstat.TcpExt.PAWSActive = &value case "PAWSEstab": - procNetstat.TcpExt.PAWSEstab = value + procNetstat.TcpExt.PAWSEstab = &value case "DelayedACKs": - procNetstat.TcpExt.DelayedACKs = value + procNetstat.TcpExt.DelayedACKs = &value case "DelayedACKLocked": - procNetstat.TcpExt.DelayedACKLocked = value + procNetstat.TcpExt.DelayedACKLocked = &value case "DelayedACKLost": - procNetstat.TcpExt.DelayedACKLost = value + procNetstat.TcpExt.DelayedACKLost = &value case "ListenOverflows": - procNetstat.TcpExt.ListenOverflows = value + procNetstat.TcpExt.ListenOverflows = &value case "ListenDrops": - procNetstat.TcpExt.ListenDrops = value + procNetstat.TcpExt.ListenDrops = &value case "TCPHPHits": - procNetstat.TcpExt.TCPHPHits = value + procNetstat.TcpExt.TCPHPHits = &value case "TCPPureAcks": - procNetstat.TcpExt.TCPPureAcks = value + procNetstat.TcpExt.TCPPureAcks = &value case "TCPHPAcks": - procNetstat.TcpExt.TCPHPAcks = value + procNetstat.TcpExt.TCPHPAcks = &value case "TCPRenoRecovery": - procNetstat.TcpExt.TCPRenoRecovery = value + procNetstat.TcpExt.TCPRenoRecovery = &value case "TCPSackRecovery": - procNetstat.TcpExt.TCPSackRecovery = value + procNetstat.TcpExt.TCPSackRecovery = &value case "TCPSACKReneging": - procNetstat.TcpExt.TCPSACKReneging = value + procNetstat.TcpExt.TCPSACKReneging = &value case "TCPSACKReorder": - procNetstat.TcpExt.TCPSACKReorder = value + procNetstat.TcpExt.TCPSACKReorder = &value case "TCPRenoReorder": - procNetstat.TcpExt.TCPRenoReorder = value + procNetstat.TcpExt.TCPRenoReorder = &value case "TCPTSReorder": - procNetstat.TcpExt.TCPTSReorder = value + procNetstat.TcpExt.TCPTSReorder = &value case "TCPFullUndo": - procNetstat.TcpExt.TCPFullUndo = value + procNetstat.TcpExt.TCPFullUndo = &value case "TCPPartialUndo": - procNetstat.TcpExt.TCPPartialUndo = value + procNetstat.TcpExt.TCPPartialUndo = &value case "TCPDSACKUndo": - procNetstat.TcpExt.TCPDSACKUndo = value + procNetstat.TcpExt.TCPDSACKUndo = &value case "TCPLossUndo": - procNetstat.TcpExt.TCPLossUndo = value + procNetstat.TcpExt.TCPLossUndo = &value case "TCPLostRetransmit": - procNetstat.TcpExt.TCPLostRetransmit = value + procNetstat.TcpExt.TCPLostRetransmit = &value case "TCPRenoFailures": - procNetstat.TcpExt.TCPRenoFailures = value + procNetstat.TcpExt.TCPRenoFailures = &value case "TCPSackFailures": - procNetstat.TcpExt.TCPSackFailures = value + procNetstat.TcpExt.TCPSackFailures = &value case "TCPLossFailures": - procNetstat.TcpExt.TCPLossFailures = value + procNetstat.TcpExt.TCPLossFailures = &value case "TCPFastRetrans": - procNetstat.TcpExt.TCPFastRetrans = value + procNetstat.TcpExt.TCPFastRetrans = &value case "TCPSlowStartRetrans": - procNetstat.TcpExt.TCPSlowStartRetrans = value + procNetstat.TcpExt.TCPSlowStartRetrans = &value case "TCPTimeouts": - procNetstat.TcpExt.TCPTimeouts = value + procNetstat.TcpExt.TCPTimeouts = &value case "TCPLossProbes": - procNetstat.TcpExt.TCPLossProbes = value + procNetstat.TcpExt.TCPLossProbes = &value case "TCPLossProbeRecovery": - procNetstat.TcpExt.TCPLossProbeRecovery = value + procNetstat.TcpExt.TCPLossProbeRecovery = &value case "TCPRenoRecoveryFail": - procNetstat.TcpExt.TCPRenoRecoveryFail = value + procNetstat.TcpExt.TCPRenoRecoveryFail = &value case "TCPSackRecoveryFail": - procNetstat.TcpExt.TCPSackRecoveryFail = value + procNetstat.TcpExt.TCPSackRecoveryFail = &value case "TCPRcvCollapsed": - procNetstat.TcpExt.TCPRcvCollapsed = value + procNetstat.TcpExt.TCPRcvCollapsed = &value case "TCPDSACKOldSent": - procNetstat.TcpExt.TCPDSACKOldSent = value + procNetstat.TcpExt.TCPDSACKOldSent = &value case "TCPDSACKOfoSent": - procNetstat.TcpExt.TCPDSACKOfoSent = value + procNetstat.TcpExt.TCPDSACKOfoSent = &value case "TCPDSACKRecv": - procNetstat.TcpExt.TCPDSACKRecv = value + procNetstat.TcpExt.TCPDSACKRecv = &value case "TCPDSACKOfoRecv": - procNetstat.TcpExt.TCPDSACKOfoRecv = value + procNetstat.TcpExt.TCPDSACKOfoRecv = &value case "TCPAbortOnData": - procNetstat.TcpExt.TCPAbortOnData = value + procNetstat.TcpExt.TCPAbortOnData = &value case "TCPAbortOnClose": - procNetstat.TcpExt.TCPAbortOnClose = value + procNetstat.TcpExt.TCPAbortOnClose = &value case "TCPDeferAcceptDrop": - procNetstat.TcpExt.TCPDeferAcceptDrop = value + procNetstat.TcpExt.TCPDeferAcceptDrop = &value case "IPReversePathFilter": - procNetstat.TcpExt.IPReversePathFilter = value + procNetstat.TcpExt.IPReversePathFilter = &value case "TCPTimeWaitOverflow": - procNetstat.TcpExt.TCPTimeWaitOverflow = value + procNetstat.TcpExt.TCPTimeWaitOverflow = &value case "TCPReqQFullDoCookies": - procNetstat.TcpExt.TCPReqQFullDoCookies = value + procNetstat.TcpExt.TCPReqQFullDoCookies = &value case "TCPReqQFullDrop": - procNetstat.TcpExt.TCPReqQFullDrop = value + procNetstat.TcpExt.TCPReqQFullDrop = &value case "TCPRetransFail": - procNetstat.TcpExt.TCPRetransFail = value + procNetstat.TcpExt.TCPRetransFail = &value case "TCPRcvCoalesce": - procNetstat.TcpExt.TCPRcvCoalesce = value + procNetstat.TcpExt.TCPRcvCoalesce = &value + case "TCPRcvQDrop": + procNetstat.TcpExt.TCPRcvQDrop = &value case "TCPOFOQueue": - procNetstat.TcpExt.TCPOFOQueue = value + procNetstat.TcpExt.TCPOFOQueue = &value case "TCPOFODrop": - procNetstat.TcpExt.TCPOFODrop = value + procNetstat.TcpExt.TCPOFODrop = &value case "TCPOFOMerge": - procNetstat.TcpExt.TCPOFOMerge = value + procNetstat.TcpExt.TCPOFOMerge = &value case "TCPChallengeACK": - procNetstat.TcpExt.TCPChallengeACK = value + procNetstat.TcpExt.TCPChallengeACK = &value case "TCPSYNChallenge": - procNetstat.TcpExt.TCPSYNChallenge = value + procNetstat.TcpExt.TCPSYNChallenge = &value case "TCPFastOpenActive": - procNetstat.TcpExt.TCPFastOpenActive = value + procNetstat.TcpExt.TCPFastOpenActive = &value case "TCPFastOpenActiveFail": - procNetstat.TcpExt.TCPFastOpenActiveFail = value + procNetstat.TcpExt.TCPFastOpenActiveFail = &value case "TCPFastOpenPassive": - procNetstat.TcpExt.TCPFastOpenPassive = value + procNetstat.TcpExt.TCPFastOpenPassive = &value case "TCPFastOpenPassiveFail": - procNetstat.TcpExt.TCPFastOpenPassiveFail = value + procNetstat.TcpExt.TCPFastOpenPassiveFail = &value case "TCPFastOpenListenOverflow": - procNetstat.TcpExt.TCPFastOpenListenOverflow = value + procNetstat.TcpExt.TCPFastOpenListenOverflow = &value case "TCPFastOpenCookieReqd": - procNetstat.TcpExt.TCPFastOpenCookieReqd = value + procNetstat.TcpExt.TCPFastOpenCookieReqd = &value case "TCPFastOpenBlackhole": - procNetstat.TcpExt.TCPFastOpenBlackhole = value + procNetstat.TcpExt.TCPFastOpenBlackhole = &value case "TCPSpuriousRtxHostQueues": - procNetstat.TcpExt.TCPSpuriousRtxHostQueues = value + procNetstat.TcpExt.TCPSpuriousRtxHostQueues = &value case "BusyPollRxPackets": - procNetstat.TcpExt.BusyPollRxPackets = value + procNetstat.TcpExt.BusyPollRxPackets = &value case "TCPAutoCorking": - procNetstat.TcpExt.TCPAutoCorking = value + procNetstat.TcpExt.TCPAutoCorking = &value case "TCPFromZeroWindowAdv": - procNetstat.TcpExt.TCPFromZeroWindowAdv = value + procNetstat.TcpExt.TCPFromZeroWindowAdv = &value case "TCPToZeroWindowAdv": - procNetstat.TcpExt.TCPToZeroWindowAdv = value + procNetstat.TcpExt.TCPToZeroWindowAdv = &value case "TCPWantZeroWindowAdv": - procNetstat.TcpExt.TCPWantZeroWindowAdv = value + procNetstat.TcpExt.TCPWantZeroWindowAdv = &value case "TCPSynRetrans": - procNetstat.TcpExt.TCPSynRetrans = value + procNetstat.TcpExt.TCPSynRetrans = &value case "TCPOrigDataSent": - procNetstat.TcpExt.TCPOrigDataSent = value + procNetstat.TcpExt.TCPOrigDataSent = &value case "TCPHystartTrainDetect": - procNetstat.TcpExt.TCPHystartTrainDetect = value + procNetstat.TcpExt.TCPHystartTrainDetect = &value case "TCPHystartTrainCwnd": - procNetstat.TcpExt.TCPHystartTrainCwnd = value + procNetstat.TcpExt.TCPHystartTrainCwnd = &value case "TCPHystartDelayDetect": - procNetstat.TcpExt.TCPHystartDelayDetect = value + procNetstat.TcpExt.TCPHystartDelayDetect = &value case "TCPHystartDelayCwnd": - procNetstat.TcpExt.TCPHystartDelayCwnd = value + procNetstat.TcpExt.TCPHystartDelayCwnd = &value case "TCPACKSkippedSynRecv": - procNetstat.TcpExt.TCPACKSkippedSynRecv = value + procNetstat.TcpExt.TCPACKSkippedSynRecv = &value case "TCPACKSkippedPAWS": - procNetstat.TcpExt.TCPACKSkippedPAWS = value + procNetstat.TcpExt.TCPACKSkippedPAWS = &value case "TCPACKSkippedSeq": - procNetstat.TcpExt.TCPACKSkippedSeq = value + procNetstat.TcpExt.TCPACKSkippedSeq = &value case "TCPACKSkippedFinWait2": - procNetstat.TcpExt.TCPACKSkippedFinWait2 = value + procNetstat.TcpExt.TCPACKSkippedFinWait2 = &value case "TCPACKSkippedTimeWait": - procNetstat.TcpExt.TCPACKSkippedTimeWait = value + procNetstat.TcpExt.TCPACKSkippedTimeWait = &value case "TCPACKSkippedChallenge": - procNetstat.TcpExt.TCPACKSkippedChallenge = value + procNetstat.TcpExt.TCPACKSkippedChallenge = &value case "TCPWinProbe": - procNetstat.TcpExt.TCPWinProbe = value + procNetstat.TcpExt.TCPWinProbe = &value case "TCPKeepAlive": - procNetstat.TcpExt.TCPKeepAlive = value + procNetstat.TcpExt.TCPKeepAlive = &value case "TCPMTUPFail": - procNetstat.TcpExt.TCPMTUPFail = value + procNetstat.TcpExt.TCPMTUPFail = &value case "TCPMTUPSuccess": - procNetstat.TcpExt.TCPMTUPSuccess = value + procNetstat.TcpExt.TCPMTUPSuccess = &value case "TCPWqueueTooBig": - procNetstat.TcpExt.TCPWqueueTooBig = value + procNetstat.TcpExt.TCPWqueueTooBig = &value } case "IpExt": switch key { case "InNoRoutes": - procNetstat.IpExt.InNoRoutes = value + procNetstat.IpExt.InNoRoutes = &value case "InTruncatedPkts": - procNetstat.IpExt.InTruncatedPkts = value + procNetstat.IpExt.InTruncatedPkts = &value case "InMcastPkts": - procNetstat.IpExt.InMcastPkts = value + procNetstat.IpExt.InMcastPkts = &value case "OutMcastPkts": - procNetstat.IpExt.OutMcastPkts = value + procNetstat.IpExt.OutMcastPkts = &value case "InBcastPkts": - procNetstat.IpExt.InBcastPkts = value + procNetstat.IpExt.InBcastPkts = &value case "OutBcastPkts": - procNetstat.IpExt.OutBcastPkts = value + procNetstat.IpExt.OutBcastPkts = &value case "InOctets": - procNetstat.IpExt.InOctets = value + procNetstat.IpExt.InOctets = &value case "OutOctets": - procNetstat.IpExt.OutOctets = value + procNetstat.IpExt.OutOctets = &value case "InMcastOctets": - procNetstat.IpExt.InMcastOctets = value + procNetstat.IpExt.InMcastOctets = &value case "OutMcastOctets": - procNetstat.IpExt.OutMcastOctets = value + procNetstat.IpExt.OutMcastOctets = &value case "InBcastOctets": - procNetstat.IpExt.InBcastOctets = value + procNetstat.IpExt.InBcastOctets = &value case "OutBcastOctets": - procNetstat.IpExt.OutBcastOctets = value + procNetstat.IpExt.OutBcastOctets = &value case "InCsumErrors": - procNetstat.IpExt.InCsumErrors = value + procNetstat.IpExt.InCsumErrors = &value case "InNoECTPkts": - procNetstat.IpExt.InNoECTPkts = value + procNetstat.IpExt.InNoECTPkts = &value case "InECT1Pkts": - procNetstat.IpExt.InECT1Pkts = value + procNetstat.IpExt.InECT1Pkts = &value case "InECT0Pkts": - procNetstat.IpExt.InECT0Pkts = value + procNetstat.IpExt.InECT0Pkts = &value case "InCEPkts": - procNetstat.IpExt.InCEPkts = value + procNetstat.IpExt.InCEPkts = &value case "ReasmOverlaps": - procNetstat.IpExt.ReasmOverlaps = value + procNetstat.IpExt.ReasmOverlaps = &value } } } diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_ns.go b/test/integration/vendor/github.com/prometheus/procfs/proc_ns.go index 391b4cbd1..c22666750 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_ns.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_ns.go @@ -40,7 +40,7 @@ func (p Proc) Namespaces() (Namespaces, error) { names, err := d.Readdirnames(-1) if err != nil { - return nil, fmt.Errorf("failed to read contents of ns dir: %w", err) + return nil, fmt.Errorf("%s: failed to read contents of ns dir: %w", ErrFileRead, err) } ns := make(Namespaces, len(names)) @@ -52,13 +52,13 @@ func (p Proc) Namespaces() (Namespaces, error) { fields := strings.SplitN(target, ":", 2) if len(fields) != 2 { - return nil, fmt.Errorf("failed to parse namespace type and inode from %q", target) + return nil, fmt.Errorf("%w: namespace type and inode from %q", ErrFileParse, target) } typ := fields[0] inode, err := strconv.ParseUint(strings.Trim(fields[1], "[]"), 10, 32) if err != nil { - return nil, fmt.Errorf("failed to parse inode from %q: %w", fields[1], err) + return nil, fmt.Errorf("%s: inode from %q: %w", ErrFileParse, fields[1], err) } ns[name] = Namespace{typ, uint32(inode)} diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_psi.go b/test/integration/vendor/github.com/prometheus/procfs/proc_psi.go index a68fe1529..152539d35 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_psi.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_psi.go @@ -61,7 +61,7 @@ type PSIStats struct { func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) { data, err := util.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource))) if err != nil { - return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %q: %w", resource, err) + return PSIStats{}, fmt.Errorf("%s: psi_stats: unavailable for %q: %w", ErrFileRead, resource, err) } return parsePSIStats(resource, bytes.NewReader(data)) diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_snmp.go b/test/integration/vendor/github.com/prometheus/procfs/proc_snmp.go index ae191896c..b9d2cf642 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_snmp.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_snmp.go @@ -37,100 +37,100 @@ type ProcSnmp struct { } type Ip struct { // nolint:revive - Forwarding float64 - DefaultTTL float64 - InReceives float64 - InHdrErrors float64 - InAddrErrors float64 - ForwDatagrams float64 - InUnknownProtos float64 - InDiscards float64 - InDelivers float64 - OutRequests float64 - OutDiscards float64 - OutNoRoutes float64 - ReasmTimeout float64 - ReasmReqds float64 - ReasmOKs float64 - ReasmFails float64 - FragOKs float64 - FragFails float64 - FragCreates float64 + Forwarding *float64 + DefaultTTL *float64 + InReceives *float64 + InHdrErrors *float64 + InAddrErrors *float64 + ForwDatagrams *float64 + InUnknownProtos *float64 + InDiscards *float64 + InDelivers *float64 + OutRequests *float64 + OutDiscards *float64 + OutNoRoutes *float64 + ReasmTimeout *float64 + ReasmReqds *float64 + ReasmOKs *float64 + ReasmFails *float64 + FragOKs *float64 + FragFails *float64 + FragCreates *float64 } -type Icmp struct { - InMsgs float64 - InErrors float64 - InCsumErrors float64 - InDestUnreachs float64 - InTimeExcds float64 - InParmProbs float64 - InSrcQuenchs float64 - InRedirects float64 - InEchos float64 - InEchoReps float64 - InTimestamps float64 - InTimestampReps float64 - InAddrMasks float64 - InAddrMaskReps float64 - OutMsgs float64 - OutErrors float64 - OutDestUnreachs float64 - OutTimeExcds float64 - OutParmProbs float64 - OutSrcQuenchs float64 - OutRedirects float64 - OutEchos float64 - OutEchoReps float64 - OutTimestamps float64 - OutTimestampReps float64 - OutAddrMasks float64 - OutAddrMaskReps float64 +type Icmp struct { // nolint:revive + InMsgs *float64 + InErrors *float64 + InCsumErrors *float64 + InDestUnreachs *float64 + InTimeExcds *float64 + InParmProbs *float64 + InSrcQuenchs *float64 + InRedirects *float64 + InEchos *float64 + InEchoReps *float64 + InTimestamps *float64 + InTimestampReps *float64 + InAddrMasks *float64 + InAddrMaskReps *float64 + OutMsgs *float64 + OutErrors *float64 + OutDestUnreachs *float64 + OutTimeExcds *float64 + OutParmProbs *float64 + OutSrcQuenchs *float64 + OutRedirects *float64 + OutEchos *float64 + OutEchoReps *float64 + OutTimestamps *float64 + OutTimestampReps *float64 + OutAddrMasks *float64 + OutAddrMaskReps *float64 } type IcmpMsg struct { - InType3 float64 - OutType3 float64 + InType3 *float64 + OutType3 *float64 } type Tcp struct { // nolint:revive - RtoAlgorithm float64 - RtoMin float64 - RtoMax float64 - MaxConn float64 - ActiveOpens float64 - PassiveOpens float64 - AttemptFails float64 - EstabResets float64 - CurrEstab float64 - InSegs float64 - OutSegs float64 - RetransSegs float64 - InErrs float64 - OutRsts float64 - InCsumErrors float64 + RtoAlgorithm *float64 + RtoMin *float64 + RtoMax *float64 + MaxConn *float64 + ActiveOpens *float64 + PassiveOpens *float64 + AttemptFails *float64 + EstabResets *float64 + CurrEstab *float64 + InSegs *float64 + OutSegs *float64 + RetransSegs *float64 + InErrs *float64 + OutRsts *float64 + InCsumErrors *float64 } type Udp struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 - IgnoredMulti float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 + IgnoredMulti *float64 } type UdpLite struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 - IgnoredMulti float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 + IgnoredMulti *float64 } func (p Proc) Snmp() (ProcSnmp, error) { @@ -159,8 +159,8 @@ func parseSnmp(r io.Reader, fileName string) (ProcSnmp, error) { // Remove trailing :. protocol := strings.TrimSuffix(nameParts[0], ":") if len(nameParts) != len(valueParts) { - return procSnmp, fmt.Errorf("mismatch field count mismatch in %s: %s", - fileName, protocol) + return procSnmp, fmt.Errorf("%w: mismatch field count mismatch in %s: %s", + ErrFileParse, fileName, protocol) } for i := 1; i < len(nameParts); i++ { value, err := strconv.ParseFloat(valueParts[i], 64) @@ -173,178 +173,178 @@ func parseSnmp(r io.Reader, fileName string) (ProcSnmp, error) { case "Ip": switch key { case "Forwarding": - procSnmp.Ip.Forwarding = value + procSnmp.Ip.Forwarding = &value case "DefaultTTL": - procSnmp.Ip.DefaultTTL = value + procSnmp.Ip.DefaultTTL = &value case "InReceives": - procSnmp.Ip.InReceives = value + procSnmp.Ip.InReceives = &value case "InHdrErrors": - procSnmp.Ip.InHdrErrors = value + procSnmp.Ip.InHdrErrors = &value case "InAddrErrors": - procSnmp.Ip.InAddrErrors = value + procSnmp.Ip.InAddrErrors = &value case "ForwDatagrams": - procSnmp.Ip.ForwDatagrams = value + procSnmp.Ip.ForwDatagrams = &value case "InUnknownProtos": - procSnmp.Ip.InUnknownProtos = value + procSnmp.Ip.InUnknownProtos = &value case "InDiscards": - procSnmp.Ip.InDiscards = value + procSnmp.Ip.InDiscards = &value case "InDelivers": - procSnmp.Ip.InDelivers = value + procSnmp.Ip.InDelivers = &value case "OutRequests": - procSnmp.Ip.OutRequests = value + procSnmp.Ip.OutRequests = &value case "OutDiscards": - procSnmp.Ip.OutDiscards = value + procSnmp.Ip.OutDiscards = &value case "OutNoRoutes": - procSnmp.Ip.OutNoRoutes = value + procSnmp.Ip.OutNoRoutes = &value case "ReasmTimeout": - procSnmp.Ip.ReasmTimeout = value + procSnmp.Ip.ReasmTimeout = &value case "ReasmReqds": - procSnmp.Ip.ReasmReqds = value + procSnmp.Ip.ReasmReqds = &value case "ReasmOKs": - procSnmp.Ip.ReasmOKs = value + procSnmp.Ip.ReasmOKs = &value case "ReasmFails": - procSnmp.Ip.ReasmFails = value + procSnmp.Ip.ReasmFails = &value case "FragOKs": - procSnmp.Ip.FragOKs = value + procSnmp.Ip.FragOKs = &value case "FragFails": - procSnmp.Ip.FragFails = value + procSnmp.Ip.FragFails = &value case "FragCreates": - procSnmp.Ip.FragCreates = value + procSnmp.Ip.FragCreates = &value } case "Icmp": switch key { case "InMsgs": - procSnmp.Icmp.InMsgs = value + procSnmp.Icmp.InMsgs = &value case "InErrors": - procSnmp.Icmp.InErrors = value + procSnmp.Icmp.InErrors = &value case "InCsumErrors": - procSnmp.Icmp.InCsumErrors = value + procSnmp.Icmp.InCsumErrors = &value case "InDestUnreachs": - procSnmp.Icmp.InDestUnreachs = value + procSnmp.Icmp.InDestUnreachs = &value case "InTimeExcds": - procSnmp.Icmp.InTimeExcds = value + procSnmp.Icmp.InTimeExcds = &value case "InParmProbs": - procSnmp.Icmp.InParmProbs = value + procSnmp.Icmp.InParmProbs = &value case "InSrcQuenchs": - procSnmp.Icmp.InSrcQuenchs = value + procSnmp.Icmp.InSrcQuenchs = &value case "InRedirects": - procSnmp.Icmp.InRedirects = value + procSnmp.Icmp.InRedirects = &value case "InEchos": - procSnmp.Icmp.InEchos = value + procSnmp.Icmp.InEchos = &value case "InEchoReps": - procSnmp.Icmp.InEchoReps = value + procSnmp.Icmp.InEchoReps = &value case "InTimestamps": - procSnmp.Icmp.InTimestamps = value + procSnmp.Icmp.InTimestamps = &value case "InTimestampReps": - procSnmp.Icmp.InTimestampReps = value + procSnmp.Icmp.InTimestampReps = &value case "InAddrMasks": - procSnmp.Icmp.InAddrMasks = value + procSnmp.Icmp.InAddrMasks = &value case "InAddrMaskReps": - procSnmp.Icmp.InAddrMaskReps = value + procSnmp.Icmp.InAddrMaskReps = &value case "OutMsgs": - procSnmp.Icmp.OutMsgs = value + procSnmp.Icmp.OutMsgs = &value case "OutErrors": - procSnmp.Icmp.OutErrors = value + procSnmp.Icmp.OutErrors = &value case "OutDestUnreachs": - procSnmp.Icmp.OutDestUnreachs = value + procSnmp.Icmp.OutDestUnreachs = &value case "OutTimeExcds": - procSnmp.Icmp.OutTimeExcds = value + procSnmp.Icmp.OutTimeExcds = &value case "OutParmProbs": - procSnmp.Icmp.OutParmProbs = value + procSnmp.Icmp.OutParmProbs = &value case "OutSrcQuenchs": - procSnmp.Icmp.OutSrcQuenchs = value + procSnmp.Icmp.OutSrcQuenchs = &value case "OutRedirects": - procSnmp.Icmp.OutRedirects = value + procSnmp.Icmp.OutRedirects = &value case "OutEchos": - procSnmp.Icmp.OutEchos = value + procSnmp.Icmp.OutEchos = &value case "OutEchoReps": - procSnmp.Icmp.OutEchoReps = value + procSnmp.Icmp.OutEchoReps = &value case "OutTimestamps": - procSnmp.Icmp.OutTimestamps = value + procSnmp.Icmp.OutTimestamps = &value case "OutTimestampReps": - procSnmp.Icmp.OutTimestampReps = value + procSnmp.Icmp.OutTimestampReps = &value case "OutAddrMasks": - procSnmp.Icmp.OutAddrMasks = value + procSnmp.Icmp.OutAddrMasks = &value case "OutAddrMaskReps": - procSnmp.Icmp.OutAddrMaskReps = value + procSnmp.Icmp.OutAddrMaskReps = &value } case "IcmpMsg": switch key { case "InType3": - procSnmp.IcmpMsg.InType3 = value + procSnmp.IcmpMsg.InType3 = &value case "OutType3": - procSnmp.IcmpMsg.OutType3 = value + procSnmp.IcmpMsg.OutType3 = &value } case "Tcp": switch key { case "RtoAlgorithm": - procSnmp.Tcp.RtoAlgorithm = value + procSnmp.Tcp.RtoAlgorithm = &value case "RtoMin": - procSnmp.Tcp.RtoMin = value + procSnmp.Tcp.RtoMin = &value case "RtoMax": - procSnmp.Tcp.RtoMax = value + procSnmp.Tcp.RtoMax = &value case "MaxConn": - procSnmp.Tcp.MaxConn = value + procSnmp.Tcp.MaxConn = &value case "ActiveOpens": - procSnmp.Tcp.ActiveOpens = value + procSnmp.Tcp.ActiveOpens = &value case "PassiveOpens": - procSnmp.Tcp.PassiveOpens = value + procSnmp.Tcp.PassiveOpens = &value case "AttemptFails": - procSnmp.Tcp.AttemptFails = value + procSnmp.Tcp.AttemptFails = &value case "EstabResets": - procSnmp.Tcp.EstabResets = value + procSnmp.Tcp.EstabResets = &value case "CurrEstab": - procSnmp.Tcp.CurrEstab = value + procSnmp.Tcp.CurrEstab = &value case "InSegs": - procSnmp.Tcp.InSegs = value + procSnmp.Tcp.InSegs = &value case "OutSegs": - procSnmp.Tcp.OutSegs = value + procSnmp.Tcp.OutSegs = &value case "RetransSegs": - procSnmp.Tcp.RetransSegs = value + procSnmp.Tcp.RetransSegs = &value case "InErrs": - procSnmp.Tcp.InErrs = value + procSnmp.Tcp.InErrs = &value case "OutRsts": - procSnmp.Tcp.OutRsts = value + procSnmp.Tcp.OutRsts = &value case "InCsumErrors": - procSnmp.Tcp.InCsumErrors = value + procSnmp.Tcp.InCsumErrors = &value } case "Udp": switch key { case "InDatagrams": - procSnmp.Udp.InDatagrams = value + procSnmp.Udp.InDatagrams = &value case "NoPorts": - procSnmp.Udp.NoPorts = value + procSnmp.Udp.NoPorts = &value case "InErrors": - procSnmp.Udp.InErrors = value + procSnmp.Udp.InErrors = &value case "OutDatagrams": - procSnmp.Udp.OutDatagrams = value + procSnmp.Udp.OutDatagrams = &value case "RcvbufErrors": - procSnmp.Udp.RcvbufErrors = value + procSnmp.Udp.RcvbufErrors = &value case "SndbufErrors": - procSnmp.Udp.SndbufErrors = value + procSnmp.Udp.SndbufErrors = &value case "InCsumErrors": - procSnmp.Udp.InCsumErrors = value + procSnmp.Udp.InCsumErrors = &value case "IgnoredMulti": - procSnmp.Udp.IgnoredMulti = value + procSnmp.Udp.IgnoredMulti = &value } case "UdpLite": switch key { case "InDatagrams": - procSnmp.UdpLite.InDatagrams = value + procSnmp.UdpLite.InDatagrams = &value case "NoPorts": - procSnmp.UdpLite.NoPorts = value + procSnmp.UdpLite.NoPorts = &value case "InErrors": - procSnmp.UdpLite.InErrors = value + procSnmp.UdpLite.InErrors = &value case "OutDatagrams": - procSnmp.UdpLite.OutDatagrams = value + procSnmp.UdpLite.OutDatagrams = &value case "RcvbufErrors": - procSnmp.UdpLite.RcvbufErrors = value + procSnmp.UdpLite.RcvbufErrors = &value case "SndbufErrors": - procSnmp.UdpLite.SndbufErrors = value + procSnmp.UdpLite.SndbufErrors = &value case "InCsumErrors": - procSnmp.UdpLite.InCsumErrors = value + procSnmp.UdpLite.InCsumErrors = &value case "IgnoredMulti": - procSnmp.UdpLite.IgnoredMulti = value + procSnmp.UdpLite.IgnoredMulti = &value } } } diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_snmp6.go b/test/integration/vendor/github.com/prometheus/procfs/proc_snmp6.go index f611992d5..3059cc6a1 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_snmp6.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_snmp6.go @@ -36,106 +36,106 @@ type ProcSnmp6 struct { } type Ip6 struct { // nolint:revive - InReceives float64 - InHdrErrors float64 - InTooBigErrors float64 - InNoRoutes float64 - InAddrErrors float64 - InUnknownProtos float64 - InTruncatedPkts float64 - InDiscards float64 - InDelivers float64 - OutForwDatagrams float64 - OutRequests float64 - OutDiscards float64 - OutNoRoutes float64 - ReasmTimeout float64 - ReasmReqds float64 - ReasmOKs float64 - ReasmFails float64 - FragOKs float64 - FragFails float64 - FragCreates float64 - InMcastPkts float64 - OutMcastPkts float64 - InOctets float64 - OutOctets float64 - InMcastOctets float64 - OutMcastOctets float64 - InBcastOctets float64 - OutBcastOctets float64 - InNoECTPkts float64 - InECT1Pkts float64 - InECT0Pkts float64 - InCEPkts float64 + InReceives *float64 + InHdrErrors *float64 + InTooBigErrors *float64 + InNoRoutes *float64 + InAddrErrors *float64 + InUnknownProtos *float64 + InTruncatedPkts *float64 + InDiscards *float64 + InDelivers *float64 + OutForwDatagrams *float64 + OutRequests *float64 + OutDiscards *float64 + OutNoRoutes *float64 + ReasmTimeout *float64 + ReasmReqds *float64 + ReasmOKs *float64 + ReasmFails *float64 + FragOKs *float64 + FragFails *float64 + FragCreates *float64 + InMcastPkts *float64 + OutMcastPkts *float64 + InOctets *float64 + OutOctets *float64 + InMcastOctets *float64 + OutMcastOctets *float64 + InBcastOctets *float64 + OutBcastOctets *float64 + InNoECTPkts *float64 + InECT1Pkts *float64 + InECT0Pkts *float64 + InCEPkts *float64 } type Icmp6 struct { - InMsgs float64 - InErrors float64 - OutMsgs float64 - OutErrors float64 - InCsumErrors float64 - InDestUnreachs float64 - InPktTooBigs float64 - InTimeExcds float64 - InParmProblems float64 - InEchos float64 - InEchoReplies float64 - InGroupMembQueries float64 - InGroupMembResponses float64 - InGroupMembReductions float64 - InRouterSolicits float64 - InRouterAdvertisements float64 - InNeighborSolicits float64 - InNeighborAdvertisements float64 - InRedirects float64 - InMLDv2Reports float64 - OutDestUnreachs float64 - OutPktTooBigs float64 - OutTimeExcds float64 - OutParmProblems float64 - OutEchos float64 - OutEchoReplies float64 - OutGroupMembQueries float64 - OutGroupMembResponses float64 - OutGroupMembReductions float64 - OutRouterSolicits float64 - OutRouterAdvertisements float64 - OutNeighborSolicits float64 - OutNeighborAdvertisements float64 - OutRedirects float64 - OutMLDv2Reports float64 - InType1 float64 - InType134 float64 - InType135 float64 - InType136 float64 - InType143 float64 - OutType133 float64 - OutType135 float64 - OutType136 float64 - OutType143 float64 + InMsgs *float64 + InErrors *float64 + OutMsgs *float64 + OutErrors *float64 + InCsumErrors *float64 + InDestUnreachs *float64 + InPktTooBigs *float64 + InTimeExcds *float64 + InParmProblems *float64 + InEchos *float64 + InEchoReplies *float64 + InGroupMembQueries *float64 + InGroupMembResponses *float64 + InGroupMembReductions *float64 + InRouterSolicits *float64 + InRouterAdvertisements *float64 + InNeighborSolicits *float64 + InNeighborAdvertisements *float64 + InRedirects *float64 + InMLDv2Reports *float64 + OutDestUnreachs *float64 + OutPktTooBigs *float64 + OutTimeExcds *float64 + OutParmProblems *float64 + OutEchos *float64 + OutEchoReplies *float64 + OutGroupMembQueries *float64 + OutGroupMembResponses *float64 + OutGroupMembReductions *float64 + OutRouterSolicits *float64 + OutRouterAdvertisements *float64 + OutNeighborSolicits *float64 + OutNeighborAdvertisements *float64 + OutRedirects *float64 + OutMLDv2Reports *float64 + InType1 *float64 + InType134 *float64 + InType135 *float64 + InType136 *float64 + InType143 *float64 + OutType133 *float64 + OutType135 *float64 + OutType136 *float64 + OutType143 *float64 } type Udp6 struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 - IgnoredMulti float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 + IgnoredMulti *float64 } type UdpLite6 struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 } func (p Proc) Snmp6() (ProcSnmp6, error) { @@ -182,197 +182,197 @@ func parseSNMP6Stats(r io.Reader) (ProcSnmp6, error) { case "Ip6": switch key { case "InReceives": - procSnmp6.Ip6.InReceives = value + procSnmp6.Ip6.InReceives = &value case "InHdrErrors": - procSnmp6.Ip6.InHdrErrors = value + procSnmp6.Ip6.InHdrErrors = &value case "InTooBigErrors": - procSnmp6.Ip6.InTooBigErrors = value + procSnmp6.Ip6.InTooBigErrors = &value case "InNoRoutes": - procSnmp6.Ip6.InNoRoutes = value + procSnmp6.Ip6.InNoRoutes = &value case "InAddrErrors": - procSnmp6.Ip6.InAddrErrors = value + procSnmp6.Ip6.InAddrErrors = &value case "InUnknownProtos": - procSnmp6.Ip6.InUnknownProtos = value + procSnmp6.Ip6.InUnknownProtos = &value case "InTruncatedPkts": - procSnmp6.Ip6.InTruncatedPkts = value + procSnmp6.Ip6.InTruncatedPkts = &value case "InDiscards": - procSnmp6.Ip6.InDiscards = value + procSnmp6.Ip6.InDiscards = &value case "InDelivers": - procSnmp6.Ip6.InDelivers = value + procSnmp6.Ip6.InDelivers = &value case "OutForwDatagrams": - procSnmp6.Ip6.OutForwDatagrams = value + procSnmp6.Ip6.OutForwDatagrams = &value case "OutRequests": - procSnmp6.Ip6.OutRequests = value + procSnmp6.Ip6.OutRequests = &value case "OutDiscards": - procSnmp6.Ip6.OutDiscards = value + procSnmp6.Ip6.OutDiscards = &value case "OutNoRoutes": - procSnmp6.Ip6.OutNoRoutes = value + procSnmp6.Ip6.OutNoRoutes = &value case "ReasmTimeout": - procSnmp6.Ip6.ReasmTimeout = value + procSnmp6.Ip6.ReasmTimeout = &value case "ReasmReqds": - procSnmp6.Ip6.ReasmReqds = value + procSnmp6.Ip6.ReasmReqds = &value case "ReasmOKs": - procSnmp6.Ip6.ReasmOKs = value + procSnmp6.Ip6.ReasmOKs = &value case "ReasmFails": - procSnmp6.Ip6.ReasmFails = value + procSnmp6.Ip6.ReasmFails = &value case "FragOKs": - procSnmp6.Ip6.FragOKs = value + procSnmp6.Ip6.FragOKs = &value case "FragFails": - procSnmp6.Ip6.FragFails = value + procSnmp6.Ip6.FragFails = &value case "FragCreates": - procSnmp6.Ip6.FragCreates = value + procSnmp6.Ip6.FragCreates = &value case "InMcastPkts": - procSnmp6.Ip6.InMcastPkts = value + procSnmp6.Ip6.InMcastPkts = &value case "OutMcastPkts": - procSnmp6.Ip6.OutMcastPkts = value + procSnmp6.Ip6.OutMcastPkts = &value case "InOctets": - procSnmp6.Ip6.InOctets = value + procSnmp6.Ip6.InOctets = &value case "OutOctets": - procSnmp6.Ip6.OutOctets = value + procSnmp6.Ip6.OutOctets = &value case "InMcastOctets": - procSnmp6.Ip6.InMcastOctets = value + procSnmp6.Ip6.InMcastOctets = &value case "OutMcastOctets": - procSnmp6.Ip6.OutMcastOctets = value + procSnmp6.Ip6.OutMcastOctets = &value case "InBcastOctets": - procSnmp6.Ip6.InBcastOctets = value + procSnmp6.Ip6.InBcastOctets = &value case "OutBcastOctets": - procSnmp6.Ip6.OutBcastOctets = value + procSnmp6.Ip6.OutBcastOctets = &value case "InNoECTPkts": - procSnmp6.Ip6.InNoECTPkts = value + procSnmp6.Ip6.InNoECTPkts = &value case "InECT1Pkts": - procSnmp6.Ip6.InECT1Pkts = value + procSnmp6.Ip6.InECT1Pkts = &value case "InECT0Pkts": - procSnmp6.Ip6.InECT0Pkts = value + procSnmp6.Ip6.InECT0Pkts = &value case "InCEPkts": - procSnmp6.Ip6.InCEPkts = value + procSnmp6.Ip6.InCEPkts = &value } case "Icmp6": switch key { case "InMsgs": - procSnmp6.Icmp6.InMsgs = value + procSnmp6.Icmp6.InMsgs = &value case "InErrors": - procSnmp6.Icmp6.InErrors = value + procSnmp6.Icmp6.InErrors = &value case "OutMsgs": - procSnmp6.Icmp6.OutMsgs = value + procSnmp6.Icmp6.OutMsgs = &value case "OutErrors": - procSnmp6.Icmp6.OutErrors = value + procSnmp6.Icmp6.OutErrors = &value case "InCsumErrors": - procSnmp6.Icmp6.InCsumErrors = value + procSnmp6.Icmp6.InCsumErrors = &value case "InDestUnreachs": - procSnmp6.Icmp6.InDestUnreachs = value + procSnmp6.Icmp6.InDestUnreachs = &value case "InPktTooBigs": - procSnmp6.Icmp6.InPktTooBigs = value + procSnmp6.Icmp6.InPktTooBigs = &value case "InTimeExcds": - procSnmp6.Icmp6.InTimeExcds = value + procSnmp6.Icmp6.InTimeExcds = &value case "InParmProblems": - procSnmp6.Icmp6.InParmProblems = value + procSnmp6.Icmp6.InParmProblems = &value case "InEchos": - procSnmp6.Icmp6.InEchos = value + procSnmp6.Icmp6.InEchos = &value case "InEchoReplies": - procSnmp6.Icmp6.InEchoReplies = value + procSnmp6.Icmp6.InEchoReplies = &value case "InGroupMembQueries": - procSnmp6.Icmp6.InGroupMembQueries = value + procSnmp6.Icmp6.InGroupMembQueries = &value case "InGroupMembResponses": - procSnmp6.Icmp6.InGroupMembResponses = value + procSnmp6.Icmp6.InGroupMembResponses = &value case "InGroupMembReductions": - procSnmp6.Icmp6.InGroupMembReductions = value + procSnmp6.Icmp6.InGroupMembReductions = &value case "InRouterSolicits": - procSnmp6.Icmp6.InRouterSolicits = value + procSnmp6.Icmp6.InRouterSolicits = &value case "InRouterAdvertisements": - procSnmp6.Icmp6.InRouterAdvertisements = value + procSnmp6.Icmp6.InRouterAdvertisements = &value case "InNeighborSolicits": - procSnmp6.Icmp6.InNeighborSolicits = value + procSnmp6.Icmp6.InNeighborSolicits = &value case "InNeighborAdvertisements": - procSnmp6.Icmp6.InNeighborAdvertisements = value + procSnmp6.Icmp6.InNeighborAdvertisements = &value case "InRedirects": - procSnmp6.Icmp6.InRedirects = value + procSnmp6.Icmp6.InRedirects = &value case "InMLDv2Reports": - procSnmp6.Icmp6.InMLDv2Reports = value + procSnmp6.Icmp6.InMLDv2Reports = &value case "OutDestUnreachs": - procSnmp6.Icmp6.OutDestUnreachs = value + procSnmp6.Icmp6.OutDestUnreachs = &value case "OutPktTooBigs": - procSnmp6.Icmp6.OutPktTooBigs = value + procSnmp6.Icmp6.OutPktTooBigs = &value case "OutTimeExcds": - procSnmp6.Icmp6.OutTimeExcds = value + procSnmp6.Icmp6.OutTimeExcds = &value case "OutParmProblems": - procSnmp6.Icmp6.OutParmProblems = value + procSnmp6.Icmp6.OutParmProblems = &value case "OutEchos": - procSnmp6.Icmp6.OutEchos = value + procSnmp6.Icmp6.OutEchos = &value case "OutEchoReplies": - procSnmp6.Icmp6.OutEchoReplies = value + procSnmp6.Icmp6.OutEchoReplies = &value case "OutGroupMembQueries": - procSnmp6.Icmp6.OutGroupMembQueries = value + procSnmp6.Icmp6.OutGroupMembQueries = &value case "OutGroupMembResponses": - procSnmp6.Icmp6.OutGroupMembResponses = value + procSnmp6.Icmp6.OutGroupMembResponses = &value case "OutGroupMembReductions": - procSnmp6.Icmp6.OutGroupMembReductions = value + procSnmp6.Icmp6.OutGroupMembReductions = &value case "OutRouterSolicits": - procSnmp6.Icmp6.OutRouterSolicits = value + procSnmp6.Icmp6.OutRouterSolicits = &value case "OutRouterAdvertisements": - procSnmp6.Icmp6.OutRouterAdvertisements = value + procSnmp6.Icmp6.OutRouterAdvertisements = &value case "OutNeighborSolicits": - procSnmp6.Icmp6.OutNeighborSolicits = value + procSnmp6.Icmp6.OutNeighborSolicits = &value case "OutNeighborAdvertisements": - procSnmp6.Icmp6.OutNeighborAdvertisements = value + procSnmp6.Icmp6.OutNeighborAdvertisements = &value case "OutRedirects": - procSnmp6.Icmp6.OutRedirects = value + procSnmp6.Icmp6.OutRedirects = &value case "OutMLDv2Reports": - procSnmp6.Icmp6.OutMLDv2Reports = value + procSnmp6.Icmp6.OutMLDv2Reports = &value case "InType1": - procSnmp6.Icmp6.InType1 = value + procSnmp6.Icmp6.InType1 = &value case "InType134": - procSnmp6.Icmp6.InType134 = value + procSnmp6.Icmp6.InType134 = &value case "InType135": - procSnmp6.Icmp6.InType135 = value + procSnmp6.Icmp6.InType135 = &value case "InType136": - procSnmp6.Icmp6.InType136 = value + procSnmp6.Icmp6.InType136 = &value case "InType143": - procSnmp6.Icmp6.InType143 = value + procSnmp6.Icmp6.InType143 = &value case "OutType133": - procSnmp6.Icmp6.OutType133 = value + procSnmp6.Icmp6.OutType133 = &value case "OutType135": - procSnmp6.Icmp6.OutType135 = value + procSnmp6.Icmp6.OutType135 = &value case "OutType136": - procSnmp6.Icmp6.OutType136 = value + procSnmp6.Icmp6.OutType136 = &value case "OutType143": - procSnmp6.Icmp6.OutType143 = value + procSnmp6.Icmp6.OutType143 = &value } case "Udp6": switch key { case "InDatagrams": - procSnmp6.Udp6.InDatagrams = value + procSnmp6.Udp6.InDatagrams = &value case "NoPorts": - procSnmp6.Udp6.NoPorts = value + procSnmp6.Udp6.NoPorts = &value case "InErrors": - procSnmp6.Udp6.InErrors = value + procSnmp6.Udp6.InErrors = &value case "OutDatagrams": - procSnmp6.Udp6.OutDatagrams = value + procSnmp6.Udp6.OutDatagrams = &value case "RcvbufErrors": - procSnmp6.Udp6.RcvbufErrors = value + procSnmp6.Udp6.RcvbufErrors = &value case "SndbufErrors": - procSnmp6.Udp6.SndbufErrors = value + procSnmp6.Udp6.SndbufErrors = &value case "InCsumErrors": - procSnmp6.Udp6.InCsumErrors = value + procSnmp6.Udp6.InCsumErrors = &value case "IgnoredMulti": - procSnmp6.Udp6.IgnoredMulti = value + procSnmp6.Udp6.IgnoredMulti = &value } case "UdpLite6": switch key { case "InDatagrams": - procSnmp6.UdpLite6.InDatagrams = value + procSnmp6.UdpLite6.InDatagrams = &value case "NoPorts": - procSnmp6.UdpLite6.NoPorts = value + procSnmp6.UdpLite6.NoPorts = &value case "InErrors": - procSnmp6.UdpLite6.InErrors = value + procSnmp6.UdpLite6.InErrors = &value case "OutDatagrams": - procSnmp6.UdpLite6.OutDatagrams = value + procSnmp6.UdpLite6.OutDatagrams = &value case "RcvbufErrors": - procSnmp6.UdpLite6.RcvbufErrors = value + procSnmp6.UdpLite6.RcvbufErrors = &value case "SndbufErrors": - procSnmp6.UdpLite6.SndbufErrors = value + procSnmp6.UdpLite6.SndbufErrors = &value case "InCsumErrors": - procSnmp6.UdpLite6.InCsumErrors = value + procSnmp6.UdpLite6.InCsumErrors = &value } } } diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_stat.go b/test/integration/vendor/github.com/prometheus/procfs/proc_stat.go index 06c556ef9..923e55005 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_stat.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_stat.go @@ -18,7 +18,6 @@ import ( "fmt" "os" - "github.com/prometheus/procfs/internal/fs" "github.com/prometheus/procfs/internal/util" ) @@ -102,6 +101,8 @@ type ProcStat struct { RSS int // Soft limit in bytes on the rss of the process. RSSLimit uint64 + // CPU number last executed on. + Processor uint // Real-time scheduling priority, a number in the range 1 to 99 for processes // scheduled under a real-time policy, or 0, for non-real-time processes. RTPriority uint @@ -110,7 +111,7 @@ type ProcStat struct { // Aggregated block I/O delays, measured in clock ticks (centiseconds). DelayAcctBlkIOTicks uint64 - proc fs.FS + proc FS } // NewStat returns the current status information of the process. @@ -137,7 +138,7 @@ func (p Proc) Stat() (ProcStat, error) { ) if l < 0 || r < 0 { - return ProcStat{}, fmt.Errorf("unexpected format, couldn't extract comm %q", data) + return ProcStat{}, fmt.Errorf("%w: unexpected format, couldn't extract comm %q", ErrFileParse, data) } s.Comm = string(data[l+1 : r]) @@ -184,7 +185,7 @@ func (p Proc) Stat() (ProcStat, error) { &ignoreUint64, &ignoreUint64, &ignoreInt64, - &ignoreInt64, + &s.Processor, &s.RTPriority, &s.Policy, &s.DelayAcctBlkIOTicks, @@ -208,8 +209,7 @@ func (s ProcStat) ResidentMemory() int { // StartTime returns the unix timestamp of the process in seconds. func (s ProcStat) StartTime() (float64, error) { - fs := FS{proc: s.proc} - stat, err := fs.Stat() + stat, err := s.proc.Stat() if err != nil { return 0, err } diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_status.go b/test/integration/vendor/github.com/prometheus/procfs/proc_status.go index 594022ded..c055d075d 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_status.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_status.go @@ -15,6 +15,7 @@ package procfs import ( "bytes" + "sort" "strconv" "strings" @@ -76,6 +77,9 @@ type ProcStatus struct { UIDs [4]string // GIDs of the process (Real, effective, saved set, and filesystem GIDs) GIDs [4]string + + // CpusAllowedList: List of cpu cores processes are allowed to run on. + CpusAllowedList []uint64 } // NewStatus returns the current status information of the process. @@ -96,10 +100,10 @@ func (p Proc) NewStatus() (ProcStatus, error) { kv := strings.SplitN(line, ":", 2) // removes spaces - k := string(strings.TrimSpace(kv[0])) - v := string(strings.TrimSpace(kv[1])) + k := strings.TrimSpace(kv[0]) + v := strings.TrimSpace(kv[1]) // removes "kB" - v = string(bytes.Trim([]byte(v), " kB")) + v = strings.TrimSuffix(v, " kB") // value to int when possible // we can skip error check here, 'cause vKBytes is not used when value is a string @@ -161,10 +165,38 @@ func (s *ProcStatus) fillStatus(k string, vString string, vUint uint64, vUintByt s.VoluntaryCtxtSwitches = vUint case "nonvoluntary_ctxt_switches": s.NonVoluntaryCtxtSwitches = vUint + case "Cpus_allowed_list": + s.CpusAllowedList = calcCpusAllowedList(vString) } + } // TotalCtxtSwitches returns the total context switch. func (s ProcStatus) TotalCtxtSwitches() uint64 { return s.VoluntaryCtxtSwitches + s.NonVoluntaryCtxtSwitches } + +func calcCpusAllowedList(cpuString string) []uint64 { + s := strings.Split(cpuString, ",") + + var g []uint64 + + for _, cpu := range s { + // parse cpu ranges, example: 1-3=[1,2,3] + if l := strings.Split(strings.TrimSpace(cpu), "-"); len(l) > 1 { + startCPU, _ := strconv.ParseUint(l[0], 10, 64) + endCPU, _ := strconv.ParseUint(l[1], 10, 64) + + for i := startCPU; i <= endCPU; i++ { + g = append(g, i) + } + } else if len(l) == 1 { + cpu, _ := strconv.ParseUint(l[0], 10, 64) + g = append(g, cpu) + } + + } + + sort.Slice(g, func(i, j int) bool { return g[i] < g[j] }) + return g +} diff --git a/test/integration/vendor/github.com/prometheus/procfs/proc_sys.go b/test/integration/vendor/github.com/prometheus/procfs/proc_sys.go index d46533ebf..12c5bf05b 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/proc_sys.go +++ b/test/integration/vendor/github.com/prometheus/procfs/proc_sys.go @@ -44,7 +44,7 @@ func (fs FS) SysctlInts(sysctl string) ([]int, error) { vp := util.NewValueParser(f) values[i] = vp.Int() if err := vp.Err(); err != nil { - return nil, fmt.Errorf("field %d in sysctl %s is not a valid int: %w", i, sysctl, err) + return nil, fmt.Errorf("%s: field %d in sysctl %s is not a valid int: %w", ErrFileParse, i, sysctl, err) } } return values, nil diff --git a/test/integration/vendor/github.com/prometheus/procfs/slab.go b/test/integration/vendor/github.com/prometheus/procfs/slab.go index bc9aaf5c2..8611c9017 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/slab.go +++ b/test/integration/vendor/github.com/prometheus/procfs/slab.go @@ -68,7 +68,7 @@ func parseV21SlabEntry(line string) (*Slab, error) { l := slabSpace.ReplaceAllString(line, " ") s := strings.Split(l, " ") if len(s) != 16 { - return nil, fmt.Errorf("unable to parse: %q", line) + return nil, fmt.Errorf("%w: unable to parse: %q", ErrFileParse, line) } var err error i := &Slab{Name: s[0]} diff --git a/test/integration/vendor/github.com/prometheus/procfs/softirqs.go b/test/integration/vendor/github.com/prometheus/procfs/softirqs.go index 559129cbc..b8fad677d 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/softirqs.go +++ b/test/integration/vendor/github.com/prometheus/procfs/softirqs.go @@ -57,7 +57,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { ) if !scanner.Scan() { - return Softirqs{}, fmt.Errorf("softirqs empty") + return Softirqs{}, fmt.Errorf("%w: softirqs empty", ErrFileRead) } for scanner.Scan() { @@ -74,7 +74,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Hi = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Hi[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (HI%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (HI%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "TIMER:": @@ -82,7 +82,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Timer = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Timer[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (TIMER%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (TIMER%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "NET_TX:": @@ -90,7 +90,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.NetTx = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.NetTx[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (NET_TX%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (NET_TX%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "NET_RX:": @@ -98,7 +98,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.NetRx = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.NetRx[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (NET_RX%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (NET_RX%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "BLOCK:": @@ -106,7 +106,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Block = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Block[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (BLOCK%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (BLOCK%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "IRQ_POLL:": @@ -114,7 +114,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.IRQPoll = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.IRQPoll[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (IRQ_POLL%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (IRQ_POLL%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "TASKLET:": @@ -122,7 +122,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Tasklet = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Tasklet[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (TASKLET%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (TASKLET%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "SCHED:": @@ -130,7 +130,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Sched = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Sched[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (SCHED%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (SCHED%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "HRTIMER:": @@ -138,7 +138,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.HRTimer = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.HRTimer[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (HRTIMER%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (HRTIMER%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "RCU:": @@ -146,14 +146,14 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.RCU = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.RCU[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (RCU%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (RCU%d): %w", ErrFileParse, count, i, err) } } } } if err := scanner.Err(); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse softirqs: %w", err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse softirqs: %w", ErrFileParse, err) } return softirqs, scanner.Err() diff --git a/test/integration/vendor/github.com/prometheus/procfs/stat.go b/test/integration/vendor/github.com/prometheus/procfs/stat.go index 33f97caa0..05269c896 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/stat.go +++ b/test/integration/vendor/github.com/prometheus/procfs/stat.go @@ -62,7 +62,7 @@ type Stat struct { // Summed up cpu statistics. CPUTotal CPUStat // Per-CPU statistics. - CPU []CPUStat + CPU map[int64]CPUStat // Number of times interrupts were handled, which contains numbered and unnumbered IRQs. IRQTotal uint64 // Number of times a numbered IRQ was triggered. @@ -93,10 +93,10 @@ func parseCPUStat(line string) (CPUStat, int64, error) { &cpuStat.Guest, &cpuStat.GuestNice) if err != nil && err != io.EOF { - return CPUStat{}, -1, fmt.Errorf("couldn't parse %q (cpu): %w", line, err) + return CPUStat{}, -1, fmt.Errorf("%s: couldn't parse %q (cpu): %w", ErrFileParse, line, err) } if count == 0 { - return CPUStat{}, -1, fmt.Errorf("couldn't parse %q (cpu): 0 elements parsed", line) + return CPUStat{}, -1, fmt.Errorf("%w: couldn't parse %q (cpu): 0 elements parsed", ErrFileParse, line) } cpuStat.User /= userHZ @@ -116,7 +116,7 @@ func parseCPUStat(line string) (CPUStat, int64, error) { cpuID, err := strconv.ParseInt(cpu[3:], 10, 64) if err != nil { - return CPUStat{}, -1, fmt.Errorf("couldn't parse %q (cpu/cpuid): %w", line, err) + return CPUStat{}, -1, fmt.Errorf("%s: couldn't parse %q (cpu/cpuid): %w", ErrFileParse, line, err) } return cpuStat, cpuID, nil @@ -136,7 +136,7 @@ func parseSoftIRQStat(line string) (SoftIRQStat, uint64, error) { &softIRQStat.Hrtimer, &softIRQStat.Rcu) if err != nil { - return SoftIRQStat{}, 0, fmt.Errorf("couldn't parse %q (softirq): %w", line, err) + return SoftIRQStat{}, 0, fmt.Errorf("%s: couldn't parse %q (softirq): %w", ErrFileParse, line, err) } return softIRQStat, total, nil @@ -170,10 +170,23 @@ func (fs FS) Stat() (Stat, error) { if err != nil { return Stat{}, err } + procStat, err := parseStat(bytes.NewReader(data), fileName) + if err != nil { + return Stat{}, err + } + return procStat, nil +} - stat := Stat{} +// parseStat parses the metrics from /proc/[pid]/stat. +func parseStat(r io.Reader, fileName string) (Stat, error) { + var ( + scanner = bufio.NewScanner(r) + stat = Stat{ + CPU: make(map[int64]CPUStat), + } + err error + ) - scanner := bufio.NewScanner(bytes.NewReader(data)) for scanner.Scan() { line := scanner.Text() parts := strings.Fields(scanner.Text()) @@ -184,34 +197,34 @@ func (fs FS) Stat() (Stat, error) { switch { case parts[0] == "btime": if stat.BootTime, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (btime): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (btime): %w", ErrFileParse, parts[1], err) } case parts[0] == "intr": if stat.IRQTotal, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (intr): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (intr): %w", ErrFileParse, parts[1], err) } numberedIRQs := parts[2:] stat.IRQ = make([]uint64, len(numberedIRQs)) for i, count := range numberedIRQs { if stat.IRQ[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (intr%d): %w", count, i, err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (intr%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "ctxt": if stat.ContextSwitches, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (ctxt): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (ctxt): %w", ErrFileParse, parts[1], err) } case parts[0] == "processes": if stat.ProcessCreated, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (processes): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (processes): %w", ErrFileParse, parts[1], err) } case parts[0] == "procs_running": if stat.ProcessesRunning, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (procs_running): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (procs_running): %w", ErrFileParse, parts[1], err) } case parts[0] == "procs_blocked": if stat.ProcessesBlocked, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (procs_blocked): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (procs_blocked): %w", ErrFileParse, parts[1], err) } case parts[0] == "softirq": softIRQStats, total, err := parseSoftIRQStat(line) @@ -228,16 +241,13 @@ func (fs FS) Stat() (Stat, error) { if cpuID == -1 { stat.CPUTotal = cpuStat } else { - for int64(len(stat.CPU)) <= cpuID { - stat.CPU = append(stat.CPU, CPUStat{}) - } stat.CPU[cpuID] = cpuStat } } } if err := scanner.Err(); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q: %w", fileName, err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q: %w", ErrFileParse, fileName, err) } return stat, nil diff --git a/test/integration/vendor/github.com/prometheus/procfs/swaps.go b/test/integration/vendor/github.com/prometheus/procfs/swaps.go index 15edc2212..fa00f555d 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/swaps.go +++ b/test/integration/vendor/github.com/prometheus/procfs/swaps.go @@ -64,7 +64,7 @@ func parseSwapString(swapString string) (*Swap, error) { swapFields := strings.Fields(swapString) swapLength := len(swapFields) if swapLength < 5 { - return nil, fmt.Errorf("too few fields in swap string: %s", swapString) + return nil, fmt.Errorf("%w: too few fields in swap string: %s", ErrFileParse, swapString) } swap := &Swap{ @@ -74,15 +74,15 @@ func parseSwapString(swapString string) (*Swap, error) { swap.Size, err = strconv.Atoi(swapFields[2]) if err != nil { - return nil, fmt.Errorf("invalid swap size: %s", swapFields[2]) + return nil, fmt.Errorf("%s: invalid swap size: %s: %w", ErrFileParse, swapFields[2], err) } swap.Used, err = strconv.Atoi(swapFields[3]) if err != nil { - return nil, fmt.Errorf("invalid swap used: %s", swapFields[3]) + return nil, fmt.Errorf("%s: invalid swap used: %s: %w", ErrFileParse, swapFields[3], err) } swap.Priority, err = strconv.Atoi(swapFields[4]) if err != nil { - return nil, fmt.Errorf("invalid swap priority: %s", swapFields[4]) + return nil, fmt.Errorf("%s: invalid swap priority: %s: %w", ErrFileParse, swapFields[4], err) } return swap, nil diff --git a/test/integration/vendor/github.com/prometheus/procfs/thread.go b/test/integration/vendor/github.com/prometheus/procfs/thread.go new file mode 100644 index 000000000..394762c73 --- /dev/null +++ b/test/integration/vendor/github.com/prometheus/procfs/thread.go @@ -0,0 +1,80 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "fmt" + "os" + "strconv" + + fsi "github.com/prometheus/procfs/internal/fs" +) + +// Provide access to /proc/PID/task/TID files, for thread specific values. Since +// such files have the same structure as /proc/PID/ ones, the data structures +// and the parsers for the latter may be reused. + +// AllThreads returns a list of all currently available threads under /proc/PID. +func AllThreads(pid int) (Procs, error) { + fs, err := NewFS(DefaultMountPoint) + if err != nil { + return Procs{}, err + } + return fs.AllThreads(pid) +} + +// AllThreads returns a list of all currently available threads for PID. +func (fs FS) AllThreads(pid int) (Procs, error) { + taskPath := fs.proc.Path(strconv.Itoa(pid), "task") + d, err := os.Open(taskPath) + if err != nil { + return Procs{}, err + } + defer d.Close() + + names, err := d.Readdirnames(-1) + if err != nil { + return Procs{}, fmt.Errorf("%s: could not read %q: %w", ErrFileRead, d.Name(), err) + } + + t := Procs{} + for _, n := range names { + tid, err := strconv.ParseInt(n, 10, 64) + if err != nil { + continue + } + + t = append(t, Proc{PID: int(tid), fs: FS{fsi.FS(taskPath), fs.real}}) + } + + return t, nil +} + +// Thread returns a process for a given PID, TID. +func (fs FS) Thread(pid, tid int) (Proc, error) { + taskPath := fs.proc.Path(strconv.Itoa(pid), "task") + if _, err := os.Stat(taskPath); err != nil { + return Proc{}, err + } + return Proc{PID: tid, fs: FS{fsi.FS(taskPath), fs.real}}, nil +} + +// Thread returns a process for a given TID of Proc. +func (proc Proc) Thread(tid int) (Proc, error) { + tfs := FS{fsi.FS(proc.path("task")), proc.fs.real} + if _, err := os.Stat(tfs.proc.Path(strconv.Itoa(tid))); err != nil { + return Proc{}, err + } + return Proc{PID: tid, fs: tfs}, nil +} diff --git a/test/integration/vendor/github.com/prometheus/procfs/vm.go b/test/integration/vendor/github.com/prometheus/procfs/vm.go index 20ceb77e2..51c49d89e 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/vm.go +++ b/test/integration/vendor/github.com/prometheus/procfs/vm.go @@ -26,7 +26,9 @@ import ( ) // The VM interface is described at -// https://www.kernel.org/doc/Documentation/sysctl/vm.txt +// +// https://www.kernel.org/doc/Documentation/sysctl/vm.txt +// // Each setting is exposed as a single file. // Each file contains one line with a single numerical value, except lowmem_reserve_ratio which holds an array // and numa_zonelist_order (deprecated) which is a string. @@ -84,7 +86,7 @@ func (fs FS) VM() (*VM, error) { return nil, err } if !file.Mode().IsDir() { - return nil, fmt.Errorf("%s is not a directory", path) + return nil, fmt.Errorf("%w: %s is not a directory", ErrFileRead, path) } files, err := os.ReadDir(path) diff --git a/test/integration/vendor/github.com/prometheus/procfs/zoneinfo.go b/test/integration/vendor/github.com/prometheus/procfs/zoneinfo.go index c745a4c04..ce5fefa5b 100644 --- a/test/integration/vendor/github.com/prometheus/procfs/zoneinfo.go +++ b/test/integration/vendor/github.com/prometheus/procfs/zoneinfo.go @@ -75,11 +75,11 @@ var nodeZoneRE = regexp.MustCompile(`(\d+), zone\s+(\w+)`) func (fs FS) Zoneinfo() ([]Zoneinfo, error) { data, err := os.ReadFile(fs.proc.Path("zoneinfo")) if err != nil { - return nil, fmt.Errorf("error reading zoneinfo %q: %w", fs.proc.Path("zoneinfo"), err) + return nil, fmt.Errorf("%s: error reading zoneinfo %q: %w", ErrFileRead, fs.proc.Path("zoneinfo"), err) } zoneinfo, err := parseZoneinfo(data) if err != nil { - return nil, fmt.Errorf("error parsing zoneinfo %q: %w", fs.proc.Path("zoneinfo"), err) + return nil, fmt.Errorf("%s: error parsing zoneinfo %q: %w", ErrFileParse, fs.proc.Path("zoneinfo"), err) } return zoneinfo, nil } diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/common/env.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/common/env.go new file mode 100644 index 000000000..4b5f4980c --- /dev/null +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/common/env.go @@ -0,0 +1,23 @@ +package common + +type EnvKeyType string + +// EnvKey is a context key that can be used to set programmatically the environment +// gopsutil relies on to perform calls against the OS. +// Example of use: +// +// ctx := context.WithValue(context.Background(), common.EnvKey, EnvMap{common.HostProcEnvKey: "/myproc"}) +// avg, err := load.AvgWithContext(ctx) +var EnvKey = EnvKeyType("env") + +const ( + HostProcEnvKey EnvKeyType = "HOST_PROC" + HostSysEnvKey EnvKeyType = "HOST_SYS" + HostEtcEnvKey EnvKeyType = "HOST_ETC" + HostVarEnvKey EnvKeyType = "HOST_VAR" + HostRunEnvKey EnvKeyType = "HOST_RUN" + HostDevEnvKey EnvKeyType = "HOST_DEV" + HostRootEnvKey EnvKeyType = "HOST_ROOT" +) + +type EnvMap map[EnvKeyType]string diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go index 7acb258d9..41f395e5e 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" + "github.com/shoenig/go-m1cpu" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" ) @@ -85,11 +86,15 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.CacheSize = int32(cacheSize) c.VendorID, _ = unix.Sysctl("machdep.cpu.vendor") - // Use the rated frequency of the CPU. This is a static value and does not - // account for low power or Turbo Boost modes. - cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") - if err == nil { - c.Mhz = float64(cpuFrequency) / 1000000.0 + if m1cpu.IsAppleSilicon() { + c.Mhz = float64(m1cpu.PCoreHz() / 1_000_000) + } else { + // Use the rated frequency of the CPU. This is a static value and does not + // account for low power or Turbo Boost modes. + cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") + if err == nil { + c.Mhz = float64(cpuFrequency) / 1000000.0 + } } return append(ret, c), nil diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go index 962d34300..1b64241ce 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go @@ -11,8 +11,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "github.com/tklauser/go-sysconf" + + "github.com/shirou/gopsutil/v3/internal/common" ) var ClocksPerSec = float64(100) @@ -95,7 +96,7 @@ func Times(percpu bool) ([]TimesStat, error) { } func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { - filename := common.HostProc("stat") + filename := common.HostProcWithContext(ctx, "stat") lines := []string{} if percpu { statlines, err := common.ReadLines(filename) @@ -125,17 +126,17 @@ func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { return ret, nil } -func sysCPUPath(cpu int32, relPath string) string { - return common.HostSys(fmt.Sprintf("devices/system/cpu/cpu%d", cpu), relPath) +func sysCPUPath(ctx context.Context, cpu int32, relPath string) string { + return common.HostSysWithContext(ctx, fmt.Sprintf("devices/system/cpu/cpu%d", cpu), relPath) } -func finishCPUInfo(c *InfoStat) { +func finishCPUInfo(ctx context.Context, c *InfoStat) { var lines []string var err error var value float64 if len(c.CoreID) == 0 { - lines, err = common.ReadLines(sysCPUPath(c.CPU, "topology/core_id")) + lines, err = common.ReadLines(sysCPUPath(ctx, c.CPU, "topology/core_id")) if err == nil { c.CoreID = lines[0] } @@ -144,7 +145,7 @@ func finishCPUInfo(c *InfoStat) { // override the value of c.Mhz with cpufreq/cpuinfo_max_freq regardless // of the value from /proc/cpuinfo because we want to report the maximum // clock-speed of the CPU for c.Mhz, matching the behaviour of Windows - lines, err = common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq")) + lines, err = common.ReadLines(sysCPUPath(ctx, c.CPU, "cpufreq/cpuinfo_max_freq")) // if we encounter errors below such as there are no cpuinfo_max_freq file, // we just ignore. so let Mhz is 0. if err != nil || len(lines) == 0 { @@ -172,7 +173,7 @@ func Info() ([]InfoStat, error) { } func InfoWithContext(ctx context.Context) ([]InfoStat, error) { - filename := common.HostProc("cpuinfo") + filename := common.HostProcWithContext(ctx, "cpuinfo") lines, _ := common.ReadLines(filename) var ret []InfoStat @@ -192,7 +193,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { processorName = value case "processor", "cpu number": if c.CPU >= 0 { - finishCPUInfo(&c) + finishCPUInfo(ctx, &c) ret = append(ret, c) } c = InfoStat{Cores: 1, ModelName: processorName} @@ -300,7 +301,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { } } if c.CPU >= 0 { - finishCPUInfo(&c) + finishCPUInfo(ctx, &c) ret = append(ret, c) } return ret, nil @@ -389,7 +390,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { if logical { ret := 0 // https://github.com/giampaolo/psutil/blob/d01a9eaa35a8aadf6c519839e987a49d8be2d891/psutil/_pslinux.py#L599 - procCpuinfo := common.HostProc("cpuinfo") + procCpuinfo := common.HostProcWithContext(ctx, "cpuinfo") lines, err := common.ReadLines(procCpuinfo) if err == nil { for _, line := range lines { @@ -403,7 +404,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { } } if ret == 0 { - procStat := common.HostProc("stat") + procStat := common.HostProcWithContext(ctx, "stat") lines, err = common.ReadLines(procStat) if err != nil { return 0, err @@ -424,7 +425,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { // https://github.com/giampaolo/psutil/pull/1727#issuecomment-707624964 // https://lkml.org/lkml/2019/2/26/41 for _, glob := range []string{"devices/system/cpu/cpu[0-9]*/topology/core_cpus_list", "devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list"} { - if files, err := filepath.Glob(common.HostSys(glob)); err == nil { + if files, err := filepath.Glob(common.HostSysWithContext(ctx, glob)); err == nil { for _, file := range files { lines, err := common.ReadLines(file) if err != nil || len(lines) != 1 { @@ -439,7 +440,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { } } // https://github.com/giampaolo/psutil/blob/122174a10b75c9beebe15f6c07dcf3afbe3b120d/psutil/_pslinux.py#L631-L652 - filename := common.HostProc("cpuinfo") + filename := common.HostProcWithContext(ctx, "cpuinfo") lines, err := common.ReadLines(filename) if err != nil { return 0, err diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk.go index dd4cc1d5f..0d4b25345 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk.go @@ -9,6 +9,8 @@ import ( var invoke common.Invoker = common.Invoke{} +type Warnings = common.Warnings + type UsageStat struct { Path string `json:"path"` Fstype string `json:"fstype"` diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go index 933cb0454..9362d9e5d 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go @@ -6,8 +6,9 @@ package disk import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) // PartitionsWithContext returns disk partition. diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go index b6a3adcf5..2a8c50ae4 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go @@ -16,8 +16,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) const ( @@ -259,10 +260,10 @@ func readMountFile(root string) (lines []string, useMounts bool, filename string func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) { // by default, try "/proc/1/..." first - root := common.HostProc(path.Join("1")) + root := common.HostProcWithContext(ctx, path.Join("1")) // force preference for dirname of HOST_PROC_MOUNTINFO, if set #1271 - hpmPath := os.Getenv("HOST_PROC_MOUNTINFO") + hpmPath := common.HostProcMountInfoWithContext(ctx) if hpmPath != "" { root = filepath.Dir(hpmPath) } @@ -273,13 +274,13 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro return nil, err } // fallback to "/proc/self/..." #1159 - lines, useMounts, filename, err = readMountFile(common.HostProc(path.Join("self"))) + lines, useMounts, filename, err = readMountFile(common.HostProcWithContext(ctx, path.Join("self"))) if err != nil { return nil, err } } - fs, err := getFileSystems() + fs, err := getFileSystems(ctx) if err != nil && !all { return nil, err } @@ -341,7 +342,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro } if strings.HasPrefix(d.Device, "/dev/mapper/") { - devpath, err := filepath.EvalSymlinks(common.HostDev(strings.Replace(d.Device, "/dev", "", 1))) + devpath, err := filepath.EvalSymlinks(common.HostDevWithContext(ctx, strings.Replace(d.Device, "/dev", "", 1))) if err == nil { d.Device = devpath } @@ -350,7 +351,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro // /dev/root is not the real device name // so we get the real device name from its major/minor number if d.Device == "/dev/root" { - devpath, err := os.Readlink(common.HostSys("/dev/block/" + blockDeviceID)) + devpath, err := os.Readlink(common.HostSysWithContext(ctx, "/dev/block/"+blockDeviceID)) if err == nil { d.Device = strings.Replace(d.Device, "root", filepath.Base(devpath), 1) } @@ -363,8 +364,8 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro } // getFileSystems returns supported filesystems from /proc/filesystems -func getFileSystems() ([]string, error) { - filename := common.HostProc("filesystems") +func getFileSystems(ctx context.Context) ([]string, error) { + filename := common.HostProcWithContext(ctx, "filesystems") lines, err := common.ReadLines(filename) if err != nil { return nil, err @@ -386,7 +387,7 @@ func getFileSystems() ([]string, error) { } func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) { - filename := common.HostProc("diskstats") + filename := common.HostProcWithContext(ctx, "diskstats") lines, err := common.ReadLines(filename) if err != nil { return nil, err @@ -491,7 +492,7 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) { minor := unix.Minor(uint64(stat.Rdev)) // Try to get the serial from udev data - udevDataPath := common.HostRun(fmt.Sprintf("udev/data/b%d:%d", major, minor)) + udevDataPath := common.HostRunWithContext(ctx, fmt.Sprintf("udev/data/b%d:%d", major, minor)) if udevdata, err := ioutil.ReadFile(udevDataPath); err == nil { scanner := bufio.NewScanner(bytes.NewReader(udevdata)) for scanner.Scan() { @@ -504,7 +505,7 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) { // Try to get the serial from sysfs, look at the disk device (minor 0) directly // because if it is a partition it is not going to contain any device information - devicePath := common.HostSys(fmt.Sprintf("dev/block/%d:0/device", major)) + devicePath := common.HostSysWithContext(ctx, fmt.Sprintf("dev/block/%d:0/device", major)) model, _ := ioutil.ReadFile(filepath.Join(devicePath, "model")) serial, _ := ioutil.ReadFile(filepath.Join(devicePath, "serial")) if len(model) > 0 && len(serial) > 0 { @@ -515,7 +516,7 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) { func LabelWithContext(ctx context.Context, name string) (string, error) { // Try label based on devicemapper name - dmname_filename := common.HostSys(fmt.Sprintf("block/%s/dm/name", name)) + dmname_filename := common.HostSysWithContext(ctx, fmt.Sprintf("block/%s/dm/name", name)) if !common.PathExists(dmname_filename) { return "", nil diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go index 5dfd1ca98..8a1a28d69 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go @@ -7,6 +7,7 @@ import ( "bytes" "context" "fmt" + "sync" "syscall" "unsafe" @@ -15,8 +16,6 @@ import ( "golang.org/x/sys/windows/registry" ) -type Warnings = common.Warnings - var ( procGetDiskFreeSpaceExW = common.Modkernel32.NewProc("GetDiskFreeSpaceExW") procGetLogicalDriveStringsW = common.Modkernel32.NewProc("GetLogicalDriveStringsW") @@ -90,12 +89,20 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro var ret []PartitionStat retChan := make(chan []PartitionStat) errChan := make(chan error) - defer close(retChan) - defer close(errChan) - lpBuffer := make([]byte, 254) + var waitgrp sync.WaitGroup + waitgrp.Add(1) + defer waitgrp.Done() + f := func() { + defer func() { + waitgrp.Wait() + // fires when this func and the outside func finishes. + close(errChan) + close(retChan) + }() + diskret, _, err := procGetLogicalDriveStringsW.Call( uintptr(len(lpBuffer)), uintptr(unsafe.Pointer(&lpBuffer[0]))) diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host.go index f363eed83..c7e84e3a5 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host.go @@ -11,6 +11,8 @@ import ( "github.com/shirou/gopsutil/v3/internal/common" ) +type Warnings = common.Warnings + var invoke common.Invoker = common.Invoke{} // A HostInfoStat describes the host status. diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go index 2f20fc616..1be2e8533 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go @@ -13,9 +13,10 @@ import ( "strings" "unsafe" + "golang.org/x/sys/unix" + "github.com/shirou/gopsutil/v3/internal/common" "github.com/shirou/gopsutil/v3/process" - "golang.org/x/sys/unix" ) // from utmpx.h diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go index 9dc63322b..62a4b3ca9 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go @@ -15,11 +15,10 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" -) -type Warnings = common.Warnings + "github.com/shirou/gopsutil/v3/internal/common" +) type lsbStruct struct { ID string @@ -36,9 +35,9 @@ const ( ) func HostIDWithContext(ctx context.Context) (string, error) { - sysProductUUID := common.HostSys("class/dmi/id/product_uuid") - machineID := common.HostEtc("machine-id") - procSysKernelRandomBootID := common.HostProc("sys/kernel/random/boot_id") + sysProductUUID := common.HostSysWithContext(ctx, "class/dmi/id/product_uuid") + machineID := common.HostEtcWithContext(ctx, "machine-id") + procSysKernelRandomBootID := common.HostProcWithContext(ctx, "sys/kernel/random/boot_id") switch { // In order to read this file, needs to be supported by kernel/arch and run as root // so having fallback is important @@ -68,7 +67,7 @@ func HostIDWithContext(ctx context.Context) (string, error) { } func numProcs(ctx context.Context) (uint64, error) { - return common.NumProcs() + return common.NumProcsWithContext(ctx) } func BootTimeWithContext(ctx context.Context) (uint64, error) { @@ -84,7 +83,7 @@ func UptimeWithContext(ctx context.Context) (uint64, error) { } func UsersWithContext(ctx context.Context) ([]UserStat, error) { - utmpfile := common.HostVar("run/utmp") + utmpfile := common.HostVarWithContext(ctx, "run/utmp") file, err := os.Open(utmpfile) if err != nil { @@ -125,10 +124,10 @@ func UsersWithContext(ctx context.Context) ([]UserStat, error) { return ret, nil } -func getlsbStruct() (*lsbStruct, error) { +func getlsbStruct(ctx context.Context) (*lsbStruct, error) { ret := &lsbStruct{} - if common.PathExists(common.HostEtc("lsb-release")) { - contents, err := common.ReadLines(common.HostEtc("lsb-release")) + if common.PathExists(common.HostEtcWithContext(ctx, "lsb-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "lsb-release")) if err != nil { return ret, err // return empty } @@ -176,31 +175,31 @@ func getlsbStruct() (*lsbStruct, error) { } func PlatformInformationWithContext(ctx context.Context) (platform string, family string, version string, err error) { - lsb, err := getlsbStruct() + lsb, err := getlsbStruct(ctx) if err != nil { lsb = &lsbStruct{} } - if common.PathExistsWithContents(common.HostEtc("oracle-release")) { + if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "oracle-release")) { platform = "oracle" - contents, err := common.ReadLines(common.HostEtc("oracle-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "oracle-release")) if err == nil { version = getRedhatishVersion(contents) } - } else if common.PathExistsWithContents(common.HostEtc("enterprise-release")) { + } else if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "enterprise-release")) { platform = "oracle" - contents, err := common.ReadLines(common.HostEtc("enterprise-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "enterprise-release")) if err == nil { version = getRedhatishVersion(contents) } - } else if common.PathExistsWithContents(common.HostEtc("slackware-version")) { + } else if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "slackware-version")) { platform = "slackware" - contents, err := common.ReadLines(common.HostEtc("slackware-version")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "slackware-version")) if err == nil { version = getSlackwareVersion(contents) } - } else if common.PathExistsWithContents(common.HostEtc("debian_version")) { + } else if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "debian_version")) { if lsb.ID == "Ubuntu" { platform = "ubuntu" version = lsb.Release @@ -210,59 +209,62 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil } else if lsb.ID == "Kylin" { platform = "Kylin" version = lsb.Release + } else if lsb.ID == `"Cumulus Linux"` { + platform = "cumuluslinux" + version = lsb.Release } else { if common.PathExistsWithContents("/usr/bin/raspi-config") { platform = "raspbian" } else { platform = "debian" } - contents, err := common.ReadLines(common.HostEtc("debian_version")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "debian_version")) if err == nil && len(contents) > 0 && contents[0] != "" { version = contents[0] } } - } else if common.PathExists(common.HostEtc("neokylin-release")) { - contents, err := common.ReadLines(common.HostEtc("neokylin-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "neokylin-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "neokylin-release")) if err == nil { version = getRedhatishVersion(contents) platform = getRedhatishPlatform(contents) } - } else if common.PathExists(common.HostEtc("redhat-release")) { - contents, err := common.ReadLines(common.HostEtc("redhat-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "redhat-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "redhat-release")) if err == nil { version = getRedhatishVersion(contents) platform = getRedhatishPlatform(contents) } - } else if common.PathExists(common.HostEtc("system-release")) { - contents, err := common.ReadLines(common.HostEtc("system-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "system-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "system-release")) if err == nil { version = getRedhatishVersion(contents) platform = getRedhatishPlatform(contents) } - } else if common.PathExists(common.HostEtc("gentoo-release")) { + } else if common.PathExists(common.HostEtcWithContext(ctx, "gentoo-release")) { platform = "gentoo" - contents, err := common.ReadLines(common.HostEtc("gentoo-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "gentoo-release")) if err == nil { version = getRedhatishVersion(contents) } - } else if common.PathExists(common.HostEtc("SuSE-release")) { - contents, err := common.ReadLines(common.HostEtc("SuSE-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "SuSE-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "SuSE-release")) if err == nil { version = getSuseVersion(contents) platform = getSusePlatform(contents) } // TODO: slackware detecion - } else if common.PathExists(common.HostEtc("arch-release")) { + } else if common.PathExists(common.HostEtcWithContext(ctx, "arch-release")) { platform = "arch" version = lsb.Release - } else if common.PathExists(common.HostEtc("alpine-release")) { + } else if common.PathExists(common.HostEtcWithContext(ctx, "alpine-release")) { platform = "alpine" - contents, err := common.ReadLines(common.HostEtc("alpine-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "alpine-release")) if err == nil && len(contents) > 0 && contents[0] != "" { version = contents[0] } - } else if common.PathExists(common.HostEtc("os-release")) { - p, v, err := common.GetOSRelease() + } else if common.PathExists(common.HostEtcWithContext(ctx, "os-release")) { + p, v, err := common.GetOSReleaseWithContext(ctx) if err == nil { platform = p version = v @@ -287,7 +289,7 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil platform = strings.Trim(platform, `"`) switch platform { - case "debian", "ubuntu", "linuxmint", "raspbian": + case "debian", "ubuntu", "linuxmint", "raspbian", "Kylin", "cumuluslinux": family = "debian" case "fedora": family = "fedora" @@ -388,14 +390,14 @@ func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, err // Only the temp*_input file provides current temperature // value in millidegree Celsius as reported by the temperature to the device: // https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface - if files, err = filepath.Glob(common.HostSys("/class/hwmon/hwmon*/temp*_input")); err != nil { + if files, err = filepath.Glob(common.HostSysWithContext(ctx, "/class/hwmon/hwmon*/temp*_input")); err != nil { return temperatures, err } if len(files) == 0 { // CentOS has an intermediate /device directory: // https://github.com/giampaolo/psutil/issues/971 - if files, err = filepath.Glob(common.HostSys("/class/hwmon/hwmon*/device/temp*_input")); err != nil { + if files, err = filepath.Glob(common.HostSysWithContext(ctx, "/class/hwmon/hwmon*/device/temp*_input")); err != nil { return temperatures, err } } @@ -403,7 +405,7 @@ func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, err var warns Warnings if len(files) == 0 { // handle distributions without hwmon, like raspbian #391, parse legacy thermal_zone files - files, err = filepath.Glob(common.HostSys("/class/thermal/thermal_zone*/")) + files, err = filepath.Glob(common.HostSysWithContext(ctx, "/class/thermal/thermal_zone*/")) if err != nil { return temperatures, err } diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go index c1e96ca7d..9bfece362 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go @@ -25,6 +25,8 @@ import ( "strconv" "strings" "time" + + "github.com/shirou/gopsutil/v3/common" ) var ( @@ -321,6 +323,23 @@ func PathExistsWithContents(filename string) bool { return info.Size() > 4 // at least 4 bytes } +// GetEnvWithContext retrieves the environment variable key. If it does not exist it returns the default. +// The context may optionally contain a map superseding os.EnvKey. +func GetEnvWithContext(ctx context.Context, key string, dfault string, combineWith ...string) string { + var value string + if env, ok := ctx.Value(common.EnvKey).(common.EnvMap); ok { + value = env[common.EnvKeyType(key)] + } + if value == "" { + value = os.Getenv(key) + } + if value == "" { + value = dfault + } + + return combine(value, combineWith) +} + // GetEnv retrieves the environment variable key. If it does not exist it returns the default. func GetEnv(key string, dfault string, combineWith ...string) string { value := os.Getenv(key) @@ -328,6 +347,10 @@ func GetEnv(key string, dfault string, combineWith ...string) string { value = dfault } + return combine(value, combineWith) +} + +func combine(value string, combineWith []string) string { switch len(combineWith) { case 0: return value @@ -369,6 +392,38 @@ func HostRoot(combineWith ...string) string { return GetEnv("HOST_ROOT", "/", combineWith...) } +func HostProcWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_PROC", "/proc", combineWith...) +} + +func HostProcMountInfoWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_PROC_MOUNTINFO", "", combineWith...) +} + +func HostSysWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_SYS", "/sys", combineWith...) +} + +func HostEtcWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_ETC", "/etc", combineWith...) +} + +func HostVarWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_VAR", "/var", combineWith...) +} + +func HostRunWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_RUN", "/run", combineWith...) +} + +func HostDevWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_DEV", "/dev", combineWith...) +} + +func HostRootWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_ROOT", "/", combineWith...) +} + // getSysctrlEnv sets LC_ALL=C in a list of env vars for use when running // sysctl commands (see DoSysctrl). func getSysctrlEnv(env []string) []string { diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go index fa6373b55..b58edbeb0 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go @@ -31,7 +31,11 @@ func DoSysctrl(mib string) ([]string, error) { } func NumProcs() (uint64, error) { - f, err := os.Open(HostProc()) + return NumProcsWithContext(context.Background()) +} + +func NumProcsWithContext(ctx context.Context) (uint64, error) { + f, err := os.Open(HostProcWithContext(ctx)) if err != nil { return 0, err } @@ -67,7 +71,7 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) { statFile = "uptime" } - filename := HostProc(statFile) + filename := HostProcWithContext(ctx, statFile) lines, err := ReadLines(filename) if os.IsPermission(err) { var info syscall.Sysinfo_t @@ -139,7 +143,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } cachedVirtMutex.RUnlock() - filename := HostProc("xen") + filename := HostProcWithContext(ctx, "xen") if PathExists(filename) { system = "xen" role = "guest" // assume guest @@ -154,7 +158,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc("modules") + filename = HostProcWithContext(ctx, "modules") if PathExists(filename) { contents, err := ReadLines(filename) if err == nil { @@ -177,7 +181,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc("cpuinfo") + filename = HostProcWithContext(ctx, "cpuinfo") if PathExists(filename) { contents, err := ReadLines(filename) if err == nil { @@ -190,7 +194,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc("bus/pci/devices") + filename = HostProcWithContext(ctx, "bus/pci/devices") if PathExists(filename) { contents, err := ReadLines(filename) if err == nil { @@ -200,7 +204,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc() + filename = HostProcWithContext(ctx) if PathExists(filepath.Join(filename, "bc", "0")) { system = "openvz" role = "host" @@ -251,15 +255,15 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - if PathExists(HostEtc("os-release")) { - p, _, err := GetOSRelease() + if PathExists(HostEtcWithContext(ctx, "os-release")) { + p, _, err := GetOSReleaseWithContext(ctx) if err == nil && p == "coreos" { system = "rkt" // Is it true? role = "host" } } - if PathExists(HostRoot(".dockerenv")) { + if PathExists(HostRootWithContext(ctx, ".dockerenv")) { system = "docker" role = "guest" } @@ -278,7 +282,11 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } func GetOSRelease() (platform string, version string, err error) { - contents, err := ReadLines(HostEtc("os-release")) + return GetOSReleaseWithContext(context.Background()) +} + +func GetOSReleaseWithContext(ctx context.Context) (platform string, version string, err error) { + contents, err := ReadLines(HostEtcWithContext(ctx, "os-release")) if err != nil { return "", "", nil // return empty } diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go index 8c35b1722..9bed2419e 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go @@ -11,6 +11,9 @@ func Sleep(ctx context.Context, interval time.Duration) error { timer := time.NewTimer(interval) select { case <-ctx.Done(): + if !timer.Stop() { + <-timer.C + } return ctx.Err() case <-timer.C: return nil diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go index 0527dd93c..a05a0faba 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go @@ -8,8 +8,9 @@ import ( "fmt" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) func getHwMemsize() (uint64, error) { diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go index 9a5d693b1..361d06bcc 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go @@ -14,8 +14,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) type VirtualMemoryExStat struct { @@ -36,7 +37,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) { } func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { - vm, _, err := fillFromMeminfoWithContext() + vm, _, err := fillFromMeminfoWithContext(ctx) if err != nil { return nil, err } @@ -48,15 +49,15 @@ func VirtualMemoryEx() (*VirtualMemoryExStat, error) { } func VirtualMemoryExWithContext(ctx context.Context) (*VirtualMemoryExStat, error) { - _, vmEx, err := fillFromMeminfoWithContext() + _, vmEx, err := fillFromMeminfoWithContext(ctx) if err != nil { return nil, err } return vmEx, nil } -func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, error) { - filename := common.HostProc("meminfo") +func fillFromMeminfoWithContext(ctx context.Context) (*VirtualMemoryStat, *VirtualMemoryExStat, error) { + filename := common.HostProcWithContext(ctx, "meminfo") lines, _ := common.ReadLines(filename) // flag if MemAvailable is in /proc/meminfo (kernel 3.14+) @@ -153,13 +154,13 @@ func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, err return ret, retEx, err } retEx.Unevictable = t * 1024 - case "WriteBack": + case "Writeback": t, err := strconv.ParseUint(value, 10, 64) if err != nil { return ret, retEx, err } ret.WriteBack = t * 1024 - case "WriteBackTmp": + case "WritebackTmp": t, err := strconv.ParseUint(value, 10, 64) if err != nil { return ret, retEx, err @@ -317,7 +318,7 @@ func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, err if !memavail { if activeFile && inactiveFile && sReclaimable { - ret.Available = calculateAvailVmem(ret, retEx) + ret.Available = calculateAvailVmem(ctx, ret, retEx) } else { ret.Available = ret.Cached + ret.Free } @@ -350,7 +351,7 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { } else { ret.UsedPercent = 0 } - filename := common.HostProc("vmstat") + filename := common.HostProcWithContext(ctx, "vmstat") lines, _ := common.ReadLines(filename) for _, l := range lines { fields := strings.Fields(l) @@ -402,10 +403,10 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { // calculateAvailVmem is a fallback under kernel 3.14 where /proc/meminfo does not provide // "MemAvailable:" column. It reimplements an algorithm from the link below // https://github.com/giampaolo/psutil/pull/890 -func calculateAvailVmem(ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 { +func calculateAvailVmem(ctx context.Context, ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 { var watermarkLow uint64 - fn := common.HostProc("zoneinfo") + fn := common.HostProcWithContext(ctx, "zoneinfo") lines, err := common.ReadLines(fn) if err != nil { return ret.Free + ret.Cached // fallback under kernel 2.6.13 @@ -457,18 +458,18 @@ func SwapDevices() ([]*SwapDevice, error) { } func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) { - swapsFilePath := common.HostProc(swapsFilename) + swapsFilePath := common.HostProcWithContext(ctx, swapsFilename) f, err := os.Open(swapsFilePath) if err != nil { return nil, err } defer f.Close() - return parseSwapsFile(f) + return parseSwapsFile(ctx, f) } -func parseSwapsFile(r io.Reader) ([]*SwapDevice, error) { - swapsFilePath := common.HostProc(swapsFilename) +func parseSwapsFile(ctx context.Context, r io.Reader) ([]*SwapDevice, error) { + swapsFilePath := common.HostProcWithContext(ctx, swapsFilename) scanner := bufio.NewScanner(r) if !scanner.Scan() { if err := scanner.Err(); err != nil { diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go index 1c8d4f4e3..8a7b63744 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go @@ -259,7 +259,7 @@ func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) { } func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) { - return IOCounters(pernic) + return IOCountersWithContext(ctx, pernic) } func FilterCounters() ([]FilterStat, error) { @@ -278,7 +278,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for Darwin diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go index 7f31851ea..bf8baf094 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go @@ -115,7 +115,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for FreeBSD diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go index c7cd0db18..de0ea7345 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go @@ -50,7 +50,7 @@ func IOCounters(pernic bool) ([]IOCountersStat, error) { } func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) { - filename := common.HostProc("net/dev") + filename := common.HostProcWithContext(ctx, "net/dev") return IOCountersByFileWithContext(ctx, pernic, filename) } @@ -157,7 +157,7 @@ var netProtocols = []string{ "udplite", } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Available protocols: @@ -177,7 +177,7 @@ func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoC protos[p] = true } - filename := common.HostProc("net/snmp") + filename := common.HostProcWithContext(ctx, "net/snmp") lines, err := common.ReadLines(filename) if err != nil { return nil, err @@ -230,8 +230,8 @@ func FilterCounters() ([]FilterStat, error) { } func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) { - countfile := common.HostProc("sys/net/netfilter/nf_conntrack_count") - maxfile := common.HostProc("sys/net/netfilter/nf_conntrack_max") + countfile := common.HostProcWithContext(ctx, "sys/net/netfilter/nf_conntrack_count") + maxfile := common.HostProcWithContext(ctx, "sys/net/netfilter/nf_conntrack_max") count, err := common.ReadInts(countfile) if err != nil { @@ -260,7 +260,7 @@ func ConntrackStats(percpu bool) ([]ConntrackStat, error) { // ConntrackStatsWithContext returns more detailed info about the conntrack table func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) { - return conntrackStatsFromFile(common.HostProc("net/stat/nf_conntrack"), percpu) + return conntrackStatsFromFile(common.HostProcWithContext(ctx, "net/stat/nf_conntrack"), percpu) } // conntrackStatsFromFile returns more detailed info about the conntrack table @@ -459,7 +459,7 @@ func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, p if !ok { return nil, fmt.Errorf("invalid kind, %s", kind) } - root := common.HostProc() + root := common.HostProcWithContext(ctx) var err error var inodes map[string][]inodeMap if pid == 0 { @@ -531,7 +531,7 @@ func statsFromInodesWithContext(ctx context.Context, root string, pid int32, tma if !skipUids { // fetch process owner Real, effective, saved set, and filesystem UIDs proc := process{Pid: conn.Pid} - conn.Uids, _ = proc.getUids() + conn.Uids, _ = proc.getUids(ctx) } ret = append(ret, conn) @@ -599,7 +599,7 @@ func Pids() ([]int32, error) { func PidsWithContext(ctx context.Context) ([]int32, error) { var ret []int32 - d, err := os.Open(common.HostProc()) + d, err := os.Open(common.HostProcWithContext(ctx)) if err != nil { return nil, err } @@ -631,8 +631,8 @@ type process struct { } // Uids returns user ids of the process as a slice of the int -func (p *process) getUids() ([]int32, error) { - err := p.fillFromStatus() +func (p *process) getUids(ctx context.Context) ([]int32, error) { + err := p.fillFromStatus(ctx) if err != nil { return []int32{}, err } @@ -640,9 +640,9 @@ func (p *process) getUids() ([]int32, error) { } // Get status from /proc/(pid)/status -func (p *process) fillFromStatus() error { +func (p *process) fillFromStatus(ctx context.Context) error { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "status") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "status") contents, err := ioutil.ReadFile(statPath) if err != nil { return err diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go index 5f066a09f..cf48f53e7 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go @@ -164,7 +164,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for OpenBSD diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go index 68b26bdcd..5d384342f 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go @@ -338,7 +338,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for Windows diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process.go index 0ca26c210..1a7fe1b80 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process.go @@ -335,7 +335,7 @@ func (p *Process) MemoryPercentWithContext(ctx context.Context) (float32, error) return (100 * float32(used) / float32(total)), nil } -// CPU_Percent returns how many percent of the CPU time this process uses +// CPUPercent returns how many percent of the CPU time this process uses func (p *Process) CPUPercent() (float64, error) { return p.CPUPercentWithContext(context.Background()) } @@ -507,7 +507,7 @@ func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { return p.MemoryInfoExWithContext(context.Background()) } -// PageFaultsInfo returns the process's page fault counters. +// PageFaults returns the process's page fault counters. func (p *Process) PageFaults() (*PageFaultsStat, error) { return p.PageFaultsWithContext(context.Background()) } @@ -530,7 +530,7 @@ func (p *Process) Connections() ([]net.ConnectionStat, error) { return p.ConnectionsWithContext(context.Background()) } -// Connections returns a slice of net.ConnectionStat used by the process at most `max`. +// ConnectionsMax returns a slice of net.ConnectionStat used by the process at most `max`. func (p *Process) ConnectionsMax(max int) ([]net.ConnectionStat, error) { return p.ConnectionsMaxWithContext(context.Background(), max) } diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go index 61b340b63..55c31962a 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go @@ -10,10 +10,11 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/net" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" + "github.com/shirou/gopsutil/v3/net" ) // copied from sys/sysctl.h diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go index 779f8126a..a123ccf9b 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go @@ -69,7 +69,13 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) { } func (p *Process) ExeWithContext(ctx context.Context) (string, error) { - return "", common.ErrNotImplementedError + mib := []int32{CTLKern, KernProc, KernProcPathname, p.Pid} + buf, _, err := common.CallSyscall(mib) + if err != nil { + return "", err + } + + return strings.Trim(string(buf), "\x00"), nil } func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go index d5b5bc329..29c447390 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go @@ -16,11 +16,12 @@ import ( "strconv" "strings" + "github.com/tklauser/go-sysconf" + "golang.org/x/sys/unix" + "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/internal/common" "github.com/shirou/gopsutil/v3/net" - "github.com/tklauser/go-sysconf" - "golang.org/x/sys/unix" ) var pageSize = uint64(os.Getpagesize()) @@ -100,7 +101,7 @@ func (p *Process) TgidWithContext(ctx context.Context) (int32, error) { } func (p *Process) ExeWithContext(ctx context.Context) (string, error) { - return p.fillFromExeWithContext() + return p.fillFromExeWithContext(ctx) } func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { @@ -120,7 +121,7 @@ func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) { } func (p *Process) CwdWithContext(ctx context.Context) (string, error) { - return p.fillFromCwdWithContext() + return p.fillFromCwdWithContext(ctx) } func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) { @@ -134,7 +135,7 @@ func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) { func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) { // see https://github.com/shirou/gopsutil/issues/596#issuecomment-432707831 for implementation details pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "stat") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "stat") contents, err := ioutil.ReadFile(statPath) if err != nil { return false, err @@ -202,7 +203,7 @@ func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) { } func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) { - rlimits, err := p.fillFromLimitsWithContext() + rlimits, err := p.fillFromLimitsWithContext(ctx) if !gatherUsed || err != nil { return rlimits, err } @@ -257,7 +258,7 @@ func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ( } func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) { - return p.fillFromIOWithContext() + return p.fillFromIOWithContext(ctx) } func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) { @@ -283,7 +284,7 @@ func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) { ret := make(map[int32]*cpu.TimesStat) - taskPath := common.HostProc(strconv.Itoa(int(p.Pid)), "task") + taskPath := common.HostProcWithContext(ctx, strconv.Itoa(int(p.Pid)), "task") tids, err := readPidsFromDir(taskPath) if err != nil { @@ -314,7 +315,7 @@ func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) { } func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) { - meminfo, _, err := p.fillFromStatmWithContext() + meminfo, _, err := p.fillFromStatmWithContext(ctx) if err != nil { return nil, err } @@ -322,7 +323,7 @@ func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, e } func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) { - _, memInfoEx, err := p.fillFromStatmWithContext() + _, memInfoEx, err := p.fillFromStatmWithContext(ctx) if err != nil { return nil, err } @@ -380,12 +381,12 @@ func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) { pid := p.Pid var ret []MemoryMapsStat - smapsPath := common.HostProc(strconv.Itoa(int(pid)), "smaps") + smapsPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "smaps") if grouped { ret = make([]MemoryMapsStat, 1) // If smaps_rollup exists (require kernel >= 4.15), then we will use it // for pre-summed memory information for a process. - smapsRollupPath := common.HostProc(strconv.Itoa(int(pid)), "smaps_rollup") + smapsRollupPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "smaps_rollup") if _, err := os.Stat(smapsRollupPath); !os.IsNotExist(err) { smapsPath = smapsRollupPath } @@ -481,7 +482,7 @@ func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]M } func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) { - environPath := common.HostProc(strconv.Itoa(int(p.Pid)), "environ") + environPath := common.HostProcWithContext(ctx, strconv.Itoa(int(p.Pid)), "environ") environContent, err := ioutil.ReadFile(environPath) if err != nil { @@ -507,9 +508,9 @@ func limitToUint(val string) (uint64, error) { } // Get num_fds from /proc/(pid)/limits -func (p *Process) fillFromLimitsWithContext() ([]RlimitStat, error) { +func (p *Process) fillFromLimitsWithContext(ctx context.Context) ([]RlimitStat, error) { pid := p.Pid - limitsFile := common.HostProc(strconv.Itoa(int(pid)), "limits") + limitsFile := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "limits") d, err := os.Open(limitsFile) if err != nil { return nil, err @@ -602,7 +603,7 @@ func (p *Process) fillFromLimitsWithContext() ([]RlimitStat, error) { // Get list of /proc/(pid)/fd files func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []string, error) { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "fd") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "fd") d, err := os.Open(statPath) if err != nil { return statPath, []string{}, err @@ -642,9 +643,9 @@ func (p *Process) fillFromfdWithContext(ctx context.Context) (int32, []*OpenFile } // Get cwd from /proc/(pid)/cwd -func (p *Process) fillFromCwdWithContext() (string, error) { +func (p *Process) fillFromCwdWithContext(ctx context.Context) (string, error) { pid := p.Pid - cwdPath := common.HostProc(strconv.Itoa(int(pid)), "cwd") + cwdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cwd") cwd, err := os.Readlink(cwdPath) if err != nil { return "", err @@ -653,9 +654,9 @@ func (p *Process) fillFromCwdWithContext() (string, error) { } // Get exe from /proc/(pid)/exe -func (p *Process) fillFromExeWithContext() (string, error) { +func (p *Process) fillFromExeWithContext(ctx context.Context) (string, error) { pid := p.Pid - exePath := common.HostProc(strconv.Itoa(int(pid)), "exe") + exePath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "exe") exe, err := os.Readlink(exePath) if err != nil { return "", err @@ -666,7 +667,7 @@ func (p *Process) fillFromExeWithContext() (string, error) { // Get cmdline from /proc/(pid)/cmdline func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return "", err @@ -680,7 +681,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return nil, err @@ -701,9 +702,9 @@ func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string } // Get IO status from /proc/(pid)/io -func (p *Process) fillFromIOWithContext() (*IOCountersStat, error) { +func (p *Process) fillFromIOWithContext(ctx context.Context) (*IOCountersStat, error) { pid := p.Pid - ioPath := common.HostProc(strconv.Itoa(int(pid)), "io") + ioPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "io") ioline, err := ioutil.ReadFile(ioPath) if err != nil { return nil, err @@ -737,9 +738,9 @@ func (p *Process) fillFromIOWithContext() (*IOCountersStat, error) { } // Get memory info from /proc/(pid)/statm -func (p *Process) fillFromStatmWithContext() (*MemoryInfoStat, *MemoryInfoExStat, error) { +func (p *Process) fillFromStatmWithContext(ctx context.Context) (*MemoryInfoStat, *MemoryInfoExStat, error) { pid := p.Pid - memPath := common.HostProc(strconv.Itoa(int(pid)), "statm") + memPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "statm") contents, err := ioutil.ReadFile(memPath) if err != nil { return nil, nil, err @@ -790,7 +791,7 @@ func (p *Process) fillFromStatmWithContext() (*MemoryInfoStat, *MemoryInfoExStat // Get name from /proc/(pid)/comm or /proc/(pid)/status func (p *Process) fillNameWithContext(ctx context.Context) error { - err := p.fillFromCommWithContext() + err := p.fillFromCommWithContext(ctx) if err == nil && p.name != "" && len(p.name) < 15 { return nil } @@ -798,9 +799,9 @@ func (p *Process) fillNameWithContext(ctx context.Context) error { } // Get name from /proc/(pid)/comm -func (p *Process) fillFromCommWithContext() error { +func (p *Process) fillFromCommWithContext(ctx context.Context) error { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "comm") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "comm") contents, err := ioutil.ReadFile(statPath) if err != nil { return err @@ -817,7 +818,7 @@ func (p *Process) fillFromStatus() error { func (p *Process) fillFromStatusWithContext(ctx context.Context) error { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "status") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "status") contents, err := ioutil.ReadFile(statPath) if err != nil { return err @@ -1022,9 +1023,9 @@ func (p *Process) fillFromTIDStatWithContext(ctx context.Context, tid int32) (ui var statPath string if tid == -1 { - statPath = common.HostProc(strconv.Itoa(int(pid)), "stat") + statPath = common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "stat") } else { - statPath = common.HostProc(strconv.Itoa(int(pid)), "task", strconv.Itoa(int(tid)), "stat") + statPath = common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "task", strconv.Itoa(int(tid)), "stat") } contents, err := ioutil.ReadFile(statPath) @@ -1128,7 +1129,7 @@ func (p *Process) fillFromStatWithContext(ctx context.Context) (uint64, int32, * } func pidsWithContext(ctx context.Context) ([]int32, error) { - return readPidsFromDir(common.HostProc()) + return readPidsFromDir(common.HostProcWithContext(ctx)) } func ProcessesWithContext(ctx context.Context) ([]*Process, error) { diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go index 88e2bff53..a01f9ecfc 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go @@ -14,8 +14,9 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) type Signal = syscall.Signal @@ -108,8 +109,8 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) { return false, err } - if isMount(common.HostProc()) { // if //proc exists and is mounted, check if //proc/ folder exists - _, err := os.Stat(common.HostProc(strconv.Itoa(int(pid)))) + if isMount(common.HostProcWithContext(ctx)) { // if //proc exists and is mounted, check if //proc/ folder exists + _, err := os.Stat(common.HostProcWithContext(ctx, strconv.Itoa(int(pid)))) if os.IsNotExist(err) { return false, nil } @@ -121,7 +122,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) { if err == nil { return true, nil } - if err.Error() == "os: process already finished" { + if errors.Is(err, os.ErrProcessDone) { return false, nil } var errno syscall.Errno diff --git a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go index 4f10a67bc..ad1c3cfc1 100644 --- a/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go +++ b/test/integration/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go @@ -30,7 +30,7 @@ type MemoryMapsStat struct { type MemoryInfoExStat struct{} func pidsWithContext(ctx context.Context) ([]int32, error) { - return readPidsFromDir(common.HostProc()) + return readPidsFromDir(common.HostProcWithContext(ctx)) } func ProcessesWithContext(ctx context.Context) ([]*Process, error) { @@ -199,7 +199,7 @@ func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) { func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []string, error) { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "fd") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "fd") d, err := os.Open(statPath) if err != nil { return statPath, []string{}, err @@ -211,7 +211,7 @@ func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []stri func (p *Process) fillFromPathCwdWithContext(ctx context.Context) (string, error) { pid := p.Pid - cwdPath := common.HostProc(strconv.Itoa(int(pid)), "path", "cwd") + cwdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "path", "cwd") cwd, err := os.Readlink(cwdPath) if err != nil { return "", err @@ -221,7 +221,7 @@ func (p *Process) fillFromPathCwdWithContext(ctx context.Context) (string, error func (p *Process) fillFromPathAOutWithContext(ctx context.Context) (string, error) { pid := p.Pid - cwdPath := common.HostProc(strconv.Itoa(int(pid)), "path", "a.out") + cwdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "path", "a.out") exe, err := os.Readlink(cwdPath) if err != nil { return "", err @@ -231,7 +231,7 @@ func (p *Process) fillFromPathAOutWithContext(ctx context.Context) (string, erro func (p *Process) fillFromExecnameWithContext(ctx context.Context) (string, error) { pid := p.Pid - execNamePath := common.HostProc(strconv.Itoa(int(pid)), "execname") + execNamePath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "execname") exe, err := ioutil.ReadFile(execNamePath) if err != nil { return "", err @@ -241,7 +241,7 @@ func (p *Process) fillFromExecnameWithContext(ctx context.Context) (string, erro func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return "", err @@ -258,7 +258,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return nil, err diff --git a/test/integration/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml b/test/integration/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml new file mode 100644 index 000000000..dc6fefb97 --- /dev/null +++ b/test/integration/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml @@ -0,0 +1,12 @@ +run: + timeout: 5m +linters: + enable: + - gofmt + - errcheck + - errname + - errorlint + - bodyclose + - durationcheck + - whitespace + diff --git a/test/integration/vendor/github.com/shoenig/go-m1cpu/LICENSE b/test/integration/vendor/github.com/shoenig/go-m1cpu/LICENSE new file mode 100644 index 000000000..e87a115e4 --- /dev/null +++ b/test/integration/vendor/github.com/shoenig/go-m1cpu/LICENSE @@ -0,0 +1,363 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. + diff --git a/test/integration/vendor/github.com/shoenig/go-m1cpu/Makefile b/test/integration/vendor/github.com/shoenig/go-m1cpu/Makefile new file mode 100644 index 000000000..28d786397 --- /dev/null +++ b/test/integration/vendor/github.com/shoenig/go-m1cpu/Makefile @@ -0,0 +1,12 @@ +SHELL = bash + +default: test + +.PHONY: test +test: + @echo "--> Running Tests ..." + @go test -v -race ./... + +vet: + @echo "--> Vet Go sources ..." + @go vet ./... diff --git a/test/integration/vendor/github.com/shoenig/go-m1cpu/README.md b/test/integration/vendor/github.com/shoenig/go-m1cpu/README.md new file mode 100644 index 000000000..399657acf --- /dev/null +++ b/test/integration/vendor/github.com/shoenig/go-m1cpu/README.md @@ -0,0 +1,66 @@ +# m1cpu + +[![Go Reference](https://pkg.go.dev/badge/github.com/shoenig/go-m1cpu.svg)](https://pkg.go.dev/github.com/shoenig/go-m1cpu) +[![MPL License](https://img.shields.io/github/license/shoenig/go-m1cpu?color=g&style=flat-square)](https://github.com/shoenig/go-m1cpu/blob/main/LICENSE) +[![Run CI Tests](https://github.com/shoenig/go-m1cpu/actions/workflows/ci.yaml/badge.svg)](https://github.com/shoenig/go-m1cpu/actions/workflows/ci.yaml) + +The `go-m1cpu` module is a library for inspecting Apple Silicon CPUs in Go. + +Use the `m1cpu` Go package for looking up the CPU frequency for Apple M1 and M2 CPUs. + +# Install + +```shell +go get github.com/shoenig/go-m1cpu@latest +``` + +# CGO + +This package requires the use of [CGO](https://go.dev/blog/cgo). + +Extracting the CPU properties is done via Apple's [IOKit](https://developer.apple.com/documentation/iokit?language=objc) +framework, which is accessible only through system C libraries. + +# Example + +Simple Go program to print Apple Silicon M1/M2 CPU speeds. + +```go +package main + +import ( + "fmt" + + "github.com/shoenig/go-m1cpu" +) + +func main() { + fmt.Println("Apple Silicon", m1cpu.IsAppleSilicon()) + + fmt.Println("pCore GHz", m1cpu.PCoreGHz()) + fmt.Println("eCore GHz", m1cpu.ECoreGHz()) + + fmt.Println("pCore Hz", m1cpu.PCoreHz()) + fmt.Println("eCore Hz", m1cpu.ECoreHz()) +} +``` + +Using `go test` to print out available information. + +``` +➜ go test -v -run Show +=== RUN Test_Show + cpu_test.go:42: pCore Hz 3504000000 + cpu_test.go:43: eCore Hz 2424000000 + cpu_test.go:44: pCore GHz 3.504 + cpu_test.go:45: eCore GHz 2.424 + cpu_test.go:46: pCore count 8 + cpu_test.go:47: eCoreCount 4 + cpu_test.go:50: pCore Caches 196608 131072 16777216 + cpu_test.go:53: eCore Caches 131072 65536 4194304 +--- PASS: Test_Show (0.00s) +``` + +# License + +Open source under the [MPL](LICENSE) diff --git a/test/integration/vendor/github.com/shoenig/go-m1cpu/cpu.go b/test/integration/vendor/github.com/shoenig/go-m1cpu/cpu.go new file mode 100644 index 000000000..502a8cce9 --- /dev/null +++ b/test/integration/vendor/github.com/shoenig/go-m1cpu/cpu.go @@ -0,0 +1,213 @@ +//go:build darwin && arm64 && cgo + +package m1cpu + +// #cgo LDFLAGS: -framework CoreFoundation -framework IOKit +// #include +// #include +// #include +// #include +// +// #if !defined(MAC_OS_VERSION_12_0) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0 +// #define kIOMainPortDefault kIOMasterPortDefault +// #endif +// +// #define HzToGHz(hz) ((hz) / 1000000000.0) +// +// UInt64 global_pCoreHz; +// UInt64 global_eCoreHz; +// int global_pCoreCount; +// int global_eCoreCount; +// int global_pCoreL1InstCacheSize; +// int global_eCoreL1InstCacheSize; +// int global_pCoreL1DataCacheSize; +// int global_eCoreL1DataCacheSize; +// int global_pCoreL2CacheSize; +// int global_eCoreL2CacheSize; +// char global_brand[32]; +// +// UInt64 getFrequency(CFTypeRef typeRef) { +// CFDataRef cfData = typeRef; +// +// CFIndex size = CFDataGetLength(cfData); +// UInt8 buf[size]; +// CFDataGetBytes(cfData, CFRangeMake(0, size), buf); +// +// UInt8 b1 = buf[size-5]; +// UInt8 b2 = buf[size-6]; +// UInt8 b3 = buf[size-7]; +// UInt8 b4 = buf[size-8]; +// +// UInt64 pCoreHz = 0x00000000FFFFFFFF & ((b1<<24) | (b2 << 16) | (b3 << 8) | (b4)); +// return pCoreHz; +// } +// +// int sysctl_int(const char * name) { +// int value = -1; +// size_t size = 8; +// sysctlbyname(name, &value, &size, NULL, 0); +// return value; +// } +// +// void sysctl_string(const char * name, char * dest) { +// size_t size = 32; +// sysctlbyname(name, dest, &size, NULL, 0); +// } +// +// void initialize() { +// global_pCoreCount = sysctl_int("hw.perflevel0.physicalcpu"); +// global_eCoreCount = sysctl_int("hw.perflevel1.physicalcpu"); +// global_pCoreL1InstCacheSize = sysctl_int("hw.perflevel0.l1icachesize"); +// global_eCoreL1InstCacheSize = sysctl_int("hw.perflevel1.l1icachesize"); +// global_pCoreL1DataCacheSize = sysctl_int("hw.perflevel0.l1dcachesize"); +// global_eCoreL1DataCacheSize = sysctl_int("hw.perflevel1.l1dcachesize"); +// global_pCoreL2CacheSize = sysctl_int("hw.perflevel0.l2cachesize"); +// global_eCoreL2CacheSize = sysctl_int("hw.perflevel1.l2cachesize"); +// sysctl_string("machdep.cpu.brand_string", global_brand); +// +// CFMutableDictionaryRef matching = IOServiceMatching("AppleARMIODevice"); +// io_iterator_t iter; +// IOServiceGetMatchingServices(kIOMainPortDefault, matching, &iter); +// +// const size_t bufsize = 512; +// io_object_t obj; +// while ((obj = IOIteratorNext(iter))) { +// char class[bufsize]; +// IOObjectGetClass(obj, class); +// char name[bufsize]; +// IORegistryEntryGetName(obj, name); +// +// if (strncmp(name, "pmgr", bufsize) == 0) { +// CFTypeRef pCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states5-sram"), kCFAllocatorDefault, 0); +// CFTypeRef eCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states1-sram"), kCFAllocatorDefault, 0); +// +// long long pCoreHz = getFrequency(pCoreRef); +// long long eCoreHz = getFrequency(eCoreRef); +// +// global_pCoreHz = pCoreHz; +// global_eCoreHz = eCoreHz; +// return; +// } +// } +// } +// +// UInt64 eCoreHz() { +// return global_eCoreHz; +// } +// +// UInt64 pCoreHz() { +// return global_pCoreHz; +// } +// +// Float64 eCoreGHz() { +// return HzToGHz(global_eCoreHz); +// } +// +// Float64 pCoreGHz() { +// return HzToGHz(global_pCoreHz); +// } +// +// int pCoreCount() { +// return global_pCoreCount; +// } +// +// int eCoreCount() { +// return global_eCoreCount; +// } +// +// int pCoreL1InstCacheSize() { +// return global_pCoreL1InstCacheSize; +// } +// +// int pCoreL1DataCacheSize() { +// return global_pCoreL1DataCacheSize; +// } +// +// int pCoreL2CacheSize() { +// return global_pCoreL2CacheSize; +// } +// +// int eCoreL1InstCacheSize() { +// return global_eCoreL1InstCacheSize; +// } +// +// int eCoreL1DataCacheSize() { +// return global_eCoreL1DataCacheSize; +// } +// +// int eCoreL2CacheSize() { +// return global_eCoreL2CacheSize; +// } +// +// char * modelName() { +// return global_brand; +// } +import "C" + +func init() { + C.initialize() +} + +// IsAppleSilicon returns true on this platform. +func IsAppleSilicon() bool { + return true +} + +// PCoreHZ returns the max frequency in Hertz of the P-Core of an Apple Silicon CPU. +func PCoreHz() uint64 { + return uint64(C.pCoreHz()) +} + +// ECoreHZ returns the max frequency in Hertz of the E-Core of an Apple Silicon CPU. +func ECoreHz() uint64 { + return uint64(C.eCoreHz()) +} + +// PCoreGHz returns the max frequency in Gigahertz of the P-Core of an Apple Silicon CPU. +func PCoreGHz() float64 { + return float64(C.pCoreGHz()) +} + +// ECoreGHz returns the max frequency in Gigahertz of the E-Core of an Apple Silicon CPU. +func ECoreGHz() float64 { + return float64(C.eCoreGHz()) +} + +// PCoreCount returns the number of physical P (performance) cores. +func PCoreCount() int { + return int(C.pCoreCount()) +} + +// ECoreCount returns the number of physical E (efficiency) cores. +func ECoreCount() int { + return int(C.eCoreCount()) +} + +// PCoreCacheSize returns the sizes of the P (performance) core cache sizes +// in the order of +// +// - L1 instruction cache +// - L1 data cache +// - L2 cache +func PCoreCache() (int, int, int) { + return int(C.pCoreL1InstCacheSize()), + int(C.pCoreL1DataCacheSize()), + int(C.pCoreL2CacheSize()) +} + +// ECoreCacheSize returns the sizes of the E (efficiency) core cache sizes +// in the order of +// +// - L1 instruction cache +// - L1 data cache +// - L2 cache +func ECoreCache() (int, int, int) { + return int(C.eCoreL1InstCacheSize()), + int(C.eCoreL1DataCacheSize()), + int(C.eCoreL2CacheSize()) +} + +// ModelName returns the model name of the CPU. +func ModelName() string { + return C.GoString(C.modelName()) +} diff --git a/test/integration/vendor/github.com/shoenig/go-m1cpu/incompatible.go b/test/integration/vendor/github.com/shoenig/go-m1cpu/incompatible.go new file mode 100644 index 000000000..d425025aa --- /dev/null +++ b/test/integration/vendor/github.com/shoenig/go-m1cpu/incompatible.go @@ -0,0 +1,53 @@ +//go:build !darwin || !arm64 || !cgo + +package m1cpu + +// IsAppleSilicon return false on this platform. +func IsAppleSilicon() bool { + return false +} + +// PCoreHZ requires darwin/arm64 +func PCoreHz() uint64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreHZ requires darwin/arm64 +func ECoreHz() uint64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreGHz requires darwin/arm64 +func PCoreGHz() float64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreGHz requires darwin/arm64 +func ECoreGHz() float64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreCount requires darwin/arm64 +func PCoreCount() int { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreCount requires darwin/arm64 +func ECoreCount() int { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreCacheSize requires darwin/arm64 +func PCoreCache() (int, int, int) { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreCacheSize requires darwin/arm64 +func ECoreCache() (int, int, int) { + panic("m1cpu: not a darwin/arm64 system") +} + +// ModelName requires darwin/arm64 +func ModelName() string { + panic("m1cpu: not a darwin/arm64 system") +} diff --git a/test/integration/vendor/github.com/yusufpapurcu/wmi/README.md b/test/integration/vendor/github.com/yusufpapurcu/wmi/README.md index c4a432d6d..426d1a46b 100644 --- a/test/integration/vendor/github.com/yusufpapurcu/wmi/README.md +++ b/test/integration/vendor/github.com/yusufpapurcu/wmi/README.md @@ -4,10 +4,3 @@ wmi Package wmi provides a WQL interface to Windows WMI. Note: It interfaces with WMI on the local machine, therefore it only runs on Windows. - ---- - -NOTE: This project is no longer being actively maintained. If you would like -to become its new owner, please contact tlimoncelli at stack over flow dot com. - ---- diff --git a/test/integration/vendor/github.com/yusufpapurcu/wmi/swbemservices.go b/test/integration/vendor/github.com/yusufpapurcu/wmi/swbemservices.go index 3ff875630..a250c846d 100644 --- a/test/integration/vendor/github.com/yusufpapurcu/wmi/swbemservices.go +++ b/test/integration/vendor/github.com/yusufpapurcu/wmi/swbemservices.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package wmi diff --git a/test/integration/vendor/github.com/yusufpapurcu/wmi/wmi.go b/test/integration/vendor/github.com/yusufpapurcu/wmi/wmi.go index b4bb4f090..26c3581c9 100644 --- a/test/integration/vendor/github.com/yusufpapurcu/wmi/wmi.go +++ b/test/integration/vendor/github.com/yusufpapurcu/wmi/wmi.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows /* @@ -20,7 +21,6 @@ Example code to print names of running processes: println(i, v.Name) } } - */ package wmi @@ -338,11 +338,6 @@ func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismat f := v.Field(i) of := f isPtr := f.Kind() == reflect.Ptr - if isPtr { - ptr := reflect.New(f.Type().Elem()) - f.Set(ptr) - f = f.Elem() - } n := v.Type().Field(i).Name if n[0] < 'A' || n[0] > 'Z' { continue @@ -367,6 +362,12 @@ func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismat } defer prop.Clear() + if isPtr && !(c.PtrNil && prop.VT == 0x1) { + ptr := reflect.New(f.Type().Elem()) + f.Set(ptr) + f = f.Elem() + } + if prop.VT == 0x1 { //VT_NULL continue } diff --git a/test/integration/vendor/modules.txt b/test/integration/vendor/modules.txt index 8656710cc..5bc51424e 100644 --- a/test/integration/vendor/modules.txt +++ b/test/integration/vendor/modules.txt @@ -106,7 +106,7 @@ github.com/docker/buildx/util/platformutil github.com/docker/buildx/util/progress github.com/docker/buildx/util/resolver github.com/docker/buildx/util/waitmap -# github.com/docker/cli v23.0.5+incompatible => github.com/docker/cli v20.10.3-0.20221013132413-1d6c6e2367e2+incompatible +# github.com/docker/cli v24.0.2+incompatible => github.com/docker/cli v20.10.3-0.20221013132413-1d6c6e2367e2+incompatible ## explicit github.com/docker/cli/cli github.com/docker/cli/cli-plugins/manager @@ -151,7 +151,7 @@ github.com/docker/compose/v2/pkg/compose github.com/docker/compose/v2/pkg/progress github.com/docker/compose/v2/pkg/prompt github.com/docker/compose/v2/pkg/utils -# github.com/docker/distribution v2.8.2-beta.1+incompatible +# github.com/docker/distribution v2.8.2+incompatible ## explicit github.com/docker/distribution github.com/docker/distribution/digestset @@ -169,7 +169,7 @@ github.com/docker/distribution/registry/client/transport github.com/docker/distribution/registry/storage/cache github.com/docker/distribution/registry/storage/cache/memory github.com/docker/distribution/uuid -# github.com/docker/docker v23.0.5+incompatible => github.com/docker/docker v20.10.3-0.20221013203545-33ab36d6b304+incompatible +# github.com/docker/docker v24.0.2+incompatible => github.com/docker/docker v20.10.3-0.20221013203545-33ab36d6b304+incompatible ## explicit github.com/docker/docker/api github.com/docker/docker/api/types @@ -378,7 +378,7 @@ github.com/magiconair/properties # github.com/mattn/go-colorable v0.1.13 ## explicit; go 1.15 github.com/mattn/go-colorable -# github.com/mattn/go-isatty v0.0.18 +# github.com/mattn/go-isatty v0.0.19 ## explicit; go 1.15 github.com/mattn/go-isatty # github.com/mattn/go-runewidth v0.0.14 @@ -567,21 +567,21 @@ github.com/pmezard/go-difflib/difflib # github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c ## explicit; go 1.14 github.com/power-devops/perfstat -# github.com/prometheus/client_golang v1.13.0 +# github.com/prometheus/client_golang v1.16.0 ## explicit; go 1.17 github.com/prometheus/client_golang/prometheus github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/promhttp -# github.com/prometheus/client_model v0.3.0 -## explicit; go 1.9 +# github.com/prometheus/client_model v0.4.0 +## explicit; go 1.18 github.com/prometheus/client_model/go -# github.com/prometheus/common v0.37.0 -## explicit; go 1.16 +# github.com/prometheus/common v0.44.0 +## explicit; go 1.18 github.com/prometheus/common/expfmt github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg github.com/prometheus/common/model -# github.com/prometheus/procfs v0.8.0 -## explicit; go 1.17 +# github.com/prometheus/procfs v0.11.0 +## explicit; go 1.19 github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util @@ -591,8 +591,9 @@ github.com/rivo/uniseg # github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002 ## explicit github.com/serialx/hashring -# github.com/shirou/gopsutil/v3 v3.23.2 +# github.com/shirou/gopsutil/v3 v3.23.6 ## explicit; go 1.15 +github.com/shirou/gopsutil/v3/common github.com/shirou/gopsutil/v3/cpu github.com/shirou/gopsutil/v3/disk github.com/shirou/gopsutil/v3/host @@ -600,6 +601,9 @@ github.com/shirou/gopsutil/v3/internal/common github.com/shirou/gopsutil/v3/mem github.com/shirou/gopsutil/v3/net github.com/shirou/gopsutil/v3/process +# github.com/shoenig/go-m1cpu v0.1.6 +## explicit; go 1.20 +github.com/shoenig/go-m1cpu # github.com/sirupsen/logrus v1.9.3 ## explicit; go 1.13 github.com/sirupsen/logrus @@ -694,7 +698,7 @@ github.com/xeipuuv/gojsonreference # github.com/xeipuuv/gojsonschema v1.2.0 ## explicit github.com/xeipuuv/gojsonschema -# github.com/yusufpapurcu/wmi v1.2.2 +# github.com/yusufpapurcu/wmi v1.2.3 ## explicit; go 1.16 github.com/yusufpapurcu/wmi # go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.29.0 diff --git a/test/performance/go.mod b/test/performance/go.mod index 3aebe9394..a0fab72c9 100644 --- a/test/performance/go.mod +++ b/test/performance/go.mod @@ -10,7 +10,7 @@ require ( github.com/nats-io/nats.go v1.16.0 github.com/nginx/agent/sdk/v2 v2.0.0-00010101000000-000000000000 github.com/nginx/agent/v2 v2.0.0-00010101000000-000000000000 - github.com/prometheus/client_golang v1.13.0 + github.com/prometheus/client_golang v1.16.0 github.com/sanity-io/litter v1.5.5 github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.8.4 @@ -45,18 +45,19 @@ require ( github.com/nats-io/nuid v1.0.1 // indirect github.com/nginxinc/nginx-go-crossplane v0.4.17 // indirect github.com/nginxinc/nginx-plus-go-client v0.10.0 // indirect - github.com/nginxinc/nginx-prometheus-exporter v0.10.0 // indirect + github.com/nginxinc/nginx-prometheus-exporter v0.11.0 // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/orcaman/concurrent-map v1.0.0 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.37.0 // indirect - github.com/prometheus/procfs v0.8.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.11.0 // indirect github.com/rs/cors v1.9.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect - github.com/shirou/gopsutil/v3 v3.23.2 // indirect + github.com/shirou/gopsutil/v3 v3.23.6 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/cobra v1.7.0 // indirect @@ -69,7 +70,7 @@ require ( github.com/tklauser/numcpus v0.6.0 // indirect github.com/trivago/grok v1.0.0 // indirect github.com/vardius/message-bus v1.1.5 // indirect - github.com/yusufpapurcu/wmi v1.2.2 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect golang.org/x/crypto v0.11.0 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.12.0 // indirect diff --git a/test/performance/go.sum b/test/performance/go.sum index f49a4235c..d1d0ce4d7 100644 --- a/test/performance/go.sum +++ b/test/performance/go.sum @@ -38,21 +38,12 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -80,20 +71,13 @@ github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbS github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -123,7 +107,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -142,7 +125,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -173,17 +155,10 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jstemmer/go-junit-report v1.0.0 h1:8X1gzZpR+nVQLAht+L/foqOeX2l9DTZoaIPbEQHxsds= github.com/jstemmer/go-junit-report v1.0.0/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -193,9 +168,7 @@ github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs github.com/klauspost/cpuid/v2 v2.1.0 h1:eyi1Ad2aNJMW95zcSbmGg7Cg6cq3ADwLpMAP96d8rF0= github.com/klauspost/cpuid/v2 v2.1.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -206,7 +179,6 @@ github.com/lufia/plan9stats v0.0.0-20220517141722-cf486979b281 h1:aczX6NMOtt6L4Y github.com/lufia/plan9stats v0.0.0-20220517141722-cf486979b281/go.mod h1:lc+czkgO/8F7puNki5jk8QyujbfK1LOT7Wl0ON2hxyk= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/maxbrunsfeld/counterfeiter/v6 v6.6.1 h1:9XE5ykDiC8eNSqIPkxx0EsV3kMX1oe4kQWRZjIgytUA= @@ -215,13 +187,6 @@ github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nats-io/jwt/v2 v2.3.0 h1:z2mA1a7tIf5ShggOFlR1oBPgd6hGqcDYsISxZByUzdI= github.com/nats-io/jwt/v2 v2.3.0/go.mod h1:0tqz9Hlu6bCBFLWAASKhE5vUA4c24L9KPUUgvwumE/k= github.com/nats-io/nats-server/v2 v2.8.4 h1:0jQzze1T9mECg8YZEl8+WYUXb9JKluJfCBriPUtluB4= @@ -236,8 +201,8 @@ github.com/nginxinc/nginx-go-crossplane v0.4.17 h1:kBISwQT36Uv4h57ran0bT4MIWUqao github.com/nginxinc/nginx-go-crossplane v0.4.17/go.mod h1:UzbZnyFv0vPlt1Urbnp/mrFCzBL4tYCReFuNBpFQEfI= github.com/nginxinc/nginx-plus-go-client v0.10.0 h1:3zsMMkPvRDo8D7ZSprXtbAEW/SDmezZWzxdyS+6oAlc= github.com/nginxinc/nginx-plus-go-client v0.10.0/go.mod h1:0v3RsQCvRn/IyrMtW+DK6CNkz+PxEsXDJPjQ3yUMBF0= -github.com/nginxinc/nginx-prometheus-exporter v0.10.0 h1:wFP8mYMtmn8uK1I5tzXb3s4CQq+r3h6Y0Qdc7d+QpyM= -github.com/nginxinc/nginx-prometheus-exporter v0.10.0/go.mod h1:U3BudpuBp/uO++yvnaaI4Dz7oOFJPdM726WEv70k3O4= +github.com/nginxinc/nginx-prometheus-exporter v0.11.0 h1:21xjnqNgxtni2jDgAQ90bl15uDnrTreO9sIlu1YsX/U= +github.com/nginxinc/nginx-prometheus-exporter v0.11.0/go.mod h1:GdyHnWAb8q8OW1Pssrrqbcqra0SH0Vn6UXICMmyWkw8= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= @@ -246,7 +211,6 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= @@ -256,34 +220,17 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c h1:NRoLoZvkBTKvR5gQLgA3e0hqjkY9u1wm+iOL45VN/qI= github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= -github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= -github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= +github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= +github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE= github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -292,11 +239,13 @@ github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil/v3 v3.23.2 h1:PAWSuiAszn7IhPMBtXsbSCafej7PqUOvY6YywlQUExU= -github.com/shirou/gopsutil/v3 v3.23.2/go.mod h1:gv0aQw33GLo3pG8SiWKiQrbDzbRY1K80RyZJ7V4Th1M= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/shirou/gopsutil/v3 v3.23.6 h1:5y46WPI9QBKBbK7EEccUPNXpJpNrvPuTD0O2zHEHT08= +github.com/shirou/gopsutil/v3 v3.23.6/go.mod h1:j7QX50DrXYggrpN30W0Mo+I4/8U2UUIQrnrhqUeWrAU= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= @@ -324,7 +273,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -343,8 +291,8 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= -github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -357,7 +305,6 @@ go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -405,7 +352,6 @@ golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -413,7 +359,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -436,11 +381,8 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -452,8 +394,6 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -467,8 +407,6 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -484,7 +422,6 @@ golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -497,8 +434,6 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -507,24 +442,19 @@ golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -693,10 +623,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= @@ -705,12 +633,8 @@ gopkg.in/mcuadros/go-syslog.v2 v2.3.0 h1:kcsiS+WsTKyIEPABJBJtoG0KkOS6yzvJ+/eZlhD gopkg.in/mcuadros/go-syslog.v2 v2.3.0/go.mod h1:l5LPIyOOyIdQquNg+oU6Z3524YwrcqEm0aKH+5zpt2U= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/counter.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/counter.go index de30de6da..62de4dc59 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/counter.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/counter.go @@ -59,6 +59,18 @@ type ExemplarAdder interface { // CounterOpts is an alias for Opts. See there for doc comments. type CounterOpts Opts +// CounterVecOpts bundles the options to create a CounterVec metric. +// It is mandatory to set CounterOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type CounterVecOpts struct { + CounterOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels +} + // NewCounter creates a new Counter based on the provided CounterOpts. // // The returned implementation also implements ExemplarAdder. It is safe to @@ -140,12 +152,13 @@ func (c *counter) get() float64 { } func (c *counter) Write(out *dto.Metric) error { - val := c.get() - + // Read the Exemplar first and the value second. This is to avoid a race condition + // where users see an exemplar for a not-yet-existing observation. var exemplar *dto.Exemplar if e := c.exemplar.Load(); e != nil { exemplar = e.(*dto.Exemplar) } + val := c.get() return populateMetric(CounterValue, val, c.labelPairs, exemplar, out) } @@ -173,16 +186,24 @@ type CounterVec struct { // NewCounterVec creates a new CounterVec based on the provided CounterOpts and // partitioned by the given label names. func NewCounterVec(opts CounterOpts, labelNames []string) *CounterVec { - desc := NewDesc( + return V2.NewCounterVec(CounterVecOpts{ + CounterOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewCounterVec creates a new CounterVec based on the provided CounterVecOpts. +func (v2) NewCounterVec(opts CounterVecOpts) *CounterVec { + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &CounterVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { if len(lvs) != len(desc.variableLabels) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, lvs)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), lvs)) } result := &counter{desc: desc, labelPairs: MakeLabelPairs(desc, lvs), now: time.Now} result.init(result) // Init self-collection. @@ -245,7 +266,8 @@ func (v *CounterVec) GetMetricWith(labels Labels) (Counter, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Add(42) +// +// myVec.WithLabelValues("404", "GET").Add(42) func (v *CounterVec) WithLabelValues(lvs ...string) Counter { c, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -256,7 +278,8 @@ func (v *CounterVec) WithLabelValues(lvs ...string) Counter { // With works as GetMetricWith, but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) func (v *CounterVec) With(labels Labels) Counter { c, err := v.GetMetricWith(labels) if err != nil { diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/desc.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/desc.go index 8bc5e44e2..deedc2dfb 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/desc.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/desc.go @@ -14,20 +14,16 @@ package prometheus import ( - "errors" "fmt" "sort" "strings" "github.com/cespare/xxhash/v2" - - "github.com/prometheus/client_golang/prometheus/internal" - - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" + dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/model" + "google.golang.org/protobuf/proto" - dto "github.com/prometheus/client_model/go" + "github.com/prometheus/client_golang/prometheus/internal" ) // Desc is the descriptor used by every Prometheus Metric. It is essentially @@ -54,9 +50,9 @@ type Desc struct { // constLabelPairs contains precalculated DTO label pairs based on // the constant labels. constLabelPairs []*dto.LabelPair - // variableLabels contains names of labels for which the metric - // maintains variable values. - variableLabels []string + // variableLabels contains names of labels and normalization function for + // which the metric maintains variable values. + variableLabels ConstrainedLabels // id is a hash of the values of the ConstLabels and fqName. This // must be unique among all registered descriptors and can therefore be // used as an identifier of the descriptor. @@ -80,10 +76,24 @@ type Desc struct { // For constLabels, the label values are constant. Therefore, they are fully // specified in the Desc. See the Collector example for a usage pattern. func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *Desc { + return V2.NewDesc(fqName, help, UnconstrainedLabels(variableLabels), constLabels) +} + +// NewDesc allocates and initializes a new Desc. Errors are recorded in the Desc +// and will be reported on registration time. variableLabels and constLabels can +// be nil if no such labels should be set. fqName must not be empty. +// +// variableLabels only contain the label names and normalization functions. Their +// label values are variable and therefore not part of the Desc. (They are managed +// within the Metric.) +// +// For constLabels, the label values are constant. Therefore, they are fully +// specified in the Desc. See the Collector example for a usage pattern. +func (v2) NewDesc(fqName, help string, variableLabels ConstrainableLabels, constLabels Labels) *Desc { d := &Desc{ fqName: fqName, help: help, - variableLabels: variableLabels, + variableLabels: variableLabels.constrainedLabels(), } if !model.IsValidMetricName(model.LabelValue(fqName)) { d.err = fmt.Errorf("%q is not a valid metric name", fqName) @@ -93,7 +103,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) * // their sorted label names) plus the fqName (at position 0). labelValues := make([]string, 1, len(constLabels)+1) labelValues[0] = fqName - labelNames := make([]string, 0, len(constLabels)+len(variableLabels)) + labelNames := make([]string, 0, len(constLabels)+len(d.variableLabels)) labelNameSet := map[string]struct{}{} // First add only the const label names and sort them... for labelName := range constLabels { @@ -118,16 +128,16 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) * // Now add the variable label names, but prefix them with something that // cannot be in a regular label name. That prevents matching the label // dimension with a different mix between preset and variable labels. - for _, labelName := range variableLabels { - if !checkLabelName(labelName) { - d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName) + for _, label := range d.variableLabels { + if !checkLabelName(label.Name) { + d.err = fmt.Errorf("%q is not a valid label name for metric %q", label.Name, fqName) return d } - labelNames = append(labelNames, "$"+labelName) - labelNameSet[labelName] = struct{}{} + labelNames = append(labelNames, "$"+label.Name) + labelNameSet[label.Name] = struct{}{} } if len(labelNames) != len(labelNameSet) { - d.err = errors.New("duplicate label names") + d.err = fmt.Errorf("duplicate label names in constant and variable labels for metric %q", fqName) return d } diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/doc.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/doc.go index 98450125d..962608f02 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/doc.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/doc.go @@ -21,55 +21,66 @@ // All exported functions and methods are safe to be used concurrently unless // specified otherwise. // -// A Basic Example +// # A Basic Example // // As a starting point, a very basic usage example: // -// package main -// -// import ( -// "log" -// "net/http" -// -// "github.com/prometheus/client_golang/prometheus" -// "github.com/prometheus/client_golang/prometheus/promhttp" -// ) -// -// var ( -// cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{ -// Name: "cpu_temperature_celsius", -// Help: "Current temperature of the CPU.", -// }) -// hdFailures = prometheus.NewCounterVec( -// prometheus.CounterOpts{ -// Name: "hd_errors_total", -// Help: "Number of hard-disk errors.", -// }, -// []string{"device"}, -// ) -// ) -// -// func init() { -// // Metrics have to be registered to be exposed: -// prometheus.MustRegister(cpuTemp) -// prometheus.MustRegister(hdFailures) -// } -// -// func main() { -// cpuTemp.Set(65.3) -// hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc() -// -// // The Handler function provides a default handler to expose metrics -// // via an HTTP server. "/metrics" is the usual endpoint for that. -// http.Handle("/metrics", promhttp.Handler()) -// log.Fatal(http.ListenAndServe(":8080", nil)) -// } -// +// package main +// +// import ( +// "log" +// "net/http" +// +// "github.com/prometheus/client_golang/prometheus" +// "github.com/prometheus/client_golang/prometheus/promhttp" +// ) +// +// type metrics struct { +// cpuTemp prometheus.Gauge +// hdFailures *prometheus.CounterVec +// } +// +// func NewMetrics(reg prometheus.Registerer) *metrics { +// m := &metrics{ +// cpuTemp: prometheus.NewGauge(prometheus.GaugeOpts{ +// Name: "cpu_temperature_celsius", +// Help: "Current temperature of the CPU.", +// }), +// hdFailures: prometheus.NewCounterVec( +// prometheus.CounterOpts{ +// Name: "hd_errors_total", +// Help: "Number of hard-disk errors.", +// }, +// []string{"device"}, +// ), +// } +// reg.MustRegister(m.cpuTemp) +// reg.MustRegister(m.hdFailures) +// return m +// } +// +// func main() { +// // Create a non-global registry. +// reg := prometheus.NewRegistry() +// +// // Create new metrics and register them using the custom registry. +// m := NewMetrics(reg) +// // Set values for the new created metrics. +// m.cpuTemp.Set(65.3) +// m.hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc() +// +// // Expose metrics and custom registry via an HTTP server +// // using the HandleFor function. "/metrics" is the usual endpoint for that. +// http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: reg})) +// log.Fatal(http.ListenAndServe(":8080", nil)) +// } // // This is a complete program that exports two metrics, a Gauge and a Counter, // the latter with a label attached to turn it into a (one-dimensional) vector. +// It register the metrics using a custom registry and exposes them via an HTTP server +// on the /metrics endpoint. // -// Metrics +// # Metrics // // The number of exported identifiers in this package might appear a bit // overwhelming. However, in addition to the basic plumbing shown in the example @@ -100,7 +111,7 @@ // To create instances of Metrics and their vector versions, you need a suitable // …Opts struct, i.e. GaugeOpts, CounterOpts, SummaryOpts, or HistogramOpts. // -// Custom Collectors and constant Metrics +// # Custom Collectors and constant Metrics // // While you could create your own implementations of Metric, most likely you // will only ever implement the Collector interface on your own. At a first @@ -141,7 +152,7 @@ // a metric, GaugeFunc, CounterFunc, or UntypedFunc might be interesting // shortcuts. // -// Advanced Uses of the Registry +// # Advanced Uses of the Registry // // While MustRegister is the by far most common way of registering a Collector, // sometimes you might want to handle the errors the registration might cause. @@ -176,23 +187,23 @@ // NewProcessCollector). With a custom registry, you are in control and decide // yourself about the Collectors to register. // -// HTTP Exposition +// # HTTP Exposition // // The Registry implements the Gatherer interface. The caller of the Gather // method can then expose the gathered metrics in some way. Usually, the metrics // are served via HTTP on the /metrics endpoint. That's happening in the example // above. The tools to expose metrics via HTTP are in the promhttp sub-package. // -// Pushing to the Pushgateway +// # Pushing to the Pushgateway // // Function for pushing to the Pushgateway can be found in the push sub-package. // -// Graphite Bridge +// # Graphite Bridge // // Functions and examples to push metrics from a Gatherer to Graphite can be // found in the graphite sub-package. // -// Other Means of Exposition +// # Other Means of Exposition // // More ways of exposing metrics can easily be added by following the approaches // of the existing implementations. diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/gauge.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/gauge.go index bd0733d6a..f1ea6c76f 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/gauge.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/gauge.go @@ -55,6 +55,18 @@ type Gauge interface { // GaugeOpts is an alias for Opts. See there for doc comments. type GaugeOpts Opts +// GaugeVecOpts bundles the options to create a GaugeVec metric. +// It is mandatory to set GaugeOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type GaugeVecOpts struct { + GaugeOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels +} + // NewGauge creates a new Gauge based on the provided GaugeOpts. // // The returned implementation is optimized for a fast Set method. If you have a @@ -138,16 +150,24 @@ type GaugeVec struct { // NewGaugeVec creates a new GaugeVec based on the provided GaugeOpts and // partitioned by the given label names. func NewGaugeVec(opts GaugeOpts, labelNames []string) *GaugeVec { - desc := NewDesc( + return V2.NewGaugeVec(GaugeVecOpts{ + GaugeOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewGaugeVec creates a new GaugeVec based on the provided GaugeVecOpts. +func (v2) NewGaugeVec(opts GaugeVecOpts) *GaugeVec { + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &GaugeVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { if len(lvs) != len(desc.variableLabels) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, lvs)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), lvs)) } result := &gauge{desc: desc, labelPairs: MakeLabelPairs(desc, lvs)} result.init(result) // Init self-collection. @@ -210,7 +230,8 @@ func (v *GaugeVec) GetMetricWith(labels Labels) (Gauge, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Add(42) +// +// myVec.WithLabelValues("404", "GET").Add(42) func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge { g, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -221,7 +242,8 @@ func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge { // With works as GetMetricWith, but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) func (v *GaugeVec) With(labels Labels) Gauge { g, err := v.GetMetricWith(labels) if err != nil { diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go index 3a2d55e84..2d8d9f64f 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go @@ -23,11 +23,10 @@ import ( "strings" "sync" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - dto "github.com/prometheus/client_model/go" - "github.com/prometheus/client_golang/prometheus/internal" + + dto "github.com/prometheus/client_model/go" + "google.golang.org/protobuf/proto" ) const ( diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/histogram.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/histogram.go index 0d47fecdc..8d818afe9 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/histogram.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/histogram.go @@ -22,25 +22,221 @@ import ( "sync/atomic" "time" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - dto "github.com/prometheus/client_model/go" + + "google.golang.org/protobuf/proto" ) +// nativeHistogramBounds for the frac of observed values. Only relevant for +// schema > 0. The position in the slice is the schema. (0 is never used, just +// here for convenience of using the schema directly as the index.) +// +// TODO(beorn7): Currently, we do a binary search into these slices. There are +// ways to turn it into a small number of simple array lookups. It probably only +// matters for schema 5 and beyond, but should be investigated. See this comment +// as a starting point: +// https://github.com/open-telemetry/opentelemetry-specification/issues/1776#issuecomment-870164310 +var nativeHistogramBounds = [][]float64{ + // Schema "0": + {0.5}, + // Schema 1: + {0.5, 0.7071067811865475}, + // Schema 2: + {0.5, 0.5946035575013605, 0.7071067811865475, 0.8408964152537144}, + // Schema 3: + { + 0.5, 0.5452538663326288, 0.5946035575013605, 0.6484197773255048, + 0.7071067811865475, 0.7711054127039704, 0.8408964152537144, 0.9170040432046711, + }, + // Schema 4: + { + 0.5, 0.5221368912137069, 0.5452538663326288, 0.5693943173783458, + 0.5946035575013605, 0.620928906036742, 0.6484197773255048, 0.6771277734684463, + 0.7071067811865475, 0.7384130729697496, 0.7711054127039704, 0.805245165974627, + 0.8408964152537144, 0.8781260801866495, 0.9170040432046711, 0.9576032806985735, + }, + // Schema 5: + { + 0.5, 0.5109485743270583, 0.5221368912137069, 0.5335702003384117, + 0.5452538663326288, 0.5571933712979462, 0.5693943173783458, 0.5818624293887887, + 0.5946035575013605, 0.6076236799902344, 0.620928906036742, 0.6345254785958666, + 0.6484197773255048, 0.6626183215798706, 0.6771277734684463, 0.6919549409819159, + 0.7071067811865475, 0.7225904034885232, 0.7384130729697496, 0.7545822137967112, + 0.7711054127039704, 0.7879904225539431, 0.805245165974627, 0.8228777390769823, + 0.8408964152537144, 0.8593096490612387, 0.8781260801866495, 0.8973545375015533, + 0.9170040432046711, 0.9370838170551498, 0.9576032806985735, 0.9785720620876999, + }, + // Schema 6: + { + 0.5, 0.5054446430258502, 0.5109485743270583, 0.5165124395106142, + 0.5221368912137069, 0.5278225891802786, 0.5335702003384117, 0.5393803988785598, + 0.5452538663326288, 0.5511912916539204, 0.5571933712979462, 0.5632608093041209, + 0.5693943173783458, 0.5755946149764913, 0.5818624293887887, 0.5881984958251406, + 0.5946035575013605, 0.6010783657263515, 0.6076236799902344, 0.6142402680534349, + 0.620928906036742, 0.6276903785123455, 0.6345254785958666, 0.6414350080393891, + 0.6484197773255048, 0.6554806057623822, 0.6626183215798706, 0.6698337620266515, + 0.6771277734684463, 0.6845012114872953, 0.6919549409819159, 0.6994898362691555, + 0.7071067811865475, 0.7148066691959849, 0.7225904034885232, 0.7304588970903234, + 0.7384130729697496, 0.7464538641456323, 0.7545822137967112, 0.762799075372269, + 0.7711054127039704, 0.7795022001189185, 0.7879904225539431, 0.7965710756711334, + 0.805245165974627, 0.8140137109286738, 0.8228777390769823, 0.8318382901633681, + 0.8408964152537144, 0.8500531768592616, 0.8593096490612387, 0.8686669176368529, + 0.8781260801866495, 0.8876882462632604, 0.8973545375015533, 0.9071260877501991, + 0.9170040432046711, 0.9269895625416926, 0.9370838170551498, 0.9472879907934827, + 0.9576032806985735, 0.9680308967461471, 0.9785720620876999, 0.9892280131939752, + }, + // Schema 7: + { + 0.5, 0.5027149505564014, 0.5054446430258502, 0.5081891574554764, + 0.5109485743270583, 0.5137229745593818, 0.5165124395106142, 0.5193170509806894, + 0.5221368912137069, 0.5249720429003435, 0.5278225891802786, 0.5306886136446309, + 0.5335702003384117, 0.5364674337629877, 0.5393803988785598, 0.5423091811066545, + 0.5452538663326288, 0.5482145409081883, 0.5511912916539204, 0.5541842058618393, + 0.5571933712979462, 0.5602188762048033, 0.5632608093041209, 0.5663192597993595, + 0.5693943173783458, 0.572486072215902, 0.5755946149764913, 0.5787200368168754, + 0.5818624293887887, 0.585021884841625, 0.5881984958251406, 0.5913923554921704, + 0.5946035575013605, 0.5978321960199137, 0.6010783657263515, 0.6043421618132907, + 0.6076236799902344, 0.6109230164863786, 0.6142402680534349, 0.6175755319684665, + 0.620928906036742, 0.6243004885946023, 0.6276903785123455, 0.6310986751971253, + 0.6345254785958666, 0.637970889198196, 0.6414350080393891, 0.6449179367033329, + 0.6484197773255048, 0.6519406325959679, 0.6554806057623822, 0.659039800633032, + 0.6626183215798706, 0.6662162735415805, 0.6698337620266515, 0.6734708931164728, + 0.6771277734684463, 0.6808045103191123, 0.6845012114872953, 0.688217985377265, + 0.6919549409819159, 0.6957121878859629, 0.6994898362691555, 0.7032879969095076, + 0.7071067811865475, 0.7109463010845827, 0.7148066691959849, 0.718687998724491, + 0.7225904034885232, 0.7265139979245261, 0.7304588970903234, 0.7344252166684908, + 0.7384130729697496, 0.7424225829363761, 0.7464538641456323, 0.7505070348132126, + 0.7545822137967112, 0.7586795205991071, 0.762799075372269, 0.7669409989204777, + 0.7711054127039704, 0.7752924388424999, 0.7795022001189185, 0.7837348199827764, + 0.7879904225539431, 0.7922691326262467, 0.7965710756711334, 0.8008963778413465, + 0.805245165974627, 0.8096175675974316, 0.8140137109286738, 0.8184337248834821, + 0.8228777390769823, 0.8273458838280969, 0.8318382901633681, 0.8363550898207981, + 0.8408964152537144, 0.8454623996346523, 0.8500531768592616, 0.8546688815502312, + 0.8593096490612387, 0.8639756154809185, 0.8686669176368529, 0.8733836930995842, + 0.8781260801866495, 0.8828942179666361, 0.8876882462632604, 0.8925083056594671, + 0.8973545375015533, 0.9022270839033115, 0.9071260877501991, 0.9120516927035263, + 0.9170040432046711, 0.9219832844793128, 0.9269895625416926, 0.9320230241988943, + 0.9370838170551498, 0.9421720895161669, 0.9472879907934827, 0.9524316709088368, + 0.9576032806985735, 0.9628029718180622, 0.9680308967461471, 0.9732872087896164, + 0.9785720620876999, 0.9838856116165875, 0.9892280131939752, 0.9945994234836328, + }, + // Schema 8: + { + 0.5, 0.5013556375251013, 0.5027149505564014, 0.5040779490592088, + 0.5054446430258502, 0.5068150424757447, 0.5081891574554764, 0.509566998038869, + 0.5109485743270583, 0.5123338964485679, 0.5137229745593818, 0.5151158188430205, + 0.5165124395106142, 0.5179128468009786, 0.5193170509806894, 0.520725062344158, + 0.5221368912137069, 0.5235525479396449, 0.5249720429003435, 0.526395386502313, + 0.5278225891802786, 0.5292536613972564, 0.5306886136446309, 0.5321274564422321, + 0.5335702003384117, 0.5350168559101208, 0.5364674337629877, 0.5379219445313954, + 0.5393803988785598, 0.5408428074966075, 0.5423091811066545, 0.5437795304588847, + 0.5452538663326288, 0.5467321995364429, 0.5482145409081883, 0.549700901315111, + 0.5511912916539204, 0.5526857228508706, 0.5541842058618393, 0.5556867516724088, + 0.5571933712979462, 0.5587040757836845, 0.5602188762048033, 0.5617377836665098, + 0.5632608093041209, 0.564787964283144, 0.5663192597993595, 0.5678547070789026, + 0.5693943173783458, 0.5709381019847808, 0.572486072215902, 0.5740382394200894, + 0.5755946149764913, 0.5771552102951081, 0.5787200368168754, 0.5802891060137493, + 0.5818624293887887, 0.5834400184762408, 0.585021884841625, 0.5866080400818185, + 0.5881984958251406, 0.5897932637314379, 0.5913923554921704, 0.5929957828304968, + 0.5946035575013605, 0.5962156912915756, 0.5978321960199137, 0.5994530835371903, + 0.6010783657263515, 0.6027080545025619, 0.6043421618132907, 0.6059806996384005, + 0.6076236799902344, 0.6092711149137041, 0.6109230164863786, 0.6125793968185725, + 0.6142402680534349, 0.6159056423670379, 0.6175755319684665, 0.6192499490999082, + 0.620928906036742, 0.622612415087629, 0.6243004885946023, 0.6259931389331581, + 0.6276903785123455, 0.6293922197748583, 0.6310986751971253, 0.6328097572894031, + 0.6345254785958666, 0.6362458516947014, 0.637970889198196, 0.6397006037528346, + 0.6414350080393891, 0.6431741147730128, 0.6449179367033329, 0.6466664866145447, + 0.6484197773255048, 0.6501778216898253, 0.6519406325959679, 0.6537082229673385, + 0.6554806057623822, 0.6572577939746774, 0.659039800633032, 0.6608266388015788, + 0.6626183215798706, 0.6644148621029772, 0.6662162735415805, 0.6680225691020727, + 0.6698337620266515, 0.6716498655934177, 0.6734708931164728, 0.6752968579460171, + 0.6771277734684463, 0.6789636531064505, 0.6808045103191123, 0.6826503586020058, + 0.6845012114872953, 0.6863570825438342, 0.688217985377265, 0.690083933630119, + 0.6919549409819159, 0.6938310211492645, 0.6957121878859629, 0.6975984549830999, + 0.6994898362691555, 0.7013863456101023, 0.7032879969095076, 0.7051948041086352, + 0.7071067811865475, 0.7090239421602076, 0.7109463010845827, 0.7128738720527471, + 0.7148066691959849, 0.7167447066838943, 0.718687998724491, 0.7206365595643126, + 0.7225904034885232, 0.7245495448210174, 0.7265139979245261, 0.7284837772007218, + 0.7304588970903234, 0.7324393720732029, 0.7344252166684908, 0.7364164454346837, + 0.7384130729697496, 0.7404151139112358, 0.7424225829363761, 0.7444354947621984, + 0.7464538641456323, 0.7484777058836176, 0.7505070348132126, 0.7525418658117031, + 0.7545822137967112, 0.7566280937263048, 0.7586795205991071, 0.7607365094544071, + 0.762799075372269, 0.7648672334736434, 0.7669409989204777, 0.7690203869158282, + 0.7711054127039704, 0.7731960915705107, 0.7752924388424999, 0.7773944698885442, + 0.7795022001189185, 0.7816156449856788, 0.7837348199827764, 0.7858597406461707, + 0.7879904225539431, 0.7901268813264122, 0.7922691326262467, 0.7944171921585818, + 0.7965710756711334, 0.7987307989543135, 0.8008963778413465, 0.8030678282083853, + 0.805245165974627, 0.8074284071024302, 0.8096175675974316, 0.8118126635086642, + 0.8140137109286738, 0.8162207259936375, 0.8184337248834821, 0.820652723822003, + 0.8228777390769823, 0.8251087869603088, 0.8273458838280969, 0.8295890460808079, + 0.8318382901633681, 0.8340936325652911, 0.8363550898207981, 0.8386226785089391, + 0.8408964152537144, 0.8431763167241966, 0.8454623996346523, 0.8477546807446661, + 0.8500531768592616, 0.8523579048290255, 0.8546688815502312, 0.8569861239649629, + 0.8593096490612387, 0.8616394738731368, 0.8639756154809185, 0.8663180910111553, + 0.8686669176368529, 0.871022112577578, 0.8733836930995842, 0.8757516765159389, + 0.8781260801866495, 0.8805069215187917, 0.8828942179666361, 0.8852879870317771, + 0.8876882462632604, 0.890095013257712, 0.8925083056594671, 0.8949281411607002, + 0.8973545375015533, 0.8997875124702672, 0.9022270839033115, 0.9046732696855155, + 0.9071260877501991, 0.909585556079304, 0.9120516927035263, 0.9145245157024483, + 0.9170040432046711, 0.9194902933879467, 0.9219832844793128, 0.9244830347552253, + 0.9269895625416926, 0.92950288621441, 0.9320230241988943, 0.9345499949706191, + 0.9370838170551498, 0.93962450902828, 0.9421720895161669, 0.9447265771954693, + 0.9472879907934827, 0.9498563490882775, 0.9524316709088368, 0.9550139751351947, + 0.9576032806985735, 0.9601996065815236, 0.9628029718180622, 0.9654133954938133, + 0.9680308967461471, 0.9706554947643201, 0.9732872087896164, 0.9759260581154889, + 0.9785720620876999, 0.9812252401044634, 0.9838856116165875, 0.9865531961276168, + 0.9892280131939752, 0.9919100824251095, 0.9945994234836328, 0.9972960560854698, + }, +} + +// The nativeHistogramBounds above can be generated with the code below. +// +// TODO(beorn7): It's tempting to actually use `go generate` to generate the +// code above. However, this could lead to slightly different numbers on +// different architectures. We still need to come to terms if we are fine with +// that, or if we might prefer to specify precise numbers in the standard. +// +// var nativeHistogramBounds [][]float64 = make([][]float64, 9) +// +// func init() { +// // Populate nativeHistogramBounds. +// numBuckets := 1 +// for i := range nativeHistogramBounds { +// bounds := []float64{0.5} +// factor := math.Exp2(math.Exp2(float64(-i))) +// for j := 0; j < numBuckets-1; j++ { +// var bound float64 +// if (j+1)%2 == 0 { +// // Use previously calculated value for increased precision. +// bound = nativeHistogramBounds[i-1][j/2+1] +// } else { +// bound = bounds[j] * factor +// } +// bounds = append(bounds, bound) +// } +// numBuckets *= 2 +// nativeHistogramBounds[i] = bounds +// } +// } + // A Histogram counts individual observations from an event or sample stream in -// configurable buckets. Similar to a summary, it also provides a sum of -// observations and an observation count. +// configurable static buckets (or in dynamic sparse buckets as part of the +// experimental Native Histograms, see below for more details). Similar to a +// Summary, it also provides a sum of observations and an observation count. // // On the Prometheus server, quantiles can be calculated from a Histogram using -// the histogram_quantile function in the query language. +// the histogram_quantile PromQL function. // -// Note that Histograms, in contrast to Summaries, can be aggregated with the -// Prometheus query language (see the documentation for detailed -// procedures). However, Histograms require the user to pre-define suitable -// buckets, and they are in general less accurate. The Observe method of a -// Histogram has a very low performance overhead in comparison with the Observe -// method of a Summary. +// Note that Histograms, in contrast to Summaries, can be aggregated in PromQL +// (see the documentation for detailed procedures). However, Histograms require +// the user to pre-define suitable buckets, and they are in general less +// accurate. (Both problems are addressed by the experimental Native +// Histograms. To use them, configure a NativeHistogramBucketFactor in the +// HistogramOpts. They also require a Prometheus server v2.40+ with the +// corresponding feature flag enabled.) +// +// The Observe method of a Histogram has a very low performance overhead in +// comparison with the Observe method of a Summary. // // To create Histogram instances, use NewHistogram. type Histogram interface { @@ -50,7 +246,8 @@ type Histogram interface { // Observe adds a single observation to the histogram. Observations are // usually positive or zero. Negative observations are accepted but // prevent current versions of Prometheus from properly detecting - // counter resets in the sum of observations. See + // counter resets in the sum of observations. (The experimental Native + // Histograms handle negative observations properly.) See // https://prometheus.io/docs/practices/histograms/#count-and-sum-of-observations // for details. Observe(float64) @@ -64,18 +261,28 @@ const bucketLabel = "le" // tailored to broadly measure the response time (in seconds) of a network // service. Most likely, however, you will be required to define buckets // customized to your use case. -var ( - DefBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10} +var DefBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10} - errBucketLabelNotAllowed = fmt.Errorf( - "%q is not allowed as label name in histograms", bucketLabel, - ) +// DefNativeHistogramZeroThreshold is the default value for +// NativeHistogramZeroThreshold in the HistogramOpts. +// +// The value is 2^-128 (or 0.5*2^-127 in the actual IEEE 754 representation), +// which is a bucket boundary at all possible resolutions. +const DefNativeHistogramZeroThreshold = 2.938735877055719e-39 + +// NativeHistogramZeroThresholdZero can be used as NativeHistogramZeroThreshold +// in the HistogramOpts to create a zero bucket of width zero, i.e. a zero +// bucket that only receives observations of precisely zero. +const NativeHistogramZeroThresholdZero = -1 + +var errBucketLabelNotAllowed = fmt.Errorf( + "%q is not allowed as label name in histograms", bucketLabel, ) -// LinearBuckets creates 'count' buckets, each 'width' wide, where the lowest -// bucket has an upper bound of 'start'. The final +Inf bucket is not counted -// and not included in the returned slice. The returned slice is meant to be -// used for the Buckets field of HistogramOpts. +// LinearBuckets creates 'count' regular buckets, each 'width' wide, where the +// lowest bucket has an upper bound of 'start'. The final +Inf bucket is not +// counted and not included in the returned slice. The returned slice is meant +// to be used for the Buckets field of HistogramOpts. // // The function panics if 'count' is zero or negative. func LinearBuckets(start, width float64, count int) []float64 { @@ -90,11 +297,11 @@ func LinearBuckets(start, width float64, count int) []float64 { return buckets } -// ExponentialBuckets creates 'count' buckets, where the lowest bucket has an -// upper bound of 'start' and each following bucket's upper bound is 'factor' -// times the previous bucket's upper bound. The final +Inf bucket is not counted -// and not included in the returned slice. The returned slice is meant to be -// used for the Buckets field of HistogramOpts. +// ExponentialBuckets creates 'count' regular buckets, where the lowest bucket +// has an upper bound of 'start' and each following bucket's upper bound is +// 'factor' times the previous bucket's upper bound. The final +Inf bucket is +// not counted and not included in the returned slice. The returned slice is +// meant to be used for the Buckets field of HistogramOpts. // // The function panics if 'count' is 0 or negative, if 'start' is 0 or negative, // or if 'factor' is less than or equal 1. @@ -180,8 +387,97 @@ type HistogramOpts struct { // element in the slice is the upper inclusive bound of a bucket. The // values must be sorted in strictly increasing order. There is no need // to add a highest bucket with +Inf bound, it will be added - // implicitly. The default value is DefBuckets. + // implicitly. If Buckets is left as nil or set to a slice of length + // zero, it is replaced by default buckets. The default buckets are + // DefBuckets if no buckets for a native histogram (see below) are used, + // otherwise the default is no buckets. (In other words, if you want to + // use both reguler buckets and buckets for a native histogram, you have + // to define the regular buckets here explicitly.) Buckets []float64 + + // If NativeHistogramBucketFactor is greater than one, so-called sparse + // buckets are used (in addition to the regular buckets, if defined + // above). A Histogram with sparse buckets will be ingested as a Native + // Histogram by a Prometheus server with that feature enabled (requires + // Prometheus v2.40+). Sparse buckets are exponential buckets covering + // the whole float64 range (with the exception of the “zero” bucket, see + // NativeHistogramZeroThreshold below). From any one bucket to the next, + // the width of the bucket grows by a constant + // factor. NativeHistogramBucketFactor provides an upper bound for this + // factor (exception see below). The smaller + // NativeHistogramBucketFactor, the more buckets will be used and thus + // the more costly the histogram will become. A generally good trade-off + // between cost and accuracy is a value of 1.1 (each bucket is at most + // 10% wider than the previous one), which will result in each power of + // two divided into 8 buckets (e.g. there will be 8 buckets between 1 + // and 2, same as between 2 and 4, and 4 and 8, etc.). + // + // Details about the actually used factor: The factor is calculated as + // 2^(2^n), where n is an integer number between (and including) -8 and + // 4. n is chosen so that the resulting factor is the largest that is + // still smaller or equal to NativeHistogramBucketFactor. Note that the + // smallest possible factor is therefore approx. 1.00271 (i.e. 2^(2^-8) + // ). If NativeHistogramBucketFactor is greater than 1 but smaller than + // 2^(2^-8), then the actually used factor is still 2^(2^-8) even though + // it is larger than the provided NativeHistogramBucketFactor. + // + // NOTE: Native Histograms are still an experimental feature. Their + // behavior might still change without a major version + // bump. Subsequently, all NativeHistogram... options here might still + // change their behavior or name (or might completely disappear) without + // a major version bump. + NativeHistogramBucketFactor float64 + // All observations with an absolute value of less or equal + // NativeHistogramZeroThreshold are accumulated into a “zero” + // bucket. For best results, this should be close to a bucket + // boundary. This is usually the case if picking a power of two. If + // NativeHistogramZeroThreshold is left at zero, + // DefNativeHistogramZeroThreshold is used as the threshold. To configure + // a zero bucket with an actual threshold of zero (i.e. only + // observations of precisely zero will go into the zero bucket), set + // NativeHistogramZeroThreshold to the NativeHistogramZeroThresholdZero + // constant (or any negative float value). + NativeHistogramZeroThreshold float64 + + // The remaining fields define a strategy to limit the number of + // populated sparse buckets. If NativeHistogramMaxBucketNumber is left + // at zero, the number of buckets is not limited. (Note that this might + // lead to unbounded memory consumption if the values observed by the + // Histogram are sufficiently wide-spread. In particular, this could be + // used as a DoS attack vector. Where the observed values depend on + // external inputs, it is highly recommended to set a + // NativeHistogramMaxBucketNumber.) Once the set + // NativeHistogramMaxBucketNumber is exceeded, the following strategy is + // enacted: First, if the last reset (or the creation) of the histogram + // is at least NativeHistogramMinResetDuration ago, then the whole + // histogram is reset to its initial state (including regular + // buckets). If less time has passed, or if + // NativeHistogramMinResetDuration is zero, no reset is + // performed. Instead, the zero threshold is increased sufficiently to + // reduce the number of buckets to or below + // NativeHistogramMaxBucketNumber, but not to more than + // NativeHistogramMaxZeroThreshold. Thus, if + // NativeHistogramMaxZeroThreshold is already at or below the current + // zero threshold, nothing happens at this step. After that, if the + // number of buckets still exceeds NativeHistogramMaxBucketNumber, the + // resolution of the histogram is reduced by doubling the width of the + // sparse buckets (up to a growth factor between one bucket to the next + // of 2^(2^4) = 65536, see above). + NativeHistogramMaxBucketNumber uint32 + NativeHistogramMinResetDuration time.Duration + NativeHistogramMaxZeroThreshold float64 +} + +// HistogramVecOpts bundles the options to create a HistogramVec metric. +// It is mandatory to set HistogramOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type HistogramVecOpts struct { + HistogramOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels } // NewHistogram creates a new Histogram based on the provided HistogramOpts. It @@ -204,11 +500,11 @@ func NewHistogram(opts HistogramOpts) Histogram { func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogram { if len(desc.variableLabels) != len(labelValues) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, labelValues)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), labelValues)) } for _, n := range desc.variableLabels { - if n == bucketLabel { + if n.Name == bucketLabel { panic(errBucketLabelNotAllowed) } } @@ -218,16 +514,29 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr } } - if len(opts.Buckets) == 0 { - opts.Buckets = DefBuckets - } - h := &histogram{ - desc: desc, - upperBounds: opts.Buckets, - labelPairs: MakeLabelPairs(desc, labelValues), - counts: [2]*histogramCounts{{}, {}}, - now: time.Now, + desc: desc, + upperBounds: opts.Buckets, + labelPairs: MakeLabelPairs(desc, labelValues), + nativeHistogramMaxBuckets: opts.NativeHistogramMaxBucketNumber, + nativeHistogramMaxZeroThreshold: opts.NativeHistogramMaxZeroThreshold, + nativeHistogramMinResetDuration: opts.NativeHistogramMinResetDuration, + lastResetTime: time.Now(), + now: time.Now, + } + if len(h.upperBounds) == 0 && opts.NativeHistogramBucketFactor <= 1 { + h.upperBounds = DefBuckets + } + if opts.NativeHistogramBucketFactor <= 1 { + h.nativeHistogramSchema = math.MinInt32 // To mark that there are no sparse buckets. + } else { + switch { + case opts.NativeHistogramZeroThreshold > 0: + h.nativeHistogramZeroThreshold = opts.NativeHistogramZeroThreshold + case opts.NativeHistogramZeroThreshold == 0: + h.nativeHistogramZeroThreshold = DefNativeHistogramZeroThreshold + } // Leave h.nativeHistogramZeroThreshold at 0 otherwise. + h.nativeHistogramSchema = pickSchema(opts.NativeHistogramBucketFactor) } for i, upperBound := range h.upperBounds { if i < len(h.upperBounds)-1 { @@ -246,8 +555,12 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr } // Finally we know the final length of h.upperBounds and can make buckets // for both counts as well as exemplars: - h.counts[0].buckets = make([]uint64, len(h.upperBounds)) - h.counts[1].buckets = make([]uint64, len(h.upperBounds)) + h.counts[0] = &histogramCounts{buckets: make([]uint64, len(h.upperBounds))} + atomic.StoreUint64(&h.counts[0].nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold)) + atomic.StoreInt32(&h.counts[0].nativeHistogramSchema, h.nativeHistogramSchema) + h.counts[1] = &histogramCounts{buckets: make([]uint64, len(h.upperBounds))} + atomic.StoreUint64(&h.counts[1].nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold)) + atomic.StoreInt32(&h.counts[1].nativeHistogramSchema, h.nativeHistogramSchema) h.exemplars = make([]atomic.Value, len(h.upperBounds)+1) h.init(h) // Init self-collection. @@ -255,13 +568,98 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr } type histogramCounts struct { + // Order in this struct matters for the alignment required by atomic + // operations, see http://golang.org/pkg/sync/atomic/#pkg-note-BUG + // sumBits contains the bits of the float64 representing the sum of all - // observations. sumBits and count have to go first in the struct to - // guarantee alignment for atomic operations. - // http://golang.org/pkg/sync/atomic/#pkg-note-BUG + // observations. sumBits uint64 count uint64 + + // nativeHistogramZeroBucket counts all (positive and negative) + // observations in the zero bucket (with an absolute value less or equal + // the current threshold, see next field. + nativeHistogramZeroBucket uint64 + // nativeHistogramZeroThresholdBits is the bit pattern of the current + // threshold for the zero bucket. It's initially equal to + // nativeHistogramZeroThreshold but may change according to the bucket + // count limitation strategy. + nativeHistogramZeroThresholdBits uint64 + // nativeHistogramSchema may change over time according to the bucket + // count limitation strategy and therefore has to be saved here. + nativeHistogramSchema int32 + // Number of (positive and negative) sparse buckets. + nativeHistogramBucketsNumber uint32 + + // Regular buckets. buckets []uint64 + + // The sparse buckets for native histograms are implemented with a + // sync.Map for now. A dedicated data structure will likely be more + // efficient. There are separate maps for negative and positive + // observations. The map's value is an *int64, counting observations in + // that bucket. (Note that we don't use uint64 as an int64 won't + // overflow in practice, and working with signed numbers from the + // beginning simplifies the handling of deltas.) The map's key is the + // index of the bucket according to the used + // nativeHistogramSchema. Index 0 is for an upper bound of 1. + nativeHistogramBucketsPositive, nativeHistogramBucketsNegative sync.Map +} + +// observe manages the parts of observe that only affects +// histogramCounts. doSparse is true if sparse buckets should be done, +// too. +func (hc *histogramCounts) observe(v float64, bucket int, doSparse bool) { + if bucket < len(hc.buckets) { + atomic.AddUint64(&hc.buckets[bucket], 1) + } + atomicAddFloat(&hc.sumBits, v) + if doSparse && !math.IsNaN(v) { + var ( + key int + schema = atomic.LoadInt32(&hc.nativeHistogramSchema) + zeroThreshold = math.Float64frombits(atomic.LoadUint64(&hc.nativeHistogramZeroThresholdBits)) + bucketCreated, isInf bool + ) + if math.IsInf(v, 0) { + // Pretend v is MaxFloat64 but later increment key by one. + if math.IsInf(v, +1) { + v = math.MaxFloat64 + } else { + v = -math.MaxFloat64 + } + isInf = true + } + frac, exp := math.Frexp(math.Abs(v)) + if schema > 0 { + bounds := nativeHistogramBounds[schema] + key = sort.SearchFloat64s(bounds, frac) + (exp-1)*len(bounds) + } else { + key = exp + if frac == 0.5 { + key-- + } + offset := (1 << -schema) - 1 + key = (key + offset) >> -schema + } + if isInf { + key++ + } + switch { + case v > zeroThreshold: + bucketCreated = addToBucket(&hc.nativeHistogramBucketsPositive, key, 1) + case v < -zeroThreshold: + bucketCreated = addToBucket(&hc.nativeHistogramBucketsNegative, key, 1) + default: + atomic.AddUint64(&hc.nativeHistogramZeroBucket, 1) + } + if bucketCreated { + atomic.AddUint32(&hc.nativeHistogramBucketsNumber, 1) + } + } + // Increment count last as we take it as a signal that the observation + // is complete. + atomic.AddUint64(&hc.count, 1) } type histogram struct { @@ -276,7 +674,7 @@ type histogram struct { // perspective of the histogram) swap the hot–cold under the writeMtx // lock. A cooldown is awaited (while locked) by comparing the number of // observations with the initiation count. Once they match, then the - // last observation on the now cool one has completed. All cool fields must + // last observation on the now cool one has completed. All cold fields must // be merged into the new hot before releasing writeMtx. // // Fields with atomic access first! See alignment constraint: @@ -284,8 +682,10 @@ type histogram struct { countAndHotIdx uint64 selfCollector - desc *Desc - writeMtx sync.Mutex // Only used in the Write method. + desc *Desc + + // Only used in the Write method and for sparse bucket management. + mtx sync.Mutex // Two counts, one is "hot" for lock-free observations, the other is // "cold" for writing out a dto.Metric. It has to be an array of @@ -293,9 +693,15 @@ type histogram struct { // http://golang.org/pkg/sync/atomic/#pkg-note-BUG. counts [2]*histogramCounts - upperBounds []float64 - labelPairs []*dto.LabelPair - exemplars []atomic.Value // One more than buckets (to include +Inf), each a *dto.Exemplar. + upperBounds []float64 + labelPairs []*dto.LabelPair + exemplars []atomic.Value // One more than buckets (to include +Inf), each a *dto.Exemplar. + nativeHistogramSchema int32 // The initial schema. Set to math.MinInt32 if no sparse buckets are used. + nativeHistogramZeroThreshold float64 // The initial zero threshold. + nativeHistogramMaxZeroThreshold float64 + nativeHistogramMaxBuckets uint32 + nativeHistogramMinResetDuration time.Duration + lastResetTime time.Time // Protected by mtx. now func() time.Time // To mock out time.Now() for testing. } @@ -319,8 +725,8 @@ func (h *histogram) Write(out *dto.Metric) error { // the hot path, i.e. Observe is called much more often than Write. The // complication of making Write lock-free isn't worth it, if possible at // all. - h.writeMtx.Lock() - defer h.writeMtx.Unlock() + h.mtx.Lock() + defer h.mtx.Unlock() // Adding 1<<63 switches the hot index (from 0 to 1 or from 1 to 0) // without touching the count bits. See the struct comments for a full @@ -333,16 +739,16 @@ func (h *histogram) Write(out *dto.Metric) error { hotCounts := h.counts[n>>63] coldCounts := h.counts[(^n)>>63] - // Await cooldown. - for count != atomic.LoadUint64(&coldCounts.count) { - runtime.Gosched() // Let observations get work done. - } + waitForCooldown(count, coldCounts) his := &dto.Histogram{ Bucket: make([]*dto.Bucket, len(h.upperBounds)), SampleCount: proto.Uint64(count), SampleSum: proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.sumBits))), } + out.Histogram = his + out.Label = h.labelPairs + var cumCount uint64 for i, upperBound := range h.upperBounds { cumCount += atomic.LoadUint64(&coldCounts.buckets[i]) @@ -363,25 +769,21 @@ func (h *histogram) Write(out *dto.Metric) error { } his.Bucket = append(his.Bucket, b) } - - out.Histogram = his - out.Label = h.labelPairs - - // Finally add all the cold counts to the new hot counts and reset the cold counts. - atomic.AddUint64(&hotCounts.count, count) - atomic.StoreUint64(&coldCounts.count, 0) - for { - oldBits := atomic.LoadUint64(&hotCounts.sumBits) - newBits := math.Float64bits(math.Float64frombits(oldBits) + his.GetSampleSum()) - if atomic.CompareAndSwapUint64(&hotCounts.sumBits, oldBits, newBits) { - atomic.StoreUint64(&coldCounts.sumBits, 0) - break - } - } - for i := range h.upperBounds { - atomic.AddUint64(&hotCounts.buckets[i], atomic.LoadUint64(&coldCounts.buckets[i])) - atomic.StoreUint64(&coldCounts.buckets[i], 0) + if h.nativeHistogramSchema > math.MinInt32 { + his.ZeroThreshold = proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.nativeHistogramZeroThresholdBits))) + his.Schema = proto.Int32(atomic.LoadInt32(&coldCounts.nativeHistogramSchema)) + zeroBucket := atomic.LoadUint64(&coldCounts.nativeHistogramZeroBucket) + + defer func() { + coldCounts.nativeHistogramBucketsPositive.Range(addAndReset(&hotCounts.nativeHistogramBucketsPositive, &hotCounts.nativeHistogramBucketsNumber)) + coldCounts.nativeHistogramBucketsNegative.Range(addAndReset(&hotCounts.nativeHistogramBucketsNegative, &hotCounts.nativeHistogramBucketsNumber)) + }() + + his.ZeroCount = proto.Uint64(zeroBucket) + his.NegativeSpan, his.NegativeDelta = makeBuckets(&coldCounts.nativeHistogramBucketsNegative) + his.PositiveSpan, his.PositiveDelta = makeBuckets(&coldCounts.nativeHistogramBucketsPositive) } + addAndResetCounts(hotCounts, coldCounts) return nil } @@ -402,25 +804,216 @@ func (h *histogram) findBucket(v float64) int { // observe is the implementation for Observe without the findBucket part. func (h *histogram) observe(v float64, bucket int) { + // Do not add to sparse buckets for NaN observations. + doSparse := h.nativeHistogramSchema > math.MinInt32 && !math.IsNaN(v) // We increment h.countAndHotIdx so that the counter in the lower // 63 bits gets incremented. At the same time, we get the new value // back, which we can use to find the currently-hot counts. n := atomic.AddUint64(&h.countAndHotIdx, 1) hotCounts := h.counts[n>>63] + hotCounts.observe(v, bucket, doSparse) + if doSparse { + h.limitBuckets(hotCounts, v, bucket) + } +} - if bucket < len(h.upperBounds) { - atomic.AddUint64(&hotCounts.buckets[bucket], 1) +// limitBuckets applies a strategy to limit the number of populated sparse +// buckets. It's generally best effort, and there are situations where the +// number can go higher (if even the lowest resolution isn't enough to reduce +// the number sufficiently, or if the provided counts aren't fully updated yet +// by a concurrently happening Write call). +func (h *histogram) limitBuckets(counts *histogramCounts, value float64, bucket int) { + if h.nativeHistogramMaxBuckets == 0 { + return // No limit configured. } - for { - oldBits := atomic.LoadUint64(&hotCounts.sumBits) - newBits := math.Float64bits(math.Float64frombits(oldBits) + v) - if atomic.CompareAndSwapUint64(&hotCounts.sumBits, oldBits, newBits) { - break + if h.nativeHistogramMaxBuckets >= atomic.LoadUint32(&counts.nativeHistogramBucketsNumber) { + return // Bucket limit not exceeded yet. + } + + h.mtx.Lock() + defer h.mtx.Unlock() + + // The hot counts might have been swapped just before we acquired the + // lock. Re-fetch the hot counts first... + n := atomic.LoadUint64(&h.countAndHotIdx) + hotIdx := n >> 63 + coldIdx := (^n) >> 63 + hotCounts := h.counts[hotIdx] + coldCounts := h.counts[coldIdx] + // ...and then check again if we really have to reduce the bucket count. + if h.nativeHistogramMaxBuckets >= atomic.LoadUint32(&hotCounts.nativeHistogramBucketsNumber) { + return // Bucket limit not exceeded after all. + } + // Try the various strategies in order. + if h.maybeReset(hotCounts, coldCounts, coldIdx, value, bucket) { + return + } + if h.maybeWidenZeroBucket(hotCounts, coldCounts) { + return + } + h.doubleBucketWidth(hotCounts, coldCounts) +} + +// maybeReset resests the whole histogram if at least h.nativeHistogramMinResetDuration +// has been passed. It returns true if the histogram has been reset. The caller +// must have locked h.mtx. +func (h *histogram) maybeReset(hot, cold *histogramCounts, coldIdx uint64, value float64, bucket int) bool { + // We are using the possibly mocked h.now() rather than + // time.Since(h.lastResetTime) to enable testing. + if h.nativeHistogramMinResetDuration == 0 || h.now().Sub(h.lastResetTime) < h.nativeHistogramMinResetDuration { + return false + } + // Completely reset coldCounts. + h.resetCounts(cold) + // Repeat the latest observation to not lose it completely. + cold.observe(value, bucket, true) + // Make coldCounts the new hot counts while ressetting countAndHotIdx. + n := atomic.SwapUint64(&h.countAndHotIdx, (coldIdx<<63)+1) + count := n & ((1 << 63) - 1) + waitForCooldown(count, hot) + // Finally, reset the formerly hot counts, too. + h.resetCounts(hot) + h.lastResetTime = h.now() + return true +} + +// maybeWidenZeroBucket widens the zero bucket until it includes the existing +// buckets closest to the zero bucket (which could be two, if an equidistant +// negative and a positive bucket exists, but usually it's only one bucket to be +// merged into the new wider zero bucket). h.nativeHistogramMaxZeroThreshold +// limits how far the zero bucket can be extended, and if that's not enough to +// include an existing bucket, the method returns false. The caller must have +// locked h.mtx. +func (h *histogram) maybeWidenZeroBucket(hot, cold *histogramCounts) bool { + currentZeroThreshold := math.Float64frombits(atomic.LoadUint64(&hot.nativeHistogramZeroThresholdBits)) + if currentZeroThreshold >= h.nativeHistogramMaxZeroThreshold { + return false + } + // Find the key of the bucket closest to zero. + smallestKey := findSmallestKey(&hot.nativeHistogramBucketsPositive) + smallestNegativeKey := findSmallestKey(&hot.nativeHistogramBucketsNegative) + if smallestNegativeKey < smallestKey { + smallestKey = smallestNegativeKey + } + if smallestKey == math.MaxInt32 { + return false + } + newZeroThreshold := getLe(smallestKey, atomic.LoadInt32(&hot.nativeHistogramSchema)) + if newZeroThreshold > h.nativeHistogramMaxZeroThreshold { + return false // New threshold would exceed the max threshold. + } + atomic.StoreUint64(&cold.nativeHistogramZeroThresholdBits, math.Float64bits(newZeroThreshold)) + // Remove applicable buckets. + if _, loaded := cold.nativeHistogramBucketsNegative.LoadAndDelete(smallestKey); loaded { + atomicDecUint32(&cold.nativeHistogramBucketsNumber) + } + if _, loaded := cold.nativeHistogramBucketsPositive.LoadAndDelete(smallestKey); loaded { + atomicDecUint32(&cold.nativeHistogramBucketsNumber) + } + // Make cold counts the new hot counts. + n := atomic.AddUint64(&h.countAndHotIdx, 1<<63) + count := n & ((1 << 63) - 1) + // Swap the pointer names to represent the new roles and make + // the rest less confusing. + hot, cold = cold, hot + waitForCooldown(count, cold) + // Add all the now cold counts to the new hot counts... + addAndResetCounts(hot, cold) + // ...adjust the new zero threshold in the cold counts, too... + atomic.StoreUint64(&cold.nativeHistogramZeroThresholdBits, math.Float64bits(newZeroThreshold)) + // ...and then merge the newly deleted buckets into the wider zero + // bucket. + mergeAndDeleteOrAddAndReset := func(hotBuckets, coldBuckets *sync.Map) func(k, v interface{}) bool { + return func(k, v interface{}) bool { + key := k.(int) + bucket := v.(*int64) + if key == smallestKey { + // Merge into hot zero bucket... + atomic.AddUint64(&hot.nativeHistogramZeroBucket, uint64(atomic.LoadInt64(bucket))) + // ...and delete from cold counts. + coldBuckets.Delete(key) + atomicDecUint32(&cold.nativeHistogramBucketsNumber) + } else { + // Add to corresponding hot bucket... + if addToBucket(hotBuckets, key, atomic.LoadInt64(bucket)) { + atomic.AddUint32(&hot.nativeHistogramBucketsNumber, 1) + } + // ...and reset cold bucket. + atomic.StoreInt64(bucket, 0) + } + return true } } - // Increment count last as we take it as a signal that the observation - // is complete. - atomic.AddUint64(&hotCounts.count, 1) + + cold.nativeHistogramBucketsPositive.Range(mergeAndDeleteOrAddAndReset(&hot.nativeHistogramBucketsPositive, &cold.nativeHistogramBucketsPositive)) + cold.nativeHistogramBucketsNegative.Range(mergeAndDeleteOrAddAndReset(&hot.nativeHistogramBucketsNegative, &cold.nativeHistogramBucketsNegative)) + return true +} + +// doubleBucketWidth doubles the bucket width (by decrementing the schema +// number). Note that very sparse buckets could lead to a low reduction of the +// bucket count (or even no reduction at all). The method does nothing if the +// schema is already -4. +func (h *histogram) doubleBucketWidth(hot, cold *histogramCounts) { + coldSchema := atomic.LoadInt32(&cold.nativeHistogramSchema) + if coldSchema == -4 { + return // Already at lowest resolution. + } + coldSchema-- + atomic.StoreInt32(&cold.nativeHistogramSchema, coldSchema) + // Play it simple and just delete all cold buckets. + atomic.StoreUint32(&cold.nativeHistogramBucketsNumber, 0) + deleteSyncMap(&cold.nativeHistogramBucketsNegative) + deleteSyncMap(&cold.nativeHistogramBucketsPositive) + // Make coldCounts the new hot counts. + n := atomic.AddUint64(&h.countAndHotIdx, 1<<63) + count := n & ((1 << 63) - 1) + // Swap the pointer names to represent the new roles and make + // the rest less confusing. + hot, cold = cold, hot + waitForCooldown(count, cold) + // Add all the now cold counts to the new hot counts... + addAndResetCounts(hot, cold) + // ...adjust the schema in the cold counts, too... + atomic.StoreInt32(&cold.nativeHistogramSchema, coldSchema) + // ...and then merge the cold buckets into the wider hot buckets. + merge := func(hotBuckets *sync.Map) func(k, v interface{}) bool { + return func(k, v interface{}) bool { + key := k.(int) + bucket := v.(*int64) + // Adjust key to match the bucket to merge into. + if key > 0 { + key++ + } + key /= 2 + // Add to corresponding hot bucket. + if addToBucket(hotBuckets, key, atomic.LoadInt64(bucket)) { + atomic.AddUint32(&hot.nativeHistogramBucketsNumber, 1) + } + return true + } + } + + cold.nativeHistogramBucketsPositive.Range(merge(&hot.nativeHistogramBucketsPositive)) + cold.nativeHistogramBucketsNegative.Range(merge(&hot.nativeHistogramBucketsNegative)) + // Play it simple again and just delete all cold buckets. + atomic.StoreUint32(&cold.nativeHistogramBucketsNumber, 0) + deleteSyncMap(&cold.nativeHistogramBucketsNegative) + deleteSyncMap(&cold.nativeHistogramBucketsPositive) +} + +func (h *histogram) resetCounts(counts *histogramCounts) { + atomic.StoreUint64(&counts.sumBits, 0) + atomic.StoreUint64(&counts.count, 0) + atomic.StoreUint64(&counts.nativeHistogramZeroBucket, 0) + atomic.StoreUint64(&counts.nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold)) + atomic.StoreInt32(&counts.nativeHistogramSchema, h.nativeHistogramSchema) + atomic.StoreUint32(&counts.nativeHistogramBucketsNumber, 0) + for i := range h.upperBounds { + atomic.StoreUint64(&counts.buckets[i], 0) + } + deleteSyncMap(&counts.nativeHistogramBucketsNegative) + deleteSyncMap(&counts.nativeHistogramBucketsPositive) } // updateExemplar replaces the exemplar for the provided bucket. With empty @@ -448,15 +1041,23 @@ type HistogramVec struct { // NewHistogramVec creates a new HistogramVec based on the provided HistogramOpts and // partitioned by the given label names. func NewHistogramVec(opts HistogramOpts, labelNames []string) *HistogramVec { - desc := NewDesc( + return V2.NewHistogramVec(HistogramVecOpts{ + HistogramOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewHistogramVec creates a new HistogramVec based on the provided HistogramVecOpts. +func (v2) NewHistogramVec(opts HistogramVecOpts) *HistogramVec { + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &HistogramVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { - return newHistogram(desc, opts, lvs...) + return newHistogram(desc, opts.HistogramOpts, lvs...) }), } } @@ -516,7 +1117,8 @@ func (v *HistogramVec) GetMetricWith(labels Labels) (Observer, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Observe(42.21) +// +// myVec.WithLabelValues("404", "GET").Observe(42.21) func (v *HistogramVec) WithLabelValues(lvs ...string) Observer { h, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -527,7 +1129,8 @@ func (v *HistogramVec) WithLabelValues(lvs ...string) Observer { // With works as GetMetricWith but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) func (v *HistogramVec) With(labels Labels) Observer { h, err := v.GetMetricWith(labels) if err != nil { @@ -613,7 +1216,7 @@ func (h *constHistogram) Write(out *dto.Metric) error { // to send it to Prometheus in the Collect method. // // buckets is a map of upper bounds to cumulative counts, excluding the +Inf -// bucket. +// bucket. The +Inf bucket is implicit, and its value is equal to the provided count. // // NewConstHistogram returns an error if the length of labelValues is not // consistent with the variable labels in Desc or if Desc is invalid. @@ -668,3 +1271,229 @@ func (s buckSort) Swap(i, j int) { func (s buckSort) Less(i, j int) bool { return s[i].GetUpperBound() < s[j].GetUpperBound() } + +// pickSchema returns the largest number n between -4 and 8 such that +// 2^(2^-n) is less or equal the provided bucketFactor. +// +// Special cases: +// - bucketFactor <= 1: panics. +// - bucketFactor < 2^(2^-8) (but > 1): still returns 8. +func pickSchema(bucketFactor float64) int32 { + if bucketFactor <= 1 { + panic(fmt.Errorf("bucketFactor %f is <=1", bucketFactor)) + } + floor := math.Floor(math.Log2(math.Log2(bucketFactor))) + switch { + case floor <= -8: + return 8 + case floor >= 4: + return -4 + default: + return -int32(floor) + } +} + +func makeBuckets(buckets *sync.Map) ([]*dto.BucketSpan, []int64) { + var ii []int + buckets.Range(func(k, v interface{}) bool { + ii = append(ii, k.(int)) + return true + }) + sort.Ints(ii) + + if len(ii) == 0 { + return nil, nil + } + + var ( + spans []*dto.BucketSpan + deltas []int64 + prevCount int64 + nextI int + ) + + appendDelta := func(count int64) { + *spans[len(spans)-1].Length++ + deltas = append(deltas, count-prevCount) + prevCount = count + } + + for n, i := range ii { + v, _ := buckets.Load(i) + count := atomic.LoadInt64(v.(*int64)) + // Multiple spans with only small gaps in between are probably + // encoded more efficiently as one larger span with a few empty + // buckets. Needs some research to find the sweet spot. For now, + // we assume that gaps of one ore two buckets should not create + // a new span. + iDelta := int32(i - nextI) + if n == 0 || iDelta > 2 { + // We have to create a new span, either because we are + // at the very beginning, or because we have found a gap + // of more than two buckets. + spans = append(spans, &dto.BucketSpan{ + Offset: proto.Int32(iDelta), + Length: proto.Uint32(0), + }) + } else { + // We have found a small gap (or no gap at all). + // Insert empty buckets as needed. + for j := int32(0); j < iDelta; j++ { + appendDelta(0) + } + } + appendDelta(count) + nextI = i + 1 + } + return spans, deltas +} + +// addToBucket increments the sparse bucket at key by the provided amount. It +// returns true if a new sparse bucket had to be created for that. +func addToBucket(buckets *sync.Map, key int, increment int64) bool { + if existingBucket, ok := buckets.Load(key); ok { + // Fast path without allocation. + atomic.AddInt64(existingBucket.(*int64), increment) + return false + } + // Bucket doesn't exist yet. Slow path allocating new counter. + newBucket := increment // TODO(beorn7): Check if this is sufficient to not let increment escape. + if actualBucket, loaded := buckets.LoadOrStore(key, &newBucket); loaded { + // The bucket was created concurrently in another goroutine. + // Have to increment after all. + atomic.AddInt64(actualBucket.(*int64), increment) + return false + } + return true +} + +// addAndReset returns a function to be used with sync.Map.Range of spare +// buckets in coldCounts. It increments the buckets in the provided hotBuckets +// according to the buckets ranged through. It then resets all buckets ranged +// through to 0 (but leaves them in place so that they don't need to get +// recreated on the next scrape). +func addAndReset(hotBuckets *sync.Map, bucketNumber *uint32) func(k, v interface{}) bool { + return func(k, v interface{}) bool { + bucket := v.(*int64) + if addToBucket(hotBuckets, k.(int), atomic.LoadInt64(bucket)) { + atomic.AddUint32(bucketNumber, 1) + } + atomic.StoreInt64(bucket, 0) + return true + } +} + +func deleteSyncMap(m *sync.Map) { + m.Range(func(k, v interface{}) bool { + m.Delete(k) + return true + }) +} + +func findSmallestKey(m *sync.Map) int { + result := math.MaxInt32 + m.Range(func(k, v interface{}) bool { + key := k.(int) + if key < result { + result = key + } + return true + }) + return result +} + +func getLe(key int, schema int32) float64 { + // Here a bit of context about the behavior for the last bucket counting + // regular numbers (called simply "last bucket" below) and the bucket + // counting observations of ±Inf (called "inf bucket" below, with a key + // one higher than that of the "last bucket"): + // + // If we apply the usual formula to the last bucket, its upper bound + // would be calculated as +Inf. The reason is that the max possible + // regular float64 number (math.MaxFloat64) doesn't coincide with one of + // the calculated bucket boundaries. So the calculated boundary has to + // be larger than math.MaxFloat64, and the only float64 larger than + // math.MaxFloat64 is +Inf. However, we want to count actual + // observations of ±Inf in the inf bucket. Therefore, we have to treat + // the upper bound of the last bucket specially and set it to + // math.MaxFloat64. (The upper bound of the inf bucket, with its key + // being one higher than that of the last bucket, naturally comes out as + // +Inf by the usual formula. So that's fine.) + // + // math.MaxFloat64 has a frac of 0.9999999999999999 and an exp of + // 1024. If there were a float64 number following math.MaxFloat64, it + // would have a frac of 1.0 and an exp of 1024, or equivalently a frac + // of 0.5 and an exp of 1025. However, since frac must be smaller than + // 1, and exp must be smaller than 1025, either representation overflows + // a float64. (Which, in turn, is the reason that math.MaxFloat64 is the + // largest possible float64. Q.E.D.) However, the formula for + // calculating the upper bound from the idx and schema of the last + // bucket results in precisely that. It is either frac=1.0 & exp=1024 + // (for schema < 0) or frac=0.5 & exp=1025 (for schema >=0). (This is, + // by the way, a power of two where the exponent itself is a power of + // two, 2¹⁰ in fact, which coinicides with a bucket boundary in all + // schemas.) So these are the special cases we have to catch below. + if schema < 0 { + exp := key << -schema + if exp == 1024 { + // This is the last bucket before the overflow bucket + // (for ±Inf observations). Return math.MaxFloat64 as + // explained above. + return math.MaxFloat64 + } + return math.Ldexp(1, exp) + } + + fracIdx := key & ((1 << schema) - 1) + frac := nativeHistogramBounds[schema][fracIdx] + exp := (key >> schema) + 1 + if frac == 0.5 && exp == 1025 { + // This is the last bucket before the overflow bucket (for ±Inf + // observations). Return math.MaxFloat64 as explained above. + return math.MaxFloat64 + } + return math.Ldexp(frac, exp) +} + +// waitForCooldown returns after the count field in the provided histogramCounts +// has reached the provided count value. +func waitForCooldown(count uint64, counts *histogramCounts) { + for count != atomic.LoadUint64(&counts.count) { + runtime.Gosched() // Let observations get work done. + } +} + +// atomicAddFloat adds the provided float atomically to another float +// represented by the bit pattern the bits pointer is pointing to. +func atomicAddFloat(bits *uint64, v float64) { + for { + loadedBits := atomic.LoadUint64(bits) + newBits := math.Float64bits(math.Float64frombits(loadedBits) + v) + if atomic.CompareAndSwapUint64(bits, loadedBits, newBits) { + break + } + } +} + +// atomicDecUint32 atomically decrements the uint32 p points to. See +// https://pkg.go.dev/sync/atomic#AddUint32 to understand how this is done. +func atomicDecUint32(p *uint32) { + atomic.AddUint32(p, ^uint32(0)) +} + +// addAndResetCounts adds certain fields (count, sum, conventional buckets, zero +// bucket) from the cold counts to the corresponding fields in the hot +// counts. Those fields are then reset to 0 in the cold counts. +func addAndResetCounts(hot, cold *histogramCounts) { + atomic.AddUint64(&hot.count, atomic.LoadUint64(&cold.count)) + atomic.StoreUint64(&cold.count, 0) + coldSum := math.Float64frombits(atomic.LoadUint64(&cold.sumBits)) + atomicAddFloat(&hot.sumBits, coldSum) + atomic.StoreUint64(&cold.sumBits, 0) + for i := range hot.buckets { + atomic.AddUint64(&hot.buckets[i], atomic.LoadUint64(&cold.buckets[i])) + atomic.StoreUint64(&cold.buckets[i], 0) + } + atomic.AddUint64(&hot.nativeHistogramZeroBucket, atomic.LoadUint64(&cold.nativeHistogramZeroBucket)) + atomic.StoreUint64(&cold.nativeHistogramZeroBucket, 0) +} diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go new file mode 100644 index 000000000..1ed5abe74 --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go @@ -0,0 +1,60 @@ +// Copyright (c) 2015 Björn Rabenstein +// +// 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. +// +// The code in this package is copy/paste to avoid a dependency. Hence this file +// carries the copyright of the original repo. +// https://github.com/beorn7/floats +package internal + +import ( + "math" +) + +// minNormalFloat64 is the smallest positive normal value of type float64. +var minNormalFloat64 = math.Float64frombits(0x0010000000000000) + +// AlmostEqualFloat64 returns true if a and b are equal within a relative error +// of epsilon. See http://floating-point-gui.de/errors/comparison/ for the +// details of the applied method. +func AlmostEqualFloat64(a, b, epsilon float64) bool { + if a == b { + return true + } + absA := math.Abs(a) + absB := math.Abs(b) + diff := math.Abs(a - b) + if a == 0 || b == 0 || absA+absB < minNormalFloat64 { + return diff < epsilon*minNormalFloat64 + } + return diff/math.Min(absA+absB, math.MaxFloat64) < epsilon +} + +// AlmostEqualFloat64s is the slice form of AlmostEqualFloat64. +func AlmostEqualFloat64s(a, b []float64, epsilon float64) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if !AlmostEqualFloat64(a[i], b[i], epsilon) { + return false + } + } + return true +} diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go index fd45cadc0..fd0750f2c 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go @@ -201,12 +201,15 @@ func (m *SequenceMatcher) isBJunk(s string) bool { // If IsJunk is not defined: // // Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where -// alo <= i <= i+k <= ahi -// blo <= j <= j+k <= bhi +// +// alo <= i <= i+k <= ahi +// blo <= j <= j+k <= bhi +// // and for all (i',j',k') meeting those conditions, -// k >= k' -// i <= i' -// and if i == i', j <= j' +// +// k >= k' +// i <= i' +// and if i == i', j <= j' // // In other words, of all maximal matching blocks, return one that // starts earliest in a, and of all those maximal matching blocks that diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/labels.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/labels.go index 6eee198fe..63ff8683c 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/labels.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/labels.go @@ -25,12 +25,85 @@ import ( // Labels represents a collection of label name -> value mappings. This type is // commonly used with the With(Labels) and GetMetricWith(Labels) methods of // metric vector Collectors, e.g.: -// myVec.With(Labels{"code": "404", "method": "GET"}).Add(42) +// +// myVec.With(Labels{"code": "404", "method": "GET"}).Add(42) // // The other use-case is the specification of constant label pairs in Opts or to // create a Desc. type Labels map[string]string +// ConstrainedLabels represents a label name and its constrain function +// to normalize label values. This type is commonly used when constructing +// metric vector Collectors. +type ConstrainedLabel struct { + Name string + Constraint func(string) string +} + +func (cl ConstrainedLabel) Constrain(v string) string { + if cl.Constraint == nil { + return v + } + return cl.Constraint(v) +} + +// ConstrainableLabels is an interface that allows creating of labels that can +// be optionally constrained. +// +// prometheus.V2().NewCounterVec(CounterVecOpts{ +// CounterOpts: {...}, // Usual CounterOpts fields +// VariableLabels: []ConstrainedLabels{ +// {Name: "A"}, +// {Name: "B", Constraint: func(v string) string { ... }}, +// }, +// }) +type ConstrainableLabels interface { + constrainedLabels() ConstrainedLabels + labelNames() []string +} + +// ConstrainedLabels represents a collection of label name -> constrain function +// to normalize label values. This type is commonly used when constructing +// metric vector Collectors. +type ConstrainedLabels []ConstrainedLabel + +func (cls ConstrainedLabels) constrainedLabels() ConstrainedLabels { + return cls +} + +func (cls ConstrainedLabels) labelNames() []string { + names := make([]string, len(cls)) + for i, label := range cls { + names[i] = label.Name + } + return names +} + +// UnconstrainedLabels represents collection of label without any constraint on +// their value. Thus, it is simply a collection of label names. +// +// UnconstrainedLabels([]string{ "A", "B" }) +// +// is equivalent to +// +// ConstrainedLabels { +// { Name: "A" }, +// { Name: "B" }, +// } +type UnconstrainedLabels []string + +func (uls UnconstrainedLabels) constrainedLabels() ConstrainedLabels { + constrainedLabels := make([]ConstrainedLabel, len(uls)) + for i, l := range uls { + constrainedLabels[i] = ConstrainedLabel{Name: l} + } + return constrainedLabels +} + +func (uls UnconstrainedLabels) labelNames() []string { + return uls +} + // reservedLabelPrefix is a prefix which is not legal in user-supplied // label names. const reservedLabelPrefix = "__" diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/metric.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/metric.go index f0941f6f0..07bbc9d76 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/metric.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/metric.go @@ -20,11 +20,9 @@ import ( "strings" "time" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - "github.com/prometheus/common/model" - dto "github.com/prometheus/client_model/go" + "github.com/prometheus/common/model" + "google.golang.org/protobuf/proto" ) var separatorByteSlice = []byte{model.SeparatorByte} // For convenient use with xxhash. @@ -187,7 +185,7 @@ func (m *withExemplarsMetric) Write(pb *dto.Metric) error { } else { // The +Inf bucket should be explicitly added if there is an exemplar for it, similar to non-const histogram logic in https://github.com/prometheus/client_golang/blob/main/prometheus/histogram.go#L357-L365. b := &dto.Bucket{ - CumulativeCount: proto.Uint64(pb.Histogram.Bucket[len(pb.Histogram.GetBucket())-1].GetCumulativeCount()), + CumulativeCount: proto.Uint64(pb.Histogram.GetSampleCount()), UpperBound: proto.Float64(math.Inf(1)), Exemplar: e, } diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promauto/auto.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promauto/auto.go index f8d50d1f9..fa9011592 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promauto/auto.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promauto/auto.go @@ -14,114 +14,114 @@ // Package promauto provides alternative constructors for the fundamental // Prometheus metric types and their …Vec and …Func variants. The difference to // their counterparts in the prometheus package is that the promauto -// constructors return Collectors that are already registered with a -// registry. There are two sets of constructors. The constructors in the first -// set are top-level functions, while the constructors in the other set are -// methods of the Factory type. The top-level function return Collectors -// registered with the global registry (prometheus.DefaultRegisterer), while the -// methods return Collectors registered with the registry the Factory was -// constructed with. All constructors panic if the registration fails. +// constructors register the Collectors with a registry before returning them. +// There are two sets of constructors. The constructors in the first set are +// top-level functions, while the constructors in the other set are methods of +// the Factory type. The top-level function return Collectors registered with +// the global registry (prometheus.DefaultRegisterer), while the methods return +// Collectors registered with the registry the Factory was constructed with. All +// constructors panic if the registration fails. // // The following example is a complete program to create a histogram of normally // distributed random numbers from the math/rand package: // -// package main +// package main // -// import ( -// "math/rand" -// "net/http" +// import ( +// "math/rand" +// "net/http" // -// "github.com/prometheus/client_golang/prometheus" -// "github.com/prometheus/client_golang/prometheus/promauto" -// "github.com/prometheus/client_golang/prometheus/promhttp" -// ) +// "github.com/prometheus/client_golang/prometheus" +// "github.com/prometheus/client_golang/prometheus/promauto" +// "github.com/prometheus/client_golang/prometheus/promhttp" +// ) // -// var histogram = promauto.NewHistogram(prometheus.HistogramOpts{ -// Name: "random_numbers", -// Help: "A histogram of normally distributed random numbers.", -// Buckets: prometheus.LinearBuckets(-3, .1, 61), -// }) +// var histogram = promauto.NewHistogram(prometheus.HistogramOpts{ +// Name: "random_numbers", +// Help: "A histogram of normally distributed random numbers.", +// Buckets: prometheus.LinearBuckets(-3, .1, 61), +// }) // -// func Random() { -// for { -// histogram.Observe(rand.NormFloat64()) -// } -// } +// func Random() { +// for { +// histogram.Observe(rand.NormFloat64()) +// } +// } // -// func main() { -// go Random() -// http.Handle("/metrics", promhttp.Handler()) -// http.ListenAndServe(":1971", nil) -// } +// func main() { +// go Random() +// http.Handle("/metrics", promhttp.Handler()) +// http.ListenAndServe(":1971", nil) +// } // // Prometheus's version of a minimal hello-world program: // -// package main +// package main // -// import ( -// "fmt" -// "net/http" +// import ( +// "fmt" +// "net/http" // -// "github.com/prometheus/client_golang/prometheus" -// "github.com/prometheus/client_golang/prometheus/promauto" -// "github.com/prometheus/client_golang/prometheus/promhttp" -// ) +// "github.com/prometheus/client_golang/prometheus" +// "github.com/prometheus/client_golang/prometheus/promauto" +// "github.com/prometheus/client_golang/prometheus/promhttp" +// ) // -// func main() { -// http.Handle("/", promhttp.InstrumentHandlerCounter( -// promauto.NewCounterVec( -// prometheus.CounterOpts{ -// Name: "hello_requests_total", -// Help: "Total number of hello-world requests by HTTP code.", -// }, -// []string{"code"}, -// ), -// http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { -// fmt.Fprint(w, "Hello, world!") -// }), -// )) -// http.Handle("/metrics", promhttp.Handler()) -// http.ListenAndServe(":1971", nil) -// } +// func main() { +// http.Handle("/", promhttp.InstrumentHandlerCounter( +// promauto.NewCounterVec( +// prometheus.CounterOpts{ +// Name: "hello_requests_total", +// Help: "Total number of hello-world requests by HTTP code.", +// }, +// []string{"code"}, +// ), +// http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { +// fmt.Fprint(w, "Hello, world!") +// }), +// )) +// http.Handle("/metrics", promhttp.Handler()) +// http.ListenAndServe(":1971", nil) +// } // // A Factory is created with the With(prometheus.Registerer) function, which // enables two usage pattern. With(prometheus.Registerer) can be called once per // line: // -// var ( -// reg = prometheus.NewRegistry() -// randomNumbers = promauto.With(reg).NewHistogram(prometheus.HistogramOpts{ -// Name: "random_numbers", -// Help: "A histogram of normally distributed random numbers.", -// Buckets: prometheus.LinearBuckets(-3, .1, 61), -// }) -// requestCount = promauto.With(reg).NewCounterVec( -// prometheus.CounterOpts{ -// Name: "http_requests_total", -// Help: "Total number of HTTP requests by status code and method.", -// }, -// []string{"code", "method"}, -// ) -// ) +// var ( +// reg = prometheus.NewRegistry() +// randomNumbers = promauto.With(reg).NewHistogram(prometheus.HistogramOpts{ +// Name: "random_numbers", +// Help: "A histogram of normally distributed random numbers.", +// Buckets: prometheus.LinearBuckets(-3, .1, 61), +// }) +// requestCount = promauto.With(reg).NewCounterVec( +// prometheus.CounterOpts{ +// Name: "http_requests_total", +// Help: "Total number of HTTP requests by status code and method.", +// }, +// []string{"code", "method"}, +// ) +// ) // // Or it can be used to create a Factory once to be used multiple times: // -// var ( -// reg = prometheus.NewRegistry() -// factory = promauto.With(reg) -// randomNumbers = factory.NewHistogram(prometheus.HistogramOpts{ -// Name: "random_numbers", -// Help: "A histogram of normally distributed random numbers.", -// Buckets: prometheus.LinearBuckets(-3, .1, 61), -// }) -// requestCount = factory.NewCounterVec( -// prometheus.CounterOpts{ -// Name: "http_requests_total", -// Help: "Total number of HTTP requests by status code and method.", -// }, -// []string{"code", "method"}, -// ) -// ) +// var ( +// reg = prometheus.NewRegistry() +// factory = promauto.With(reg) +// randomNumbers = factory.NewHistogram(prometheus.HistogramOpts{ +// Name: "random_numbers", +// Help: "A histogram of normally distributed random numbers.", +// Buckets: prometheus.LinearBuckets(-3, .1, 61), +// }) +// requestCount = factory.NewCounterVec( +// prometheus.CounterOpts{ +// Name: "http_requests_total", +// Help: "Total number of HTTP requests by status code and method.", +// }, +// []string{"code", "method"}, +// ) +// ) // // This appears very handy. So why are these constructors locked away in a // separate package? diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go index a4cc9810b..09b8d2fbe 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go @@ -37,6 +37,7 @@ import ( "fmt" "io" "net/http" + "strconv" "strings" "sync" "time" @@ -47,9 +48,10 @@ import ( ) const ( - contentTypeHeader = "Content-Type" - contentEncodingHeader = "Content-Encoding" - acceptEncodingHeader = "Accept-Encoding" + contentTypeHeader = "Content-Type" + contentEncodingHeader = "Content-Encoding" + acceptEncodingHeader = "Accept-Encoding" + processStartTimeHeader = "Process-Start-Time-Unix" ) var gzipPool = sync.Pool{ @@ -121,6 +123,9 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO } h := http.HandlerFunc(func(rsp http.ResponseWriter, req *http.Request) { + if !opts.ProcessStartTime.IsZero() { + rsp.Header().Set(processStartTimeHeader, strconv.FormatInt(opts.ProcessStartTime.Unix(), 10)) + } if inFlightSem != nil { select { case inFlightSem <- struct{}{}: // All good, carry on. @@ -366,6 +371,14 @@ type HandlerOpts struct { // (which changes the identity of the resulting series on the Prometheus // server). EnableOpenMetrics bool + // ProcessStartTime allows setting process start timevalue that will be exposed + // with "Process-Start-Time-Unix" response header along with the metrics + // payload. This allow callers to have efficient transformations to cumulative + // counters (e.g. OpenTelemetry) or generally _created timestamp estimation per + // scrape target. + // NOTE: This feature is experimental and not covered by OpenMetrics or Prometheus + // exposition format. + ProcessStartTime time.Time } // gzipAccepted returns whether the client will accept gzip-encoded content. diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go index 097aff2df..d3482c40c 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go @@ -68,17 +68,17 @@ func InstrumentRoundTripperCounter(counter *prometheus.CounterVec, next http.Rou o.apply(rtOpts) } - code, method := checkLabels(counter) + // Curry the counter with dynamic labels before checking the remaining labels. + code, method := checkLabels(counter.MustCurryWith(rtOpts.emptyDynamicLabels())) return func(r *http.Request) (*http.Response, error) { resp, err := next.RoundTrip(r) if err == nil { - exemplarAdd( - counter.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)), - 1, - rtOpts.getExemplarFn(r.Context()), - ) - counter.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)).Inc() + l := labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...) + for label, resolve := range rtOpts.extraLabelsFromCtx { + l[label] = resolve(resp.Request.Context()) + } + addWithExemplar(counter.With(l), 1, rtOpts.getExemplarFn(r.Context())) } return resp, err } @@ -111,17 +111,18 @@ func InstrumentRoundTripperDuration(obs prometheus.ObserverVec, next http.RoundT o.apply(rtOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(rtOpts.emptyDynamicLabels())) return func(r *http.Request) (*http.Response, error) { start := time.Now() resp, err := next.RoundTrip(r) if err == nil { - exemplarObserve( - obs.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)), - time.Since(start).Seconds(), - rtOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...) + for label, resolve := range rtOpts.extraLabelsFromCtx { + l[label] = resolve(resp.Request.Context()) + } + observeWithExemplar(obs.With(l), time.Since(start).Seconds(), rtOpts.getExemplarFn(r.Context())) } return resp, err } diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go index bfe500987..3793036ad 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go @@ -28,7 +28,9 @@ import ( // magicString is used for the hacky label test in checkLabels. Remove once fixed. const magicString = "zZgWfBxLqvG8kc8IMv3POi2Bb0tZI3vAnBx+gBaFi9FyPzB/CzKUer1yufDa" -func exemplarObserve(obs prometheus.Observer, val float64, labels map[string]string) { +// observeWithExemplar is a wrapper for [prometheus.ExemplarAdder.ExemplarObserver], +// which falls back to [prometheus.Observer.Observe] if no labels are provided. +func observeWithExemplar(obs prometheus.Observer, val float64, labels map[string]string) { if labels == nil { obs.Observe(val) return @@ -36,7 +38,9 @@ func exemplarObserve(obs prometheus.Observer, val float64, labels map[string]str obs.(prometheus.ExemplarObserver).ObserveWithExemplar(val, labels) } -func exemplarAdd(obs prometheus.Counter, val float64, labels map[string]string) { +// addWithExemplar is a wrapper for [prometheus.ExemplarAdder.AddWithExemplar], +// which falls back to [prometheus.Counter.Add] if no labels are provided. +func addWithExemplar(obs prometheus.Counter, val float64, labels map[string]string) { if labels == nil { obs.Add(val) return @@ -83,7 +87,8 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler, op o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) if code { return func(w http.ResponseWriter, r *http.Request) { @@ -91,23 +96,22 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler, op d := newDelegator(w, nil) next.ServeHTTP(d, r) - exemplarObserve( - obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - time.Since(now).Seconds(), - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) } } return func(w http.ResponseWriter, r *http.Request) { now := time.Now() next.ServeHTTP(w, r) - - exemplarObserve( - obs.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)), - time.Since(now).Seconds(), - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, 0, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) } } @@ -134,28 +138,30 @@ func InstrumentHandlerCounter(counter *prometheus.CounterVec, next http.Handler, o.apply(hOpts) } - code, method := checkLabels(counter) + // Curry the counter with dynamic labels before checking the remaining labels. + code, method := checkLabels(counter.MustCurryWith(hOpts.emptyDynamicLabels())) if code { return func(w http.ResponseWriter, r *http.Request) { d := newDelegator(w, nil) next.ServeHTTP(d, r) - exemplarAdd( - counter.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - 1, - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r.Context())) } } return func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) - exemplarAdd( - counter.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)), - 1, - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, 0, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r.Context())) } } @@ -187,16 +193,17 @@ func InstrumentHandlerTimeToWriteHeader(obs prometheus.ObserverVec, next http.Ha o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) return func(w http.ResponseWriter, r *http.Request) { now := time.Now() d := newDelegator(w, func(status int) { - exemplarObserve( - obs.With(labels(code, method, r.Method, status, hOpts.extraMethods...)), - time.Since(now).Seconds(), - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, status, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) }) next.ServeHTTP(d, r) } @@ -227,28 +234,32 @@ func InstrumentHandlerRequestSize(obs prometheus.ObserverVec, next http.Handler, o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) + if code { return func(w http.ResponseWriter, r *http.Request) { d := newDelegator(w, nil) next.ServeHTTP(d, r) size := computeApproximateRequestSize(r) - exemplarObserve( - obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - float64(size), - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r.Context())) } } return func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) size := computeApproximateRequestSize(r) - exemplarObserve( - obs.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)), - float64(size), - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, 0, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r.Context())) } } @@ -277,16 +288,18 @@ func InstrumentHandlerResponseSize(obs prometheus.ObserverVec, next http.Handler o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { d := newDelegator(w, nil) next.ServeHTTP(d, r) - exemplarObserve( - obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - float64(d.Written()), - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), float64(d.Written()), hOpts.getExemplarFn(r.Context())) }) } diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go index c590d912c..5d4383aa1 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go @@ -24,14 +24,32 @@ type Option interface { apply(*options) } +// LabelValueFromCtx are used to compute the label value from request context. +// Context can be filled with values from request through middleware. +type LabelValueFromCtx func(ctx context.Context) string + // options store options for both a handler or round tripper. type options struct { - extraMethods []string - getExemplarFn func(requestCtx context.Context) prometheus.Labels + extraMethods []string + getExemplarFn func(requestCtx context.Context) prometheus.Labels + extraLabelsFromCtx map[string]LabelValueFromCtx } func defaultOptions() *options { - return &options{getExemplarFn: func(ctx context.Context) prometheus.Labels { return nil }} + return &options{ + getExemplarFn: func(ctx context.Context) prometheus.Labels { return nil }, + extraLabelsFromCtx: map[string]LabelValueFromCtx{}, + } +} + +func (o *options) emptyDynamicLabels() prometheus.Labels { + labels := prometheus.Labels{} + + for label := range o.extraLabelsFromCtx { + labels[label] = "" + } + + return labels } type optionApplyFunc func(*options) @@ -48,11 +66,19 @@ func WithExtraMethods(methods ...string) Option { }) } -// WithExemplarFromContext adds allows to put a hook to all counter and histogram metrics. -// If the hook function returns non-nil labels, exemplars will be added for that request, otherwise metric -// will get instrumented without exemplar. +// WithExemplarFromContext allows to inject function that will get exemplar from context that will be put to counter and histogram metrics. +// If the function returns nil labels or the metric does not support exemplars, no exemplar will be added (noop), but +// metric will continue to observe/increment. func WithExemplarFromContext(getExemplarFn func(requestCtx context.Context) prometheus.Labels) Option { return optionApplyFunc(func(o *options) { o.getExemplarFn = getExemplarFn }) } + +// WithLabelFromCtx registers a label for dynamic resolution with access to context. +// See the example for ExampleInstrumentHandlerWithLabelResolver for example usage +func WithLabelFromCtx(name string, valueFn LabelValueFromCtx) Option { + return optionApplyFunc(func(o *options) { + o.extraLabelsFromCtx[name] = valueFn + }) +} diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/registry.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/registry.go index 325f665ff..44da9433b 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/registry.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/registry.go @@ -21,18 +21,17 @@ import ( "path/filepath" "runtime" "sort" + "strconv" "strings" "sync" "unicode/utf8" - "github.com/cespare/xxhash/v2" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - "github.com/prometheus/common/expfmt" + "github.com/prometheus/client_golang/prometheus/internal" + "github.com/cespare/xxhash/v2" dto "github.com/prometheus/client_model/go" - - "github.com/prometheus/client_golang/prometheus/internal" + "github.com/prometheus/common/expfmt" + "google.golang.org/protobuf/proto" ) const ( @@ -252,9 +251,12 @@ func (errs MultiError) MaybeUnwrap() error { } // Registry registers Prometheus collectors, collects their metrics, and gathers -// them into MetricFamilies for exposition. It implements both Registerer and -// Gatherer. The zero value is not usable. Create instances with NewRegistry or -// NewPedanticRegistry. +// them into MetricFamilies for exposition. It implements Registerer, Gatherer, +// and Collector. The zero value is not usable. Create instances with +// NewRegistry or NewPedanticRegistry. +// +// Registry implements Collector to allow it to be used for creating groups of +// metrics. See the Grouping example for how this can be done. type Registry struct { mtx sync.RWMutex collectorsByID map[uint64]Collector // ID is a hash of the descIDs. @@ -556,6 +558,31 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { return internal.NormalizeMetricFamilies(metricFamiliesByName), errs.MaybeUnwrap() } +// Describe implements Collector. +func (r *Registry) Describe(ch chan<- *Desc) { + r.mtx.RLock() + defer r.mtx.RUnlock() + + // Only report the checked Collectors; unchecked collectors don't report any + // Desc. + for _, c := range r.collectorsByID { + c.Describe(ch) + } +} + +// Collect implements Collector. +func (r *Registry) Collect(ch chan<- Metric) { + r.mtx.RLock() + defer r.mtx.RUnlock() + + for _, c := range r.collectorsByID { + c.Collect(ch) + } + for _, c := range r.uncheckedCollectors { + c.Collect(ch) + } +} + // WriteToTextfile calls Gather on the provided Gatherer, encodes the result in the // Prometheus text format, and writes it to a temporary file. Upon success, the // temporary file is renamed to the provided filename. @@ -905,6 +932,10 @@ func checkMetricConsistency( h.WriteString(lp.GetValue()) h.Write(separatorByteSlice) } + if dtoMetric.TimestampMs != nil { + h.WriteString(strconv.FormatInt(*(dtoMetric.TimestampMs), 10)) + h.Write(separatorByteSlice) + } hSum := h.Sum64() if _, exists := metricHashes[hSum]; exists { return fmt.Errorf( @@ -934,7 +965,7 @@ func checkDescConsistency( copy(lpsFromDesc, desc.constLabelPairs) for _, l := range desc.variableLabels { lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{ - Name: proto.String(l), + Name: proto.String(l.Name), }) } if len(lpsFromDesc) != len(dtoMetric.Label) { diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/summary.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/summary.go index c5fa8ed7c..dd359264e 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/summary.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/summary.go @@ -22,11 +22,10 @@ import ( "sync/atomic" "time" - "github.com/beorn7/perks/quantile" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - dto "github.com/prometheus/client_model/go" + + "github.com/beorn7/perks/quantile" + "google.golang.org/protobuf/proto" ) // quantileLabel is used for the label that defines the quantile in a @@ -148,6 +147,18 @@ type SummaryOpts struct { BufCap uint32 } +// SummaryVecOpts bundles the options to create a SummaryVec metric. +// It is mandatory to set SummaryOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type SummaryVecOpts struct { + SummaryOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels +} + // Problem with the sliding-window decay algorithm... The Merge method of // perk/quantile is actually not working as advertised - and it might be // unfixable, as the underlying algorithm is apparently not capable of merging @@ -178,11 +189,11 @@ func NewSummary(opts SummaryOpts) Summary { func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary { if len(desc.variableLabels) != len(labelValues) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, labelValues)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), labelValues)) } for _, n := range desc.variableLabels { - if n == quantileLabel { + if n.Name == quantileLabel { panic(errQuantileLabelNotAllowed) } } @@ -530,20 +541,28 @@ type SummaryVec struct { // it is handled by the Prometheus server internally, “quantile” is an illegal // label name. NewSummaryVec will panic if this label name is used. func NewSummaryVec(opts SummaryOpts, labelNames []string) *SummaryVec { - for _, ln := range labelNames { + return V2.NewSummaryVec(SummaryVecOpts{ + SummaryOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewSummaryVec creates a new SummaryVec based on the provided SummaryVecOpts. +func (v2) NewSummaryVec(opts SummaryVecOpts) *SummaryVec { + for _, ln := range opts.VariableLabels.labelNames() { if ln == quantileLabel { panic(errQuantileLabelNotAllowed) } } - desc := NewDesc( + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &SummaryVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { - return newSummary(desc, opts, lvs...) + return newSummary(desc, opts.SummaryOpts, lvs...) }), } } @@ -603,7 +622,8 @@ func (v *SummaryVec) GetMetricWith(labels Labels) (Observer, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Observe(42.21) +// +// myVec.WithLabelValues("404", "GET").Observe(42.21) func (v *SummaryVec) WithLabelValues(lvs ...string) Observer { s, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -614,7 +634,8 @@ func (v *SummaryVec) WithLabelValues(lvs ...string) Observer { // With works as GetMetricWith, but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) func (v *SummaryVec) With(labels Labels) Observer { s, err := v.GetMetricWith(labels) if err != nil { @@ -701,7 +722,8 @@ func (s *constSummary) Write(out *dto.Metric) error { // // quantiles maps ranks to quantile values. For example, a median latency of // 0.23s and a 99th percentile latency of 0.56s would be expressed as: -// map[float64]float64{0.5: 0.23, 0.99: 0.56} +// +// map[float64]float64{0.5: 0.23, 0.99: 0.56} // // NewConstSummary returns an error if the length of labelValues is not // consistent with the variable labels in Desc or if Desc is invalid. diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/timer.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/timer.go index 8d5f10523..52344fef5 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/timer.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/timer.go @@ -23,13 +23,24 @@ type Timer struct { } // NewTimer creates a new Timer. The provided Observer is used to observe a -// duration in seconds. Timer is usually used to time a function call in the +// duration in seconds. If the Observer implements ExemplarObserver, passing exemplar +// later on will be also supported. +// Timer is usually used to time a function call in the // following way: -// func TimeMe() { -// timer := NewTimer(myHistogram) -// defer timer.ObserveDuration() -// // Do actual work. -// } +// +// func TimeMe() { +// timer := NewTimer(myHistogram) +// defer timer.ObserveDuration() +// // Do actual work. +// } +// +// or +// +// func TimeMeWithExemplar() { +// timer := NewTimer(myHistogram) +// defer timer.ObserveDurationWithExemplar(exemplar) +// // Do actual work. +// } func NewTimer(o Observer) *Timer { return &Timer{ begin: time.Now(), @@ -52,3 +63,19 @@ func (t *Timer) ObserveDuration() time.Duration { } return d } + +// ObserveDurationWithExemplar is like ObserveDuration, but it will also +// observe exemplar with the duration unless exemplar is nil or provided Observer can't +// be casted to ExemplarObserver. +func (t *Timer) ObserveDurationWithExemplar(exemplar Labels) time.Duration { + d := time.Since(t.begin) + eo, ok := t.observer.(ExemplarObserver) + if ok && exemplar != nil { + eo.ObserveWithExemplar(d.Seconds(), exemplar) + return d + } + if t.observer != nil { + t.observer.Observe(d.Seconds()) + } + return d +} diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/value.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/value.go index 2d3abc1cb..5f6bb8001 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/value.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/value.go @@ -19,13 +19,11 @@ import ( "time" "unicode/utf8" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - "google.golang.org/protobuf/types/known/timestamppb" - "github.com/prometheus/client_golang/prometheus/internal" dto "github.com/prometheus/client_model/go" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/timestamppb" ) // ValueType is an enumeration of metric types that represent a simple value. @@ -188,9 +186,9 @@ func MakeLabelPairs(desc *Desc, labelValues []string) []*dto.LabelPair { return desc.constLabelPairs } labelPairs := make([]*dto.LabelPair, 0, totalLen) - for i, n := range desc.variableLabels { + for i, l := range desc.variableLabels { labelPairs = append(labelPairs, &dto.LabelPair{ - Name: proto.String(n), + Name: proto.String(l.Name), Value: proto.String(labelValues[i]), }) } diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/vec.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/vec.go index 7ae322590..f0d0015a0 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/vec.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/vec.go @@ -20,6 +20,24 @@ import ( "github.com/prometheus/common/model" ) +var labelsPool = &sync.Pool{ + New: func() interface{} { + return make(Labels) + }, +} + +func getLabelsFromPool() Labels { + return labelsPool.Get().(Labels) +} + +func putLabelsToPool(labels Labels) { + for k := range labels { + delete(labels, k) + } + + labelsPool.Put(labels) +} + // MetricVec is a Collector to bundle metrics of the same name that differ in // their label values. MetricVec is not used directly but as a building block // for implementations of vectors of a given metric type, like GaugeVec, @@ -72,6 +90,7 @@ func NewMetricVec(desc *Desc, newMetric func(lvs ...string) Metric) *MetricVec { // with a performance overhead (for creating and processing the Labels map). // See also the CounterVec example. func (m *MetricVec) DeleteLabelValues(lvs ...string) bool { + lvs = constrainLabelValues(m.desc, lvs, m.curry) h, err := m.hashLabelValues(lvs) if err != nil { return false @@ -91,6 +110,9 @@ func (m *MetricVec) DeleteLabelValues(lvs ...string) bool { // This method is used for the same purpose as DeleteLabelValues(...string). See // there for pros and cons of the two methods. func (m *MetricVec) Delete(labels Labels) bool { + labels = constrainLabels(m.desc, labels) + defer putLabelsToPool(labels) + h, err := m.hashLabels(labels) if err != nil { return false @@ -106,6 +128,9 @@ func (m *MetricVec) Delete(labels Labels) bool { // Note that curried labels will never be matched if deleting from the curried vector. // To match curried labels with DeletePartialMatch, it must be called on the base vector. func (m *MetricVec) DeletePartialMatch(labels Labels) int { + labels = constrainLabels(m.desc, labels) + defer putLabelsToPool(labels) + return m.metricMap.deleteByLabels(labels, m.curry) } @@ -145,10 +170,10 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) { iCurry int ) for i, label := range m.desc.variableLabels { - val, ok := labels[label] + val, ok := labels[label.Name] if iCurry < len(oldCurry) && oldCurry[iCurry].index == i { if ok { - return nil, fmt.Errorf("label name %q is already curried", label) + return nil, fmt.Errorf("label name %q is already curried", label.Name) } newCurry = append(newCurry, oldCurry[iCurry]) iCurry++ @@ -156,7 +181,7 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) { if !ok { continue // Label stays uncurried. } - newCurry = append(newCurry, curriedLabelValue{i, val}) + newCurry = append(newCurry, curriedLabelValue{i, label.Constrain(val)}) } } if l := len(oldCurry) + len(labels) - len(newCurry); l > 0 { @@ -199,6 +224,7 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) { // a wrapper around MetricVec, implementing a vector for a specific Metric // implementation, for example GaugeVec. func (m *MetricVec) GetMetricWithLabelValues(lvs ...string) (Metric, error) { + lvs = constrainLabelValues(m.desc, lvs, m.curry) h, err := m.hashLabelValues(lvs) if err != nil { return nil, err @@ -224,6 +250,9 @@ func (m *MetricVec) GetMetricWithLabelValues(lvs ...string) (Metric, error) { // around MetricVec, implementing a vector for a specific Metric implementation, // for example GaugeVec. func (m *MetricVec) GetMetricWith(labels Labels) (Metric, error) { + labels = constrainLabels(m.desc, labels) + defer putLabelsToPool(labels) + h, err := m.hashLabels(labels) if err != nil { return nil, err @@ -266,16 +295,16 @@ func (m *MetricVec) hashLabels(labels Labels) (uint64, error) { iCurry int ) for i, label := range m.desc.variableLabels { - val, ok := labels[label] + val, ok := labels[label.Name] if iCurry < len(curry) && curry[iCurry].index == i { if ok { - return 0, fmt.Errorf("label name %q is already curried", label) + return 0, fmt.Errorf("label name %q is already curried", label.Name) } h = m.hashAdd(h, curry[iCurry].value) iCurry++ } else { if !ok { - return 0, fmt.Errorf("label name %q missing in label map", label) + return 0, fmt.Errorf("label name %q missing in label map", label.Name) } h = m.hashAdd(h, val) } @@ -453,7 +482,7 @@ func valueMatchesVariableOrCurriedValue(targetValue string, index int, values [] func matchPartialLabels(desc *Desc, values []string, labels Labels, curry []curriedLabelValue) bool { for l, v := range labels { // Check if the target label exists in our metrics and get the index. - varLabelIndex, validLabel := indexOf(l, desc.variableLabels) + varLabelIndex, validLabel := indexOf(l, desc.variableLabels.labelNames()) if validLabel { // Check the value of that label against the target value. // We don't consider curried values in partial matches. @@ -605,7 +634,7 @@ func matchLabels(desc *Desc, values []string, labels Labels, curry []curriedLabe iCurry++ continue } - if values[i] != labels[k] { + if values[i] != labels[k.Name] { return false } } @@ -621,7 +650,7 @@ func extractLabelValues(desc *Desc, labels Labels, curry []curriedLabelValue) [] iCurry++ continue } - labelValues[i] = labels[k] + labelValues[i] = labels[k.Name] } return labelValues } @@ -640,3 +669,35 @@ func inlineLabelValues(lvs []string, curry []curriedLabelValue) []string { } return labelValues } + +func constrainLabels(desc *Desc, labels Labels) Labels { + constrainedLabels := getLabelsFromPool() + for l, v := range labels { + if i, ok := indexOf(l, desc.variableLabels.labelNames()); ok { + v = desc.variableLabels[i].Constrain(v) + } + + constrainedLabels[l] = v + } + + return constrainedLabels +} + +func constrainLabelValues(desc *Desc, lvs []string, curry []curriedLabelValue) []string { + constrainedValues := make([]string, len(lvs)) + var iCurry, iLVs int + for i := 0; i < len(lvs)+len(curry); i++ { + if iCurry < len(curry) && curry[iCurry].index == i { + iCurry++ + continue + } + + if i < len(desc.variableLabels) { + constrainedValues[iLVs] = desc.variableLabels[i].Constrain(lvs[iLVs]) + } else { + constrainedValues[iLVs] = lvs[iLVs] + } + iLVs++ + } + return constrainedValues +} diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/vnext.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/vnext.go new file mode 100644 index 000000000..42bc3a8f0 --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/vnext.go @@ -0,0 +1,23 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package prometheus + +type v2 struct{} + +// V2 is a struct that can be referenced to access experimental API that might +// be present in v2 of client golang someday. It offers extended functionality +// of v1 with slightly changed API. It is acceptable to use some pieces from v1 +// and e.g `prometheus.NewGauge` and some from v2 e.g. `prometheus.V2.NewDesc` +// in the same codebase. +var V2 = v2{} diff --git a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/wrap.go b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/wrap.go index 1498ee144..25da157f1 100644 --- a/test/performance/vendor/github.com/prometheus/client_golang/prometheus/wrap.go +++ b/test/performance/vendor/github.com/prometheus/client_golang/prometheus/wrap.go @@ -17,12 +17,10 @@ import ( "fmt" "sort" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" + "github.com/prometheus/client_golang/prometheus/internal" dto "github.com/prometheus/client_model/go" - - "github.com/prometheus/client_golang/prometheus/internal" + "google.golang.org/protobuf/proto" ) // WrapRegistererWith returns a Registerer wrapping the provided @@ -206,7 +204,7 @@ func wrapDesc(desc *Desc, prefix string, labels Labels) *Desc { constLabels[ln] = lv } // NewDesc will do remaining validations. - newDesc := NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels) + newDesc := V2.NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels) // Propagate errors if there was any. This will override any errer // created by NewDesc above, i.e. earlier errors get precedence. if desc.err != nil { diff --git a/test/performance/vendor/github.com/prometheus/client_model/go/metrics.pb.go b/test/performance/vendor/github.com/prometheus/client_model/go/metrics.pb.go index 35904ea19..2b5bca4b9 100644 --- a/test/performance/vendor/github.com/prometheus/client_model/go/metrics.pb.go +++ b/test/performance/vendor/github.com/prometheus/client_model/go/metrics.pb.go @@ -1,25 +1,38 @@ +// Copyright 2013 Prometheus Team +// 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. + // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.20.3 // source: io/prometheus/client/metrics.proto package io_prometheus_client import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" ) -// 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.ProtoPackageIsVersion3 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type MetricType int32 @@ -38,23 +51,25 @@ const ( MetricType_GAUGE_HISTOGRAM MetricType = 5 ) -var MetricType_name = map[int32]string{ - 0: "COUNTER", - 1: "GAUGE", - 2: "SUMMARY", - 3: "UNTYPED", - 4: "HISTOGRAM", - 5: "GAUGE_HISTOGRAM", -} - -var MetricType_value = map[string]int32{ - "COUNTER": 0, - "GAUGE": 1, - "SUMMARY": 2, - "UNTYPED": 3, - "HISTOGRAM": 4, - "GAUGE_HISTOGRAM": 5, -} +// Enum value maps for MetricType. +var ( + MetricType_name = map[int32]string{ + 0: "COUNTER", + 1: "GAUGE", + 2: "SUMMARY", + 3: "UNTYPED", + 4: "HISTOGRAM", + 5: "GAUGE_HISTOGRAM", + } + MetricType_value = map[string]int32{ + "COUNTER": 0, + "GAUGE": 1, + "SUMMARY": 2, + "UNTYPED": 3, + "HISTOGRAM": 4, + "GAUGE_HISTOGRAM": 5, + } +) func (x MetricType) Enum() *MetricType { p := new(MetricType) @@ -63,449 +78,519 @@ func (x MetricType) Enum() *MetricType { } func (x MetricType) String() string { - return proto.EnumName(MetricType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (x *MetricType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(MetricType_value, data, "MetricType") +func (MetricType) Descriptor() protoreflect.EnumDescriptor { + return file_io_prometheus_client_metrics_proto_enumTypes[0].Descriptor() +} + +func (MetricType) Type() protoreflect.EnumType { + return &file_io_prometheus_client_metrics_proto_enumTypes[0] +} + +func (x MetricType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *MetricType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = MetricType(value) + *x = MetricType(num) return nil } +// Deprecated: Use MetricType.Descriptor instead. func (MetricType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{0} + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{0} } type LabelPair struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *LabelPair) Reset() { *m = LabelPair{} } -func (m *LabelPair) String() string { return proto.CompactTextString(m) } -func (*LabelPair) ProtoMessage() {} -func (*LabelPair) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{0} + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` } -func (m *LabelPair) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LabelPair.Unmarshal(m, b) -} -func (m *LabelPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LabelPair.Marshal(b, m, deterministic) -} -func (m *LabelPair) XXX_Merge(src proto.Message) { - xxx_messageInfo_LabelPair.Merge(m, src) +func (x *LabelPair) Reset() { + *x = LabelPair{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *LabelPair) XXX_Size() int { - return xxx_messageInfo_LabelPair.Size(m) + +func (x *LabelPair) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *LabelPair) XXX_DiscardUnknown() { - xxx_messageInfo_LabelPair.DiscardUnknown(m) + +func (*LabelPair) ProtoMessage() {} + +func (x *LabelPair) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_LabelPair proto.InternalMessageInfo +// Deprecated: Use LabelPair.ProtoReflect.Descriptor instead. +func (*LabelPair) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{0} +} -func (m *LabelPair) GetName() string { - if m != nil && m.Name != nil { - return *m.Name +func (x *LabelPair) GetName() string { + if x != nil && x.Name != nil { + return *x.Name } return "" } -func (m *LabelPair) GetValue() string { - if m != nil && m.Value != nil { - return *m.Value +func (x *LabelPair) GetValue() string { + if x != nil && x.Value != nil { + return *x.Value } return "" } type Gauge struct { - Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Gauge) Reset() { *m = Gauge{} } -func (m *Gauge) String() string { return proto.CompactTextString(m) } -func (*Gauge) ProtoMessage() {} -func (*Gauge) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{1} + Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` } -func (m *Gauge) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Gauge.Unmarshal(m, b) -} -func (m *Gauge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Gauge.Marshal(b, m, deterministic) -} -func (m *Gauge) XXX_Merge(src proto.Message) { - xxx_messageInfo_Gauge.Merge(m, src) +func (x *Gauge) Reset() { + *x = Gauge{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Gauge) XXX_Size() int { - return xxx_messageInfo_Gauge.Size(m) + +func (x *Gauge) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Gauge) XXX_DiscardUnknown() { - xxx_messageInfo_Gauge.DiscardUnknown(m) + +func (*Gauge) ProtoMessage() {} + +func (x *Gauge) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Gauge proto.InternalMessageInfo +// Deprecated: Use Gauge.ProtoReflect.Descriptor instead. +func (*Gauge) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{1} +} -func (m *Gauge) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Gauge) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } type Counter struct { - Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` - Exemplar *Exemplar `protobuf:"bytes,2,opt,name=exemplar" json:"exemplar,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Counter) Reset() { *m = Counter{} } -func (m *Counter) String() string { return proto.CompactTextString(m) } -func (*Counter) ProtoMessage() {} -func (*Counter) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{2} + Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` + Exemplar *Exemplar `protobuf:"bytes,2,opt,name=exemplar" json:"exemplar,omitempty"` } -func (m *Counter) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Counter.Unmarshal(m, b) -} -func (m *Counter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Counter.Marshal(b, m, deterministic) -} -func (m *Counter) XXX_Merge(src proto.Message) { - xxx_messageInfo_Counter.Merge(m, src) +func (x *Counter) Reset() { + *x = Counter{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Counter) XXX_Size() int { - return xxx_messageInfo_Counter.Size(m) + +func (x *Counter) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Counter) XXX_DiscardUnknown() { - xxx_messageInfo_Counter.DiscardUnknown(m) + +func (*Counter) ProtoMessage() {} + +func (x *Counter) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Counter proto.InternalMessageInfo +// Deprecated: Use Counter.ProtoReflect.Descriptor instead. +func (*Counter) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{2} +} -func (m *Counter) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Counter) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } -func (m *Counter) GetExemplar() *Exemplar { - if m != nil { - return m.Exemplar +func (x *Counter) GetExemplar() *Exemplar { + if x != nil { + return x.Exemplar } return nil } type Quantile struct { - Quantile *float64 `protobuf:"fixed64,1,opt,name=quantile" json:"quantile,omitempty"` - Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Quantile) Reset() { *m = Quantile{} } -func (m *Quantile) String() string { return proto.CompactTextString(m) } -func (*Quantile) ProtoMessage() {} -func (*Quantile) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{3} + Quantile *float64 `protobuf:"fixed64,1,opt,name=quantile" json:"quantile,omitempty"` + Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` } -func (m *Quantile) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Quantile.Unmarshal(m, b) -} -func (m *Quantile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Quantile.Marshal(b, m, deterministic) -} -func (m *Quantile) XXX_Merge(src proto.Message) { - xxx_messageInfo_Quantile.Merge(m, src) +func (x *Quantile) Reset() { + *x = Quantile{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Quantile) XXX_Size() int { - return xxx_messageInfo_Quantile.Size(m) + +func (x *Quantile) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Quantile) XXX_DiscardUnknown() { - xxx_messageInfo_Quantile.DiscardUnknown(m) + +func (*Quantile) ProtoMessage() {} + +func (x *Quantile) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Quantile proto.InternalMessageInfo +// Deprecated: Use Quantile.ProtoReflect.Descriptor instead. +func (*Quantile) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{3} +} -func (m *Quantile) GetQuantile() float64 { - if m != nil && m.Quantile != nil { - return *m.Quantile +func (x *Quantile) GetQuantile() float64 { + if x != nil && x.Quantile != nil { + return *x.Quantile } return 0 } -func (m *Quantile) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Quantile) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } type Summary struct { - SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"` - SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"` - Quantile []*Quantile `protobuf:"bytes,3,rep,name=quantile" json:"quantile,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Summary) Reset() { *m = Summary{} } -func (m *Summary) String() string { return proto.CompactTextString(m) } -func (*Summary) ProtoMessage() {} -func (*Summary) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{4} + SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"` + SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"` + Quantile []*Quantile `protobuf:"bytes,3,rep,name=quantile" json:"quantile,omitempty"` } -func (m *Summary) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Summary.Unmarshal(m, b) -} -func (m *Summary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Summary.Marshal(b, m, deterministic) -} -func (m *Summary) XXX_Merge(src proto.Message) { - xxx_messageInfo_Summary.Merge(m, src) +func (x *Summary) Reset() { + *x = Summary{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Summary) XXX_Size() int { - return xxx_messageInfo_Summary.Size(m) + +func (x *Summary) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Summary) XXX_DiscardUnknown() { - xxx_messageInfo_Summary.DiscardUnknown(m) + +func (*Summary) ProtoMessage() {} + +func (x *Summary) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Summary proto.InternalMessageInfo +// Deprecated: Use Summary.ProtoReflect.Descriptor instead. +func (*Summary) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{4} +} -func (m *Summary) GetSampleCount() uint64 { - if m != nil && m.SampleCount != nil { - return *m.SampleCount +func (x *Summary) GetSampleCount() uint64 { + if x != nil && x.SampleCount != nil { + return *x.SampleCount } return 0 } -func (m *Summary) GetSampleSum() float64 { - if m != nil && m.SampleSum != nil { - return *m.SampleSum +func (x *Summary) GetSampleSum() float64 { + if x != nil && x.SampleSum != nil { + return *x.SampleSum } return 0 } -func (m *Summary) GetQuantile() []*Quantile { - if m != nil { - return m.Quantile +func (x *Summary) GetQuantile() []*Quantile { + if x != nil { + return x.Quantile } return nil } type Untyped struct { - Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Untyped) Reset() { *m = Untyped{} } -func (m *Untyped) String() string { return proto.CompactTextString(m) } -func (*Untyped) ProtoMessage() {} -func (*Untyped) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{5} + Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` } -func (m *Untyped) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Untyped.Unmarshal(m, b) -} -func (m *Untyped) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Untyped.Marshal(b, m, deterministic) -} -func (m *Untyped) XXX_Merge(src proto.Message) { - xxx_messageInfo_Untyped.Merge(m, src) +func (x *Untyped) Reset() { + *x = Untyped{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Untyped) XXX_Size() int { - return xxx_messageInfo_Untyped.Size(m) + +func (x *Untyped) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Untyped) XXX_DiscardUnknown() { - xxx_messageInfo_Untyped.DiscardUnknown(m) + +func (*Untyped) ProtoMessage() {} + +func (x *Untyped) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Untyped proto.InternalMessageInfo +// Deprecated: Use Untyped.ProtoReflect.Descriptor instead. +func (*Untyped) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{5} +} -func (m *Untyped) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Untyped) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } type Histogram struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"` - SampleCountFloat *float64 `protobuf:"fixed64,4,opt,name=sample_count_float,json=sampleCountFloat" json:"sample_count_float,omitempty"` + SampleCountFloat *float64 `protobuf:"fixed64,4,opt,name=sample_count_float,json=sampleCountFloat" json:"sample_count_float,omitempty"` // Overrides sample_count if > 0. SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"` // Buckets for the conventional histogram. - Bucket []*Bucket `protobuf:"bytes,3,rep,name=bucket" json:"bucket,omitempty"` + Bucket []*Bucket `protobuf:"bytes,3,rep,name=bucket" json:"bucket,omitempty"` // Ordered in increasing order of upper_bound, +Inf bucket is optional. // schema defines the bucket schema. Currently, valid numbers are -4 <= n <= 8. // They are all for base-2 bucket schemas, where 1 is a bucket boundary in each case, and // then each power of two is divided into 2^n logarithmic buckets. // Or in other words, each bucket boundary is the previous boundary times 2^(2^-n). // In the future, more bucket schemas may be added using numbers < -4 or > 8. Schema *int32 `protobuf:"zigzag32,5,opt,name=schema" json:"schema,omitempty"` - ZeroThreshold *float64 `protobuf:"fixed64,6,opt,name=zero_threshold,json=zeroThreshold" json:"zero_threshold,omitempty"` - ZeroCount *uint64 `protobuf:"varint,7,opt,name=zero_count,json=zeroCount" json:"zero_count,omitempty"` - ZeroCountFloat *float64 `protobuf:"fixed64,8,opt,name=zero_count_float,json=zeroCountFloat" json:"zero_count_float,omitempty"` + ZeroThreshold *float64 `protobuf:"fixed64,6,opt,name=zero_threshold,json=zeroThreshold" json:"zero_threshold,omitempty"` // Breadth of the zero bucket. + ZeroCount *uint64 `protobuf:"varint,7,opt,name=zero_count,json=zeroCount" json:"zero_count,omitempty"` // Count in zero bucket. + ZeroCountFloat *float64 `protobuf:"fixed64,8,opt,name=zero_count_float,json=zeroCountFloat" json:"zero_count_float,omitempty"` // Overrides sb_zero_count if > 0. // Negative buckets for the native histogram. NegativeSpan []*BucketSpan `protobuf:"bytes,9,rep,name=negative_span,json=negativeSpan" json:"negative_span,omitempty"` // Use either "negative_delta" or "negative_count", the former for // regular histograms with integer counts, the latter for float // histograms. - NegativeDelta []int64 `protobuf:"zigzag64,10,rep,name=negative_delta,json=negativeDelta" json:"negative_delta,omitempty"` - NegativeCount []float64 `protobuf:"fixed64,11,rep,name=negative_count,json=negativeCount" json:"negative_count,omitempty"` + NegativeDelta []int64 `protobuf:"zigzag64,10,rep,name=negative_delta,json=negativeDelta" json:"negative_delta,omitempty"` // Count delta of each bucket compared to previous one (or to zero for 1st bucket). + NegativeCount []float64 `protobuf:"fixed64,11,rep,name=negative_count,json=negativeCount" json:"negative_count,omitempty"` // Absolute count of each bucket. // Positive buckets for the native histogram. PositiveSpan []*BucketSpan `protobuf:"bytes,12,rep,name=positive_span,json=positiveSpan" json:"positive_span,omitempty"` // Use either "positive_delta" or "positive_count", the former for // regular histograms with integer counts, the latter for float // histograms. - PositiveDelta []int64 `protobuf:"zigzag64,13,rep,name=positive_delta,json=positiveDelta" json:"positive_delta,omitempty"` - PositiveCount []float64 `protobuf:"fixed64,14,rep,name=positive_count,json=positiveCount" json:"positive_count,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + PositiveDelta []int64 `protobuf:"zigzag64,13,rep,name=positive_delta,json=positiveDelta" json:"positive_delta,omitempty"` // Count delta of each bucket compared to previous one (or to zero for 1st bucket). + PositiveCount []float64 `protobuf:"fixed64,14,rep,name=positive_count,json=positiveCount" json:"positive_count,omitempty"` // Absolute count of each bucket. } -func (m *Histogram) Reset() { *m = Histogram{} } -func (m *Histogram) String() string { return proto.CompactTextString(m) } -func (*Histogram) ProtoMessage() {} -func (*Histogram) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{6} +func (x *Histogram) Reset() { + *x = Histogram{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Histogram) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Histogram.Unmarshal(m, b) +func (x *Histogram) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Histogram) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Histogram.Marshal(b, m, deterministic) -} -func (m *Histogram) XXX_Merge(src proto.Message) { - xxx_messageInfo_Histogram.Merge(m, src) -} -func (m *Histogram) XXX_Size() int { - return xxx_messageInfo_Histogram.Size(m) -} -func (m *Histogram) XXX_DiscardUnknown() { - xxx_messageInfo_Histogram.DiscardUnknown(m) + +func (*Histogram) ProtoMessage() {} + +func (x *Histogram) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Histogram proto.InternalMessageInfo +// Deprecated: Use Histogram.ProtoReflect.Descriptor instead. +func (*Histogram) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{6} +} -func (m *Histogram) GetSampleCount() uint64 { - if m != nil && m.SampleCount != nil { - return *m.SampleCount +func (x *Histogram) GetSampleCount() uint64 { + if x != nil && x.SampleCount != nil { + return *x.SampleCount } return 0 } -func (m *Histogram) GetSampleCountFloat() float64 { - if m != nil && m.SampleCountFloat != nil { - return *m.SampleCountFloat +func (x *Histogram) GetSampleCountFloat() float64 { + if x != nil && x.SampleCountFloat != nil { + return *x.SampleCountFloat } return 0 } -func (m *Histogram) GetSampleSum() float64 { - if m != nil && m.SampleSum != nil { - return *m.SampleSum +func (x *Histogram) GetSampleSum() float64 { + if x != nil && x.SampleSum != nil { + return *x.SampleSum } return 0 } -func (m *Histogram) GetBucket() []*Bucket { - if m != nil { - return m.Bucket +func (x *Histogram) GetBucket() []*Bucket { + if x != nil { + return x.Bucket } return nil } -func (m *Histogram) GetSchema() int32 { - if m != nil && m.Schema != nil { - return *m.Schema +func (x *Histogram) GetSchema() int32 { + if x != nil && x.Schema != nil { + return *x.Schema } return 0 } -func (m *Histogram) GetZeroThreshold() float64 { - if m != nil && m.ZeroThreshold != nil { - return *m.ZeroThreshold +func (x *Histogram) GetZeroThreshold() float64 { + if x != nil && x.ZeroThreshold != nil { + return *x.ZeroThreshold } return 0 } -func (m *Histogram) GetZeroCount() uint64 { - if m != nil && m.ZeroCount != nil { - return *m.ZeroCount +func (x *Histogram) GetZeroCount() uint64 { + if x != nil && x.ZeroCount != nil { + return *x.ZeroCount } return 0 } -func (m *Histogram) GetZeroCountFloat() float64 { - if m != nil && m.ZeroCountFloat != nil { - return *m.ZeroCountFloat +func (x *Histogram) GetZeroCountFloat() float64 { + if x != nil && x.ZeroCountFloat != nil { + return *x.ZeroCountFloat } return 0 } -func (m *Histogram) GetNegativeSpan() []*BucketSpan { - if m != nil { - return m.NegativeSpan +func (x *Histogram) GetNegativeSpan() []*BucketSpan { + if x != nil { + return x.NegativeSpan } return nil } -func (m *Histogram) GetNegativeDelta() []int64 { - if m != nil { - return m.NegativeDelta +func (x *Histogram) GetNegativeDelta() []int64 { + if x != nil { + return x.NegativeDelta } return nil } -func (m *Histogram) GetNegativeCount() []float64 { - if m != nil { - return m.NegativeCount +func (x *Histogram) GetNegativeCount() []float64 { + if x != nil { + return x.NegativeCount } return nil } -func (m *Histogram) GetPositiveSpan() []*BucketSpan { - if m != nil { - return m.PositiveSpan +func (x *Histogram) GetPositiveSpan() []*BucketSpan { + if x != nil { + return x.PositiveSpan } return nil } -func (m *Histogram) GetPositiveDelta() []int64 { - if m != nil { - return m.PositiveDelta +func (x *Histogram) GetPositiveDelta() []int64 { + if x != nil { + return x.PositiveDelta } return nil } -func (m *Histogram) GetPositiveCount() []float64 { - if m != nil { - return m.PositiveCount +func (x *Histogram) GetPositiveCount() []float64 { + if x != nil { + return x.PositiveCount } return nil } @@ -513,64 +598,72 @@ func (m *Histogram) GetPositiveCount() []float64 { // A Bucket of a conventional histogram, each of which is treated as // an individual counter-like time series by Prometheus. type Bucket struct { - CumulativeCount *uint64 `protobuf:"varint,1,opt,name=cumulative_count,json=cumulativeCount" json:"cumulative_count,omitempty"` - CumulativeCountFloat *float64 `protobuf:"fixed64,4,opt,name=cumulative_count_float,json=cumulativeCountFloat" json:"cumulative_count_float,omitempty"` - UpperBound *float64 `protobuf:"fixed64,2,opt,name=upper_bound,json=upperBound" json:"upper_bound,omitempty"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CumulativeCount *uint64 `protobuf:"varint,1,opt,name=cumulative_count,json=cumulativeCount" json:"cumulative_count,omitempty"` // Cumulative in increasing order. + CumulativeCountFloat *float64 `protobuf:"fixed64,4,opt,name=cumulative_count_float,json=cumulativeCountFloat" json:"cumulative_count_float,omitempty"` // Overrides cumulative_count if > 0. + UpperBound *float64 `protobuf:"fixed64,2,opt,name=upper_bound,json=upperBound" json:"upper_bound,omitempty"` // Inclusive. Exemplar *Exemplar `protobuf:"bytes,3,opt,name=exemplar" json:"exemplar,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` } -func (m *Bucket) Reset() { *m = Bucket{} } -func (m *Bucket) String() string { return proto.CompactTextString(m) } -func (*Bucket) ProtoMessage() {} -func (*Bucket) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{7} +func (x *Bucket) Reset() { + *x = Bucket{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Bucket) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Bucket.Unmarshal(m, b) -} -func (m *Bucket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Bucket.Marshal(b, m, deterministic) -} -func (m *Bucket) XXX_Merge(src proto.Message) { - xxx_messageInfo_Bucket.Merge(m, src) -} -func (m *Bucket) XXX_Size() int { - return xxx_messageInfo_Bucket.Size(m) +func (x *Bucket) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Bucket) XXX_DiscardUnknown() { - xxx_messageInfo_Bucket.DiscardUnknown(m) + +func (*Bucket) ProtoMessage() {} + +func (x *Bucket) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Bucket proto.InternalMessageInfo +// Deprecated: Use Bucket.ProtoReflect.Descriptor instead. +func (*Bucket) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{7} +} -func (m *Bucket) GetCumulativeCount() uint64 { - if m != nil && m.CumulativeCount != nil { - return *m.CumulativeCount +func (x *Bucket) GetCumulativeCount() uint64 { + if x != nil && x.CumulativeCount != nil { + return *x.CumulativeCount } return 0 } -func (m *Bucket) GetCumulativeCountFloat() float64 { - if m != nil && m.CumulativeCountFloat != nil { - return *m.CumulativeCountFloat +func (x *Bucket) GetCumulativeCountFloat() float64 { + if x != nil && x.CumulativeCountFloat != nil { + return *x.CumulativeCountFloat } return 0 } -func (m *Bucket) GetUpperBound() float64 { - if m != nil && m.UpperBound != nil { - return *m.UpperBound +func (x *Bucket) GetUpperBound() float64 { + if x != nil && x.UpperBound != nil { + return *x.UpperBound } return 0 } -func (m *Bucket) GetExemplar() *Exemplar { - if m != nil { - return m.Exemplar +func (x *Bucket) GetExemplar() *Exemplar { + if x != nil { + return x.Exemplar } return nil } @@ -582,333 +675,658 @@ func (m *Bucket) GetExemplar() *Exemplar { // structured here (with all the buckets in a single array separate // from the Spans). type BucketSpan struct { - Offset *int32 `protobuf:"zigzag32,1,opt,name=offset" json:"offset,omitempty"` - Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *BucketSpan) Reset() { *m = BucketSpan{} } -func (m *BucketSpan) String() string { return proto.CompactTextString(m) } -func (*BucketSpan) ProtoMessage() {} -func (*BucketSpan) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{8} + Offset *int32 `protobuf:"zigzag32,1,opt,name=offset" json:"offset,omitempty"` // Gap to previous span, or starting point for 1st span (which can be negative). + Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` // Length of consecutive buckets. } -func (m *BucketSpan) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_BucketSpan.Unmarshal(m, b) -} -func (m *BucketSpan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_BucketSpan.Marshal(b, m, deterministic) -} -func (m *BucketSpan) XXX_Merge(src proto.Message) { - xxx_messageInfo_BucketSpan.Merge(m, src) +func (x *BucketSpan) Reset() { + *x = BucketSpan{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *BucketSpan) XXX_Size() int { - return xxx_messageInfo_BucketSpan.Size(m) + +func (x *BucketSpan) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *BucketSpan) XXX_DiscardUnknown() { - xxx_messageInfo_BucketSpan.DiscardUnknown(m) + +func (*BucketSpan) ProtoMessage() {} + +func (x *BucketSpan) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_BucketSpan proto.InternalMessageInfo +// Deprecated: Use BucketSpan.ProtoReflect.Descriptor instead. +func (*BucketSpan) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{8} +} -func (m *BucketSpan) GetOffset() int32 { - if m != nil && m.Offset != nil { - return *m.Offset +func (x *BucketSpan) GetOffset() int32 { + if x != nil && x.Offset != nil { + return *x.Offset } return 0 } -func (m *BucketSpan) GetLength() uint32 { - if m != nil && m.Length != nil { - return *m.Length +func (x *BucketSpan) GetLength() uint32 { + if x != nil && x.Length != nil { + return *x.Length } return 0 } type Exemplar struct { - Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` - Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` - Timestamp *timestamp.Timestamp `protobuf:"bytes,3,opt,name=timestamp" json:"timestamp,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Exemplar) Reset() { *m = Exemplar{} } -func (m *Exemplar) String() string { return proto.CompactTextString(m) } -func (*Exemplar) ProtoMessage() {} -func (*Exemplar) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{9} + Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` + Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=timestamp" json:"timestamp,omitempty"` // OpenMetrics-style. } -func (m *Exemplar) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Exemplar.Unmarshal(m, b) -} -func (m *Exemplar) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Exemplar.Marshal(b, m, deterministic) -} -func (m *Exemplar) XXX_Merge(src proto.Message) { - xxx_messageInfo_Exemplar.Merge(m, src) +func (x *Exemplar) Reset() { + *x = Exemplar{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Exemplar) XXX_Size() int { - return xxx_messageInfo_Exemplar.Size(m) + +func (x *Exemplar) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Exemplar) XXX_DiscardUnknown() { - xxx_messageInfo_Exemplar.DiscardUnknown(m) + +func (*Exemplar) ProtoMessage() {} + +func (x *Exemplar) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Exemplar proto.InternalMessageInfo +// Deprecated: Use Exemplar.ProtoReflect.Descriptor instead. +func (*Exemplar) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{9} +} -func (m *Exemplar) GetLabel() []*LabelPair { - if m != nil { - return m.Label +func (x *Exemplar) GetLabel() []*LabelPair { + if x != nil { + return x.Label } return nil } -func (m *Exemplar) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Exemplar) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } -func (m *Exemplar) GetTimestamp() *timestamp.Timestamp { - if m != nil { - return m.Timestamp +func (x *Exemplar) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp } return nil } type Metric struct { - Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` - Gauge *Gauge `protobuf:"bytes,2,opt,name=gauge" json:"gauge,omitempty"` - Counter *Counter `protobuf:"bytes,3,opt,name=counter" json:"counter,omitempty"` - Summary *Summary `protobuf:"bytes,4,opt,name=summary" json:"summary,omitempty"` - Untyped *Untyped `protobuf:"bytes,5,opt,name=untyped" json:"untyped,omitempty"` - Histogram *Histogram `protobuf:"bytes,7,opt,name=histogram" json:"histogram,omitempty"` - TimestampMs *int64 `protobuf:"varint,6,opt,name=timestamp_ms,json=timestampMs" json:"timestamp_ms,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Metric) Reset() { *m = Metric{} } -func (m *Metric) String() string { return proto.CompactTextString(m) } -func (*Metric) ProtoMessage() {} -func (*Metric) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{10} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` + Gauge *Gauge `protobuf:"bytes,2,opt,name=gauge" json:"gauge,omitempty"` + Counter *Counter `protobuf:"bytes,3,opt,name=counter" json:"counter,omitempty"` + Summary *Summary `protobuf:"bytes,4,opt,name=summary" json:"summary,omitempty"` + Untyped *Untyped `protobuf:"bytes,5,opt,name=untyped" json:"untyped,omitempty"` + Histogram *Histogram `protobuf:"bytes,7,opt,name=histogram" json:"histogram,omitempty"` + TimestampMs *int64 `protobuf:"varint,6,opt,name=timestamp_ms,json=timestampMs" json:"timestamp_ms,omitempty"` +} + +func (x *Metric) Reset() { + *x = Metric{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Metric) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Metric.Unmarshal(m, b) +func (x *Metric) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Metric) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Metric.Marshal(b, m, deterministic) -} -func (m *Metric) XXX_Merge(src proto.Message) { - xxx_messageInfo_Metric.Merge(m, src) -} -func (m *Metric) XXX_Size() int { - return xxx_messageInfo_Metric.Size(m) -} -func (m *Metric) XXX_DiscardUnknown() { - xxx_messageInfo_Metric.DiscardUnknown(m) + +func (*Metric) ProtoMessage() {} + +func (x *Metric) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Metric proto.InternalMessageInfo +// Deprecated: Use Metric.ProtoReflect.Descriptor instead. +func (*Metric) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{10} +} -func (m *Metric) GetLabel() []*LabelPair { - if m != nil { - return m.Label +func (x *Metric) GetLabel() []*LabelPair { + if x != nil { + return x.Label } return nil } -func (m *Metric) GetGauge() *Gauge { - if m != nil { - return m.Gauge +func (x *Metric) GetGauge() *Gauge { + if x != nil { + return x.Gauge } return nil } -func (m *Metric) GetCounter() *Counter { - if m != nil { - return m.Counter +func (x *Metric) GetCounter() *Counter { + if x != nil { + return x.Counter } return nil } -func (m *Metric) GetSummary() *Summary { - if m != nil { - return m.Summary +func (x *Metric) GetSummary() *Summary { + if x != nil { + return x.Summary } return nil } -func (m *Metric) GetUntyped() *Untyped { - if m != nil { - return m.Untyped +func (x *Metric) GetUntyped() *Untyped { + if x != nil { + return x.Untyped } return nil } -func (m *Metric) GetHistogram() *Histogram { - if m != nil { - return m.Histogram +func (x *Metric) GetHistogram() *Histogram { + if x != nil { + return x.Histogram } return nil } -func (m *Metric) GetTimestampMs() int64 { - if m != nil && m.TimestampMs != nil { - return *m.TimestampMs +func (x *Metric) GetTimestampMs() int64 { + if x != nil && x.TimestampMs != nil { + return *x.TimestampMs } return 0 } type MetricFamily struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Help *string `protobuf:"bytes,2,opt,name=help" json:"help,omitempty"` - Type *MetricType `protobuf:"varint,3,opt,name=type,enum=io.prometheus.client.MetricType" json:"type,omitempty"` - Metric []*Metric `protobuf:"bytes,4,rep,name=metric" json:"metric,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *MetricFamily) Reset() { *m = MetricFamily{} } -func (m *MetricFamily) String() string { return proto.CompactTextString(m) } -func (*MetricFamily) ProtoMessage() {} -func (*MetricFamily) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{11} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Help *string `protobuf:"bytes,2,opt,name=help" json:"help,omitempty"` + Type *MetricType `protobuf:"varint,3,opt,name=type,enum=io.prometheus.client.MetricType" json:"type,omitempty"` + Metric []*Metric `protobuf:"bytes,4,rep,name=metric" json:"metric,omitempty"` +} + +func (x *MetricFamily) Reset() { + *x = MetricFamily{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *MetricFamily) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_MetricFamily.Unmarshal(m, b) -} -func (m *MetricFamily) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_MetricFamily.Marshal(b, m, deterministic) -} -func (m *MetricFamily) XXX_Merge(src proto.Message) { - xxx_messageInfo_MetricFamily.Merge(m, src) -} -func (m *MetricFamily) XXX_Size() int { - return xxx_messageInfo_MetricFamily.Size(m) +func (x *MetricFamily) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *MetricFamily) XXX_DiscardUnknown() { - xxx_messageInfo_MetricFamily.DiscardUnknown(m) + +func (*MetricFamily) ProtoMessage() {} + +func (x *MetricFamily) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_MetricFamily proto.InternalMessageInfo +// Deprecated: Use MetricFamily.ProtoReflect.Descriptor instead. +func (*MetricFamily) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{11} +} -func (m *MetricFamily) GetName() string { - if m != nil && m.Name != nil { - return *m.Name +func (x *MetricFamily) GetName() string { + if x != nil && x.Name != nil { + return *x.Name } return "" } -func (m *MetricFamily) GetHelp() string { - if m != nil && m.Help != nil { - return *m.Help +func (x *MetricFamily) GetHelp() string { + if x != nil && x.Help != nil { + return *x.Help } return "" } -func (m *MetricFamily) GetType() MetricType { - if m != nil && m.Type != nil { - return *m.Type +func (x *MetricFamily) GetType() MetricType { + if x != nil && x.Type != nil { + return *x.Type } return MetricType_COUNTER } -func (m *MetricFamily) GetMetric() []*Metric { - if m != nil { - return m.Metric +func (x *MetricFamily) GetMetric() []*Metric { + if x != nil { + return x.Metric } return nil } -func init() { - proto.RegisterEnum("io.prometheus.client.MetricType", MetricType_name, MetricType_value) - proto.RegisterType((*LabelPair)(nil), "io.prometheus.client.LabelPair") - proto.RegisterType((*Gauge)(nil), "io.prometheus.client.Gauge") - proto.RegisterType((*Counter)(nil), "io.prometheus.client.Counter") - proto.RegisterType((*Quantile)(nil), "io.prometheus.client.Quantile") - proto.RegisterType((*Summary)(nil), "io.prometheus.client.Summary") - proto.RegisterType((*Untyped)(nil), "io.prometheus.client.Untyped") - proto.RegisterType((*Histogram)(nil), "io.prometheus.client.Histogram") - proto.RegisterType((*Bucket)(nil), "io.prometheus.client.Bucket") - proto.RegisterType((*BucketSpan)(nil), "io.prometheus.client.BucketSpan") - proto.RegisterType((*Exemplar)(nil), "io.prometheus.client.Exemplar") - proto.RegisterType((*Metric)(nil), "io.prometheus.client.Metric") - proto.RegisterType((*MetricFamily)(nil), "io.prometheus.client.MetricFamily") -} - -func init() { - proto.RegisterFile("io/prometheus/client/metrics.proto", fileDescriptor_d1e5ddb18987a258) -} - -var fileDescriptor_d1e5ddb18987a258 = []byte{ - // 896 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xdd, 0x8e, 0xdb, 0x44, - 0x18, 0xc5, 0x9b, 0x5f, 0x7f, 0xd9, 0x6c, 0xd3, 0x61, 0x55, 0x59, 0x0b, 0xcb, 0x06, 0x4b, 0x48, - 0x0b, 0x42, 0x8e, 0x40, 0x5b, 0x81, 0x0a, 0x5c, 0xec, 0xb6, 0xe9, 0x16, 0x89, 0xb4, 0x65, 0x92, - 0x5c, 0x14, 0x2e, 0xac, 0x49, 0x32, 0xeb, 0x58, 0x78, 0x3c, 0xc6, 0x1e, 0x57, 0x2c, 0x2f, 0xc0, - 0x35, 0xaf, 0xc0, 0xc3, 0xf0, 0x22, 0x3c, 0x08, 0x68, 0xfe, 0xec, 0xdd, 0xe2, 0x94, 0xd2, 0x3b, - 0x7f, 0x67, 0xce, 0xf7, 0xcd, 0x39, 0xe3, 0xc9, 0x71, 0xc0, 0x8f, 0xf9, 0x24, 0xcb, 0x39, 0xa3, - 0x62, 0x4b, 0xcb, 0x62, 0xb2, 0x4e, 0x62, 0x9a, 0x8a, 0x09, 0xa3, 0x22, 0x8f, 0xd7, 0x45, 0x90, - 0xe5, 0x5c, 0x70, 0x74, 0x18, 0xf3, 0xa0, 0xe6, 0x04, 0x9a, 0x73, 0x74, 0x12, 0x71, 0x1e, 0x25, - 0x74, 0xa2, 0x38, 0xab, 0xf2, 0x6a, 0x22, 0x62, 0x46, 0x0b, 0x41, 0x58, 0xa6, 0xdb, 0xfc, 0xfb, - 0xe0, 0x7e, 0x47, 0x56, 0x34, 0x79, 0x4e, 0xe2, 0x1c, 0x21, 0x68, 0xa7, 0x84, 0x51, 0xcf, 0x19, - 0x3b, 0xa7, 0x2e, 0x56, 0xcf, 0xe8, 0x10, 0x3a, 0x2f, 0x49, 0x52, 0x52, 0x6f, 0x4f, 0x81, 0xba, - 0xf0, 0x8f, 0xa1, 0x73, 0x49, 0xca, 0xe8, 0xc6, 0xb2, 0xec, 0x71, 0xec, 0xf2, 0x8f, 0xd0, 0x7b, - 0xc8, 0xcb, 0x54, 0xd0, 0xbc, 0x99, 0x80, 0x1e, 0x40, 0x9f, 0xfe, 0x42, 0x59, 0x96, 0x90, 0x5c, - 0x0d, 0x1e, 0x7c, 0xfe, 0x41, 0xd0, 0x64, 0x20, 0x98, 0x1a, 0x16, 0xae, 0xf8, 0xfe, 0xd7, 0xd0, - 0xff, 0xbe, 0x24, 0xa9, 0x88, 0x13, 0x8a, 0x8e, 0xa0, 0xff, 0xb3, 0x79, 0x36, 0x1b, 0x54, 0xf5, - 0x6d, 0xe5, 0x95, 0xb4, 0xdf, 0x1c, 0xe8, 0xcd, 0x4b, 0xc6, 0x48, 0x7e, 0x8d, 0x3e, 0x84, 0xfd, - 0x82, 0xb0, 0x2c, 0xa1, 0xe1, 0x5a, 0xaa, 0x55, 0x13, 0xda, 0x78, 0xa0, 0x31, 0x65, 0x00, 0x1d, - 0x03, 0x18, 0x4a, 0x51, 0x32, 0x33, 0xc9, 0xd5, 0xc8, 0xbc, 0x64, 0xd2, 0x47, 0xb5, 0x7f, 0x6b, - 0xdc, 0xda, 0xed, 0xc3, 0x2a, 0xae, 0xf5, 0xf9, 0x27, 0xd0, 0x5b, 0xa6, 0xe2, 0x3a, 0xa3, 0x9b, - 0x1d, 0xa7, 0xf8, 0x57, 0x1b, 0xdc, 0x27, 0x71, 0x21, 0x78, 0x94, 0x13, 0xf6, 0x26, 0x62, 0x3f, - 0x05, 0x74, 0x93, 0x12, 0x5e, 0x25, 0x9c, 0x08, 0xaf, 0xad, 0x66, 0x8e, 0x6e, 0x10, 0x1f, 0x4b, - 0xfc, 0xbf, 0xac, 0x9d, 0x41, 0x77, 0x55, 0xae, 0x7f, 0xa2, 0xc2, 0x18, 0x7b, 0xbf, 0xd9, 0xd8, - 0x85, 0xe2, 0x60, 0xc3, 0x45, 0xf7, 0xa0, 0x5b, 0xac, 0xb7, 0x94, 0x11, 0xaf, 0x33, 0x76, 0x4e, - 0xef, 0x62, 0x53, 0xa1, 0x8f, 0xe0, 0xe0, 0x57, 0x9a, 0xf3, 0x50, 0x6c, 0x73, 0x5a, 0x6c, 0x79, - 0xb2, 0xf1, 0xba, 0x6a, 0xc3, 0xa1, 0x44, 0x17, 0x16, 0x94, 0x9a, 0x14, 0x4d, 0x5b, 0xec, 0x29, - 0x8b, 0xae, 0x44, 0xb4, 0xc1, 0x53, 0x18, 0xd5, 0xcb, 0xc6, 0x5e, 0x5f, 0xcd, 0x39, 0xa8, 0x48, - 0xda, 0xdc, 0x14, 0x86, 0x29, 0x8d, 0x88, 0x88, 0x5f, 0xd2, 0xb0, 0xc8, 0x48, 0xea, 0xb9, 0xca, - 0xc4, 0xf8, 0x75, 0x26, 0xe6, 0x19, 0x49, 0xf1, 0xbe, 0x6d, 0x93, 0x95, 0x94, 0x5d, 0x8d, 0xd9, - 0xd0, 0x44, 0x10, 0x0f, 0xc6, 0xad, 0x53, 0x84, 0xab, 0xe1, 0x8f, 0x24, 0x78, 0x8b, 0xa6, 0xa5, - 0x0f, 0xc6, 0x2d, 0xe9, 0xce, 0xa2, 0x5a, 0xfe, 0x14, 0x86, 0x19, 0x2f, 0xe2, 0x5a, 0xd4, 0xfe, - 0x9b, 0x8a, 0xb2, 0x6d, 0x56, 0x54, 0x35, 0x46, 0x8b, 0x1a, 0x6a, 0x51, 0x16, 0xad, 0x44, 0x55, - 0x34, 0x2d, 0xea, 0x40, 0x8b, 0xb2, 0xa8, 0x12, 0xe5, 0xff, 0xe9, 0x40, 0x57, 0x6f, 0x85, 0x3e, - 0x86, 0xd1, 0xba, 0x64, 0x65, 0x72, 0xd3, 0x88, 0xbe, 0x66, 0x77, 0x6a, 0x5c, 0x5b, 0x39, 0x83, - 0x7b, 0xaf, 0x52, 0x6f, 0x5d, 0xb7, 0xc3, 0x57, 0x1a, 0xf4, 0x5b, 0x39, 0x81, 0x41, 0x99, 0x65, - 0x34, 0x0f, 0x57, 0xbc, 0x4c, 0x37, 0xe6, 0xce, 0x81, 0x82, 0x2e, 0x24, 0x72, 0x2b, 0x17, 0x5a, - 0xff, 0x3b, 0x17, 0xa0, 0x3e, 0x32, 0x79, 0x11, 0xf9, 0xd5, 0x55, 0x41, 0xb5, 0x83, 0xbb, 0xd8, - 0x54, 0x12, 0x4f, 0x68, 0x1a, 0x89, 0xad, 0xda, 0x7d, 0x88, 0x4d, 0xe5, 0xff, 0xee, 0x40, 0xdf, - 0x0e, 0x45, 0xf7, 0xa1, 0x93, 0xc8, 0x54, 0xf4, 0x1c, 0xf5, 0x82, 0x4e, 0x9a, 0x35, 0x54, 0xc1, - 0x89, 0x35, 0xbb, 0x39, 0x71, 0xd0, 0x97, 0xe0, 0x56, 0xa9, 0x6b, 0x4c, 0x1d, 0x05, 0x3a, 0x97, - 0x03, 0x9b, 0xcb, 0xc1, 0xc2, 0x32, 0x70, 0x4d, 0xf6, 0xff, 0xde, 0x83, 0xee, 0x4c, 0xa5, 0xfc, - 0xdb, 0x2a, 0xfa, 0x0c, 0x3a, 0x91, 0xcc, 0x69, 0x13, 0xb2, 0xef, 0x35, 0xb7, 0xa9, 0x28, 0xc7, - 0x9a, 0x89, 0xbe, 0x80, 0xde, 0x5a, 0x67, 0xb7, 0x11, 0x7b, 0xdc, 0xdc, 0x64, 0x02, 0x1e, 0x5b, - 0xb6, 0x6c, 0x2c, 0x74, 0xb0, 0xaa, 0x3b, 0xb0, 0xb3, 0xd1, 0xa4, 0x2f, 0xb6, 0x6c, 0xd9, 0x58, - 0xea, 0x20, 0x54, 0xa1, 0xb1, 0xb3, 0xd1, 0xa4, 0x25, 0xb6, 0x6c, 0xf4, 0x0d, 0xb8, 0x5b, 0x9b, - 0x8f, 0x2a, 0x2c, 0x76, 0x1e, 0x4c, 0x15, 0xa3, 0xb8, 0xee, 0x90, 0x89, 0x5a, 0x9d, 0x75, 0xc8, - 0x0a, 0x95, 0x48, 0x2d, 0x3c, 0xa8, 0xb0, 0x59, 0xe1, 0xff, 0xe1, 0xc0, 0xbe, 0x7e, 0x03, 0x8f, - 0x09, 0x8b, 0x93, 0xeb, 0xc6, 0x4f, 0x24, 0x82, 0xf6, 0x96, 0x26, 0x99, 0xf9, 0x42, 0xaa, 0x67, - 0x74, 0x06, 0x6d, 0xa9, 0x51, 0x1d, 0xe1, 0xc1, 0xae, 0x5f, 0xb8, 0x9e, 0xbc, 0xb8, 0xce, 0x28, - 0x56, 0x6c, 0x99, 0xb9, 0xfa, 0xab, 0xee, 0xb5, 0x5f, 0x97, 0xb9, 0xba, 0x0f, 0x1b, 0xee, 0x27, - 0x2b, 0x80, 0x7a, 0x12, 0x1a, 0x40, 0xef, 0xe1, 0xb3, 0xe5, 0xd3, 0xc5, 0x14, 0x8f, 0xde, 0x41, - 0x2e, 0x74, 0x2e, 0xcf, 0x97, 0x97, 0xd3, 0x91, 0x23, 0xf1, 0xf9, 0x72, 0x36, 0x3b, 0xc7, 0x2f, - 0x46, 0x7b, 0xb2, 0x58, 0x3e, 0x5d, 0xbc, 0x78, 0x3e, 0x7d, 0x34, 0x6a, 0xa1, 0x21, 0xb8, 0x4f, - 0xbe, 0x9d, 0x2f, 0x9e, 0x5d, 0xe2, 0xf3, 0xd9, 0xa8, 0x8d, 0xde, 0x85, 0x3b, 0xaa, 0x27, 0xac, - 0xc1, 0xce, 0x05, 0x86, 0xc6, 0x3f, 0x18, 0x3f, 0x3c, 0x88, 0x62, 0xb1, 0x2d, 0x57, 0xc1, 0x9a, - 0xb3, 0x7f, 0xff, 0x45, 0x09, 0x19, 0xdf, 0xd0, 0x64, 0x12, 0xf1, 0xaf, 0x62, 0x1e, 0xd6, 0xab, - 0xa1, 0x5e, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0x16, 0x77, 0x81, 0x98, 0xd7, 0x08, 0x00, 0x00, +var File_io_prometheus_client_metrics_proto protoreflect.FileDescriptor + +var file_io_prometheus_client_metrics_proto_rawDesc = []byte{ + 0x0a, 0x22, 0x69, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2f, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, + 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x35, 0x0a, 0x09, 0x4c, + 0x61, 0x62, 0x65, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x22, 0x1d, 0x0a, 0x05, 0x47, 0x61, 0x75, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x22, 0x5b, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x12, 0x3a, 0x0a, 0x08, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, + 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x78, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x72, 0x52, 0x08, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x22, 0x3c, + 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x87, 0x01, 0x0a, + 0x07, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, + 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, + 0x09, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x53, 0x75, 0x6d, 0x12, 0x3a, 0x0a, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, + 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x2e, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x52, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x22, 0x1f, 0x0a, 0x07, 0x55, 0x6e, 0x74, 0x79, 0x70, 0x65, + 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xe3, 0x04, 0x0a, 0x09, 0x48, 0x69, 0x73, 0x74, + 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x73, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x01, 0x52, 0x10, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x5f, 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x53, 0x75, 0x6d, 0x12, 0x34, 0x0a, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, + 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x42, 0x75, 0x63, + 0x6b, 0x65, 0x74, 0x52, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x11, 0x52, 0x06, 0x73, 0x63, 0x68, + 0x65, 0x6d, 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x7a, 0x65, 0x72, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, + 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0d, 0x7a, 0x65, 0x72, + 0x6f, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x7a, 0x65, + 0x72, 0x6f, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, + 0x7a, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x7a, 0x65, 0x72, + 0x6f, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x0e, 0x7a, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x6c, + 0x6f, 0x61, 0x74, 0x12, 0x45, 0x0a, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, + 0x73, 0x70, 0x61, 0x6e, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x6f, 0x2e, + 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x52, 0x0c, 0x6e, 0x65, + 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6e, 0x65, + 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x74, 0x61, 0x18, 0x0a, 0x20, 0x03, + 0x28, 0x12, 0x52, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x44, 0x65, 0x6c, 0x74, + 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x01, 0x52, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, + 0x69, 0x76, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x45, 0x0a, 0x0d, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x76, 0x65, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x20, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x70, 0x61, + 0x6e, 0x52, 0x0c, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x12, + 0x25, 0x0a, 0x0e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x74, + 0x61, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x12, 0x52, 0x0d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, + 0x65, 0x44, 0x65, 0x6c, 0x74, 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x01, 0x52, 0x0d, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xc6, 0x01, + 0x0a, 0x06, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x75, 0x6d, 0x75, + 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0f, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x12, 0x34, 0x0a, 0x16, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, + 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x14, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x70, 0x70, + 0x65, 0x72, 0x5f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0a, + 0x75, 0x70, 0x70, 0x65, 0x72, 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x3a, 0x0a, 0x08, 0x65, 0x78, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, + 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x52, 0x08, 0x65, 0x78, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x22, 0x3c, 0x0a, 0x0a, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, + 0x53, 0x70, 0x61, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x11, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, + 0x6e, 0x67, 0x74, 0x68, 0x22, 0x91, 0x01, 0x0a, 0x08, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x72, 0x12, 0x35, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, + 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x50, 0x61, 0x69, + 0x72, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x38, + 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xff, 0x02, 0x0a, 0x06, 0x4d, 0x65, 0x74, + 0x72, 0x69, 0x63, 0x12, 0x35, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, + 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x50, + 0x61, 0x69, 0x72, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x31, 0x0a, 0x05, 0x67, 0x61, + 0x75, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x69, 0x6f, 0x2e, 0x70, + 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x2e, 0x47, 0x61, 0x75, 0x67, 0x65, 0x52, 0x05, 0x67, 0x61, 0x75, 0x67, 0x65, 0x12, 0x37, 0x0a, + 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, + 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x07, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, + 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x53, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, + 0x37, 0x0a, 0x07, 0x75, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1d, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, + 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x55, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x64, 0x52, + 0x07, 0x75, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x64, 0x12, 0x3d, 0x0a, 0x09, 0x68, 0x69, 0x73, 0x74, + 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6f, + 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x52, 0x09, 0x68, 0x69, + 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x6d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x4d, 0x73, 0x22, 0xa2, 0x01, 0x0a, 0x0c, 0x4d, + 0x65, 0x74, 0x72, 0x69, 0x63, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x68, 0x65, 0x6c, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, + 0x65, 0x6c, 0x70, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x20, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, + 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x54, + 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x34, 0x0a, 0x06, 0x6d, 0x65, 0x74, + 0x72, 0x69, 0x63, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x69, 0x6f, 0x2e, 0x70, + 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x2a, + 0x62, 0x0a, 0x0a, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, + 0x07, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x47, 0x41, + 0x55, 0x47, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x4d, 0x4d, 0x41, 0x52, 0x59, + 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x54, 0x59, 0x50, 0x45, 0x44, 0x10, 0x03, 0x12, + 0x0d, 0x0a, 0x09, 0x48, 0x49, 0x53, 0x54, 0x4f, 0x47, 0x52, 0x41, 0x4d, 0x10, 0x04, 0x12, 0x13, + 0x0a, 0x0f, 0x47, 0x41, 0x55, 0x47, 0x45, 0x5f, 0x48, 0x49, 0x53, 0x54, 0x4f, 0x47, 0x52, 0x41, + 0x4d, 0x10, 0x05, 0x42, 0x52, 0x0a, 0x14, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, + 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5a, 0x3a, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, + 0x75, 0x73, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, + 0x67, 0x6f, 0x3b, 0x69, 0x6f, 0x5f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, + 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, +} + +var ( + file_io_prometheus_client_metrics_proto_rawDescOnce sync.Once + file_io_prometheus_client_metrics_proto_rawDescData = file_io_prometheus_client_metrics_proto_rawDesc +) + +func file_io_prometheus_client_metrics_proto_rawDescGZIP() []byte { + file_io_prometheus_client_metrics_proto_rawDescOnce.Do(func() { + file_io_prometheus_client_metrics_proto_rawDescData = protoimpl.X.CompressGZIP(file_io_prometheus_client_metrics_proto_rawDescData) + }) + return file_io_prometheus_client_metrics_proto_rawDescData +} + +var file_io_prometheus_client_metrics_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_io_prometheus_client_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_io_prometheus_client_metrics_proto_goTypes = []interface{}{ + (MetricType)(0), // 0: io.prometheus.client.MetricType + (*LabelPair)(nil), // 1: io.prometheus.client.LabelPair + (*Gauge)(nil), // 2: io.prometheus.client.Gauge + (*Counter)(nil), // 3: io.prometheus.client.Counter + (*Quantile)(nil), // 4: io.prometheus.client.Quantile + (*Summary)(nil), // 5: io.prometheus.client.Summary + (*Untyped)(nil), // 6: io.prometheus.client.Untyped + (*Histogram)(nil), // 7: io.prometheus.client.Histogram + (*Bucket)(nil), // 8: io.prometheus.client.Bucket + (*BucketSpan)(nil), // 9: io.prometheus.client.BucketSpan + (*Exemplar)(nil), // 10: io.prometheus.client.Exemplar + (*Metric)(nil), // 11: io.prometheus.client.Metric + (*MetricFamily)(nil), // 12: io.prometheus.client.MetricFamily + (*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp +} +var file_io_prometheus_client_metrics_proto_depIdxs = []int32{ + 10, // 0: io.prometheus.client.Counter.exemplar:type_name -> io.prometheus.client.Exemplar + 4, // 1: io.prometheus.client.Summary.quantile:type_name -> io.prometheus.client.Quantile + 8, // 2: io.prometheus.client.Histogram.bucket:type_name -> io.prometheus.client.Bucket + 9, // 3: io.prometheus.client.Histogram.negative_span:type_name -> io.prometheus.client.BucketSpan + 9, // 4: io.prometheus.client.Histogram.positive_span:type_name -> io.prometheus.client.BucketSpan + 10, // 5: io.prometheus.client.Bucket.exemplar:type_name -> io.prometheus.client.Exemplar + 1, // 6: io.prometheus.client.Exemplar.label:type_name -> io.prometheus.client.LabelPair + 13, // 7: io.prometheus.client.Exemplar.timestamp:type_name -> google.protobuf.Timestamp + 1, // 8: io.prometheus.client.Metric.label:type_name -> io.prometheus.client.LabelPair + 2, // 9: io.prometheus.client.Metric.gauge:type_name -> io.prometheus.client.Gauge + 3, // 10: io.prometheus.client.Metric.counter:type_name -> io.prometheus.client.Counter + 5, // 11: io.prometheus.client.Metric.summary:type_name -> io.prometheus.client.Summary + 6, // 12: io.prometheus.client.Metric.untyped:type_name -> io.prometheus.client.Untyped + 7, // 13: io.prometheus.client.Metric.histogram:type_name -> io.prometheus.client.Histogram + 0, // 14: io.prometheus.client.MetricFamily.type:type_name -> io.prometheus.client.MetricType + 11, // 15: io.prometheus.client.MetricFamily.metric:type_name -> io.prometheus.client.Metric + 16, // [16:16] is the sub-list for method output_type + 16, // [16:16] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name +} + +func init() { file_io_prometheus_client_metrics_proto_init() } +func file_io_prometheus_client_metrics_proto_init() { + if File_io_prometheus_client_metrics_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_io_prometheus_client_metrics_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LabelPair); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Gauge); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Counter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Quantile); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Summary); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Untyped); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Histogram); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Bucket); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BucketSpan); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Exemplar); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Metric); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MetricFamily); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_io_prometheus_client_metrics_proto_rawDesc, + NumEnums: 1, + NumMessages: 12, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_io_prometheus_client_metrics_proto_goTypes, + DependencyIndexes: file_io_prometheus_client_metrics_proto_depIdxs, + EnumInfos: file_io_prometheus_client_metrics_proto_enumTypes, + MessageInfos: file_io_prometheus_client_metrics_proto_msgTypes, + }.Build() + File_io_prometheus_client_metrics_proto = out.File + file_io_prometheus_client_metrics_proto_rawDesc = nil + file_io_prometheus_client_metrics_proto_goTypes = nil + file_io_prometheus_client_metrics_proto_depIdxs = nil } diff --git a/test/performance/vendor/github.com/prometheus/common/expfmt/decode.go b/test/performance/vendor/github.com/prometheus/common/expfmt/decode.go index 7657f841d..906397815 100644 --- a/test/performance/vendor/github.com/prometheus/common/expfmt/decode.go +++ b/test/performance/vendor/github.com/prometheus/common/expfmt/decode.go @@ -115,32 +115,31 @@ func (d *protoDecoder) Decode(v *dto.MetricFamily) error { // textDecoder implements the Decoder interface for the text protocol. type textDecoder struct { r io.Reader - p TextParser - fams []*dto.MetricFamily + fams map[string]*dto.MetricFamily + err error } // Decode implements the Decoder interface. func (d *textDecoder) Decode(v *dto.MetricFamily) error { - // TODO(fabxc): Wrap this as a line reader to make streaming safer. - if len(d.fams) == 0 { - // No cached metric families, read everything and parse metrics. - fams, err := d.p.TextToMetricFamilies(d.r) - if err != nil { - return err - } - if len(fams) == 0 { - return io.EOF - } - d.fams = make([]*dto.MetricFamily, 0, len(fams)) - for _, f := range fams { - d.fams = append(d.fams, f) + if d.err == nil { + // Read all metrics in one shot. + var p TextParser + d.fams, d.err = p.TextToMetricFamilies(d.r) + // If we don't get an error, store io.EOF for the end. + if d.err == nil { + d.err = io.EOF } } - - *v = *d.fams[0] - d.fams = d.fams[1:] - - return nil + // Pick off one MetricFamily per Decode until there's nothing left. + for key, fam := range d.fams { + v.Name = fam.Name + v.Help = fam.Help + v.Type = fam.Type + v.Metric = fam.Metric + delete(d.fams, key) + return nil + } + return d.err } // SampleDecoder wraps a Decoder to extract samples from the metric families diff --git a/test/performance/vendor/github.com/prometheus/common/expfmt/encode.go b/test/performance/vendor/github.com/prometheus/common/expfmt/encode.go index 64dc0eb40..7f611ffaa 100644 --- a/test/performance/vendor/github.com/prometheus/common/expfmt/encode.go +++ b/test/performance/vendor/github.com/prometheus/common/expfmt/encode.go @@ -18,9 +18,9 @@ import ( "io" "net/http" - "github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. "github.com/matttproud/golang_protobuf_extensions/pbutil" "github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg" + "google.golang.org/protobuf/encoding/prototext" dto "github.com/prometheus/client_model/go" ) @@ -99,8 +99,11 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format { if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") { return FmtText } - if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion || ver == "") { - return FmtOpenMetrics + if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion_0_0_1 || ver == OpenMetricsVersion_1_0_0 || ver == "") { + if ver == OpenMetricsVersion_1_0_0 { + return FmtOpenMetrics_1_0_0 + } + return FmtOpenMetrics_0_0_1 } } return FmtText @@ -133,7 +136,7 @@ func NewEncoder(w io.Writer, format Format) Encoder { case FmtProtoText: return encoderCloser{ encode: func(v *dto.MetricFamily) error { - _, err := fmt.Fprintln(w, proto.MarshalTextString(v)) + _, err := fmt.Fprintln(w, prototext.Format(v)) return err }, close: func() error { return nil }, @@ -146,7 +149,7 @@ func NewEncoder(w io.Writer, format Format) Encoder { }, close: func() error { return nil }, } - case FmtOpenMetrics: + case FmtOpenMetrics_0_0_1, FmtOpenMetrics_1_0_0: return encoderCloser{ encode: func(v *dto.MetricFamily) error { _, err := MetricFamilyToOpenMetrics(w, v) diff --git a/test/performance/vendor/github.com/prometheus/common/expfmt/expfmt.go b/test/performance/vendor/github.com/prometheus/common/expfmt/expfmt.go index 0f176fa64..c4cb20f0d 100644 --- a/test/performance/vendor/github.com/prometheus/common/expfmt/expfmt.go +++ b/test/performance/vendor/github.com/prometheus/common/expfmt/expfmt.go @@ -19,20 +19,22 @@ type Format string // Constants to assemble the Content-Type values for the different wire protocols. const ( - TextVersion = "0.0.4" - ProtoType = `application/vnd.google.protobuf` - ProtoProtocol = `io.prometheus.client.MetricFamily` - ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";" - OpenMetricsType = `application/openmetrics-text` - OpenMetricsVersion = "0.0.1" + TextVersion = "0.0.4" + ProtoType = `application/vnd.google.protobuf` + ProtoProtocol = `io.prometheus.client.MetricFamily` + ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";" + OpenMetricsType = `application/openmetrics-text` + OpenMetricsVersion_0_0_1 = "0.0.1" + OpenMetricsVersion_1_0_0 = "1.0.0" // The Content-Type values for the different wire protocols. - FmtUnknown Format = `` - FmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8` - FmtProtoDelim Format = ProtoFmt + ` encoding=delimited` - FmtProtoText Format = ProtoFmt + ` encoding=text` - FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text` - FmtOpenMetrics Format = OpenMetricsType + `; version=` + OpenMetricsVersion + `; charset=utf-8` + FmtUnknown Format = `` + FmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8` + FmtProtoDelim Format = ProtoFmt + ` encoding=delimited` + FmtProtoText Format = ProtoFmt + ` encoding=text` + FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text` + FmtOpenMetrics_1_0_0 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_1_0_0 + `; charset=utf-8` + FmtOpenMetrics_0_0_1 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_0_0_1 + `; charset=utf-8` ) const ( diff --git a/test/performance/vendor/github.com/prometheus/common/expfmt/fuzz.go b/test/performance/vendor/github.com/prometheus/common/expfmt/fuzz.go index f819e4f8b..dfac962a4 100644 --- a/test/performance/vendor/github.com/prometheus/common/expfmt/fuzz.go +++ b/test/performance/vendor/github.com/prometheus/common/expfmt/fuzz.go @@ -21,8 +21,8 @@ import "bytes" // Fuzz text metric parser with with github.com/dvyukov/go-fuzz: // -// go-fuzz-build github.com/prometheus/common/expfmt -// go-fuzz -bin expfmt-fuzz.zip -workdir fuzz +// go-fuzz-build github.com/prometheus/common/expfmt +// go-fuzz -bin expfmt-fuzz.zip -workdir fuzz // // Further input samples should go in the folder fuzz/corpus. func Fuzz(in []byte) int { diff --git a/test/performance/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go b/test/performance/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go index 9d94ae9ef..21cdddcf0 100644 --- a/test/performance/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go +++ b/test/performance/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go @@ -46,20 +46,20 @@ import ( // missing features and peculiarities to avoid complications when switching from // Prometheus to OpenMetrics or vice versa: // -// - Counters are expected to have the `_total` suffix in their metric name. In -// the output, the suffix will be truncated from the `# TYPE` and `# HELP` -// line. A counter with a missing `_total` suffix is not an error. However, -// its type will be set to `unknown` in that case to avoid invalid OpenMetrics -// output. +// - Counters are expected to have the `_total` suffix in their metric name. In +// the output, the suffix will be truncated from the `# TYPE` and `# HELP` +// line. A counter with a missing `_total` suffix is not an error. However, +// its type will be set to `unknown` in that case to avoid invalid OpenMetrics +// output. // -// - No support for the following (optional) features: `# UNIT` line, `_created` -// line, info type, stateset type, gaugehistogram type. +// - No support for the following (optional) features: `# UNIT` line, `_created` +// line, info type, stateset type, gaugehistogram type. // -// - The size of exemplar labels is not checked (i.e. it's possible to create -// exemplars that are larger than allowed by the OpenMetrics specification). +// - The size of exemplar labels is not checked (i.e. it's possible to create +// exemplars that are larger than allowed by the OpenMetrics specification). // -// - The value of Counters is not checked. (OpenMetrics doesn't allow counters -// with a `NaN` value.) +// - The value of Counters is not checked. (OpenMetrics doesn't allow counters +// with a `NaN` value.) func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily) (written int, err error) { name := in.GetName() if name == "" { diff --git a/test/performance/vendor/github.com/prometheus/common/expfmt/text_create.go b/test/performance/vendor/github.com/prometheus/common/expfmt/text_create.go index 5ba503b06..2946b8f1a 100644 --- a/test/performance/vendor/github.com/prometheus/common/expfmt/text_create.go +++ b/test/performance/vendor/github.com/prometheus/common/expfmt/text_create.go @@ -17,7 +17,6 @@ import ( "bufio" "fmt" "io" - "io/ioutil" "math" "strconv" "strings" @@ -44,7 +43,7 @@ const ( var ( bufPool = sync.Pool{ New: func() interface{} { - return bufio.NewWriter(ioutil.Discard) + return bufio.NewWriter(io.Discard) }, } numBufPool = sync.Pool{ diff --git a/test/performance/vendor/github.com/prometheus/common/expfmt/text_parse.go b/test/performance/vendor/github.com/prometheus/common/expfmt/text_parse.go index 84be0643e..35db1cc9d 100644 --- a/test/performance/vendor/github.com/prometheus/common/expfmt/text_parse.go +++ b/test/performance/vendor/github.com/prometheus/common/expfmt/text_parse.go @@ -24,8 +24,8 @@ import ( dto "github.com/prometheus/client_model/go" - "github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. "github.com/prometheus/common/model" + "google.golang.org/protobuf/proto" ) // A stateFn is a function that represents a state in a state machine. By @@ -142,9 +142,13 @@ func (p *TextParser) reset(in io.Reader) { func (p *TextParser) startOfLine() stateFn { p.lineCount++ if p.skipBlankTab(); p.err != nil { - // End of input reached. This is the only case where - // that is not an error but a signal that we are done. - p.err = nil + // This is the only place that we expect to see io.EOF, + // which is not an error but the signal that we are done. + // Any other error that happens to align with the start of + // a line is still an error. + if p.err == io.EOF { + p.err = nil + } return nil } switch p.currentByte { diff --git a/test/performance/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go b/test/performance/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go index 26e92288c..a21b9d15d 100644 --- a/test/performance/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go +++ b/test/performance/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go @@ -11,18 +11,18 @@ 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 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. + 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 the Open Knowledge Foundation Ltd. nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. + Neither the name of the Open Knowledge Foundation Ltd. 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 @@ -35,8 +35,6 @@ 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 goautoneg diff --git a/test/performance/vendor/github.com/prometheus/common/model/time.go b/test/performance/vendor/github.com/prometheus/common/model/time.go index c909b8aa8..5727452c1 100644 --- a/test/performance/vendor/github.com/prometheus/common/model/time.go +++ b/test/performance/vendor/github.com/prometheus/common/model/time.go @@ -18,7 +18,6 @@ import ( "errors" "fmt" "math" - "regexp" "strconv" "strings" "time" @@ -183,54 +182,78 @@ func (d *Duration) Type() string { return "duration" } -var durationRE = regexp.MustCompile("^(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?$") +func isdigit(c byte) bool { return c >= '0' && c <= '9' } + +// Units are required to go in order from biggest to smallest. +// This guards against confusion from "1m1d" being 1 minute + 1 day, not 1 month + 1 day. +var unitMap = map[string]struct { + pos int + mult uint64 +}{ + "ms": {7, uint64(time.Millisecond)}, + "s": {6, uint64(time.Second)}, + "m": {5, uint64(time.Minute)}, + "h": {4, uint64(time.Hour)}, + "d": {3, uint64(24 * time.Hour)}, + "w": {2, uint64(7 * 24 * time.Hour)}, + "y": {1, uint64(365 * 24 * time.Hour)}, +} // ParseDuration parses a string into a time.Duration, assuming that a year // always has 365d, a week always has 7d, and a day always has 24h. -func ParseDuration(durationStr string) (Duration, error) { - switch durationStr { +func ParseDuration(s string) (Duration, error) { + switch s { case "0": // Allow 0 without a unit. return 0, nil case "": return 0, errors.New("empty duration string") } - matches := durationRE.FindStringSubmatch(durationStr) - if matches == nil { - return 0, fmt.Errorf("not a valid duration string: %q", durationStr) - } - var dur time.Duration - // Parse the match at pos `pos` in the regex and use `mult` to turn that - // into ms, then add that value to the total parsed duration. - var overflowErr error - m := func(pos int, mult time.Duration) { - if matches[pos] == "" { - return + orig := s + var dur uint64 + lastUnitPos := 0 + + for s != "" { + if !isdigit(s[0]) { + return 0, fmt.Errorf("not a valid duration string: %q", orig) + } + // Consume [0-9]* + i := 0 + for ; i < len(s) && isdigit(s[i]); i++ { + } + v, err := strconv.ParseUint(s[:i], 10, 0) + if err != nil { + return 0, fmt.Errorf("not a valid duration string: %q", orig) } - n, _ := strconv.Atoi(matches[pos]) + s = s[i:] + // Consume unit. + for i = 0; i < len(s) && !isdigit(s[i]); i++ { + } + if i == 0 { + return 0, fmt.Errorf("not a valid duration string: %q", orig) + } + u := s[:i] + s = s[i:] + unit, ok := unitMap[u] + if !ok { + return 0, fmt.Errorf("unknown unit %q in duration %q", u, orig) + } + if unit.pos <= lastUnitPos { // Units must go in order from biggest to smallest. + return 0, fmt.Errorf("not a valid duration string: %q", orig) + } + lastUnitPos = unit.pos // Check if the provided duration overflows time.Duration (> ~ 290years). - if n > int((1<<63-1)/mult/time.Millisecond) { - overflowErr = errors.New("duration out of range") + if v > 1<<63/unit.mult { + return 0, errors.New("duration out of range") } - d := time.Duration(n) * time.Millisecond - dur += d * mult - - if dur < 0 { - overflowErr = errors.New("duration out of range") + dur += v * unit.mult + if dur > 1<<63-1 { + return 0, errors.New("duration out of range") } } - - m(2, 1000*60*60*24*365) // y - m(4, 1000*60*60*24*7) // w - m(6, 1000*60*60*24) // d - m(8, 1000*60*60) // h - m(10, 1000*60) // m - m(12, 1000) // s - m(14, 1) // ms - - return Duration(dur), overflowErr + return Duration(dur), nil } func (d Duration) String() string { diff --git a/test/performance/vendor/github.com/prometheus/common/model/value.go b/test/performance/vendor/github.com/prometheus/common/model/value.go index c9d8fb1a2..9eb440413 100644 --- a/test/performance/vendor/github.com/prometheus/common/model/value.go +++ b/test/performance/vendor/github.com/prometheus/common/model/value.go @@ -16,20 +16,12 @@ package model import ( "encoding/json" "fmt" - "math" "sort" "strconv" "strings" ) var ( - // ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a - // non-existing sample pair. It is a SamplePair with timestamp Earliest and - // value 0.0. Note that the natural zero value of SamplePair has a timestamp - // of 0, which is possible to appear in a real SamplePair and thus not - // suitable to signal a non-existing SamplePair. - ZeroSamplePair = SamplePair{Timestamp: Earliest} - // ZeroSample is the pseudo zero-value of Sample used to signal a // non-existing sample. It is a Sample with timestamp Earliest, value 0.0, // and metric nil. Note that the natural zero value of Sample has a timestamp @@ -38,82 +30,14 @@ var ( ZeroSample = Sample{Timestamp: Earliest} ) -// A SampleValue is a representation of a value for a given sample at a given -// time. -type SampleValue float64 - -// MarshalJSON implements json.Marshaler. -func (v SampleValue) MarshalJSON() ([]byte, error) { - return json.Marshal(v.String()) -} - -// UnmarshalJSON implements json.Unmarshaler. -func (v *SampleValue) UnmarshalJSON(b []byte) error { - if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { - return fmt.Errorf("sample value must be a quoted string") - } - f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) - if err != nil { - return err - } - *v = SampleValue(f) - return nil -} - -// Equal returns true if the value of v and o is equal or if both are NaN. Note -// that v==o is false if both are NaN. If you want the conventional float -// behavior, use == to compare two SampleValues. -func (v SampleValue) Equal(o SampleValue) bool { - if v == o { - return true - } - return math.IsNaN(float64(v)) && math.IsNaN(float64(o)) -} - -func (v SampleValue) String() string { - return strconv.FormatFloat(float64(v), 'f', -1, 64) -} - -// SamplePair pairs a SampleValue with a Timestamp. -type SamplePair struct { - Timestamp Time - Value SampleValue -} - -// MarshalJSON implements json.Marshaler. -func (s SamplePair) MarshalJSON() ([]byte, error) { - t, err := json.Marshal(s.Timestamp) - if err != nil { - return nil, err - } - v, err := json.Marshal(s.Value) - if err != nil { - return nil, err - } - return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (s *SamplePair) UnmarshalJSON(b []byte) error { - v := [...]json.Unmarshaler{&s.Timestamp, &s.Value} - return json.Unmarshal(b, &v) -} - -// Equal returns true if this SamplePair and o have equal Values and equal -// Timestamps. The semantics of Value equality is defined by SampleValue.Equal. -func (s *SamplePair) Equal(o *SamplePair) bool { - return s == o || (s.Value.Equal(o.Value) && s.Timestamp.Equal(o.Timestamp)) -} - -func (s SamplePair) String() string { - return fmt.Sprintf("%s @[%s]", s.Value, s.Timestamp) -} - -// Sample is a sample pair associated with a metric. +// Sample is a sample pair associated with a metric. A single sample must either +// define Value or Histogram but not both. Histogram == nil implies the Value +// field is used, otherwise it should be ignored. type Sample struct { - Metric Metric `json:"metric"` - Value SampleValue `json:"value"` - Timestamp Time `json:"timestamp"` + Metric Metric `json:"metric"` + Value SampleValue `json:"value"` + Timestamp Time `json:"timestamp"` + Histogram *SampleHistogram `json:"histogram"` } // Equal compares first the metrics, then the timestamp, then the value. The @@ -129,11 +53,19 @@ func (s *Sample) Equal(o *Sample) bool { if !s.Timestamp.Equal(o.Timestamp) { return false } - + if s.Histogram != nil { + return s.Histogram.Equal(o.Histogram) + } return s.Value.Equal(o.Value) } func (s Sample) String() string { + if s.Histogram != nil { + return fmt.Sprintf("%s => %s", s.Metric, SampleHistogramPair{ + Timestamp: s.Timestamp, + Histogram: s.Histogram, + }) + } return fmt.Sprintf("%s => %s", s.Metric, SamplePair{ Timestamp: s.Timestamp, Value: s.Value, @@ -142,6 +74,19 @@ func (s Sample) String() string { // MarshalJSON implements json.Marshaler. func (s Sample) MarshalJSON() ([]byte, error) { + if s.Histogram != nil { + v := struct { + Metric Metric `json:"metric"` + Histogram SampleHistogramPair `json:"histogram"` + }{ + Metric: s.Metric, + Histogram: SampleHistogramPair{ + Timestamp: s.Timestamp, + Histogram: s.Histogram, + }, + } + return json.Marshal(&v) + } v := struct { Metric Metric `json:"metric"` Value SamplePair `json:"value"` @@ -152,21 +97,25 @@ func (s Sample) MarshalJSON() ([]byte, error) { Value: s.Value, }, } - return json.Marshal(&v) } // UnmarshalJSON implements json.Unmarshaler. func (s *Sample) UnmarshalJSON(b []byte) error { v := struct { - Metric Metric `json:"metric"` - Value SamplePair `json:"value"` + Metric Metric `json:"metric"` + Value SamplePair `json:"value"` + Histogram SampleHistogramPair `json:"histogram"` }{ Metric: s.Metric, Value: SamplePair{ Timestamp: s.Timestamp, Value: s.Value, }, + Histogram: SampleHistogramPair{ + Timestamp: s.Timestamp, + Histogram: s.Histogram, + }, } if err := json.Unmarshal(b, &v); err != nil { @@ -174,8 +123,13 @@ func (s *Sample) UnmarshalJSON(b []byte) error { } s.Metric = v.Metric - s.Timestamp = v.Value.Timestamp - s.Value = v.Value.Value + if v.Histogram.Histogram != nil { + s.Timestamp = v.Histogram.Timestamp + s.Histogram = v.Histogram.Histogram + } else { + s.Timestamp = v.Value.Timestamp + s.Value = v.Value.Value + } return nil } @@ -221,80 +175,76 @@ func (s Samples) Equal(o Samples) bool { // SampleStream is a stream of Values belonging to an attached COWMetric. type SampleStream struct { - Metric Metric `json:"metric"` - Values []SamplePair `json:"values"` + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + Histograms []SampleHistogramPair `json:"histograms"` } func (ss SampleStream) String() string { - vals := make([]string, len(ss.Values)) + valuesLength := len(ss.Values) + vals := make([]string, valuesLength+len(ss.Histograms)) for i, v := range ss.Values { vals[i] = v.String() } + for i, v := range ss.Histograms { + vals[i+valuesLength] = v.String() + } return fmt.Sprintf("%s =>\n%s", ss.Metric, strings.Join(vals, "\n")) } -// Value is a generic interface for values resulting from a query evaluation. -type Value interface { - Type() ValueType - String() string +func (ss SampleStream) MarshalJSON() ([]byte, error) { + if len(ss.Histograms) > 0 && len(ss.Values) > 0 { + v := struct { + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + Histograms []SampleHistogramPair `json:"histograms"` + }{ + Metric: ss.Metric, + Values: ss.Values, + Histograms: ss.Histograms, + } + return json.Marshal(&v) + } else if len(ss.Histograms) > 0 { + v := struct { + Metric Metric `json:"metric"` + Histograms []SampleHistogramPair `json:"histograms"` + }{ + Metric: ss.Metric, + Histograms: ss.Histograms, + } + return json.Marshal(&v) + } else { + v := struct { + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + }{ + Metric: ss.Metric, + Values: ss.Values, + } + return json.Marshal(&v) + } } -func (Matrix) Type() ValueType { return ValMatrix } -func (Vector) Type() ValueType { return ValVector } -func (*Scalar) Type() ValueType { return ValScalar } -func (*String) Type() ValueType { return ValString } - -type ValueType int - -const ( - ValNone ValueType = iota - ValScalar - ValVector - ValMatrix - ValString -) - -// MarshalJSON implements json.Marshaler. -func (et ValueType) MarshalJSON() ([]byte, error) { - return json.Marshal(et.String()) -} +func (ss *SampleStream) UnmarshalJSON(b []byte) error { + v := struct { + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + Histograms []SampleHistogramPair `json:"histograms"` + }{ + Metric: ss.Metric, + Values: ss.Values, + Histograms: ss.Histograms, + } -func (et *ValueType) UnmarshalJSON(b []byte) error { - var s string - if err := json.Unmarshal(b, &s); err != nil { + if err := json.Unmarshal(b, &v); err != nil { return err } - switch s { - case "": - *et = ValNone - case "scalar": - *et = ValScalar - case "vector": - *et = ValVector - case "matrix": - *et = ValMatrix - case "string": - *et = ValString - default: - return fmt.Errorf("unknown value type %q", s) - } - return nil -} -func (e ValueType) String() string { - switch e { - case ValNone: - return "" - case ValScalar: - return "scalar" - case ValVector: - return "vector" - case ValMatrix: - return "matrix" - case ValString: - return "string" - } - panic("ValueType.String: unhandled value type") + ss.Metric = v.Metric + ss.Values = v.Values + ss.Histograms = v.Histograms + + return nil } // Scalar is a scalar value evaluated at the set timestamp. diff --git a/test/performance/vendor/github.com/prometheus/common/model/value_float.go b/test/performance/vendor/github.com/prometheus/common/model/value_float.go new file mode 100644 index 000000000..0f615a705 --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/common/model/value_float.go @@ -0,0 +1,100 @@ +// Copyright 2013 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package model + +import ( + "encoding/json" + "fmt" + "math" + "strconv" +) + +var ( + // ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a + // non-existing sample pair. It is a SamplePair with timestamp Earliest and + // value 0.0. Note that the natural zero value of SamplePair has a timestamp + // of 0, which is possible to appear in a real SamplePair and thus not + // suitable to signal a non-existing SamplePair. + ZeroSamplePair = SamplePair{Timestamp: Earliest} +) + +// A SampleValue is a representation of a value for a given sample at a given +// time. +type SampleValue float64 + +// MarshalJSON implements json.Marshaler. +func (v SampleValue) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +// UnmarshalJSON implements json.Unmarshaler. +func (v *SampleValue) UnmarshalJSON(b []byte) error { + if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { + return fmt.Errorf("sample value must be a quoted string") + } + f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) + if err != nil { + return err + } + *v = SampleValue(f) + return nil +} + +// Equal returns true if the value of v and o is equal or if both are NaN. Note +// that v==o is false if both are NaN. If you want the conventional float +// behavior, use == to compare two SampleValues. +func (v SampleValue) Equal(o SampleValue) bool { + if v == o { + return true + } + return math.IsNaN(float64(v)) && math.IsNaN(float64(o)) +} + +func (v SampleValue) String() string { + return strconv.FormatFloat(float64(v), 'f', -1, 64) +} + +// SamplePair pairs a SampleValue with a Timestamp. +type SamplePair struct { + Timestamp Time + Value SampleValue +} + +func (s SamplePair) MarshalJSON() ([]byte, error) { + t, err := json.Marshal(s.Timestamp) + if err != nil { + return nil, err + } + v, err := json.Marshal(s.Value) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (s *SamplePair) UnmarshalJSON(b []byte) error { + v := [...]json.Unmarshaler{&s.Timestamp, &s.Value} + return json.Unmarshal(b, &v) +} + +// Equal returns true if this SamplePair and o have equal Values and equal +// Timestamps. The semantics of Value equality is defined by SampleValue.Equal. +func (s *SamplePair) Equal(o *SamplePair) bool { + return s == o || (s.Value.Equal(o.Value) && s.Timestamp.Equal(o.Timestamp)) +} + +func (s SamplePair) String() string { + return fmt.Sprintf("%s @[%s]", s.Value, s.Timestamp) +} diff --git a/test/performance/vendor/github.com/prometheus/common/model/value_histogram.go b/test/performance/vendor/github.com/prometheus/common/model/value_histogram.go new file mode 100644 index 000000000..54bb038cf --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/common/model/value_histogram.go @@ -0,0 +1,178 @@ +// Copyright 2013 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package model + +import ( + "encoding/json" + "fmt" + "strconv" + "strings" +) + +type FloatString float64 + +func (v FloatString) String() string { + return strconv.FormatFloat(float64(v), 'f', -1, 64) +} + +func (v FloatString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +func (v *FloatString) UnmarshalJSON(b []byte) error { + if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { + return fmt.Errorf("float value must be a quoted string") + } + f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) + if err != nil { + return err + } + *v = FloatString(f) + return nil +} + +type HistogramBucket struct { + Boundaries int32 + Lower FloatString + Upper FloatString + Count FloatString +} + +func (s HistogramBucket) MarshalJSON() ([]byte, error) { + b, err := json.Marshal(s.Boundaries) + if err != nil { + return nil, err + } + l, err := json.Marshal(s.Lower) + if err != nil { + return nil, err + } + u, err := json.Marshal(s.Upper) + if err != nil { + return nil, err + } + c, err := json.Marshal(s.Count) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf("[%s,%s,%s,%s]", b, l, u, c)), nil +} + +func (s *HistogramBucket) UnmarshalJSON(buf []byte) error { + tmp := []interface{}{&s.Boundaries, &s.Lower, &s.Upper, &s.Count} + wantLen := len(tmp) + if err := json.Unmarshal(buf, &tmp); err != nil { + return err + } + if gotLen := len(tmp); gotLen != wantLen { + return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen) + } + return nil +} + +func (s *HistogramBucket) Equal(o *HistogramBucket) bool { + return s == o || (s.Boundaries == o.Boundaries && s.Lower == o.Lower && s.Upper == o.Upper && s.Count == o.Count) +} + +func (b HistogramBucket) String() string { + var sb strings.Builder + lowerInclusive := b.Boundaries == 1 || b.Boundaries == 3 + upperInclusive := b.Boundaries == 0 || b.Boundaries == 3 + if lowerInclusive { + sb.WriteRune('[') + } else { + sb.WriteRune('(') + } + fmt.Fprintf(&sb, "%g,%g", b.Lower, b.Upper) + if upperInclusive { + sb.WriteRune(']') + } else { + sb.WriteRune(')') + } + fmt.Fprintf(&sb, ":%v", b.Count) + return sb.String() +} + +type HistogramBuckets []*HistogramBucket + +func (s HistogramBuckets) Equal(o HistogramBuckets) bool { + if len(s) != len(o) { + return false + } + + for i, bucket := range s { + if !bucket.Equal(o[i]) { + return false + } + } + return true +} + +type SampleHistogram struct { + Count FloatString `json:"count"` + Sum FloatString `json:"sum"` + Buckets HistogramBuckets `json:"buckets"` +} + +func (s SampleHistogram) String() string { + return fmt.Sprintf("Count: %f, Sum: %f, Buckets: %v", s.Count, s.Sum, s.Buckets) +} + +func (s *SampleHistogram) Equal(o *SampleHistogram) bool { + return s == o || (s.Count == o.Count && s.Sum == o.Sum && s.Buckets.Equal(o.Buckets)) +} + +type SampleHistogramPair struct { + Timestamp Time + // Histogram should never be nil, it's only stored as pointer for efficiency. + Histogram *SampleHistogram +} + +func (s SampleHistogramPair) MarshalJSON() ([]byte, error) { + if s.Histogram == nil { + return nil, fmt.Errorf("histogram is nil") + } + t, err := json.Marshal(s.Timestamp) + if err != nil { + return nil, err + } + v, err := json.Marshal(s.Histogram) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil +} + +func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error { + tmp := []interface{}{&s.Timestamp, &s.Histogram} + wantLen := len(tmp) + if err := json.Unmarshal(buf, &tmp); err != nil { + return err + } + if gotLen := len(tmp); gotLen != wantLen { + return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen) + } + if s.Histogram == nil { + return fmt.Errorf("histogram is null") + } + return nil +} + +func (s SampleHistogramPair) String() string { + return fmt.Sprintf("%s @[%s]", s.Histogram, s.Timestamp) +} + +func (s *SampleHistogramPair) Equal(o *SampleHistogramPair) bool { + return s == o || (s.Histogram.Equal(o.Histogram) && s.Timestamp.Equal(o.Timestamp)) +} diff --git a/test/performance/vendor/github.com/prometheus/common/model/value_type.go b/test/performance/vendor/github.com/prometheus/common/model/value_type.go new file mode 100644 index 000000000..726c50ee6 --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/common/model/value_type.go @@ -0,0 +1,83 @@ +// Copyright 2013 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package model + +import ( + "encoding/json" + "fmt" +) + +// Value is a generic interface for values resulting from a query evaluation. +type Value interface { + Type() ValueType + String() string +} + +func (Matrix) Type() ValueType { return ValMatrix } +func (Vector) Type() ValueType { return ValVector } +func (*Scalar) Type() ValueType { return ValScalar } +func (*String) Type() ValueType { return ValString } + +type ValueType int + +const ( + ValNone ValueType = iota + ValScalar + ValVector + ValMatrix + ValString +) + +// MarshalJSON implements json.Marshaler. +func (et ValueType) MarshalJSON() ([]byte, error) { + return json.Marshal(et.String()) +} + +func (et *ValueType) UnmarshalJSON(b []byte) error { + var s string + if err := json.Unmarshal(b, &s); err != nil { + return err + } + switch s { + case "": + *et = ValNone + case "scalar": + *et = ValScalar + case "vector": + *et = ValVector + case "matrix": + *et = ValMatrix + case "string": + *et = ValString + default: + return fmt.Errorf("unknown value type %q", s) + } + return nil +} + +func (e ValueType) String() string { + switch e { + case ValNone: + return "" + case ValScalar: + return "scalar" + case ValVector: + return "vector" + case ValMatrix: + return "matrix" + case ValString: + return "string" + } + panic("ValueType.String: unhandled value type") +} diff --git a/test/performance/vendor/github.com/prometheus/procfs/.golangci.yml b/test/performance/vendor/github.com/prometheus/procfs/.golangci.yml index a197699a1..c24864a92 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/.golangci.yml +++ b/test/performance/vendor/github.com/prometheus/procfs/.golangci.yml @@ -2,6 +2,7 @@ linters: enable: - godot + - misspell - revive linter-settings: @@ -10,3 +11,5 @@ linter-settings: exclude: # Ignore "See: URL" - 'See:' + misspell: + locale: US diff --git a/test/performance/vendor/github.com/prometheus/procfs/Makefile.common b/test/performance/vendor/github.com/prometheus/procfs/Makefile.common index 6c8e3e219..b111d2562 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/Makefile.common +++ b/test/performance/vendor/github.com/prometheus/procfs/Makefile.common @@ -55,19 +55,22 @@ ifneq ($(shell which gotestsum),) endif endif -PROMU_VERSION ?= 0.13.0 +PROMU_VERSION ?= 0.14.0 PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz +SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v1.45.2 +GOLANGCI_LINT_VERSION ?= v1.51.2 # golangci-lint only supports linux, darwin and windows platforms on i386/amd64. # windows isn't included here because of the path separator being different. ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386)) # If we're in CI and there is an Actions file, that means the linter # is being run in Actions, so we don't need to run it here. - ifeq (,$(CIRCLE_JOB)) + ifneq (,$(SKIP_GOLANGCI_LINT)) + GOLANGCI_LINT := + else ifeq (,$(CIRCLE_JOB)) GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint else ifeq (,$(wildcard .github/workflows/golangci-lint.yml)) GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint @@ -88,6 +91,8 @@ BUILD_DOCKER_ARCHS = $(addprefix common-docker-,$(DOCKER_ARCHS)) PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS)) TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS)) +SANITIZED_DOCKER_IMAGE_TAG := $(subst +,-,$(DOCKER_IMAGE_TAG)) + ifeq ($(GOHOSTARCH),amd64) ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin windows)) # Only supported on amd64 @@ -202,7 +207,7 @@ common-tarball: promu .PHONY: common-docker $(BUILD_DOCKER_ARCHS) common-docker: $(BUILD_DOCKER_ARCHS) $(BUILD_DOCKER_ARCHS): common-docker-%: - docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" \ + docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" \ -f $(DOCKERFILE_PATH) \ --build-arg ARCH="$*" \ --build-arg OS="linux" \ @@ -211,19 +216,19 @@ $(BUILD_DOCKER_ARCHS): common-docker-%: .PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS) common-docker-publish: $(PUBLISH_DOCKER_ARCHS) $(PUBLISH_DOCKER_ARCHS): common-docker-publish-%: - docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" + docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" DOCKER_MAJOR_VERSION_TAG = $(firstword $(subst ., ,$(shell cat VERSION))) .PHONY: common-docker-tag-latest $(TAG_DOCKER_ARCHS) common-docker-tag-latest: $(TAG_DOCKER_ARCHS) $(TAG_DOCKER_ARCHS): common-docker-tag-latest-%: - docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest" - docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)" + docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest" + docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)" .PHONY: common-docker-manifest common-docker-manifest: - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(DOCKER_IMAGE_TAG)) - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" + DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(SANITIZED_DOCKER_IMAGE_TAG)) + DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)" .PHONY: promu promu: $(PROMU) diff --git a/test/performance/vendor/github.com/prometheus/procfs/README.md b/test/performance/vendor/github.com/prometheus/procfs/README.md index 43c37735a..1224816c2 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/README.md +++ b/test/performance/vendor/github.com/prometheus/procfs/README.md @@ -51,11 +51,11 @@ ensure the `fixtures` directory is up to date by removing the existing directory extracting the ttar file using `make fixtures/.unpacked` or just `make test`. ```bash -rm -rf fixtures +rm -rf testdata/fixtures make test ``` Next, make the required changes to the extracted files in the `fixtures` directory. When the changes are complete, run `make update_fixtures` to create a new `fixtures.ttar` file based on the updated `fixtures` directory. And finally, verify the changes using -`git diff fixtures.ttar`. +`git diff testdata/fixtures.ttar`. diff --git a/test/performance/vendor/github.com/prometheus/procfs/arp.go b/test/performance/vendor/github.com/prometheus/procfs/arp.go index 68f36e888..28783e2dd 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/arp.go +++ b/test/performance/vendor/github.com/prometheus/procfs/arp.go @@ -55,7 +55,7 @@ type ARPEntry struct { func (fs FS) GatherARPEntries() ([]ARPEntry, error) { data, err := os.ReadFile(fs.proc.Path("net/arp")) if err != nil { - return nil, fmt.Errorf("error reading arp %q: %w", fs.proc.Path("net/arp"), err) + return nil, fmt.Errorf("%s: error reading arp %s: %w", ErrFileRead, fs.proc.Path("net/arp"), err) } return parseARPEntries(data) @@ -78,11 +78,11 @@ func parseARPEntries(data []byte) ([]ARPEntry, error) { } else if width == expectedDataWidth { entry, err := parseARPEntry(columns) if err != nil { - return []ARPEntry{}, fmt.Errorf("failed to parse ARP entry: %w", err) + return []ARPEntry{}, fmt.Errorf("%s: Failed to parse ARP entry: %v: %w", ErrFileParse, entry, err) } entries = append(entries, entry) } else { - return []ARPEntry{}, fmt.Errorf("%d columns were detected, but %d were expected", width, expectedDataWidth) + return []ARPEntry{}, fmt.Errorf("%s: %d columns found, but expected %d: %w", ErrFileParse, width, expectedDataWidth, err) } } diff --git a/test/performance/vendor/github.com/prometheus/procfs/buddyinfo.go b/test/performance/vendor/github.com/prometheus/procfs/buddyinfo.go index f5b7939b2..4a173636c 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/buddyinfo.go +++ b/test/performance/vendor/github.com/prometheus/procfs/buddyinfo.go @@ -55,7 +55,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { parts := strings.Fields(line) if len(parts) < 4 { - return nil, fmt.Errorf("invalid number of fields when parsing buddyinfo") + return nil, fmt.Errorf("%w: Invalid number of fields, found: %v", ErrFileParse, parts) } node := strings.TrimRight(parts[1], ",") @@ -66,7 +66,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { bucketCount = arraySize } else { if bucketCount != arraySize { - return nil, fmt.Errorf("mismatch in number of buddyinfo buckets, previous count %d, new count %d", bucketCount, arraySize) + return nil, fmt.Errorf("%w: mismatch in number of buddyinfo buckets, previous count %d, new count %d", ErrFileParse, bucketCount, arraySize) } } @@ -74,7 +74,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { for i := 0; i < arraySize; i++ { sizes[i], err = strconv.ParseFloat(parts[i+4], 64) if err != nil { - return nil, fmt.Errorf("invalid value in buddyinfo: %w", err) + return nil, fmt.Errorf("%s: Invalid valid in buddyinfo: %f: %w", ErrFileParse, sizes[i], err) } } diff --git a/test/performance/vendor/github.com/prometheus/procfs/cpuinfo.go b/test/performance/vendor/github.com/prometheus/procfs/cpuinfo.go index ff6b927da..f4f5501c6 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/cpuinfo.go +++ b/test/performance/vendor/github.com/prometheus/procfs/cpuinfo.go @@ -79,7 +79,7 @@ func parseCPUInfoX86(info []byte) ([]CPUInfo, error) { // find the first "processor" line firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) v, err := strconv.ParseUint(field[1], 0, 32) @@ -192,9 +192,10 @@ func parseCPUInfoARM(info []byte) ([]CPUInfo, error) { scanner := bufio.NewScanner(bytes.NewReader(info)) firstLine := firstNonEmptyLine(scanner) - match, _ := regexp.MatchString("^[Pp]rocessor", firstLine) + match, err := regexp.MatchString("^[Pp]rocessor", firstLine) if !match || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%s: Cannot parse line: %q: %w", ErrFileParse, firstLine, err) + } field := strings.SplitN(firstLine, ": ", 2) cpuinfo := []CPUInfo{} @@ -258,7 +259,7 @@ func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) { firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "vendor_id") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) cpuinfo := []CPUInfo{} @@ -283,7 +284,7 @@ func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) { if strings.HasPrefix(line, "processor") { match := cpuinfoS390XProcessorRegexp.FindStringSubmatch(line) if len(match) < 2 { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } cpu := commonCPUInfo v, err := strconv.ParseUint(match[1], 0, 32) @@ -343,7 +344,7 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) { // find the first "processor" line firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) cpuinfo := []CPUInfo{} @@ -380,12 +381,48 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) { return cpuinfo, nil } +func parseCPUInfoLoong(info []byte) ([]CPUInfo, error) { + scanner := bufio.NewScanner(bytes.NewReader(info)) + // find the first "processor" line + firstLine := firstNonEmptyLine(scanner) + if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") { + return nil, errors.New("invalid cpuinfo file: " + firstLine) + } + field := strings.SplitN(firstLine, ": ", 2) + cpuinfo := []CPUInfo{} + systemType := field[1] + i := 0 + for scanner.Scan() { + line := scanner.Text() + if !strings.Contains(line, ":") { + continue + } + field := strings.SplitN(line, ": ", 2) + switch strings.TrimSpace(field[0]) { + case "processor": + v, err := strconv.ParseUint(field[1], 0, 32) + if err != nil { + return nil, err + } + i = int(v) + cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor + cpuinfo[i].Processor = uint(v) + cpuinfo[i].VendorID = systemType + case "CPU Family": + cpuinfo[i].CPUFamily = field[1] + case "Model Name": + cpuinfo[i].ModelName = field[1] + } + } + return cpuinfo, nil +} + func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) { scanner := bufio.NewScanner(bytes.NewReader(info)) firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) v, err := strconv.ParseUint(field[1], 0, 32) @@ -430,7 +467,7 @@ func parseCPUInfoRISCV(info []byte) ([]CPUInfo, error) { firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) v, err := strconv.ParseUint(field[1], 0, 32) diff --git a/test/performance/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go b/test/performance/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go new file mode 100644 index 000000000..d88442f0e --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go @@ -0,0 +1,19 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build linux +// +build linux + +package procfs + +var parseCPUInfo = parseCPUInfoLoong diff --git a/test/performance/vendor/github.com/prometheus/procfs/cpuinfo_others.go b/test/performance/vendor/github.com/prometheus/procfs/cpuinfo_others.go index ea41bf2ca..a6b2b3127 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/cpuinfo_others.go +++ b/test/performance/vendor/github.com/prometheus/procfs/cpuinfo_others.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build linux && !386 && !amd64 && !arm && !arm64 && !mips && !mips64 && !mips64le && !mipsle && !ppc64 && !ppc64le && !riscv64 && !s390x -// +build linux,!386,!amd64,!arm,!arm64,!mips,!mips64,!mips64le,!mipsle,!ppc64,!ppc64le,!riscv64,!s390x +//go:build linux && !386 && !amd64 && !arm && !arm64 && !loong64 && !mips && !mips64 && !mips64le && !mipsle && !ppc64 && !ppc64le && !riscv64 && !s390x +// +build linux,!386,!amd64,!arm,!arm64,!loong64,!mips,!mips64,!mips64le,!mipsle,!ppc64,!ppc64le,!riscv64,!s390x package procfs diff --git a/test/performance/vendor/github.com/prometheus/procfs/crypto.go b/test/performance/vendor/github.com/prometheus/procfs/crypto.go index 5048ad1f2..9a73e2639 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/crypto.go +++ b/test/performance/vendor/github.com/prometheus/procfs/crypto.go @@ -55,12 +55,13 @@ func (fs FS) Crypto() ([]Crypto, error) { path := fs.proc.Path("crypto") b, err := util.ReadFileNoStat(path) if err != nil { - return nil, fmt.Errorf("error reading crypto %q: %w", path, err) + return nil, fmt.Errorf("%s: Cannot read file %v: %w", ErrFileRead, b, err) + } crypto, err := parseCrypto(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("error parsing crypto %q: %w", path, err) + return nil, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, crypto, err) } return crypto, nil @@ -83,7 +84,7 @@ func parseCrypto(r io.Reader) ([]Crypto, error) { kv := strings.Split(text, ":") if len(kv) != 2 { - return nil, fmt.Errorf("malformed crypto line: %q", text) + return nil, fmt.Errorf("%w: Cannot parae line: %q", ErrFileParse, text) } k := strings.TrimSpace(kv[0]) diff --git a/test/performance/vendor/github.com/prometheus/procfs/doc.go b/test/performance/vendor/github.com/prometheus/procfs/doc.go index d31a82600..f9d961e44 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/doc.go +++ b/test/performance/vendor/github.com/prometheus/procfs/doc.go @@ -16,30 +16,29 @@ // // Example: // -// package main -// -// import ( -// "fmt" -// "log" -// -// "github.com/prometheus/procfs" -// ) -// -// func main() { -// p, err := procfs.Self() -// if err != nil { -// log.Fatalf("could not get process: %s", err) -// } -// -// stat, err := p.Stat() -// if err != nil { -// log.Fatalf("could not get process stat: %s", err) -// } -// -// fmt.Printf("command: %s\n", stat.Comm) -// fmt.Printf("cpu time: %fs\n", stat.CPUTime()) -// fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) -// fmt.Printf("rss: %dB\n", stat.ResidentMemory()) -// } -// +// package main +// +// import ( +// "fmt" +// "log" +// +// "github.com/prometheus/procfs" +// ) +// +// func main() { +// p, err := procfs.Self() +// if err != nil { +// log.Fatalf("could not get process: %s", err) +// } +// +// stat, err := p.Stat() +// if err != nil { +// log.Fatalf("could not get process stat: %s", err) +// } +// +// fmt.Printf("command: %s\n", stat.Comm) +// fmt.Printf("cpu time: %fs\n", stat.CPUTime()) +// fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) +// fmt.Printf("rss: %dB\n", stat.ResidentMemory()) +// } package procfs diff --git a/test/performance/vendor/github.com/prometheus/procfs/fs.go b/test/performance/vendor/github.com/prometheus/procfs/fs.go index 0102ab0fd..60c551e02 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/fs.go +++ b/test/performance/vendor/github.com/prometheus/procfs/fs.go @@ -21,6 +21,7 @@ import ( // kernel data structures. type FS struct { proc fs.FS + real bool } // DefaultMountPoint is the common mount point of the proc filesystem. @@ -39,5 +40,11 @@ func NewFS(mountPoint string) (FS, error) { if err != nil { return FS{}, err } - return FS{fs}, nil + + real, err := isRealProc(mountPoint) + if err != nil { + return FS{}, err + } + + return FS{fs, real}, nil } diff --git a/test/performance/vendor/github.com/prometheus/procfs/fs_statfs_notype.go b/test/performance/vendor/github.com/prometheus/procfs/fs_statfs_notype.go new file mode 100644 index 000000000..800576968 --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/procfs/fs_statfs_notype.go @@ -0,0 +1,23 @@ +// Copyright 2018 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build netbsd || openbsd || solaris || windows +// +build netbsd openbsd solaris windows + +package procfs + +// isRealProc returns true on architectures that don't have a Type argument +// in their Statfs_t struct +func isRealProc(mountPoint string) (bool, error) { + return true, nil +} diff --git a/test/performance/vendor/github.com/prometheus/procfs/fs_statfs_type.go b/test/performance/vendor/github.com/prometheus/procfs/fs_statfs_type.go new file mode 100644 index 000000000..6233217ad --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/procfs/fs_statfs_type.go @@ -0,0 +1,33 @@ +// Copyright 2018 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !netbsd && !openbsd && !solaris && !windows +// +build !netbsd,!openbsd,!solaris,!windows + +package procfs + +import ( + "syscall" +) + +// isRealProc determines whether supplied mountpoint is really a proc filesystem. +func isRealProc(mountPoint string) (bool, error) { + stat := syscall.Statfs_t{} + err := syscall.Statfs(mountPoint, &stat) + if err != nil { + return false, err + } + + // 0x9fa0 is PROC_SUPER_MAGIC: https://elixir.bootlin.com/linux/v6.1/source/include/uapi/linux/magic.h#L87 + return stat.Type == 0x9fa0, nil +} diff --git a/test/performance/vendor/github.com/prometheus/procfs/fscache.go b/test/performance/vendor/github.com/prometheus/procfs/fscache.go index f8070e6e2..f560a8db3 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/fscache.go +++ b/test/performance/vendor/github.com/prometheus/procfs/fscache.go @@ -236,7 +236,7 @@ func (fs FS) Fscacheinfo() (Fscacheinfo, error) { m, err := parseFscacheinfo(bytes.NewReader(b)) if err != nil { - return Fscacheinfo{}, fmt.Errorf("failed to parse Fscacheinfo: %w", err) + return Fscacheinfo{}, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, m, err) } return *m, nil @@ -245,7 +245,7 @@ func (fs FS) Fscacheinfo() (Fscacheinfo, error) { func setFSCacheFields(fields []string, setFields ...*uint64) error { var err error if len(fields) < len(setFields) { - return fmt.Errorf("Insufficient number of fields, expected %v, got %v", len(setFields), len(fields)) + return fmt.Errorf("%s: Expected %d, but got %d: %w", ErrFileParse, len(setFields), len(fields), err) } for i := range setFields { @@ -263,7 +263,7 @@ func parseFscacheinfo(r io.Reader) (*Fscacheinfo, error) { for s.Scan() { fields := strings.Fields(s.Text()) if len(fields) < 2 { - return nil, fmt.Errorf("malformed Fscacheinfo line: %q", s.Text()) + return nil, fmt.Errorf("%w: malformed Fscacheinfo line: %q", ErrFileParse, s.Text()) } switch fields[0] { diff --git a/test/performance/vendor/github.com/prometheus/procfs/internal/util/parse.go b/test/performance/vendor/github.com/prometheus/procfs/internal/util/parse.go index b030951fa..14272dc78 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/internal/util/parse.go +++ b/test/performance/vendor/github.com/prometheus/procfs/internal/util/parse.go @@ -64,6 +64,21 @@ func ParsePInt64s(ss []string) ([]*int64, error) { return us, nil } +// Parses a uint64 from given hex in string. +func ParseHexUint64s(ss []string) ([]*uint64, error) { + us := make([]*uint64, 0, len(ss)) + for _, s := range ss { + u, err := strconv.ParseUint(s, 16, 64) + if err != nil { + return nil, err + } + + us = append(us, &u) + } + + return us, nil +} + // ReadUintFromFile reads a file and attempts to parse a uint64 from it. func ReadUintFromFile(path string) (uint64, error) { data, err := os.ReadFile(path) diff --git a/test/performance/vendor/github.com/prometheus/procfs/ipvs.go b/test/performance/vendor/github.com/prometheus/procfs/ipvs.go index 391c07957..5a145bbfe 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/ipvs.go +++ b/test/performance/vendor/github.com/prometheus/procfs/ipvs.go @@ -221,15 +221,16 @@ func parseIPPort(s string) (net.IP, uint16, error) { case 46: ip = net.ParseIP(s[1:40]) if ip == nil { - return nil, 0, fmt.Errorf("invalid IPv6 address: %s", s[1:40]) + return nil, 0, fmt.Errorf("%s: Invalid IPv6 addr %s: %w", ErrFileParse, s[1:40], err) } default: - return nil, 0, fmt.Errorf("unexpected IP:Port: %s", s) + return nil, 0, fmt.Errorf("%s: Unexpected IP:Port %s: %w", ErrFileParse, s, err) } portString := s[len(s)-4:] if len(portString) != 4 { - return nil, 0, fmt.Errorf("unexpected port string format: %s", portString) + return nil, 0, + fmt.Errorf("%s: Unexpected port string format %s: %w", ErrFileParse, portString, err) } port, err := strconv.ParseUint(portString, 16, 16) if err != nil { diff --git a/test/performance/vendor/github.com/prometheus/procfs/loadavg.go b/test/performance/vendor/github.com/prometheus/procfs/loadavg.go index 0096cafbd..59465c5bb 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/loadavg.go +++ b/test/performance/vendor/github.com/prometheus/procfs/loadavg.go @@ -44,14 +44,14 @@ func parseLoad(loadavgBytes []byte) (*LoadAvg, error) { loads := make([]float64, 3) parts := strings.Fields(string(loadavgBytes)) if len(parts) < 3 { - return nil, fmt.Errorf("malformed loadavg line: too few fields in loadavg string: %q", string(loadavgBytes)) + return nil, fmt.Errorf("%w: Malformed line %q", ErrFileParse, string(loadavgBytes)) } var err error for i, load := range parts[0:3] { loads[i], err = strconv.ParseFloat(load, 64) if err != nil { - return nil, fmt.Errorf("could not parse load %q: %w", load, err) + return nil, fmt.Errorf("%s: Cannot parse load: %f: %w", ErrFileParse, loads[i], err) } } return &LoadAvg{ diff --git a/test/performance/vendor/github.com/prometheus/procfs/mdstat.go b/test/performance/vendor/github.com/prometheus/procfs/mdstat.go index a95c889cb..fdd4b9544 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/mdstat.go +++ b/test/performance/vendor/github.com/prometheus/procfs/mdstat.go @@ -70,7 +70,7 @@ func (fs FS) MDStat() ([]MDStat, error) { } mdstat, err := parseMDStat(data) if err != nil { - return nil, fmt.Errorf("error parsing mdstat %q: %w", fs.proc.Path("mdstat"), err) + return nil, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, fs.proc.Path("mdstat"), err) } return mdstat, nil } @@ -90,13 +90,13 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { deviceFields := strings.Fields(line) if len(deviceFields) < 3 { - return nil, fmt.Errorf("not enough fields in mdline (expected at least 3): %s", line) + return nil, fmt.Errorf("%s: Expected 3+ lines, got %q", ErrFileParse, line) } mdName := deviceFields[0] // mdx state := deviceFields[2] // active or inactive if len(lines) <= i+3 { - return nil, fmt.Errorf("error parsing %q: too few lines for md device", mdName) + return nil, fmt.Errorf("%w: Too few lines for md device: %q", ErrFileParse, mdName) } // Failed disks have the suffix (F) & Spare disks have the suffix (S). @@ -105,7 +105,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { active, total, down, size, err := evalStatusLine(lines[i], lines[i+1]) if err != nil { - return nil, fmt.Errorf("error parsing md device lines: %w", err) + return nil, fmt.Errorf("%s: Cannot parse md device lines: %v: %w", ErrFileParse, active, err) } syncLineIdx := i + 2 @@ -140,7 +140,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { } else { syncedBlocks, pct, finish, speed, err = evalRecoveryLine(lines[syncLineIdx]) if err != nil { - return nil, fmt.Errorf("error parsing sync line in md device %q: %w", mdName, err) + return nil, fmt.Errorf("%s: Cannot parse sync line in md device: %q: %w", ErrFileParse, mdName, err) } } } @@ -168,13 +168,13 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { func evalStatusLine(deviceLine, statusLine string) (active, total, down, size int64, err error) { statusFields := strings.Fields(statusLine) if len(statusFields) < 1 { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q", statusLine) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err) } sizeStr := statusFields[0] size, err = strconv.ParseInt(sizeStr, 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err) } if strings.Contains(deviceLine, "raid0") || strings.Contains(deviceLine, "linear") { @@ -189,17 +189,17 @@ func evalStatusLine(deviceLine, statusLine string) (active, total, down, size in matches := statusLineRE.FindStringSubmatch(statusLine) if len(matches) != 5 { - return 0, 0, 0, 0, fmt.Errorf("couldn't find all the substring matches: %s", statusLine) + return 0, 0, 0, 0, fmt.Errorf("%s: Could not fild all substring matches %s: %w", ErrFileParse, statusLine, err) } total, err = strconv.ParseInt(matches[2], 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err) } active, err = strconv.ParseInt(matches[3], 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected active %d: %w", ErrFileParse, active, err) } down = int64(strings.Count(matches[4], "_")) @@ -209,42 +209,42 @@ func evalStatusLine(deviceLine, statusLine string) (active, total, down, size in func evalRecoveryLine(recoveryLine string) (syncedBlocks int64, pct float64, finish float64, speed float64, err error) { matches := recoveryLineBlocksRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return 0, 0, 0, 0, fmt.Errorf("unexpected recoveryLine: %s", recoveryLine) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected recoveryLine %s: %w", ErrFileParse, recoveryLine, err) } syncedBlocks, err = strconv.ParseInt(matches[1], 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("error parsing int from recoveryLine %q: %w", recoveryLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected parsing of recoveryLine %q: %w", ErrFileParse, recoveryLine, err) } // Get percentage complete matches = recoveryLinePctRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return syncedBlocks, 0, 0, 0, fmt.Errorf("unexpected recoveryLine matching percentage: %s", recoveryLine) + return syncedBlocks, 0, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching percentage %s", ErrFileParse, recoveryLine) } pct, err = strconv.ParseFloat(strings.TrimSpace(matches[1]), 64) if err != nil { - return syncedBlocks, 0, 0, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err) + return syncedBlocks, 0, 0, 0, fmt.Errorf("%w: Error parsing float from recoveryLine %q", ErrFileParse, recoveryLine) } // Get time expected left to complete matches = recoveryLineFinishRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return syncedBlocks, pct, 0, 0, fmt.Errorf("unexpected recoveryLine matching est. finish time: %s", recoveryLine) + return syncedBlocks, pct, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching est. finish time: %s", ErrFileParse, recoveryLine) } finish, err = strconv.ParseFloat(matches[1], 64) if err != nil { - return syncedBlocks, pct, 0, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err) + return syncedBlocks, pct, 0, 0, fmt.Errorf("%w: Unable to parse float from recoveryLine: %q", ErrFileParse, recoveryLine) } // Get recovery speed matches = recoveryLineSpeedRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return syncedBlocks, pct, finish, 0, fmt.Errorf("unexpected recoveryLine matching speed: %s", recoveryLine) + return syncedBlocks, pct, finish, 0, fmt.Errorf("%w: Unexpected recoveryLine value: %s", ErrFileParse, recoveryLine) } speed, err = strconv.ParseFloat(matches[1], 64) if err != nil { - return syncedBlocks, pct, finish, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err) + return syncedBlocks, pct, finish, 0, fmt.Errorf("%s: Error parsing float from recoveryLine: %q: %w", ErrFileParse, recoveryLine, err) } return syncedBlocks, pct, finish, speed, nil diff --git a/test/performance/vendor/github.com/prometheus/procfs/meminfo.go b/test/performance/vendor/github.com/prometheus/procfs/meminfo.go index f65e174e5..eaf00e224 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/meminfo.go +++ b/test/performance/vendor/github.com/prometheus/procfs/meminfo.go @@ -152,7 +152,7 @@ func (fs FS) Meminfo() (Meminfo, error) { m, err := parseMemInfo(bytes.NewReader(b)) if err != nil { - return Meminfo{}, fmt.Errorf("failed to parse meminfo: %w", err) + return Meminfo{}, fmt.Errorf("%s: %w", ErrFileParse, err) } return *m, nil @@ -165,7 +165,7 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) { // Each line has at least a name and value; we ignore the unit. fields := strings.Fields(s.Text()) if len(fields) < 2 { - return nil, fmt.Errorf("malformed meminfo line: %q", s.Text()) + return nil, fmt.Errorf("%w: Malformed line %q", ErrFileParse, s.Text()) } v, err := strconv.ParseUint(fields[1], 0, 64) diff --git a/test/performance/vendor/github.com/prometheus/procfs/mountinfo.go b/test/performance/vendor/github.com/prometheus/procfs/mountinfo.go index 59f4d5055..388ebf396 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/mountinfo.go +++ b/test/performance/vendor/github.com/prometheus/procfs/mountinfo.go @@ -78,11 +78,11 @@ func parseMountInfoString(mountString string) (*MountInfo, error) { mountInfo := strings.Split(mountString, " ") mountInfoLength := len(mountInfo) if mountInfoLength < 10 { - return nil, fmt.Errorf("couldn't find enough fields in mount string: %s", mountString) + return nil, fmt.Errorf("%w: Too few fields in mount string: %s", ErrFileParse, mountString) } if mountInfo[mountInfoLength-4] != "-" { - return nil, fmt.Errorf("couldn't find separator in expected field: %s", mountInfo[mountInfoLength-4]) + return nil, fmt.Errorf("%w: couldn't find separator in expected field: %s", ErrFileParse, mountInfo[mountInfoLength-4]) } mount := &MountInfo{ @@ -98,18 +98,18 @@ func parseMountInfoString(mountString string) (*MountInfo, error) { mount.MountID, err = strconv.Atoi(mountInfo[0]) if err != nil { - return nil, fmt.Errorf("failed to parse mount ID") + return nil, fmt.Errorf("%w: mount ID: %q", ErrFileParse, mount.MountID) } mount.ParentID, err = strconv.Atoi(mountInfo[1]) if err != nil { - return nil, fmt.Errorf("failed to parse parent ID") + return nil, fmt.Errorf("%w: parent ID: %q", ErrFileParse, mount.ParentID) } // Has optional fields, which is a space separated list of values. // Example: shared:2 master:7 if mountInfo[6] != "" { mount.OptionalFields, err = mountOptionsParseOptionalFields(mountInfo[6 : mountInfoLength-4]) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: %w", ErrFileParse, err) } } return mount, nil diff --git a/test/performance/vendor/github.com/prometheus/procfs/mountstats.go b/test/performance/vendor/github.com/prometheus/procfs/mountstats.go index f7a828bb1..852c8c4a0 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/mountstats.go +++ b/test/performance/vendor/github.com/prometheus/procfs/mountstats.go @@ -186,6 +186,8 @@ type NFSOperationStats struct { CumulativeTotalResponseMilliseconds uint64 // Duration from when a request was enqueued to when it was completely handled. CumulativeTotalRequestMilliseconds uint64 + // The average time from the point the client sends RPC requests until it receives the response. + AverageRTTMilliseconds float64 // The count of operations that complete with tk_status < 0. These statuses usually indicate error conditions. Errors uint64 } @@ -264,7 +266,7 @@ func parseMountStats(r io.Reader) ([]*Mount, error) { if len(ss) > deviceEntryLen { // Only NFSv3 and v4 are supported for parsing statistics if m.Type != nfs3Type && m.Type != nfs4Type { - return nil, fmt.Errorf("cannot parse MountStats for fstype %q", m.Type) + return nil, fmt.Errorf("%w: Cannot parse MountStats for %q", ErrFileParse, m.Type) } statVersion := strings.TrimPrefix(ss[8], statVersionPrefix) @@ -284,10 +286,11 @@ func parseMountStats(r io.Reader) ([]*Mount, error) { } // parseMount parses an entry in /proc/[pid]/mountstats in the format: -// device [device] mounted on [mount] with fstype [type] +// +// device [device] mounted on [mount] with fstype [type] func parseMount(ss []string) (*Mount, error) { if len(ss) < deviceEntryLen { - return nil, fmt.Errorf("invalid device entry: %v", ss) + return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss) } // Check for specific words appearing at specific indices to ensure @@ -305,7 +308,7 @@ func parseMount(ss []string) (*Mount, error) { for _, f := range format { if ss[f.i] != f.s { - return nil, fmt.Errorf("invalid device entry: %v", ss) + return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss) } } @@ -342,7 +345,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e switch ss[0] { case fieldOpts: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss) } if stats.Opts == nil { stats.Opts = map[string]string{} @@ -357,7 +360,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e } case fieldAge: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss) } // Age integer is in seconds d, err := time.ParseDuration(ss[1] + "s") @@ -368,7 +371,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e stats.Age = d case fieldBytes: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss) } bstats, err := parseNFSBytesStats(ss[1:]) if err != nil { @@ -378,7 +381,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e stats.Bytes = *bstats case fieldEvents: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS events: %v", ErrFileParse, ss) } estats, err := parseNFSEventsStats(ss[1:]) if err != nil { @@ -388,7 +391,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e stats.Events = *estats case fieldTransport: if len(ss) < 3 { - return nil, fmt.Errorf("not enough information for NFS transport stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS transport stats: %v", ErrFileParse, ss) } tstats, err := parseNFSTransportStats(ss[1:], statVersion) @@ -427,7 +430,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e // integer fields. func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) { if len(ss) != fieldBytesLen { - return nil, fmt.Errorf("invalid NFS bytes stats: %v", ss) + return nil, fmt.Errorf("%w: Invalid NFS bytes stats: %v", ErrFileParse, ss) } ns := make([]uint64, 0, fieldBytesLen) @@ -456,7 +459,7 @@ func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) { // integer fields. func parseNFSEventsStats(ss []string) (*NFSEventsStats, error) { if len(ss) != fieldEventsLen { - return nil, fmt.Errorf("invalid NFS events stats: %v", ss) + return nil, fmt.Errorf("%w: invalid NFS events stats: %v", ErrFileParse, ss) } ns := make([]uint64, 0, fieldEventsLen) @@ -520,7 +523,7 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { } if len(ss) < minFields { - return nil, fmt.Errorf("invalid NFS per-operations stats: %v", ss) + return nil, fmt.Errorf("%w: invalid NFS per-operations stats: %v", ErrFileParse, ss) } // Skip string operation name for integers @@ -533,7 +536,6 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { ns = append(ns, n) } - opStats := NFSOperationStats{ Operation: strings.TrimSuffix(ss[0], ":"), Requests: ns[0], @@ -545,6 +547,9 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { CumulativeTotalResponseMilliseconds: ns[6], CumulativeTotalRequestMilliseconds: ns[7], } + if ns[0] != 0 { + opStats.AverageRTTMilliseconds = float64(ns[6]) / float64(ns[0]) + } if len(ns) > 8 { opStats.Errors = ns[8] @@ -571,10 +576,10 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats } else if protocol == "udp" { expectedLength = fieldTransport10UDPLen } else { - return nil, fmt.Errorf("invalid NFS protocol \"%s\" in stats 1.0 statement: %v", protocol, ss) + return nil, fmt.Errorf("%w: Invalid NFS protocol \"%s\" in stats 1.0 statement: %v", ErrFileParse, protocol, ss) } if len(ss) != expectedLength { - return nil, fmt.Errorf("invalid NFS transport stats 1.0 statement: %v", ss) + return nil, fmt.Errorf("%w: Invalid NFS transport stats 1.0 statement: %v", ErrFileParse, ss) } case statVersion11: var expectedLength int @@ -583,13 +588,13 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats } else if protocol == "udp" { expectedLength = fieldTransport11UDPLen } else { - return nil, fmt.Errorf("invalid NFS protocol \"%s\" in stats 1.1 statement: %v", protocol, ss) + return nil, fmt.Errorf("%w: invalid NFS protocol \"%s\" in stats 1.1 statement: %v", ErrFileParse, protocol, ss) } if len(ss) != expectedLength { - return nil, fmt.Errorf("invalid NFS transport stats 1.1 statement: %v", ss) + return nil, fmt.Errorf("%w: invalid NFS transport stats 1.1 statement: %v", ErrFileParse, ss) } default: - return nil, fmt.Errorf("unrecognized NFS transport stats version: %q", statVersion) + return nil, fmt.Errorf("%s: Unrecognized NFS transport stats version: %q", ErrFileParse, statVersion) } // Allocate enough for v1.1 stats since zero value for v1.1 stats will be okay diff --git a/test/performance/vendor/github.com/prometheus/procfs/net_conntrackstat.go b/test/performance/vendor/github.com/prometheus/procfs/net_conntrackstat.go index 8300daca0..fdfa45611 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/net_conntrackstat.go +++ b/test/performance/vendor/github.com/prometheus/procfs/net_conntrackstat.go @@ -18,7 +18,6 @@ import ( "bytes" "fmt" "io" - "strconv" "strings" "github.com/prometheus/procfs/internal/util" @@ -28,9 +27,13 @@ import ( // and contains netfilter conntrack statistics at one CPU core. type ConntrackStatEntry struct { Entries uint64 + Searched uint64 Found uint64 + New uint64 Invalid uint64 Ignore uint64 + Delete uint64 + DeleteList uint64 Insert uint64 InsertFailed uint64 Drop uint64 @@ -55,7 +58,7 @@ func readConntrackStat(path string) ([]ConntrackStatEntry, error) { stat, err := parseConntrackStat(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("failed to read conntrack stats from %q: %w", path, err) + return nil, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, path, err) } return stat, nil @@ -81,73 +84,35 @@ func parseConntrackStat(r io.Reader) ([]ConntrackStatEntry, error) { // Parses a ConntrackStatEntry from given array of fields. func parseConntrackStatEntry(fields []string) (*ConntrackStatEntry, error) { - if len(fields) != 17 { - return nil, fmt.Errorf("invalid conntrackstat entry, missing fields") - } - entry := &ConntrackStatEntry{} - - entries, err := parseConntrackStatField(fields[0]) - if err != nil { - return nil, err - } - entry.Entries = entries - - found, err := parseConntrackStatField(fields[2]) - if err != nil { - return nil, err - } - entry.Found = found - - invalid, err := parseConntrackStatField(fields[4]) - if err != nil { - return nil, err - } - entry.Invalid = invalid - - ignore, err := parseConntrackStatField(fields[5]) - if err != nil { - return nil, err - } - entry.Ignore = ignore - - insert, err := parseConntrackStatField(fields[8]) + entries, err := util.ParseHexUint64s(fields) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: Cannot parse entry: %d: %w", ErrFileParse, entries, err) } - entry.Insert = insert - - insertFailed, err := parseConntrackStatField(fields[9]) - if err != nil { - return nil, err + numEntries := len(entries) + if numEntries < 16 || numEntries > 17 { + return nil, + fmt.Errorf("%w: invalid conntrackstat entry, invalid number of fields: %d", ErrFileParse, numEntries) } - entry.InsertFailed = insertFailed - drop, err := parseConntrackStatField(fields[10]) - if err != nil { - return nil, err + stats := &ConntrackStatEntry{ + Entries: *entries[0], + Searched: *entries[1], + Found: *entries[2], + New: *entries[3], + Invalid: *entries[4], + Ignore: *entries[5], + Delete: *entries[6], + DeleteList: *entries[7], + Insert: *entries[8], + InsertFailed: *entries[9], + Drop: *entries[10], + EarlyDrop: *entries[11], } - entry.Drop = drop - earlyDrop, err := parseConntrackStatField(fields[11]) - if err != nil { - return nil, err + // Ignore missing search_restart on Linux < 2.6.35. + if numEntries == 17 { + stats.SearchRestart = *entries[16] } - entry.EarlyDrop = earlyDrop - searchRestart, err := parseConntrackStatField(fields[16]) - if err != nil { - return nil, err - } - entry.SearchRestart = searchRestart - - return entry, nil -} - -// Parses a uint64 from given hex in string. -func parseConntrackStatField(field string) (uint64, error) { - val, err := strconv.ParseUint(field, 16, 64) - if err != nil { - return 0, fmt.Errorf("couldn't parse %q field: %w", field, err) - } - return val, err + return stats, nil } diff --git a/test/performance/vendor/github.com/prometheus/procfs/net_ip_socket.go b/test/performance/vendor/github.com/prometheus/procfs/net_ip_socket.go index 7fd57d7f4..4da81ea57 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/net_ip_socket.go +++ b/test/performance/vendor/github.com/prometheus/procfs/net_ip_socket.go @@ -130,7 +130,7 @@ func parseIP(hexIP string) (net.IP, error) { var byteIP []byte byteIP, err := hex.DecodeString(hexIP) if err != nil { - return nil, fmt.Errorf("cannot parse address field in socket line %q", hexIP) + return nil, fmt.Errorf("%s: Cannot parse socket field in %q: %w", ErrFileParse, hexIP, err) } switch len(byteIP) { case 4: @@ -144,7 +144,7 @@ func parseIP(hexIP string) (net.IP, error) { } return i, nil default: - return nil, fmt.Errorf("Unable to parse IP %s", hexIP) + return nil, fmt.Errorf("%s: Unable to parse IP %s: %w", ErrFileParse, hexIP, nil) } } @@ -153,7 +153,8 @@ func parseNetIPSocketLine(fields []string) (*netIPSocketLine, error) { line := &netIPSocketLine{} if len(fields) < 10 { return nil, fmt.Errorf( - "cannot parse net socket line as it has less then 10 columns %q", + "%w: Less than 10 columns found %q", + ErrFileParse, strings.Join(fields, " "), ) } @@ -162,64 +163,65 @@ func parseNetIPSocketLine(fields []string) (*netIPSocketLine, error) { // sl s := strings.Split(fields[0], ":") if len(s) != 2 { - return nil, fmt.Errorf("cannot parse sl field in socket line %q", fields[0]) + return nil, fmt.Errorf("%w: Unable to parse sl field in line %q", ErrFileParse, fields[0]) } if line.Sl, err = strconv.ParseUint(s[0], 0, 64); err != nil { - return nil, fmt.Errorf("cannot parse sl value in socket line: %w", err) + return nil, fmt.Errorf("%s: Unable to parse sl field in %q: %w", ErrFileParse, line.Sl, err) } // local_address l := strings.Split(fields[1], ":") if len(l) != 2 { - return nil, fmt.Errorf("cannot parse local_address field in socket line %q", fields[1]) + return nil, fmt.Errorf("%w: Unable to parse local_address field in %q", ErrFileParse, fields[1]) } if line.LocalAddr, err = parseIP(l[0]); err != nil { return nil, err } if line.LocalPort, err = strconv.ParseUint(l[1], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse local_address port value in socket line: %w", err) + return nil, fmt.Errorf("%s: Unable to parse local_address port value line %q: %w", ErrFileParse, line.LocalPort, err) } // remote_address r := strings.Split(fields[2], ":") if len(r) != 2 { - return nil, fmt.Errorf("cannot parse rem_address field in socket line %q", fields[1]) + return nil, fmt.Errorf("%w: Unable to parse rem_address field in %q", ErrFileParse, fields[1]) } if line.RemAddr, err = parseIP(r[0]); err != nil { return nil, err } if line.RemPort, err = strconv.ParseUint(r[1], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse rem_address port value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse rem_address port value in %q: %w", ErrFileParse, line.RemPort, err) } // st if line.St, err = strconv.ParseUint(fields[3], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse st value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse st value in %q: %w", ErrFileParse, line.St, err) } // tx_queue and rx_queue q := strings.Split(fields[4], ":") if len(q) != 2 { return nil, fmt.Errorf( - "cannot parse tx/rx queues in socket line as it has a missing colon %q", + "%w: Missing colon for tx/rx queues in socket line %q", + ErrFileParse, fields[4], ) } if line.TxQueue, err = strconv.ParseUint(q[0], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse tx_queue value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse tx_queue value in %q: %w", ErrFileParse, line.TxQueue, err) } if line.RxQueue, err = strconv.ParseUint(q[1], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse rx_queue value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse trx_queue value in %q: %w", ErrFileParse, line.RxQueue, err) } // uid if line.UID, err = strconv.ParseUint(fields[7], 0, 64); err != nil { - return nil, fmt.Errorf("cannot parse uid value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse UID value in %q: %w", ErrFileParse, line.UID, err) } // inode if line.Inode, err = strconv.ParseUint(fields[9], 0, 64); err != nil { - return nil, fmt.Errorf("cannot parse inode value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse inode value in %q: %w", ErrFileParse, line.Inode, err) } return line, nil diff --git a/test/performance/vendor/github.com/prometheus/procfs/net_protocols.go b/test/performance/vendor/github.com/prometheus/procfs/net_protocols.go index 374b6f73f..b6c77b709 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/net_protocols.go +++ b/test/performance/vendor/github.com/prometheus/procfs/net_protocols.go @@ -131,7 +131,7 @@ func (ps NetProtocolStats) parseLine(rawLine string) (*NetProtocolStatLine, erro } else if fields[6] == disabled { line.Slab = false } else { - return nil, fmt.Errorf("unable to parse capability for protocol: %s", line.Name) + return nil, fmt.Errorf("%w: capability for protocol: %s", ErrFileParse, line.Name) } line.ModuleName = fields[7] @@ -173,7 +173,7 @@ func (pc *NetProtocolCapabilities) parseCapabilities(capabilities []string) erro } else if capabilities[i] == "n" { *capabilityFields[i] = false } else { - return fmt.Errorf("unable to parse capability block for protocol: position %d", i) + return fmt.Errorf("%w: capability block for protocol: position %d", ErrFileParse, i) } } return nil diff --git a/test/performance/vendor/github.com/prometheus/procfs/net_route.go b/test/performance/vendor/github.com/prometheus/procfs/net_route.go new file mode 100644 index 000000000..deb7029fe --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/procfs/net_route.go @@ -0,0 +1,143 @@ +// Copyright 2023 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strconv" + "strings" + + "github.com/prometheus/procfs/internal/util" +) + +const ( + blackholeRepresentation string = "*" + blackholeIfaceName string = "blackhole" + routeLineColumns int = 11 +) + +// A NetRouteLine represents one line from net/route. +type NetRouteLine struct { + Iface string + Destination uint32 + Gateway uint32 + Flags uint32 + RefCnt uint32 + Use uint32 + Metric uint32 + Mask uint32 + MTU uint32 + Window uint32 + IRTT uint32 +} + +func (fs FS) NetRoute() ([]NetRouteLine, error) { + return readNetRoute(fs.proc.Path("net", "route")) +} + +func readNetRoute(path string) ([]NetRouteLine, error) { + b, err := util.ReadFileNoStat(path) + if err != nil { + return nil, err + } + + routelines, err := parseNetRoute(bytes.NewReader(b)) + if err != nil { + return nil, fmt.Errorf("failed to read net route from %s: %w", path, err) + } + return routelines, nil +} + +func parseNetRoute(r io.Reader) ([]NetRouteLine, error) { + var routelines []NetRouteLine + + scanner := bufio.NewScanner(r) + scanner.Scan() + for scanner.Scan() { + fields := strings.Fields(scanner.Text()) + routeline, err := parseNetRouteLine(fields) + if err != nil { + return nil, err + } + routelines = append(routelines, *routeline) + } + return routelines, nil +} + +func parseNetRouteLine(fields []string) (*NetRouteLine, error) { + if len(fields) != routeLineColumns { + return nil, fmt.Errorf("invalid routeline, num of digits: %d", len(fields)) + } + iface := fields[0] + if iface == blackholeRepresentation { + iface = blackholeIfaceName + } + destination, err := strconv.ParseUint(fields[1], 16, 32) + if err != nil { + return nil, err + } + gateway, err := strconv.ParseUint(fields[2], 16, 32) + if err != nil { + return nil, err + } + flags, err := strconv.ParseUint(fields[3], 10, 32) + if err != nil { + return nil, err + } + refcnt, err := strconv.ParseUint(fields[4], 10, 32) + if err != nil { + return nil, err + } + use, err := strconv.ParseUint(fields[5], 10, 32) + if err != nil { + return nil, err + } + metric, err := strconv.ParseUint(fields[6], 10, 32) + if err != nil { + return nil, err + } + mask, err := strconv.ParseUint(fields[7], 16, 32) + if err != nil { + return nil, err + } + mtu, err := strconv.ParseUint(fields[8], 10, 32) + if err != nil { + return nil, err + } + window, err := strconv.ParseUint(fields[9], 10, 32) + if err != nil { + return nil, err + } + irtt, err := strconv.ParseUint(fields[10], 10, 32) + if err != nil { + return nil, err + } + routeline := &NetRouteLine{ + Iface: iface, + Destination: uint32(destination), + Gateway: uint32(gateway), + Flags: uint32(flags), + RefCnt: uint32(refcnt), + Use: uint32(use), + Metric: uint32(metric), + Mask: uint32(mask), + MTU: uint32(mtu), + Window: uint32(window), + IRTT: uint32(irtt), + } + return routeline, nil +} diff --git a/test/performance/vendor/github.com/prometheus/procfs/net_sockstat.go b/test/performance/vendor/github.com/prometheus/procfs/net_sockstat.go index e36f4872d..360e36af7 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/net_sockstat.go +++ b/test/performance/vendor/github.com/prometheus/procfs/net_sockstat.go @@ -16,7 +16,6 @@ package procfs import ( "bufio" "bytes" - "errors" "fmt" "io" "strings" @@ -70,7 +69,7 @@ func readSockstat(name string) (*NetSockstat, error) { stat, err := parseSockstat(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("failed to read sockstats from %q: %w", name, err) + return nil, fmt.Errorf("%s: sockstats from %q: %w", ErrFileRead, name, err) } return stat, nil @@ -84,13 +83,13 @@ func parseSockstat(r io.Reader) (*NetSockstat, error) { // Expect a minimum of a protocol and one key/value pair. fields := strings.Split(s.Text(), " ") if len(fields) < 3 { - return nil, fmt.Errorf("malformed sockstat line: %q", s.Text()) + return nil, fmt.Errorf("%w: Malformed sockstat line: %q", ErrFileParse, s.Text()) } // The remaining fields are key/value pairs. kvs, err := parseSockstatKVs(fields[1:]) if err != nil { - return nil, fmt.Errorf("error parsing sockstat key/value pairs from %q: %w", s.Text(), err) + return nil, fmt.Errorf("%s: sockstat key/value pairs from %q: %w", ErrFileParse, s.Text(), err) } // The first field is the protocol. We must trim its colon suffix. @@ -119,7 +118,7 @@ func parseSockstat(r io.Reader) (*NetSockstat, error) { // parseSockstatKVs parses a string slice into a map of key/value pairs. func parseSockstatKVs(kvs []string) (map[string]int, error) { if len(kvs)%2 != 0 { - return nil, errors.New("odd number of fields in key/value pairs") + return nil, fmt.Errorf("%w:: Odd number of fields in key/value pairs %q", ErrFileParse, kvs) } // Iterate two values at a time to gather key/value pairs. diff --git a/test/performance/vendor/github.com/prometheus/procfs/net_softnet.go b/test/performance/vendor/github.com/prometheus/procfs/net_softnet.go index a94f86dc4..c77085291 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/net_softnet.go +++ b/test/performance/vendor/github.com/prometheus/procfs/net_softnet.go @@ -27,8 +27,9 @@ import ( // For the proc file format details, // See: // * Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2343 -// * Linux 4.17 https://elixir.bootlin.com/linux/v4.17/source/net/core/net-procfs.c#L162 -// and https://elixir.bootlin.com/linux/v4.17/source/include/linux/netdevice.h#L2810. +// * Linux 2.6.39 https://elixir.bootlin.com/linux/v2.6.39/source/net/core/dev.c#L4086 +// * Linux 4.18 https://elixir.bootlin.com/linux/v4.18/source/net/core/net-procfs.c#L162 +// * Linux 5.14 https://elixir.bootlin.com/linux/v5.14/source/net/core/net-procfs.c#L169 // SoftnetStat contains a single row of data from /proc/net/softnet_stat. type SoftnetStat struct { @@ -38,6 +39,18 @@ type SoftnetStat struct { Dropped uint32 // Number of times processing packets ran out of quota. TimeSqueezed uint32 + // Number of collision occur while obtaining device lock while transmitting. + CPUCollision uint32 + // Number of times cpu woken up received_rps. + ReceivedRps uint32 + // number of times flow limit has been reached. + FlowLimitCount uint32 + // Softnet backlog status. + SoftnetBacklogLen uint32 + // CPU id owning this softnet_data. + Index uint32 + // softnet_data's Width. + Width int } var softNetProcFile = "net/softnet_stat" @@ -51,7 +64,7 @@ func (fs FS) NetSoftnetStat() ([]SoftnetStat, error) { entries, err := parseSoftnet(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("failed to parse /proc/net/softnet_stat: %w", err) + return nil, fmt.Errorf("%s: /proc/net/softnet_stat: %w", ErrFileParse, err) } return entries, nil @@ -63,25 +76,65 @@ func parseSoftnet(r io.Reader) ([]SoftnetStat, error) { s := bufio.NewScanner(r) var stats []SoftnetStat + cpuIndex := 0 for s.Scan() { columns := strings.Fields(s.Text()) width := len(columns) + softnetStat := SoftnetStat{} if width < minColumns { - return nil, fmt.Errorf("%d columns were detected, but at least %d were expected", width, minColumns) + return nil, fmt.Errorf("%w: detected %d columns, but expected at least %d", ErrFileParse, width, minColumns) } - // We only parse the first three columns at the moment. - us, err := parseHexUint32s(columns[0:3]) - if err != nil { - return nil, err + // Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2347 + if width >= minColumns { + us, err := parseHexUint32s(columns[0:9]) + if err != nil { + return nil, err + } + + softnetStat.Processed = us[0] + softnetStat.Dropped = us[1] + softnetStat.TimeSqueezed = us[2] + softnetStat.CPUCollision = us[8] + } + + // Linux 2.6.39 https://elixir.bootlin.com/linux/v2.6.39/source/net/core/dev.c#L4086 + if width >= 10 { + us, err := parseHexUint32s(columns[9:10]) + if err != nil { + return nil, err + } + + softnetStat.ReceivedRps = us[0] } - stats = append(stats, SoftnetStat{ - Processed: us[0], - Dropped: us[1], - TimeSqueezed: us[2], - }) + // Linux 4.18 https://elixir.bootlin.com/linux/v4.18/source/net/core/net-procfs.c#L162 + if width >= 11 { + us, err := parseHexUint32s(columns[10:11]) + if err != nil { + return nil, err + } + + softnetStat.FlowLimitCount = us[0] + } + + // Linux 5.14 https://elixir.bootlin.com/linux/v5.14/source/net/core/net-procfs.c#L169 + if width >= 13 { + us, err := parseHexUint32s(columns[11:13]) + if err != nil { + return nil, err + } + + softnetStat.SoftnetBacklogLen = us[0] + softnetStat.Index = us[1] + } else { + // For older kernels, create the Index based on the scan line number. + softnetStat.Index = uint32(cpuIndex) + } + softnetStat.Width = width + stats = append(stats, softnetStat) + cpuIndex++ } return stats, nil diff --git a/test/performance/vendor/github.com/prometheus/procfs/net_unix.go b/test/performance/vendor/github.com/prometheus/procfs/net_unix.go index 98aa8e1c3..acbbc57ea 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/net_unix.go +++ b/test/performance/vendor/github.com/prometheus/procfs/net_unix.go @@ -108,14 +108,14 @@ func parseNetUNIX(r io.Reader) (*NetUNIX, error) { line := s.Text() item, err := nu.parseLine(line, hasInode, minFields) if err != nil { - return nil, fmt.Errorf("failed to parse /proc/net/unix data %q: %w", line, err) + return nil, fmt.Errorf("%s: /proc/net/unix encountered data %q: %w", ErrFileParse, line, err) } nu.Rows = append(nu.Rows, item) } if err := s.Err(); err != nil { - return nil, fmt.Errorf("failed to scan /proc/net/unix data: %w", err) + return nil, fmt.Errorf("%s: /proc/net/unix encountered data: %w", ErrFileParse, err) } return &nu, nil @@ -126,7 +126,7 @@ func (u *NetUNIX) parseLine(line string, hasInode bool, min int) (*NetUNIXLine, l := len(fields) if l < min { - return nil, fmt.Errorf("expected at least %d fields but got %d", min, l) + return nil, fmt.Errorf("%w: expected at least %d fields but got %d", ErrFileParse, min, l) } // Field offsets are as follows: @@ -136,29 +136,29 @@ func (u *NetUNIX) parseLine(line string, hasInode bool, min int) (*NetUNIXLine, users, err := u.parseUsers(fields[1]) if err != nil { - return nil, fmt.Errorf("failed to parse ref count %q: %w", fields[1], err) + return nil, fmt.Errorf("%s: ref count %q: %w", ErrFileParse, fields[1], err) } flags, err := u.parseFlags(fields[3]) if err != nil { - return nil, fmt.Errorf("failed to parse flags %q: %w", fields[3], err) + return nil, fmt.Errorf("%s: Unable to parse flags %q: %w", ErrFileParse, fields[3], err) } typ, err := u.parseType(fields[4]) if err != nil { - return nil, fmt.Errorf("failed to parse type %q: %w", fields[4], err) + return nil, fmt.Errorf("%s: Failed to parse type %q: %w", ErrFileParse, fields[4], err) } state, err := u.parseState(fields[5]) if err != nil { - return nil, fmt.Errorf("failed to parse state %q: %w", fields[5], err) + return nil, fmt.Errorf("%s: Failed to parse state %q: %w", ErrFileParse, fields[5], err) } var inode uint64 if hasInode { inode, err = u.parseInode(fields[6]) if err != nil { - return nil, fmt.Errorf("failed to parse inode %q: %w", fields[6], err) + return nil, fmt.Errorf("%s failed to parse inode %q: %w", ErrFileParse, fields[6], err) } } diff --git a/test/performance/vendor/github.com/prometheus/procfs/net_wireless.go b/test/performance/vendor/github.com/prometheus/procfs/net_wireless.go new file mode 100644 index 000000000..7443edca9 --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/procfs/net_wireless.go @@ -0,0 +1,182 @@ +// Copyright 2023 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strconv" + "strings" + + "github.com/prometheus/procfs/internal/util" +) + +// Wireless models the content of /proc/net/wireless. +type Wireless struct { + Name string + + // Status is the current 4-digit hex value status of the interface. + Status uint64 + + // QualityLink is the link quality. + QualityLink int + + // QualityLevel is the signal gain (dBm). + QualityLevel int + + // QualityNoise is the signal noise baseline (dBm). + QualityNoise int + + // DiscardedNwid is the number of discarded packets with wrong nwid/essid. + DiscardedNwid int + + // DiscardedCrypt is the number of discarded packets with wrong code/decode (WEP). + DiscardedCrypt int + + // DiscardedFrag is the number of discarded packets that can't perform MAC reassembly. + DiscardedFrag int + + // DiscardedRetry is the number of discarded packets that reached max MAC retries. + DiscardedRetry int + + // DiscardedMisc is the number of discarded packets for other reasons. + DiscardedMisc int + + // MissedBeacon is the number of missed beacons/superframe. + MissedBeacon int +} + +// Wireless returns kernel wireless statistics. +func (fs FS) Wireless() ([]*Wireless, error) { + b, err := util.ReadFileNoStat(fs.proc.Path("net/wireless")) + if err != nil { + return nil, err + } + + m, err := parseWireless(bytes.NewReader(b)) + if err != nil { + return nil, fmt.Errorf("%s: wireless: %w", ErrFileParse, err) + } + + return m, nil +} + +// parseWireless parses the contents of /proc/net/wireless. +/* +Inter-| sta-| Quality | Discarded packets | Missed | WE +face | tus | link level noise | nwid crypt frag retry misc | beacon | 22 + eth1: 0000 5. -256. -10. 0 1 0 3 0 0 + eth2: 0000 5. -256. -20. 0 2 0 4 0 0 +*/ +func parseWireless(r io.Reader) ([]*Wireless, error) { + var ( + interfaces []*Wireless + scanner = bufio.NewScanner(r) + ) + + for n := 0; scanner.Scan(); n++ { + // Skip the 2 header lines. + if n < 2 { + continue + } + + line := scanner.Text() + + parts := strings.Split(line, ":") + if len(parts) != 2 { + return nil, fmt.Errorf("%w: expected 2 parts after splitting line by ':', got %d for line %q", ErrFileParse, len(parts), line) + } + + name := strings.TrimSpace(parts[0]) + stats := strings.Fields(parts[1]) + + if len(stats) < 10 { + return nil, fmt.Errorf("%w: invalid number of fields in line %d, expected 10+, got %d: %q", ErrFileParse, n, len(stats), line) + } + + status, err := strconv.ParseUint(stats[0], 16, 16) + if err != nil { + return nil, fmt.Errorf("%w: invalid status in line %d: %q", ErrFileParse, n, line) + } + + qlink, err := strconv.Atoi(strings.TrimSuffix(stats[1], ".")) + if err != nil { + return nil, fmt.Errorf("%s: parse Quality:link as integer %q: %w", ErrFileParse, qlink, err) + } + + qlevel, err := strconv.Atoi(strings.TrimSuffix(stats[2], ".")) + if err != nil { + return nil, fmt.Errorf("%s: Quality:level as integer %q: %w", ErrFileParse, qlevel, err) + } + + qnoise, err := strconv.Atoi(strings.TrimSuffix(stats[3], ".")) + if err != nil { + return nil, fmt.Errorf("%s: Quality:noise as integer %q: %w", ErrFileParse, qnoise, err) + } + + dnwid, err := strconv.Atoi(stats[4]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:nwid as integer %q: %w", ErrFileParse, dnwid, err) + } + + dcrypt, err := strconv.Atoi(stats[5]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:crypt as integer %q: %w", ErrFileParse, dcrypt, err) + } + + dfrag, err := strconv.Atoi(stats[6]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:frag as integer %q: %w", ErrFileParse, dfrag, err) + } + + dretry, err := strconv.Atoi(stats[7]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:retry as integer %q: %w", ErrFileParse, dretry, err) + } + + dmisc, err := strconv.Atoi(stats[8]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:misc as integer %q: %w", ErrFileParse, dmisc, err) + } + + mbeacon, err := strconv.Atoi(stats[9]) + if err != nil { + return nil, fmt.Errorf("%s: Missed:beacon as integer %q: %w", ErrFileParse, mbeacon, err) + } + + w := &Wireless{ + Name: name, + Status: status, + QualityLink: qlink, + QualityLevel: qlevel, + QualityNoise: qnoise, + DiscardedNwid: dnwid, + DiscardedCrypt: dcrypt, + DiscardedFrag: dfrag, + DiscardedRetry: dretry, + DiscardedMisc: dmisc, + MissedBeacon: mbeacon, + } + + interfaces = append(interfaces, w) + } + + if err := scanner.Err(); err != nil { + return nil, fmt.Errorf("%s: Failed to scan /proc/net/wireless: %w", ErrFileRead, err) + } + + return interfaces, nil +} diff --git a/test/performance/vendor/github.com/prometheus/procfs/net_xfrm.go b/test/performance/vendor/github.com/prometheus/procfs/net_xfrm.go index f9d9d243d..932ef2046 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/net_xfrm.go +++ b/test/performance/vendor/github.com/prometheus/procfs/net_xfrm.go @@ -115,7 +115,7 @@ func (fs FS) NewXfrmStat() (XfrmStat, error) { fields := strings.Fields(s.Text()) if len(fields) != 2 { - return XfrmStat{}, fmt.Errorf("couldn't parse %q line %q", file.Name(), s.Text()) + return XfrmStat{}, fmt.Errorf("%w: %q line %q", ErrFileParse, file.Name(), s.Text()) } name := fields[0] diff --git a/test/performance/vendor/github.com/prometheus/procfs/netstat.go b/test/performance/vendor/github.com/prometheus/procfs/netstat.go index dcea9c5a6..742dff453 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/netstat.go +++ b/test/performance/vendor/github.com/prometheus/procfs/netstat.go @@ -37,32 +37,46 @@ func (fs FS) NetStat() ([]NetStat, error) { var netStatsTotal []NetStat for _, filePath := range statFiles { - file, err := os.Open(filePath) + procNetstat, err := parseNetstat(filePath) if err != nil { return nil, err } + procNetstat.Filename = filepath.Base(filePath) - netStatFile := NetStat{ - Filename: filepath.Base(filePath), - Stats: make(map[string][]uint64), - } - scanner := bufio.NewScanner(file) - scanner.Scan() - // First string is always a header for stats - var headers []string - headers = append(headers, strings.Fields(scanner.Text())...) + netStatsTotal = append(netStatsTotal, procNetstat) + } + return netStatsTotal, nil +} + +// parseNetstat parses the metrics from `/proc/net/stat/` file +// and returns a NetStat structure. +func parseNetstat(filePath string) (NetStat, error) { + netStat := NetStat{ + Stats: make(map[string][]uint64), + } + file, err := os.Open(filePath) + if err != nil { + return netStat, err + } + defer file.Close() + + scanner := bufio.NewScanner(file) + scanner.Scan() - // Other strings represent per-CPU counters - for scanner.Scan() { - for num, counter := range strings.Fields(scanner.Text()) { - value, err := strconv.ParseUint(counter, 16, 64) - if err != nil { - return nil, err - } - netStatFile.Stats[headers[num]] = append(netStatFile.Stats[headers[num]], value) + // First string is always a header for stats + var headers []string + headers = append(headers, strings.Fields(scanner.Text())...) + + // Other strings represent per-CPU counters + for scanner.Scan() { + for num, counter := range strings.Fields(scanner.Text()) { + value, err := strconv.ParseUint(counter, 16, 64) + if err != nil { + return NetStat{}, err } + netStat.Stats[headers[num]] = append(netStat.Stats[headers[num]], value) } - netStatsTotal = append(netStatsTotal, netStatFile) } - return netStatsTotal, nil + + return netStat, nil } diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc.go b/test/performance/vendor/github.com/prometheus/procfs/proc.go index c30223af7..e1599961f 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc.go @@ -15,13 +15,13 @@ package procfs import ( "bytes" + "errors" "fmt" "io" "os" "strconv" "strings" - "github.com/prometheus/procfs/internal/fs" "github.com/prometheus/procfs/internal/util" ) @@ -30,12 +30,18 @@ type Proc struct { // The process ID. PID int - fs fs.FS + fs FS } // Procs represents a list of Proc structs. type Procs []Proc +var ( + ErrFileParse = errors.New("Error Parsing File") + ErrFileRead = errors.New("Error Reading File") + ErrMountPoint = errors.New("Error Accessing Mount point") +) + func (p Procs) Len() int { return len(p) } func (p Procs) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p Procs) Less(i, j int) bool { return p[i].PID < p[j].PID } @@ -43,7 +49,7 @@ func (p Procs) Less(i, j int) bool { return p[i].PID < p[j].PID } // Self returns a process for the current process read via /proc/self. func Self() (Proc, error) { fs, err := NewFS(DefaultMountPoint) - if err != nil { + if err != nil || errors.Unwrap(err) == ErrMountPoint { return Proc{}, err } return fs.Self() @@ -92,7 +98,7 @@ func (fs FS) Proc(pid int) (Proc, error) { if _, err := os.Stat(fs.proc.Path(strconv.Itoa(pid))); err != nil { return Proc{}, err } - return Proc{PID: pid, fs: fs.proc}, nil + return Proc{PID: pid, fs: fs}, nil } // AllProcs returns a list of all currently available processes. @@ -105,7 +111,7 @@ func (fs FS) AllProcs() (Procs, error) { names, err := d.Readdirnames(-1) if err != nil { - return Procs{}, fmt.Errorf("could not read %q: %w", d.Name(), err) + return Procs{}, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, names, err) } p := Procs{} @@ -114,7 +120,7 @@ func (fs FS) AllProcs() (Procs, error) { if err != nil { continue } - p = append(p, Proc{PID: int(pid), fs: fs.proc}) + p = append(p, Proc{PID: int(pid), fs: fs}) } return p, nil @@ -206,7 +212,7 @@ func (p Proc) FileDescriptors() ([]uintptr, error) { for i, n := range names { fd, err := strconv.ParseInt(n, 10, 32) if err != nil { - return nil, fmt.Errorf("could not parse fd %q: %w", n, err) + return nil, fmt.Errorf("%s: Cannot parse line: %v: %w", ErrFileParse, i, err) } fds[i] = uintptr(fd) } @@ -237,6 +243,19 @@ func (p Proc) FileDescriptorTargets() ([]string, error) { // FileDescriptorsLen returns the number of currently open file descriptors of // a process. func (p Proc) FileDescriptorsLen() (int, error) { + // Use fast path if available (Linux v6.2): https://github.com/torvalds/linux/commit/f1f1f2569901 + if p.fs.real { + stat, err := os.Stat(p.path("fd")) + if err != nil { + return 0, err + } + + size := stat.Size() + if size > 0 { + return int(size), nil + } + } + fds, err := p.fileDescriptors() if err != nil { return 0, err @@ -278,14 +297,14 @@ func (p Proc) fileDescriptors() ([]string, error) { names, err := d.Readdirnames(-1) if err != nil { - return nil, fmt.Errorf("could not read %q: %w", d.Name(), err) + return nil, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, names, err) } return names, nil } func (p Proc) path(pa ...string) string { - return p.fs.Path(append([]string{strconv.Itoa(p.PID)}, pa...)...) + return p.fs.proc.Path(append([]string{strconv.Itoa(p.PID)}, pa...)...) } // FileDescriptorsInfo retrieves information about all file descriptors of diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_cgroup.go b/test/performance/vendor/github.com/prometheus/procfs/proc_cgroup.go index cca03327c..daeed7f57 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_cgroup.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_cgroup.go @@ -23,7 +23,7 @@ import ( "github.com/prometheus/procfs/internal/util" ) -// Cgroup models one line from /proc/[pid]/cgroup. Each Cgroup struct describes the the placement of a PID inside a +// Cgroup models one line from /proc/[pid]/cgroup. Each Cgroup struct describes the placement of a PID inside a // specific control hierarchy. The kernel has two cgroup APIs, v1 and v2. v1 has one hierarchy per available resource // controller, while v2 has one unified hierarchy shared by all controllers. Regardless of v1 or v2, all hierarchies // contain all running processes, so the question answerable with a Cgroup struct is 'where is this process in @@ -51,7 +51,7 @@ func parseCgroupString(cgroupStr string) (*Cgroup, error) { fields := strings.SplitN(cgroupStr, ":", 3) if len(fields) < 3 { - return nil, fmt.Errorf("at least 3 fields required, found %d fields in cgroup string: %s", len(fields), cgroupStr) + return nil, fmt.Errorf("%w: 3+ fields required, found %d fields in cgroup string: %s", ErrFileParse, len(fields), cgroupStr) } cgroup := &Cgroup{ @@ -60,7 +60,7 @@ func parseCgroupString(cgroupStr string) (*Cgroup, error) { } cgroup.HierarchyID, err = strconv.Atoi(fields[0]) if err != nil { - return nil, fmt.Errorf("failed to parse hierarchy ID") + return nil, fmt.Errorf("%w: hierarchy ID: %q", ErrFileParse, cgroup.HierarchyID) } if fields[1] != "" { ssNames := strings.Split(fields[1], ",") diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_cgroups.go b/test/performance/vendor/github.com/prometheus/procfs/proc_cgroups.go index 24d4dce9c..5dd493899 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_cgroups.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_cgroups.go @@ -46,7 +46,7 @@ func parseCgroupSummaryString(CgroupSummaryStr string) (*CgroupSummary, error) { fields := strings.Fields(CgroupSummaryStr) // require at least 4 fields if len(fields) < 4 { - return nil, fmt.Errorf("at least 4 fields required, found %d fields in cgroup info string: %s", len(fields), CgroupSummaryStr) + return nil, fmt.Errorf("%w: 4+ fields required, found %d fields in cgroup info string: %s", ErrFileParse, len(fields), CgroupSummaryStr) } CgroupSummary := &CgroupSummary{ @@ -54,15 +54,15 @@ func parseCgroupSummaryString(CgroupSummaryStr string) (*CgroupSummary, error) { } CgroupSummary.Hierarchy, err = strconv.Atoi(fields[1]) if err != nil { - return nil, fmt.Errorf("failed to parse hierarchy ID") + return nil, fmt.Errorf("%w: Unable to parse hierarchy ID from %q", ErrFileParse, fields[1]) } CgroupSummary.Cgroups, err = strconv.Atoi(fields[2]) if err != nil { - return nil, fmt.Errorf("failed to parse Cgroup Num") + return nil, fmt.Errorf("%w: Unable to parse Cgroup Num from %q", ErrFileParse, fields[2]) } CgroupSummary.Enabled, err = strconv.Atoi(fields[3]) if err != nil { - return nil, fmt.Errorf("failed to parse Enabled") + return nil, fmt.Errorf("%w: Unable to parse Enabled from %q", ErrFileParse, fields[3]) } return CgroupSummary, nil } diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_fdinfo.go b/test/performance/vendor/github.com/prometheus/procfs/proc_fdinfo.go index 1bbdd4a8e..4b7933e4f 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_fdinfo.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_fdinfo.go @@ -111,7 +111,7 @@ func parseInotifyInfo(line string) (*InotifyInfo, error) { } return i, nil } - return nil, fmt.Errorf("invalid inode entry: %q", line) + return nil, fmt.Errorf("%w: invalid inode entry: %q", ErrFileParse, line) } // ProcFDInfos represents a list of ProcFDInfo structs. diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_interrupts.go b/test/performance/vendor/github.com/prometheus/procfs/proc_interrupts.go new file mode 100644 index 000000000..86b4b4524 --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_interrupts.go @@ -0,0 +1,98 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "bufio" + "bytes" + "errors" + "fmt" + "io" + "strconv" + "strings" + + "github.com/prometheus/procfs/internal/util" +) + +// Interrupt represents a single interrupt line. +type Interrupt struct { + // Info is the type of interrupt. + Info string + // Devices is the name of the device that is located at that IRQ + Devices string + // Values is the number of interrupts per CPU. + Values []string +} + +// Interrupts models the content of /proc/interrupts. Key is the IRQ number. +// - https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s2-proc-interrupts +// - https://raspberrypi.stackexchange.com/questions/105802/explanation-of-proc-interrupts-output +type Interrupts map[string]Interrupt + +// Interrupts creates a new instance from a given Proc instance. +func (p Proc) Interrupts() (Interrupts, error) { + data, err := util.ReadFileNoStat(p.path("interrupts")) + if err != nil { + return nil, err + } + return parseInterrupts(bytes.NewReader(data)) +} + +func parseInterrupts(r io.Reader) (Interrupts, error) { + var ( + interrupts = Interrupts{} + scanner = bufio.NewScanner(r) + ) + + if !scanner.Scan() { + return nil, errors.New("interrupts empty") + } + cpuNum := len(strings.Fields(scanner.Text())) // one header per cpu + + for scanner.Scan() { + parts := strings.Fields(scanner.Text()) + if len(parts) == 0 { // skip empty lines + continue + } + if len(parts) < 2 { + return nil, fmt.Errorf("%w: Not enough fields in interrupts (expected 2+ fields but got %d): %s", ErrFileParse, len(parts), parts) + } + intName := parts[0][:len(parts[0])-1] // remove trailing : + + if len(parts) == 2 { + interrupts[intName] = Interrupt{ + Info: "", + Devices: "", + Values: []string{ + parts[1], + }, + } + continue + } + + intr := Interrupt{ + Values: parts[1 : cpuNum+1], + } + + if _, err := strconv.Atoi(intName); err == nil { // numeral interrupt + intr.Info = parts[cpuNum+1] + intr.Devices = strings.Join(parts[cpuNum+2:], " ") + } else { + intr.Info = strings.Join(parts[cpuNum+1:], " ") + } + interrupts[intName] = intr + } + + return interrupts, scanner.Err() +} diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_limits.go b/test/performance/vendor/github.com/prometheus/procfs/proc_limits.go index 7a1388185..c86d815d7 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_limits.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_limits.go @@ -103,7 +103,7 @@ func (p Proc) Limits() (ProcLimits, error) { //fields := limitsMatch.Split(s.Text(), limitsFields) fields := limitsMatch.FindStringSubmatch(s.Text()) if len(fields) != limitsFields { - return ProcLimits{}, fmt.Errorf("couldn't parse %q line %q", f.Name(), s.Text()) + return ProcLimits{}, fmt.Errorf("%w: couldn't parse %q line %q", ErrFileParse, f.Name(), s.Text()) } switch fields[1] { @@ -154,7 +154,7 @@ func parseUint(s string) (uint64, error) { } i, err := strconv.ParseUint(s, 10, 64) if err != nil { - return 0, fmt.Errorf("couldn't parse value %q: %w", s, err) + return 0, fmt.Errorf("%s: couldn't parse value %q: %w", ErrFileParse, s, err) } return i, nil } diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_maps.go b/test/performance/vendor/github.com/prometheus/procfs/proc_maps.go index f1bcbf32b..727549a13 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_maps.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_maps.go @@ -65,7 +65,7 @@ type ProcMap struct { func parseDevice(s string) (uint64, error) { toks := strings.Split(s, ":") if len(toks) < 2 { - return 0, fmt.Errorf("unexpected number of fields") + return 0, fmt.Errorf("%w: unexpected number of fields, expected: 2, got: %q", ErrFileParse, len(toks)) } major, err := strconv.ParseUint(toks[0], 16, 0) @@ -95,7 +95,7 @@ func parseAddress(s string) (uintptr, error) { func parseAddresses(s string) (uintptr, uintptr, error) { toks := strings.Split(s, "-") if len(toks) < 2 { - return 0, 0, fmt.Errorf("invalid address") + return 0, 0, fmt.Errorf("%w: invalid address", ErrFileParse) } saddr, err := parseAddress(toks[0]) @@ -114,7 +114,7 @@ func parseAddresses(s string) (uintptr, uintptr, error) { // parsePermissions parses a token and returns any that are set. func parsePermissions(s string) (*ProcMapPermissions, error) { if len(s) < 4 { - return nil, fmt.Errorf("invalid permissions token") + return nil, fmt.Errorf("%w: invalid permissions token", ErrFileParse) } perms := ProcMapPermissions{} @@ -141,7 +141,7 @@ func parsePermissions(s string) (*ProcMapPermissions, error) { func parseProcMap(text string) (*ProcMap, error) { fields := strings.Fields(text) if len(fields) < 5 { - return nil, fmt.Errorf("truncated procmap entry") + return nil, fmt.Errorf("%w: truncated procmap entry", ErrFileParse) } saddr, eaddr, err := parseAddresses(fields[0]) diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_netstat.go b/test/performance/vendor/github.com/prometheus/procfs/proc_netstat.go index 48b523819..8e3ff4d79 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_netstat.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_netstat.go @@ -33,139 +33,140 @@ type ProcNetstat struct { } type TcpExt struct { // nolint:revive - SyncookiesSent float64 - SyncookiesRecv float64 - SyncookiesFailed float64 - EmbryonicRsts float64 - PruneCalled float64 - RcvPruned float64 - OfoPruned float64 - OutOfWindowIcmps float64 - LockDroppedIcmps float64 - ArpFilter float64 - TW float64 - TWRecycled float64 - TWKilled float64 - PAWSActive float64 - PAWSEstab float64 - DelayedACKs float64 - DelayedACKLocked float64 - DelayedACKLost float64 - ListenOverflows float64 - ListenDrops float64 - TCPHPHits float64 - TCPPureAcks float64 - TCPHPAcks float64 - TCPRenoRecovery float64 - TCPSackRecovery float64 - TCPSACKReneging float64 - TCPSACKReorder float64 - TCPRenoReorder float64 - TCPTSReorder float64 - TCPFullUndo float64 - TCPPartialUndo float64 - TCPDSACKUndo float64 - TCPLossUndo float64 - TCPLostRetransmit float64 - TCPRenoFailures float64 - TCPSackFailures float64 - TCPLossFailures float64 - TCPFastRetrans float64 - TCPSlowStartRetrans float64 - TCPTimeouts float64 - TCPLossProbes float64 - TCPLossProbeRecovery float64 - TCPRenoRecoveryFail float64 - TCPSackRecoveryFail float64 - TCPRcvCollapsed float64 - TCPDSACKOldSent float64 - TCPDSACKOfoSent float64 - TCPDSACKRecv float64 - TCPDSACKOfoRecv float64 - TCPAbortOnData float64 - TCPAbortOnClose float64 - TCPAbortOnMemory float64 - TCPAbortOnTimeout float64 - TCPAbortOnLinger float64 - TCPAbortFailed float64 - TCPMemoryPressures float64 - TCPMemoryPressuresChrono float64 - TCPSACKDiscard float64 - TCPDSACKIgnoredOld float64 - TCPDSACKIgnoredNoUndo float64 - TCPSpuriousRTOs float64 - TCPMD5NotFound float64 - TCPMD5Unexpected float64 - TCPMD5Failure float64 - TCPSackShifted float64 - TCPSackMerged float64 - TCPSackShiftFallback float64 - TCPBacklogDrop float64 - PFMemallocDrop float64 - TCPMinTTLDrop float64 - TCPDeferAcceptDrop float64 - IPReversePathFilter float64 - TCPTimeWaitOverflow float64 - TCPReqQFullDoCookies float64 - TCPReqQFullDrop float64 - TCPRetransFail float64 - TCPRcvCoalesce float64 - TCPOFOQueue float64 - TCPOFODrop float64 - TCPOFOMerge float64 - TCPChallengeACK float64 - TCPSYNChallenge float64 - TCPFastOpenActive float64 - TCPFastOpenActiveFail float64 - TCPFastOpenPassive float64 - TCPFastOpenPassiveFail float64 - TCPFastOpenListenOverflow float64 - TCPFastOpenCookieReqd float64 - TCPFastOpenBlackhole float64 - TCPSpuriousRtxHostQueues float64 - BusyPollRxPackets float64 - TCPAutoCorking float64 - TCPFromZeroWindowAdv float64 - TCPToZeroWindowAdv float64 - TCPWantZeroWindowAdv float64 - TCPSynRetrans float64 - TCPOrigDataSent float64 - TCPHystartTrainDetect float64 - TCPHystartTrainCwnd float64 - TCPHystartDelayDetect float64 - TCPHystartDelayCwnd float64 - TCPACKSkippedSynRecv float64 - TCPACKSkippedPAWS float64 - TCPACKSkippedSeq float64 - TCPACKSkippedFinWait2 float64 - TCPACKSkippedTimeWait float64 - TCPACKSkippedChallenge float64 - TCPWinProbe float64 - TCPKeepAlive float64 - TCPMTUPFail float64 - TCPMTUPSuccess float64 - TCPWqueueTooBig float64 + SyncookiesSent *float64 + SyncookiesRecv *float64 + SyncookiesFailed *float64 + EmbryonicRsts *float64 + PruneCalled *float64 + RcvPruned *float64 + OfoPruned *float64 + OutOfWindowIcmps *float64 + LockDroppedIcmps *float64 + ArpFilter *float64 + TW *float64 + TWRecycled *float64 + TWKilled *float64 + PAWSActive *float64 + PAWSEstab *float64 + DelayedACKs *float64 + DelayedACKLocked *float64 + DelayedACKLost *float64 + ListenOverflows *float64 + ListenDrops *float64 + TCPHPHits *float64 + TCPPureAcks *float64 + TCPHPAcks *float64 + TCPRenoRecovery *float64 + TCPSackRecovery *float64 + TCPSACKReneging *float64 + TCPSACKReorder *float64 + TCPRenoReorder *float64 + TCPTSReorder *float64 + TCPFullUndo *float64 + TCPPartialUndo *float64 + TCPDSACKUndo *float64 + TCPLossUndo *float64 + TCPLostRetransmit *float64 + TCPRenoFailures *float64 + TCPSackFailures *float64 + TCPLossFailures *float64 + TCPFastRetrans *float64 + TCPSlowStartRetrans *float64 + TCPTimeouts *float64 + TCPLossProbes *float64 + TCPLossProbeRecovery *float64 + TCPRenoRecoveryFail *float64 + TCPSackRecoveryFail *float64 + TCPRcvCollapsed *float64 + TCPDSACKOldSent *float64 + TCPDSACKOfoSent *float64 + TCPDSACKRecv *float64 + TCPDSACKOfoRecv *float64 + TCPAbortOnData *float64 + TCPAbortOnClose *float64 + TCPAbortOnMemory *float64 + TCPAbortOnTimeout *float64 + TCPAbortOnLinger *float64 + TCPAbortFailed *float64 + TCPMemoryPressures *float64 + TCPMemoryPressuresChrono *float64 + TCPSACKDiscard *float64 + TCPDSACKIgnoredOld *float64 + TCPDSACKIgnoredNoUndo *float64 + TCPSpuriousRTOs *float64 + TCPMD5NotFound *float64 + TCPMD5Unexpected *float64 + TCPMD5Failure *float64 + TCPSackShifted *float64 + TCPSackMerged *float64 + TCPSackShiftFallback *float64 + TCPBacklogDrop *float64 + PFMemallocDrop *float64 + TCPMinTTLDrop *float64 + TCPDeferAcceptDrop *float64 + IPReversePathFilter *float64 + TCPTimeWaitOverflow *float64 + TCPReqQFullDoCookies *float64 + TCPReqQFullDrop *float64 + TCPRetransFail *float64 + TCPRcvCoalesce *float64 + TCPRcvQDrop *float64 + TCPOFOQueue *float64 + TCPOFODrop *float64 + TCPOFOMerge *float64 + TCPChallengeACK *float64 + TCPSYNChallenge *float64 + TCPFastOpenActive *float64 + TCPFastOpenActiveFail *float64 + TCPFastOpenPassive *float64 + TCPFastOpenPassiveFail *float64 + TCPFastOpenListenOverflow *float64 + TCPFastOpenCookieReqd *float64 + TCPFastOpenBlackhole *float64 + TCPSpuriousRtxHostQueues *float64 + BusyPollRxPackets *float64 + TCPAutoCorking *float64 + TCPFromZeroWindowAdv *float64 + TCPToZeroWindowAdv *float64 + TCPWantZeroWindowAdv *float64 + TCPSynRetrans *float64 + TCPOrigDataSent *float64 + TCPHystartTrainDetect *float64 + TCPHystartTrainCwnd *float64 + TCPHystartDelayDetect *float64 + TCPHystartDelayCwnd *float64 + TCPACKSkippedSynRecv *float64 + TCPACKSkippedPAWS *float64 + TCPACKSkippedSeq *float64 + TCPACKSkippedFinWait2 *float64 + TCPACKSkippedTimeWait *float64 + TCPACKSkippedChallenge *float64 + TCPWinProbe *float64 + TCPKeepAlive *float64 + TCPMTUPFail *float64 + TCPMTUPSuccess *float64 + TCPWqueueTooBig *float64 } type IpExt struct { // nolint:revive - InNoRoutes float64 - InTruncatedPkts float64 - InMcastPkts float64 - OutMcastPkts float64 - InBcastPkts float64 - OutBcastPkts float64 - InOctets float64 - OutOctets float64 - InMcastOctets float64 - OutMcastOctets float64 - InBcastOctets float64 - OutBcastOctets float64 - InCsumErrors float64 - InNoECTPkts float64 - InECT1Pkts float64 - InECT0Pkts float64 - InCEPkts float64 - ReasmOverlaps float64 + InNoRoutes *float64 + InTruncatedPkts *float64 + InMcastPkts *float64 + OutMcastPkts *float64 + InBcastPkts *float64 + OutBcastPkts *float64 + InOctets *float64 + OutOctets *float64 + InMcastOctets *float64 + OutMcastOctets *float64 + InBcastOctets *float64 + OutBcastOctets *float64 + InCsumErrors *float64 + InNoECTPkts *float64 + InECT1Pkts *float64 + InECT0Pkts *float64 + InCEPkts *float64 + ReasmOverlaps *float64 } func (p Proc) Netstat() (ProcNetstat, error) { @@ -174,14 +175,14 @@ func (p Proc) Netstat() (ProcNetstat, error) { if err != nil { return ProcNetstat{PID: p.PID}, err } - procNetstat, err := parseNetstat(bytes.NewReader(data), filename) + procNetstat, err := parseProcNetstat(bytes.NewReader(data), filename) procNetstat.PID = p.PID return procNetstat, err } -// parseNetstat parses the metrics from proc//net/netstat file +// parseProcNetstat parses the metrics from proc//net/netstat file // and returns a ProcNetstat structure. -func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) { +func parseProcNetstat(r io.Reader, fileName string) (ProcNetstat, error) { var ( scanner = bufio.NewScanner(r) procNetstat = ProcNetstat{} @@ -194,8 +195,8 @@ func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) { // Remove trailing :. protocol := strings.TrimSuffix(nameParts[0], ":") if len(nameParts) != len(valueParts) { - return procNetstat, fmt.Errorf("mismatch field count mismatch in %s: %s", - fileName, protocol) + return procNetstat, fmt.Errorf("%w: mismatch field count mismatch in %s: %s", + ErrFileParse, fileName, protocol) } for i := 1; i < len(nameParts); i++ { value, err := strconv.ParseFloat(valueParts[i], 64) @@ -208,230 +209,232 @@ func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) { case "TcpExt": switch key { case "SyncookiesSent": - procNetstat.TcpExt.SyncookiesSent = value + procNetstat.TcpExt.SyncookiesSent = &value case "SyncookiesRecv": - procNetstat.TcpExt.SyncookiesRecv = value + procNetstat.TcpExt.SyncookiesRecv = &value case "SyncookiesFailed": - procNetstat.TcpExt.SyncookiesFailed = value + procNetstat.TcpExt.SyncookiesFailed = &value case "EmbryonicRsts": - procNetstat.TcpExt.EmbryonicRsts = value + procNetstat.TcpExt.EmbryonicRsts = &value case "PruneCalled": - procNetstat.TcpExt.PruneCalled = value + procNetstat.TcpExt.PruneCalled = &value case "RcvPruned": - procNetstat.TcpExt.RcvPruned = value + procNetstat.TcpExt.RcvPruned = &value case "OfoPruned": - procNetstat.TcpExt.OfoPruned = value + procNetstat.TcpExt.OfoPruned = &value case "OutOfWindowIcmps": - procNetstat.TcpExt.OutOfWindowIcmps = value + procNetstat.TcpExt.OutOfWindowIcmps = &value case "LockDroppedIcmps": - procNetstat.TcpExt.LockDroppedIcmps = value + procNetstat.TcpExt.LockDroppedIcmps = &value case "ArpFilter": - procNetstat.TcpExt.ArpFilter = value + procNetstat.TcpExt.ArpFilter = &value case "TW": - procNetstat.TcpExt.TW = value + procNetstat.TcpExt.TW = &value case "TWRecycled": - procNetstat.TcpExt.TWRecycled = value + procNetstat.TcpExt.TWRecycled = &value case "TWKilled": - procNetstat.TcpExt.TWKilled = value + procNetstat.TcpExt.TWKilled = &value case "PAWSActive": - procNetstat.TcpExt.PAWSActive = value + procNetstat.TcpExt.PAWSActive = &value case "PAWSEstab": - procNetstat.TcpExt.PAWSEstab = value + procNetstat.TcpExt.PAWSEstab = &value case "DelayedACKs": - procNetstat.TcpExt.DelayedACKs = value + procNetstat.TcpExt.DelayedACKs = &value case "DelayedACKLocked": - procNetstat.TcpExt.DelayedACKLocked = value + procNetstat.TcpExt.DelayedACKLocked = &value case "DelayedACKLost": - procNetstat.TcpExt.DelayedACKLost = value + procNetstat.TcpExt.DelayedACKLost = &value case "ListenOverflows": - procNetstat.TcpExt.ListenOverflows = value + procNetstat.TcpExt.ListenOverflows = &value case "ListenDrops": - procNetstat.TcpExt.ListenDrops = value + procNetstat.TcpExt.ListenDrops = &value case "TCPHPHits": - procNetstat.TcpExt.TCPHPHits = value + procNetstat.TcpExt.TCPHPHits = &value case "TCPPureAcks": - procNetstat.TcpExt.TCPPureAcks = value + procNetstat.TcpExt.TCPPureAcks = &value case "TCPHPAcks": - procNetstat.TcpExt.TCPHPAcks = value + procNetstat.TcpExt.TCPHPAcks = &value case "TCPRenoRecovery": - procNetstat.TcpExt.TCPRenoRecovery = value + procNetstat.TcpExt.TCPRenoRecovery = &value case "TCPSackRecovery": - procNetstat.TcpExt.TCPSackRecovery = value + procNetstat.TcpExt.TCPSackRecovery = &value case "TCPSACKReneging": - procNetstat.TcpExt.TCPSACKReneging = value + procNetstat.TcpExt.TCPSACKReneging = &value case "TCPSACKReorder": - procNetstat.TcpExt.TCPSACKReorder = value + procNetstat.TcpExt.TCPSACKReorder = &value case "TCPRenoReorder": - procNetstat.TcpExt.TCPRenoReorder = value + procNetstat.TcpExt.TCPRenoReorder = &value case "TCPTSReorder": - procNetstat.TcpExt.TCPTSReorder = value + procNetstat.TcpExt.TCPTSReorder = &value case "TCPFullUndo": - procNetstat.TcpExt.TCPFullUndo = value + procNetstat.TcpExt.TCPFullUndo = &value case "TCPPartialUndo": - procNetstat.TcpExt.TCPPartialUndo = value + procNetstat.TcpExt.TCPPartialUndo = &value case "TCPDSACKUndo": - procNetstat.TcpExt.TCPDSACKUndo = value + procNetstat.TcpExt.TCPDSACKUndo = &value case "TCPLossUndo": - procNetstat.TcpExt.TCPLossUndo = value + procNetstat.TcpExt.TCPLossUndo = &value case "TCPLostRetransmit": - procNetstat.TcpExt.TCPLostRetransmit = value + procNetstat.TcpExt.TCPLostRetransmit = &value case "TCPRenoFailures": - procNetstat.TcpExt.TCPRenoFailures = value + procNetstat.TcpExt.TCPRenoFailures = &value case "TCPSackFailures": - procNetstat.TcpExt.TCPSackFailures = value + procNetstat.TcpExt.TCPSackFailures = &value case "TCPLossFailures": - procNetstat.TcpExt.TCPLossFailures = value + procNetstat.TcpExt.TCPLossFailures = &value case "TCPFastRetrans": - procNetstat.TcpExt.TCPFastRetrans = value + procNetstat.TcpExt.TCPFastRetrans = &value case "TCPSlowStartRetrans": - procNetstat.TcpExt.TCPSlowStartRetrans = value + procNetstat.TcpExt.TCPSlowStartRetrans = &value case "TCPTimeouts": - procNetstat.TcpExt.TCPTimeouts = value + procNetstat.TcpExt.TCPTimeouts = &value case "TCPLossProbes": - procNetstat.TcpExt.TCPLossProbes = value + procNetstat.TcpExt.TCPLossProbes = &value case "TCPLossProbeRecovery": - procNetstat.TcpExt.TCPLossProbeRecovery = value + procNetstat.TcpExt.TCPLossProbeRecovery = &value case "TCPRenoRecoveryFail": - procNetstat.TcpExt.TCPRenoRecoveryFail = value + procNetstat.TcpExt.TCPRenoRecoveryFail = &value case "TCPSackRecoveryFail": - procNetstat.TcpExt.TCPSackRecoveryFail = value + procNetstat.TcpExt.TCPSackRecoveryFail = &value case "TCPRcvCollapsed": - procNetstat.TcpExt.TCPRcvCollapsed = value + procNetstat.TcpExt.TCPRcvCollapsed = &value case "TCPDSACKOldSent": - procNetstat.TcpExt.TCPDSACKOldSent = value + procNetstat.TcpExt.TCPDSACKOldSent = &value case "TCPDSACKOfoSent": - procNetstat.TcpExt.TCPDSACKOfoSent = value + procNetstat.TcpExt.TCPDSACKOfoSent = &value case "TCPDSACKRecv": - procNetstat.TcpExt.TCPDSACKRecv = value + procNetstat.TcpExt.TCPDSACKRecv = &value case "TCPDSACKOfoRecv": - procNetstat.TcpExt.TCPDSACKOfoRecv = value + procNetstat.TcpExt.TCPDSACKOfoRecv = &value case "TCPAbortOnData": - procNetstat.TcpExt.TCPAbortOnData = value + procNetstat.TcpExt.TCPAbortOnData = &value case "TCPAbortOnClose": - procNetstat.TcpExt.TCPAbortOnClose = value + procNetstat.TcpExt.TCPAbortOnClose = &value case "TCPDeferAcceptDrop": - procNetstat.TcpExt.TCPDeferAcceptDrop = value + procNetstat.TcpExt.TCPDeferAcceptDrop = &value case "IPReversePathFilter": - procNetstat.TcpExt.IPReversePathFilter = value + procNetstat.TcpExt.IPReversePathFilter = &value case "TCPTimeWaitOverflow": - procNetstat.TcpExt.TCPTimeWaitOverflow = value + procNetstat.TcpExt.TCPTimeWaitOverflow = &value case "TCPReqQFullDoCookies": - procNetstat.TcpExt.TCPReqQFullDoCookies = value + procNetstat.TcpExt.TCPReqQFullDoCookies = &value case "TCPReqQFullDrop": - procNetstat.TcpExt.TCPReqQFullDrop = value + procNetstat.TcpExt.TCPReqQFullDrop = &value case "TCPRetransFail": - procNetstat.TcpExt.TCPRetransFail = value + procNetstat.TcpExt.TCPRetransFail = &value case "TCPRcvCoalesce": - procNetstat.TcpExt.TCPRcvCoalesce = value + procNetstat.TcpExt.TCPRcvCoalesce = &value + case "TCPRcvQDrop": + procNetstat.TcpExt.TCPRcvQDrop = &value case "TCPOFOQueue": - procNetstat.TcpExt.TCPOFOQueue = value + procNetstat.TcpExt.TCPOFOQueue = &value case "TCPOFODrop": - procNetstat.TcpExt.TCPOFODrop = value + procNetstat.TcpExt.TCPOFODrop = &value case "TCPOFOMerge": - procNetstat.TcpExt.TCPOFOMerge = value + procNetstat.TcpExt.TCPOFOMerge = &value case "TCPChallengeACK": - procNetstat.TcpExt.TCPChallengeACK = value + procNetstat.TcpExt.TCPChallengeACK = &value case "TCPSYNChallenge": - procNetstat.TcpExt.TCPSYNChallenge = value + procNetstat.TcpExt.TCPSYNChallenge = &value case "TCPFastOpenActive": - procNetstat.TcpExt.TCPFastOpenActive = value + procNetstat.TcpExt.TCPFastOpenActive = &value case "TCPFastOpenActiveFail": - procNetstat.TcpExt.TCPFastOpenActiveFail = value + procNetstat.TcpExt.TCPFastOpenActiveFail = &value case "TCPFastOpenPassive": - procNetstat.TcpExt.TCPFastOpenPassive = value + procNetstat.TcpExt.TCPFastOpenPassive = &value case "TCPFastOpenPassiveFail": - procNetstat.TcpExt.TCPFastOpenPassiveFail = value + procNetstat.TcpExt.TCPFastOpenPassiveFail = &value case "TCPFastOpenListenOverflow": - procNetstat.TcpExt.TCPFastOpenListenOverflow = value + procNetstat.TcpExt.TCPFastOpenListenOverflow = &value case "TCPFastOpenCookieReqd": - procNetstat.TcpExt.TCPFastOpenCookieReqd = value + procNetstat.TcpExt.TCPFastOpenCookieReqd = &value case "TCPFastOpenBlackhole": - procNetstat.TcpExt.TCPFastOpenBlackhole = value + procNetstat.TcpExt.TCPFastOpenBlackhole = &value case "TCPSpuriousRtxHostQueues": - procNetstat.TcpExt.TCPSpuriousRtxHostQueues = value + procNetstat.TcpExt.TCPSpuriousRtxHostQueues = &value case "BusyPollRxPackets": - procNetstat.TcpExt.BusyPollRxPackets = value + procNetstat.TcpExt.BusyPollRxPackets = &value case "TCPAutoCorking": - procNetstat.TcpExt.TCPAutoCorking = value + procNetstat.TcpExt.TCPAutoCorking = &value case "TCPFromZeroWindowAdv": - procNetstat.TcpExt.TCPFromZeroWindowAdv = value + procNetstat.TcpExt.TCPFromZeroWindowAdv = &value case "TCPToZeroWindowAdv": - procNetstat.TcpExt.TCPToZeroWindowAdv = value + procNetstat.TcpExt.TCPToZeroWindowAdv = &value case "TCPWantZeroWindowAdv": - procNetstat.TcpExt.TCPWantZeroWindowAdv = value + procNetstat.TcpExt.TCPWantZeroWindowAdv = &value case "TCPSynRetrans": - procNetstat.TcpExt.TCPSynRetrans = value + procNetstat.TcpExt.TCPSynRetrans = &value case "TCPOrigDataSent": - procNetstat.TcpExt.TCPOrigDataSent = value + procNetstat.TcpExt.TCPOrigDataSent = &value case "TCPHystartTrainDetect": - procNetstat.TcpExt.TCPHystartTrainDetect = value + procNetstat.TcpExt.TCPHystartTrainDetect = &value case "TCPHystartTrainCwnd": - procNetstat.TcpExt.TCPHystartTrainCwnd = value + procNetstat.TcpExt.TCPHystartTrainCwnd = &value case "TCPHystartDelayDetect": - procNetstat.TcpExt.TCPHystartDelayDetect = value + procNetstat.TcpExt.TCPHystartDelayDetect = &value case "TCPHystartDelayCwnd": - procNetstat.TcpExt.TCPHystartDelayCwnd = value + procNetstat.TcpExt.TCPHystartDelayCwnd = &value case "TCPACKSkippedSynRecv": - procNetstat.TcpExt.TCPACKSkippedSynRecv = value + procNetstat.TcpExt.TCPACKSkippedSynRecv = &value case "TCPACKSkippedPAWS": - procNetstat.TcpExt.TCPACKSkippedPAWS = value + procNetstat.TcpExt.TCPACKSkippedPAWS = &value case "TCPACKSkippedSeq": - procNetstat.TcpExt.TCPACKSkippedSeq = value + procNetstat.TcpExt.TCPACKSkippedSeq = &value case "TCPACKSkippedFinWait2": - procNetstat.TcpExt.TCPACKSkippedFinWait2 = value + procNetstat.TcpExt.TCPACKSkippedFinWait2 = &value case "TCPACKSkippedTimeWait": - procNetstat.TcpExt.TCPACKSkippedTimeWait = value + procNetstat.TcpExt.TCPACKSkippedTimeWait = &value case "TCPACKSkippedChallenge": - procNetstat.TcpExt.TCPACKSkippedChallenge = value + procNetstat.TcpExt.TCPACKSkippedChallenge = &value case "TCPWinProbe": - procNetstat.TcpExt.TCPWinProbe = value + procNetstat.TcpExt.TCPWinProbe = &value case "TCPKeepAlive": - procNetstat.TcpExt.TCPKeepAlive = value + procNetstat.TcpExt.TCPKeepAlive = &value case "TCPMTUPFail": - procNetstat.TcpExt.TCPMTUPFail = value + procNetstat.TcpExt.TCPMTUPFail = &value case "TCPMTUPSuccess": - procNetstat.TcpExt.TCPMTUPSuccess = value + procNetstat.TcpExt.TCPMTUPSuccess = &value case "TCPWqueueTooBig": - procNetstat.TcpExt.TCPWqueueTooBig = value + procNetstat.TcpExt.TCPWqueueTooBig = &value } case "IpExt": switch key { case "InNoRoutes": - procNetstat.IpExt.InNoRoutes = value + procNetstat.IpExt.InNoRoutes = &value case "InTruncatedPkts": - procNetstat.IpExt.InTruncatedPkts = value + procNetstat.IpExt.InTruncatedPkts = &value case "InMcastPkts": - procNetstat.IpExt.InMcastPkts = value + procNetstat.IpExt.InMcastPkts = &value case "OutMcastPkts": - procNetstat.IpExt.OutMcastPkts = value + procNetstat.IpExt.OutMcastPkts = &value case "InBcastPkts": - procNetstat.IpExt.InBcastPkts = value + procNetstat.IpExt.InBcastPkts = &value case "OutBcastPkts": - procNetstat.IpExt.OutBcastPkts = value + procNetstat.IpExt.OutBcastPkts = &value case "InOctets": - procNetstat.IpExt.InOctets = value + procNetstat.IpExt.InOctets = &value case "OutOctets": - procNetstat.IpExt.OutOctets = value + procNetstat.IpExt.OutOctets = &value case "InMcastOctets": - procNetstat.IpExt.InMcastOctets = value + procNetstat.IpExt.InMcastOctets = &value case "OutMcastOctets": - procNetstat.IpExt.OutMcastOctets = value + procNetstat.IpExt.OutMcastOctets = &value case "InBcastOctets": - procNetstat.IpExt.InBcastOctets = value + procNetstat.IpExt.InBcastOctets = &value case "OutBcastOctets": - procNetstat.IpExt.OutBcastOctets = value + procNetstat.IpExt.OutBcastOctets = &value case "InCsumErrors": - procNetstat.IpExt.InCsumErrors = value + procNetstat.IpExt.InCsumErrors = &value case "InNoECTPkts": - procNetstat.IpExt.InNoECTPkts = value + procNetstat.IpExt.InNoECTPkts = &value case "InECT1Pkts": - procNetstat.IpExt.InECT1Pkts = value + procNetstat.IpExt.InECT1Pkts = &value case "InECT0Pkts": - procNetstat.IpExt.InECT0Pkts = value + procNetstat.IpExt.InECT0Pkts = &value case "InCEPkts": - procNetstat.IpExt.InCEPkts = value + procNetstat.IpExt.InCEPkts = &value case "ReasmOverlaps": - procNetstat.IpExt.ReasmOverlaps = value + procNetstat.IpExt.ReasmOverlaps = &value } } } diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_ns.go b/test/performance/vendor/github.com/prometheus/procfs/proc_ns.go index 391b4cbd1..c22666750 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_ns.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_ns.go @@ -40,7 +40,7 @@ func (p Proc) Namespaces() (Namespaces, error) { names, err := d.Readdirnames(-1) if err != nil { - return nil, fmt.Errorf("failed to read contents of ns dir: %w", err) + return nil, fmt.Errorf("%s: failed to read contents of ns dir: %w", ErrFileRead, err) } ns := make(Namespaces, len(names)) @@ -52,13 +52,13 @@ func (p Proc) Namespaces() (Namespaces, error) { fields := strings.SplitN(target, ":", 2) if len(fields) != 2 { - return nil, fmt.Errorf("failed to parse namespace type and inode from %q", target) + return nil, fmt.Errorf("%w: namespace type and inode from %q", ErrFileParse, target) } typ := fields[0] inode, err := strconv.ParseUint(strings.Trim(fields[1], "[]"), 10, 32) if err != nil { - return nil, fmt.Errorf("failed to parse inode from %q: %w", fields[1], err) + return nil, fmt.Errorf("%s: inode from %q: %w", ErrFileParse, fields[1], err) } ns[name] = Namespace{typ, uint32(inode)} diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_psi.go b/test/performance/vendor/github.com/prometheus/procfs/proc_psi.go index a68fe1529..152539d35 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_psi.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_psi.go @@ -61,7 +61,7 @@ type PSIStats struct { func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) { data, err := util.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource))) if err != nil { - return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %q: %w", resource, err) + return PSIStats{}, fmt.Errorf("%s: psi_stats: unavailable for %q: %w", ErrFileRead, resource, err) } return parsePSIStats(resource, bytes.NewReader(data)) diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_snmp.go b/test/performance/vendor/github.com/prometheus/procfs/proc_snmp.go index ae191896c..b9d2cf642 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_snmp.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_snmp.go @@ -37,100 +37,100 @@ type ProcSnmp struct { } type Ip struct { // nolint:revive - Forwarding float64 - DefaultTTL float64 - InReceives float64 - InHdrErrors float64 - InAddrErrors float64 - ForwDatagrams float64 - InUnknownProtos float64 - InDiscards float64 - InDelivers float64 - OutRequests float64 - OutDiscards float64 - OutNoRoutes float64 - ReasmTimeout float64 - ReasmReqds float64 - ReasmOKs float64 - ReasmFails float64 - FragOKs float64 - FragFails float64 - FragCreates float64 + Forwarding *float64 + DefaultTTL *float64 + InReceives *float64 + InHdrErrors *float64 + InAddrErrors *float64 + ForwDatagrams *float64 + InUnknownProtos *float64 + InDiscards *float64 + InDelivers *float64 + OutRequests *float64 + OutDiscards *float64 + OutNoRoutes *float64 + ReasmTimeout *float64 + ReasmReqds *float64 + ReasmOKs *float64 + ReasmFails *float64 + FragOKs *float64 + FragFails *float64 + FragCreates *float64 } -type Icmp struct { - InMsgs float64 - InErrors float64 - InCsumErrors float64 - InDestUnreachs float64 - InTimeExcds float64 - InParmProbs float64 - InSrcQuenchs float64 - InRedirects float64 - InEchos float64 - InEchoReps float64 - InTimestamps float64 - InTimestampReps float64 - InAddrMasks float64 - InAddrMaskReps float64 - OutMsgs float64 - OutErrors float64 - OutDestUnreachs float64 - OutTimeExcds float64 - OutParmProbs float64 - OutSrcQuenchs float64 - OutRedirects float64 - OutEchos float64 - OutEchoReps float64 - OutTimestamps float64 - OutTimestampReps float64 - OutAddrMasks float64 - OutAddrMaskReps float64 +type Icmp struct { // nolint:revive + InMsgs *float64 + InErrors *float64 + InCsumErrors *float64 + InDestUnreachs *float64 + InTimeExcds *float64 + InParmProbs *float64 + InSrcQuenchs *float64 + InRedirects *float64 + InEchos *float64 + InEchoReps *float64 + InTimestamps *float64 + InTimestampReps *float64 + InAddrMasks *float64 + InAddrMaskReps *float64 + OutMsgs *float64 + OutErrors *float64 + OutDestUnreachs *float64 + OutTimeExcds *float64 + OutParmProbs *float64 + OutSrcQuenchs *float64 + OutRedirects *float64 + OutEchos *float64 + OutEchoReps *float64 + OutTimestamps *float64 + OutTimestampReps *float64 + OutAddrMasks *float64 + OutAddrMaskReps *float64 } type IcmpMsg struct { - InType3 float64 - OutType3 float64 + InType3 *float64 + OutType3 *float64 } type Tcp struct { // nolint:revive - RtoAlgorithm float64 - RtoMin float64 - RtoMax float64 - MaxConn float64 - ActiveOpens float64 - PassiveOpens float64 - AttemptFails float64 - EstabResets float64 - CurrEstab float64 - InSegs float64 - OutSegs float64 - RetransSegs float64 - InErrs float64 - OutRsts float64 - InCsumErrors float64 + RtoAlgorithm *float64 + RtoMin *float64 + RtoMax *float64 + MaxConn *float64 + ActiveOpens *float64 + PassiveOpens *float64 + AttemptFails *float64 + EstabResets *float64 + CurrEstab *float64 + InSegs *float64 + OutSegs *float64 + RetransSegs *float64 + InErrs *float64 + OutRsts *float64 + InCsumErrors *float64 } type Udp struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 - IgnoredMulti float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 + IgnoredMulti *float64 } type UdpLite struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 - IgnoredMulti float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 + IgnoredMulti *float64 } func (p Proc) Snmp() (ProcSnmp, error) { @@ -159,8 +159,8 @@ func parseSnmp(r io.Reader, fileName string) (ProcSnmp, error) { // Remove trailing :. protocol := strings.TrimSuffix(nameParts[0], ":") if len(nameParts) != len(valueParts) { - return procSnmp, fmt.Errorf("mismatch field count mismatch in %s: %s", - fileName, protocol) + return procSnmp, fmt.Errorf("%w: mismatch field count mismatch in %s: %s", + ErrFileParse, fileName, protocol) } for i := 1; i < len(nameParts); i++ { value, err := strconv.ParseFloat(valueParts[i], 64) @@ -173,178 +173,178 @@ func parseSnmp(r io.Reader, fileName string) (ProcSnmp, error) { case "Ip": switch key { case "Forwarding": - procSnmp.Ip.Forwarding = value + procSnmp.Ip.Forwarding = &value case "DefaultTTL": - procSnmp.Ip.DefaultTTL = value + procSnmp.Ip.DefaultTTL = &value case "InReceives": - procSnmp.Ip.InReceives = value + procSnmp.Ip.InReceives = &value case "InHdrErrors": - procSnmp.Ip.InHdrErrors = value + procSnmp.Ip.InHdrErrors = &value case "InAddrErrors": - procSnmp.Ip.InAddrErrors = value + procSnmp.Ip.InAddrErrors = &value case "ForwDatagrams": - procSnmp.Ip.ForwDatagrams = value + procSnmp.Ip.ForwDatagrams = &value case "InUnknownProtos": - procSnmp.Ip.InUnknownProtos = value + procSnmp.Ip.InUnknownProtos = &value case "InDiscards": - procSnmp.Ip.InDiscards = value + procSnmp.Ip.InDiscards = &value case "InDelivers": - procSnmp.Ip.InDelivers = value + procSnmp.Ip.InDelivers = &value case "OutRequests": - procSnmp.Ip.OutRequests = value + procSnmp.Ip.OutRequests = &value case "OutDiscards": - procSnmp.Ip.OutDiscards = value + procSnmp.Ip.OutDiscards = &value case "OutNoRoutes": - procSnmp.Ip.OutNoRoutes = value + procSnmp.Ip.OutNoRoutes = &value case "ReasmTimeout": - procSnmp.Ip.ReasmTimeout = value + procSnmp.Ip.ReasmTimeout = &value case "ReasmReqds": - procSnmp.Ip.ReasmReqds = value + procSnmp.Ip.ReasmReqds = &value case "ReasmOKs": - procSnmp.Ip.ReasmOKs = value + procSnmp.Ip.ReasmOKs = &value case "ReasmFails": - procSnmp.Ip.ReasmFails = value + procSnmp.Ip.ReasmFails = &value case "FragOKs": - procSnmp.Ip.FragOKs = value + procSnmp.Ip.FragOKs = &value case "FragFails": - procSnmp.Ip.FragFails = value + procSnmp.Ip.FragFails = &value case "FragCreates": - procSnmp.Ip.FragCreates = value + procSnmp.Ip.FragCreates = &value } case "Icmp": switch key { case "InMsgs": - procSnmp.Icmp.InMsgs = value + procSnmp.Icmp.InMsgs = &value case "InErrors": - procSnmp.Icmp.InErrors = value + procSnmp.Icmp.InErrors = &value case "InCsumErrors": - procSnmp.Icmp.InCsumErrors = value + procSnmp.Icmp.InCsumErrors = &value case "InDestUnreachs": - procSnmp.Icmp.InDestUnreachs = value + procSnmp.Icmp.InDestUnreachs = &value case "InTimeExcds": - procSnmp.Icmp.InTimeExcds = value + procSnmp.Icmp.InTimeExcds = &value case "InParmProbs": - procSnmp.Icmp.InParmProbs = value + procSnmp.Icmp.InParmProbs = &value case "InSrcQuenchs": - procSnmp.Icmp.InSrcQuenchs = value + procSnmp.Icmp.InSrcQuenchs = &value case "InRedirects": - procSnmp.Icmp.InRedirects = value + procSnmp.Icmp.InRedirects = &value case "InEchos": - procSnmp.Icmp.InEchos = value + procSnmp.Icmp.InEchos = &value case "InEchoReps": - procSnmp.Icmp.InEchoReps = value + procSnmp.Icmp.InEchoReps = &value case "InTimestamps": - procSnmp.Icmp.InTimestamps = value + procSnmp.Icmp.InTimestamps = &value case "InTimestampReps": - procSnmp.Icmp.InTimestampReps = value + procSnmp.Icmp.InTimestampReps = &value case "InAddrMasks": - procSnmp.Icmp.InAddrMasks = value + procSnmp.Icmp.InAddrMasks = &value case "InAddrMaskReps": - procSnmp.Icmp.InAddrMaskReps = value + procSnmp.Icmp.InAddrMaskReps = &value case "OutMsgs": - procSnmp.Icmp.OutMsgs = value + procSnmp.Icmp.OutMsgs = &value case "OutErrors": - procSnmp.Icmp.OutErrors = value + procSnmp.Icmp.OutErrors = &value case "OutDestUnreachs": - procSnmp.Icmp.OutDestUnreachs = value + procSnmp.Icmp.OutDestUnreachs = &value case "OutTimeExcds": - procSnmp.Icmp.OutTimeExcds = value + procSnmp.Icmp.OutTimeExcds = &value case "OutParmProbs": - procSnmp.Icmp.OutParmProbs = value + procSnmp.Icmp.OutParmProbs = &value case "OutSrcQuenchs": - procSnmp.Icmp.OutSrcQuenchs = value + procSnmp.Icmp.OutSrcQuenchs = &value case "OutRedirects": - procSnmp.Icmp.OutRedirects = value + procSnmp.Icmp.OutRedirects = &value case "OutEchos": - procSnmp.Icmp.OutEchos = value + procSnmp.Icmp.OutEchos = &value case "OutEchoReps": - procSnmp.Icmp.OutEchoReps = value + procSnmp.Icmp.OutEchoReps = &value case "OutTimestamps": - procSnmp.Icmp.OutTimestamps = value + procSnmp.Icmp.OutTimestamps = &value case "OutTimestampReps": - procSnmp.Icmp.OutTimestampReps = value + procSnmp.Icmp.OutTimestampReps = &value case "OutAddrMasks": - procSnmp.Icmp.OutAddrMasks = value + procSnmp.Icmp.OutAddrMasks = &value case "OutAddrMaskReps": - procSnmp.Icmp.OutAddrMaskReps = value + procSnmp.Icmp.OutAddrMaskReps = &value } case "IcmpMsg": switch key { case "InType3": - procSnmp.IcmpMsg.InType3 = value + procSnmp.IcmpMsg.InType3 = &value case "OutType3": - procSnmp.IcmpMsg.OutType3 = value + procSnmp.IcmpMsg.OutType3 = &value } case "Tcp": switch key { case "RtoAlgorithm": - procSnmp.Tcp.RtoAlgorithm = value + procSnmp.Tcp.RtoAlgorithm = &value case "RtoMin": - procSnmp.Tcp.RtoMin = value + procSnmp.Tcp.RtoMin = &value case "RtoMax": - procSnmp.Tcp.RtoMax = value + procSnmp.Tcp.RtoMax = &value case "MaxConn": - procSnmp.Tcp.MaxConn = value + procSnmp.Tcp.MaxConn = &value case "ActiveOpens": - procSnmp.Tcp.ActiveOpens = value + procSnmp.Tcp.ActiveOpens = &value case "PassiveOpens": - procSnmp.Tcp.PassiveOpens = value + procSnmp.Tcp.PassiveOpens = &value case "AttemptFails": - procSnmp.Tcp.AttemptFails = value + procSnmp.Tcp.AttemptFails = &value case "EstabResets": - procSnmp.Tcp.EstabResets = value + procSnmp.Tcp.EstabResets = &value case "CurrEstab": - procSnmp.Tcp.CurrEstab = value + procSnmp.Tcp.CurrEstab = &value case "InSegs": - procSnmp.Tcp.InSegs = value + procSnmp.Tcp.InSegs = &value case "OutSegs": - procSnmp.Tcp.OutSegs = value + procSnmp.Tcp.OutSegs = &value case "RetransSegs": - procSnmp.Tcp.RetransSegs = value + procSnmp.Tcp.RetransSegs = &value case "InErrs": - procSnmp.Tcp.InErrs = value + procSnmp.Tcp.InErrs = &value case "OutRsts": - procSnmp.Tcp.OutRsts = value + procSnmp.Tcp.OutRsts = &value case "InCsumErrors": - procSnmp.Tcp.InCsumErrors = value + procSnmp.Tcp.InCsumErrors = &value } case "Udp": switch key { case "InDatagrams": - procSnmp.Udp.InDatagrams = value + procSnmp.Udp.InDatagrams = &value case "NoPorts": - procSnmp.Udp.NoPorts = value + procSnmp.Udp.NoPorts = &value case "InErrors": - procSnmp.Udp.InErrors = value + procSnmp.Udp.InErrors = &value case "OutDatagrams": - procSnmp.Udp.OutDatagrams = value + procSnmp.Udp.OutDatagrams = &value case "RcvbufErrors": - procSnmp.Udp.RcvbufErrors = value + procSnmp.Udp.RcvbufErrors = &value case "SndbufErrors": - procSnmp.Udp.SndbufErrors = value + procSnmp.Udp.SndbufErrors = &value case "InCsumErrors": - procSnmp.Udp.InCsumErrors = value + procSnmp.Udp.InCsumErrors = &value case "IgnoredMulti": - procSnmp.Udp.IgnoredMulti = value + procSnmp.Udp.IgnoredMulti = &value } case "UdpLite": switch key { case "InDatagrams": - procSnmp.UdpLite.InDatagrams = value + procSnmp.UdpLite.InDatagrams = &value case "NoPorts": - procSnmp.UdpLite.NoPorts = value + procSnmp.UdpLite.NoPorts = &value case "InErrors": - procSnmp.UdpLite.InErrors = value + procSnmp.UdpLite.InErrors = &value case "OutDatagrams": - procSnmp.UdpLite.OutDatagrams = value + procSnmp.UdpLite.OutDatagrams = &value case "RcvbufErrors": - procSnmp.UdpLite.RcvbufErrors = value + procSnmp.UdpLite.RcvbufErrors = &value case "SndbufErrors": - procSnmp.UdpLite.SndbufErrors = value + procSnmp.UdpLite.SndbufErrors = &value case "InCsumErrors": - procSnmp.UdpLite.InCsumErrors = value + procSnmp.UdpLite.InCsumErrors = &value case "IgnoredMulti": - procSnmp.UdpLite.IgnoredMulti = value + procSnmp.UdpLite.IgnoredMulti = &value } } } diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_snmp6.go b/test/performance/vendor/github.com/prometheus/procfs/proc_snmp6.go index f611992d5..3059cc6a1 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_snmp6.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_snmp6.go @@ -36,106 +36,106 @@ type ProcSnmp6 struct { } type Ip6 struct { // nolint:revive - InReceives float64 - InHdrErrors float64 - InTooBigErrors float64 - InNoRoutes float64 - InAddrErrors float64 - InUnknownProtos float64 - InTruncatedPkts float64 - InDiscards float64 - InDelivers float64 - OutForwDatagrams float64 - OutRequests float64 - OutDiscards float64 - OutNoRoutes float64 - ReasmTimeout float64 - ReasmReqds float64 - ReasmOKs float64 - ReasmFails float64 - FragOKs float64 - FragFails float64 - FragCreates float64 - InMcastPkts float64 - OutMcastPkts float64 - InOctets float64 - OutOctets float64 - InMcastOctets float64 - OutMcastOctets float64 - InBcastOctets float64 - OutBcastOctets float64 - InNoECTPkts float64 - InECT1Pkts float64 - InECT0Pkts float64 - InCEPkts float64 + InReceives *float64 + InHdrErrors *float64 + InTooBigErrors *float64 + InNoRoutes *float64 + InAddrErrors *float64 + InUnknownProtos *float64 + InTruncatedPkts *float64 + InDiscards *float64 + InDelivers *float64 + OutForwDatagrams *float64 + OutRequests *float64 + OutDiscards *float64 + OutNoRoutes *float64 + ReasmTimeout *float64 + ReasmReqds *float64 + ReasmOKs *float64 + ReasmFails *float64 + FragOKs *float64 + FragFails *float64 + FragCreates *float64 + InMcastPkts *float64 + OutMcastPkts *float64 + InOctets *float64 + OutOctets *float64 + InMcastOctets *float64 + OutMcastOctets *float64 + InBcastOctets *float64 + OutBcastOctets *float64 + InNoECTPkts *float64 + InECT1Pkts *float64 + InECT0Pkts *float64 + InCEPkts *float64 } type Icmp6 struct { - InMsgs float64 - InErrors float64 - OutMsgs float64 - OutErrors float64 - InCsumErrors float64 - InDestUnreachs float64 - InPktTooBigs float64 - InTimeExcds float64 - InParmProblems float64 - InEchos float64 - InEchoReplies float64 - InGroupMembQueries float64 - InGroupMembResponses float64 - InGroupMembReductions float64 - InRouterSolicits float64 - InRouterAdvertisements float64 - InNeighborSolicits float64 - InNeighborAdvertisements float64 - InRedirects float64 - InMLDv2Reports float64 - OutDestUnreachs float64 - OutPktTooBigs float64 - OutTimeExcds float64 - OutParmProblems float64 - OutEchos float64 - OutEchoReplies float64 - OutGroupMembQueries float64 - OutGroupMembResponses float64 - OutGroupMembReductions float64 - OutRouterSolicits float64 - OutRouterAdvertisements float64 - OutNeighborSolicits float64 - OutNeighborAdvertisements float64 - OutRedirects float64 - OutMLDv2Reports float64 - InType1 float64 - InType134 float64 - InType135 float64 - InType136 float64 - InType143 float64 - OutType133 float64 - OutType135 float64 - OutType136 float64 - OutType143 float64 + InMsgs *float64 + InErrors *float64 + OutMsgs *float64 + OutErrors *float64 + InCsumErrors *float64 + InDestUnreachs *float64 + InPktTooBigs *float64 + InTimeExcds *float64 + InParmProblems *float64 + InEchos *float64 + InEchoReplies *float64 + InGroupMembQueries *float64 + InGroupMembResponses *float64 + InGroupMembReductions *float64 + InRouterSolicits *float64 + InRouterAdvertisements *float64 + InNeighborSolicits *float64 + InNeighborAdvertisements *float64 + InRedirects *float64 + InMLDv2Reports *float64 + OutDestUnreachs *float64 + OutPktTooBigs *float64 + OutTimeExcds *float64 + OutParmProblems *float64 + OutEchos *float64 + OutEchoReplies *float64 + OutGroupMembQueries *float64 + OutGroupMembResponses *float64 + OutGroupMembReductions *float64 + OutRouterSolicits *float64 + OutRouterAdvertisements *float64 + OutNeighborSolicits *float64 + OutNeighborAdvertisements *float64 + OutRedirects *float64 + OutMLDv2Reports *float64 + InType1 *float64 + InType134 *float64 + InType135 *float64 + InType136 *float64 + InType143 *float64 + OutType133 *float64 + OutType135 *float64 + OutType136 *float64 + OutType143 *float64 } type Udp6 struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 - IgnoredMulti float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 + IgnoredMulti *float64 } type UdpLite6 struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 } func (p Proc) Snmp6() (ProcSnmp6, error) { @@ -182,197 +182,197 @@ func parseSNMP6Stats(r io.Reader) (ProcSnmp6, error) { case "Ip6": switch key { case "InReceives": - procSnmp6.Ip6.InReceives = value + procSnmp6.Ip6.InReceives = &value case "InHdrErrors": - procSnmp6.Ip6.InHdrErrors = value + procSnmp6.Ip6.InHdrErrors = &value case "InTooBigErrors": - procSnmp6.Ip6.InTooBigErrors = value + procSnmp6.Ip6.InTooBigErrors = &value case "InNoRoutes": - procSnmp6.Ip6.InNoRoutes = value + procSnmp6.Ip6.InNoRoutes = &value case "InAddrErrors": - procSnmp6.Ip6.InAddrErrors = value + procSnmp6.Ip6.InAddrErrors = &value case "InUnknownProtos": - procSnmp6.Ip6.InUnknownProtos = value + procSnmp6.Ip6.InUnknownProtos = &value case "InTruncatedPkts": - procSnmp6.Ip6.InTruncatedPkts = value + procSnmp6.Ip6.InTruncatedPkts = &value case "InDiscards": - procSnmp6.Ip6.InDiscards = value + procSnmp6.Ip6.InDiscards = &value case "InDelivers": - procSnmp6.Ip6.InDelivers = value + procSnmp6.Ip6.InDelivers = &value case "OutForwDatagrams": - procSnmp6.Ip6.OutForwDatagrams = value + procSnmp6.Ip6.OutForwDatagrams = &value case "OutRequests": - procSnmp6.Ip6.OutRequests = value + procSnmp6.Ip6.OutRequests = &value case "OutDiscards": - procSnmp6.Ip6.OutDiscards = value + procSnmp6.Ip6.OutDiscards = &value case "OutNoRoutes": - procSnmp6.Ip6.OutNoRoutes = value + procSnmp6.Ip6.OutNoRoutes = &value case "ReasmTimeout": - procSnmp6.Ip6.ReasmTimeout = value + procSnmp6.Ip6.ReasmTimeout = &value case "ReasmReqds": - procSnmp6.Ip6.ReasmReqds = value + procSnmp6.Ip6.ReasmReqds = &value case "ReasmOKs": - procSnmp6.Ip6.ReasmOKs = value + procSnmp6.Ip6.ReasmOKs = &value case "ReasmFails": - procSnmp6.Ip6.ReasmFails = value + procSnmp6.Ip6.ReasmFails = &value case "FragOKs": - procSnmp6.Ip6.FragOKs = value + procSnmp6.Ip6.FragOKs = &value case "FragFails": - procSnmp6.Ip6.FragFails = value + procSnmp6.Ip6.FragFails = &value case "FragCreates": - procSnmp6.Ip6.FragCreates = value + procSnmp6.Ip6.FragCreates = &value case "InMcastPkts": - procSnmp6.Ip6.InMcastPkts = value + procSnmp6.Ip6.InMcastPkts = &value case "OutMcastPkts": - procSnmp6.Ip6.OutMcastPkts = value + procSnmp6.Ip6.OutMcastPkts = &value case "InOctets": - procSnmp6.Ip6.InOctets = value + procSnmp6.Ip6.InOctets = &value case "OutOctets": - procSnmp6.Ip6.OutOctets = value + procSnmp6.Ip6.OutOctets = &value case "InMcastOctets": - procSnmp6.Ip6.InMcastOctets = value + procSnmp6.Ip6.InMcastOctets = &value case "OutMcastOctets": - procSnmp6.Ip6.OutMcastOctets = value + procSnmp6.Ip6.OutMcastOctets = &value case "InBcastOctets": - procSnmp6.Ip6.InBcastOctets = value + procSnmp6.Ip6.InBcastOctets = &value case "OutBcastOctets": - procSnmp6.Ip6.OutBcastOctets = value + procSnmp6.Ip6.OutBcastOctets = &value case "InNoECTPkts": - procSnmp6.Ip6.InNoECTPkts = value + procSnmp6.Ip6.InNoECTPkts = &value case "InECT1Pkts": - procSnmp6.Ip6.InECT1Pkts = value + procSnmp6.Ip6.InECT1Pkts = &value case "InECT0Pkts": - procSnmp6.Ip6.InECT0Pkts = value + procSnmp6.Ip6.InECT0Pkts = &value case "InCEPkts": - procSnmp6.Ip6.InCEPkts = value + procSnmp6.Ip6.InCEPkts = &value } case "Icmp6": switch key { case "InMsgs": - procSnmp6.Icmp6.InMsgs = value + procSnmp6.Icmp6.InMsgs = &value case "InErrors": - procSnmp6.Icmp6.InErrors = value + procSnmp6.Icmp6.InErrors = &value case "OutMsgs": - procSnmp6.Icmp6.OutMsgs = value + procSnmp6.Icmp6.OutMsgs = &value case "OutErrors": - procSnmp6.Icmp6.OutErrors = value + procSnmp6.Icmp6.OutErrors = &value case "InCsumErrors": - procSnmp6.Icmp6.InCsumErrors = value + procSnmp6.Icmp6.InCsumErrors = &value case "InDestUnreachs": - procSnmp6.Icmp6.InDestUnreachs = value + procSnmp6.Icmp6.InDestUnreachs = &value case "InPktTooBigs": - procSnmp6.Icmp6.InPktTooBigs = value + procSnmp6.Icmp6.InPktTooBigs = &value case "InTimeExcds": - procSnmp6.Icmp6.InTimeExcds = value + procSnmp6.Icmp6.InTimeExcds = &value case "InParmProblems": - procSnmp6.Icmp6.InParmProblems = value + procSnmp6.Icmp6.InParmProblems = &value case "InEchos": - procSnmp6.Icmp6.InEchos = value + procSnmp6.Icmp6.InEchos = &value case "InEchoReplies": - procSnmp6.Icmp6.InEchoReplies = value + procSnmp6.Icmp6.InEchoReplies = &value case "InGroupMembQueries": - procSnmp6.Icmp6.InGroupMembQueries = value + procSnmp6.Icmp6.InGroupMembQueries = &value case "InGroupMembResponses": - procSnmp6.Icmp6.InGroupMembResponses = value + procSnmp6.Icmp6.InGroupMembResponses = &value case "InGroupMembReductions": - procSnmp6.Icmp6.InGroupMembReductions = value + procSnmp6.Icmp6.InGroupMembReductions = &value case "InRouterSolicits": - procSnmp6.Icmp6.InRouterSolicits = value + procSnmp6.Icmp6.InRouterSolicits = &value case "InRouterAdvertisements": - procSnmp6.Icmp6.InRouterAdvertisements = value + procSnmp6.Icmp6.InRouterAdvertisements = &value case "InNeighborSolicits": - procSnmp6.Icmp6.InNeighborSolicits = value + procSnmp6.Icmp6.InNeighborSolicits = &value case "InNeighborAdvertisements": - procSnmp6.Icmp6.InNeighborAdvertisements = value + procSnmp6.Icmp6.InNeighborAdvertisements = &value case "InRedirects": - procSnmp6.Icmp6.InRedirects = value + procSnmp6.Icmp6.InRedirects = &value case "InMLDv2Reports": - procSnmp6.Icmp6.InMLDv2Reports = value + procSnmp6.Icmp6.InMLDv2Reports = &value case "OutDestUnreachs": - procSnmp6.Icmp6.OutDestUnreachs = value + procSnmp6.Icmp6.OutDestUnreachs = &value case "OutPktTooBigs": - procSnmp6.Icmp6.OutPktTooBigs = value + procSnmp6.Icmp6.OutPktTooBigs = &value case "OutTimeExcds": - procSnmp6.Icmp6.OutTimeExcds = value + procSnmp6.Icmp6.OutTimeExcds = &value case "OutParmProblems": - procSnmp6.Icmp6.OutParmProblems = value + procSnmp6.Icmp6.OutParmProblems = &value case "OutEchos": - procSnmp6.Icmp6.OutEchos = value + procSnmp6.Icmp6.OutEchos = &value case "OutEchoReplies": - procSnmp6.Icmp6.OutEchoReplies = value + procSnmp6.Icmp6.OutEchoReplies = &value case "OutGroupMembQueries": - procSnmp6.Icmp6.OutGroupMembQueries = value + procSnmp6.Icmp6.OutGroupMembQueries = &value case "OutGroupMembResponses": - procSnmp6.Icmp6.OutGroupMembResponses = value + procSnmp6.Icmp6.OutGroupMembResponses = &value case "OutGroupMembReductions": - procSnmp6.Icmp6.OutGroupMembReductions = value + procSnmp6.Icmp6.OutGroupMembReductions = &value case "OutRouterSolicits": - procSnmp6.Icmp6.OutRouterSolicits = value + procSnmp6.Icmp6.OutRouterSolicits = &value case "OutRouterAdvertisements": - procSnmp6.Icmp6.OutRouterAdvertisements = value + procSnmp6.Icmp6.OutRouterAdvertisements = &value case "OutNeighborSolicits": - procSnmp6.Icmp6.OutNeighborSolicits = value + procSnmp6.Icmp6.OutNeighborSolicits = &value case "OutNeighborAdvertisements": - procSnmp6.Icmp6.OutNeighborAdvertisements = value + procSnmp6.Icmp6.OutNeighborAdvertisements = &value case "OutRedirects": - procSnmp6.Icmp6.OutRedirects = value + procSnmp6.Icmp6.OutRedirects = &value case "OutMLDv2Reports": - procSnmp6.Icmp6.OutMLDv2Reports = value + procSnmp6.Icmp6.OutMLDv2Reports = &value case "InType1": - procSnmp6.Icmp6.InType1 = value + procSnmp6.Icmp6.InType1 = &value case "InType134": - procSnmp6.Icmp6.InType134 = value + procSnmp6.Icmp6.InType134 = &value case "InType135": - procSnmp6.Icmp6.InType135 = value + procSnmp6.Icmp6.InType135 = &value case "InType136": - procSnmp6.Icmp6.InType136 = value + procSnmp6.Icmp6.InType136 = &value case "InType143": - procSnmp6.Icmp6.InType143 = value + procSnmp6.Icmp6.InType143 = &value case "OutType133": - procSnmp6.Icmp6.OutType133 = value + procSnmp6.Icmp6.OutType133 = &value case "OutType135": - procSnmp6.Icmp6.OutType135 = value + procSnmp6.Icmp6.OutType135 = &value case "OutType136": - procSnmp6.Icmp6.OutType136 = value + procSnmp6.Icmp6.OutType136 = &value case "OutType143": - procSnmp6.Icmp6.OutType143 = value + procSnmp6.Icmp6.OutType143 = &value } case "Udp6": switch key { case "InDatagrams": - procSnmp6.Udp6.InDatagrams = value + procSnmp6.Udp6.InDatagrams = &value case "NoPorts": - procSnmp6.Udp6.NoPorts = value + procSnmp6.Udp6.NoPorts = &value case "InErrors": - procSnmp6.Udp6.InErrors = value + procSnmp6.Udp6.InErrors = &value case "OutDatagrams": - procSnmp6.Udp6.OutDatagrams = value + procSnmp6.Udp6.OutDatagrams = &value case "RcvbufErrors": - procSnmp6.Udp6.RcvbufErrors = value + procSnmp6.Udp6.RcvbufErrors = &value case "SndbufErrors": - procSnmp6.Udp6.SndbufErrors = value + procSnmp6.Udp6.SndbufErrors = &value case "InCsumErrors": - procSnmp6.Udp6.InCsumErrors = value + procSnmp6.Udp6.InCsumErrors = &value case "IgnoredMulti": - procSnmp6.Udp6.IgnoredMulti = value + procSnmp6.Udp6.IgnoredMulti = &value } case "UdpLite6": switch key { case "InDatagrams": - procSnmp6.UdpLite6.InDatagrams = value + procSnmp6.UdpLite6.InDatagrams = &value case "NoPorts": - procSnmp6.UdpLite6.NoPorts = value + procSnmp6.UdpLite6.NoPorts = &value case "InErrors": - procSnmp6.UdpLite6.InErrors = value + procSnmp6.UdpLite6.InErrors = &value case "OutDatagrams": - procSnmp6.UdpLite6.OutDatagrams = value + procSnmp6.UdpLite6.OutDatagrams = &value case "RcvbufErrors": - procSnmp6.UdpLite6.RcvbufErrors = value + procSnmp6.UdpLite6.RcvbufErrors = &value case "SndbufErrors": - procSnmp6.UdpLite6.SndbufErrors = value + procSnmp6.UdpLite6.SndbufErrors = &value case "InCsumErrors": - procSnmp6.UdpLite6.InCsumErrors = value + procSnmp6.UdpLite6.InCsumErrors = &value } } } diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_stat.go b/test/performance/vendor/github.com/prometheus/procfs/proc_stat.go index 06c556ef9..923e55005 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_stat.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_stat.go @@ -18,7 +18,6 @@ import ( "fmt" "os" - "github.com/prometheus/procfs/internal/fs" "github.com/prometheus/procfs/internal/util" ) @@ -102,6 +101,8 @@ type ProcStat struct { RSS int // Soft limit in bytes on the rss of the process. RSSLimit uint64 + // CPU number last executed on. + Processor uint // Real-time scheduling priority, a number in the range 1 to 99 for processes // scheduled under a real-time policy, or 0, for non-real-time processes. RTPriority uint @@ -110,7 +111,7 @@ type ProcStat struct { // Aggregated block I/O delays, measured in clock ticks (centiseconds). DelayAcctBlkIOTicks uint64 - proc fs.FS + proc FS } // NewStat returns the current status information of the process. @@ -137,7 +138,7 @@ func (p Proc) Stat() (ProcStat, error) { ) if l < 0 || r < 0 { - return ProcStat{}, fmt.Errorf("unexpected format, couldn't extract comm %q", data) + return ProcStat{}, fmt.Errorf("%w: unexpected format, couldn't extract comm %q", ErrFileParse, data) } s.Comm = string(data[l+1 : r]) @@ -184,7 +185,7 @@ func (p Proc) Stat() (ProcStat, error) { &ignoreUint64, &ignoreUint64, &ignoreInt64, - &ignoreInt64, + &s.Processor, &s.RTPriority, &s.Policy, &s.DelayAcctBlkIOTicks, @@ -208,8 +209,7 @@ func (s ProcStat) ResidentMemory() int { // StartTime returns the unix timestamp of the process in seconds. func (s ProcStat) StartTime() (float64, error) { - fs := FS{proc: s.proc} - stat, err := fs.Stat() + stat, err := s.proc.Stat() if err != nil { return 0, err } diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_status.go b/test/performance/vendor/github.com/prometheus/procfs/proc_status.go index 594022ded..c055d075d 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_status.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_status.go @@ -15,6 +15,7 @@ package procfs import ( "bytes" + "sort" "strconv" "strings" @@ -76,6 +77,9 @@ type ProcStatus struct { UIDs [4]string // GIDs of the process (Real, effective, saved set, and filesystem GIDs) GIDs [4]string + + // CpusAllowedList: List of cpu cores processes are allowed to run on. + CpusAllowedList []uint64 } // NewStatus returns the current status information of the process. @@ -96,10 +100,10 @@ func (p Proc) NewStatus() (ProcStatus, error) { kv := strings.SplitN(line, ":", 2) // removes spaces - k := string(strings.TrimSpace(kv[0])) - v := string(strings.TrimSpace(kv[1])) + k := strings.TrimSpace(kv[0]) + v := strings.TrimSpace(kv[1]) // removes "kB" - v = string(bytes.Trim([]byte(v), " kB")) + v = strings.TrimSuffix(v, " kB") // value to int when possible // we can skip error check here, 'cause vKBytes is not used when value is a string @@ -161,10 +165,38 @@ func (s *ProcStatus) fillStatus(k string, vString string, vUint uint64, vUintByt s.VoluntaryCtxtSwitches = vUint case "nonvoluntary_ctxt_switches": s.NonVoluntaryCtxtSwitches = vUint + case "Cpus_allowed_list": + s.CpusAllowedList = calcCpusAllowedList(vString) } + } // TotalCtxtSwitches returns the total context switch. func (s ProcStatus) TotalCtxtSwitches() uint64 { return s.VoluntaryCtxtSwitches + s.NonVoluntaryCtxtSwitches } + +func calcCpusAllowedList(cpuString string) []uint64 { + s := strings.Split(cpuString, ",") + + var g []uint64 + + for _, cpu := range s { + // parse cpu ranges, example: 1-3=[1,2,3] + if l := strings.Split(strings.TrimSpace(cpu), "-"); len(l) > 1 { + startCPU, _ := strconv.ParseUint(l[0], 10, 64) + endCPU, _ := strconv.ParseUint(l[1], 10, 64) + + for i := startCPU; i <= endCPU; i++ { + g = append(g, i) + } + } else if len(l) == 1 { + cpu, _ := strconv.ParseUint(l[0], 10, 64) + g = append(g, cpu) + } + + } + + sort.Slice(g, func(i, j int) bool { return g[i] < g[j] }) + return g +} diff --git a/test/performance/vendor/github.com/prometheus/procfs/proc_sys.go b/test/performance/vendor/github.com/prometheus/procfs/proc_sys.go index d46533ebf..12c5bf05b 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/proc_sys.go +++ b/test/performance/vendor/github.com/prometheus/procfs/proc_sys.go @@ -44,7 +44,7 @@ func (fs FS) SysctlInts(sysctl string) ([]int, error) { vp := util.NewValueParser(f) values[i] = vp.Int() if err := vp.Err(); err != nil { - return nil, fmt.Errorf("field %d in sysctl %s is not a valid int: %w", i, sysctl, err) + return nil, fmt.Errorf("%s: field %d in sysctl %s is not a valid int: %w", ErrFileParse, i, sysctl, err) } } return values, nil diff --git a/test/performance/vendor/github.com/prometheus/procfs/slab.go b/test/performance/vendor/github.com/prometheus/procfs/slab.go index bc9aaf5c2..8611c9017 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/slab.go +++ b/test/performance/vendor/github.com/prometheus/procfs/slab.go @@ -68,7 +68,7 @@ func parseV21SlabEntry(line string) (*Slab, error) { l := slabSpace.ReplaceAllString(line, " ") s := strings.Split(l, " ") if len(s) != 16 { - return nil, fmt.Errorf("unable to parse: %q", line) + return nil, fmt.Errorf("%w: unable to parse: %q", ErrFileParse, line) } var err error i := &Slab{Name: s[0]} diff --git a/test/performance/vendor/github.com/prometheus/procfs/softirqs.go b/test/performance/vendor/github.com/prometheus/procfs/softirqs.go index 559129cbc..b8fad677d 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/softirqs.go +++ b/test/performance/vendor/github.com/prometheus/procfs/softirqs.go @@ -57,7 +57,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { ) if !scanner.Scan() { - return Softirqs{}, fmt.Errorf("softirqs empty") + return Softirqs{}, fmt.Errorf("%w: softirqs empty", ErrFileRead) } for scanner.Scan() { @@ -74,7 +74,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Hi = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Hi[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (HI%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (HI%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "TIMER:": @@ -82,7 +82,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Timer = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Timer[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (TIMER%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (TIMER%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "NET_TX:": @@ -90,7 +90,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.NetTx = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.NetTx[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (NET_TX%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (NET_TX%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "NET_RX:": @@ -98,7 +98,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.NetRx = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.NetRx[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (NET_RX%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (NET_RX%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "BLOCK:": @@ -106,7 +106,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Block = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Block[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (BLOCK%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (BLOCK%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "IRQ_POLL:": @@ -114,7 +114,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.IRQPoll = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.IRQPoll[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (IRQ_POLL%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (IRQ_POLL%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "TASKLET:": @@ -122,7 +122,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Tasklet = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Tasklet[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (TASKLET%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (TASKLET%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "SCHED:": @@ -130,7 +130,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Sched = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Sched[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (SCHED%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (SCHED%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "HRTIMER:": @@ -138,7 +138,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.HRTimer = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.HRTimer[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (HRTIMER%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (HRTIMER%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "RCU:": @@ -146,14 +146,14 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.RCU = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.RCU[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (RCU%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (RCU%d): %w", ErrFileParse, count, i, err) } } } } if err := scanner.Err(); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse softirqs: %w", err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse softirqs: %w", ErrFileParse, err) } return softirqs, scanner.Err() diff --git a/test/performance/vendor/github.com/prometheus/procfs/stat.go b/test/performance/vendor/github.com/prometheus/procfs/stat.go index 33f97caa0..05269c896 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/stat.go +++ b/test/performance/vendor/github.com/prometheus/procfs/stat.go @@ -62,7 +62,7 @@ type Stat struct { // Summed up cpu statistics. CPUTotal CPUStat // Per-CPU statistics. - CPU []CPUStat + CPU map[int64]CPUStat // Number of times interrupts were handled, which contains numbered and unnumbered IRQs. IRQTotal uint64 // Number of times a numbered IRQ was triggered. @@ -93,10 +93,10 @@ func parseCPUStat(line string) (CPUStat, int64, error) { &cpuStat.Guest, &cpuStat.GuestNice) if err != nil && err != io.EOF { - return CPUStat{}, -1, fmt.Errorf("couldn't parse %q (cpu): %w", line, err) + return CPUStat{}, -1, fmt.Errorf("%s: couldn't parse %q (cpu): %w", ErrFileParse, line, err) } if count == 0 { - return CPUStat{}, -1, fmt.Errorf("couldn't parse %q (cpu): 0 elements parsed", line) + return CPUStat{}, -1, fmt.Errorf("%w: couldn't parse %q (cpu): 0 elements parsed", ErrFileParse, line) } cpuStat.User /= userHZ @@ -116,7 +116,7 @@ func parseCPUStat(line string) (CPUStat, int64, error) { cpuID, err := strconv.ParseInt(cpu[3:], 10, 64) if err != nil { - return CPUStat{}, -1, fmt.Errorf("couldn't parse %q (cpu/cpuid): %w", line, err) + return CPUStat{}, -1, fmt.Errorf("%s: couldn't parse %q (cpu/cpuid): %w", ErrFileParse, line, err) } return cpuStat, cpuID, nil @@ -136,7 +136,7 @@ func parseSoftIRQStat(line string) (SoftIRQStat, uint64, error) { &softIRQStat.Hrtimer, &softIRQStat.Rcu) if err != nil { - return SoftIRQStat{}, 0, fmt.Errorf("couldn't parse %q (softirq): %w", line, err) + return SoftIRQStat{}, 0, fmt.Errorf("%s: couldn't parse %q (softirq): %w", ErrFileParse, line, err) } return softIRQStat, total, nil @@ -170,10 +170,23 @@ func (fs FS) Stat() (Stat, error) { if err != nil { return Stat{}, err } + procStat, err := parseStat(bytes.NewReader(data), fileName) + if err != nil { + return Stat{}, err + } + return procStat, nil +} - stat := Stat{} +// parseStat parses the metrics from /proc/[pid]/stat. +func parseStat(r io.Reader, fileName string) (Stat, error) { + var ( + scanner = bufio.NewScanner(r) + stat = Stat{ + CPU: make(map[int64]CPUStat), + } + err error + ) - scanner := bufio.NewScanner(bytes.NewReader(data)) for scanner.Scan() { line := scanner.Text() parts := strings.Fields(scanner.Text()) @@ -184,34 +197,34 @@ func (fs FS) Stat() (Stat, error) { switch { case parts[0] == "btime": if stat.BootTime, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (btime): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (btime): %w", ErrFileParse, parts[1], err) } case parts[0] == "intr": if stat.IRQTotal, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (intr): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (intr): %w", ErrFileParse, parts[1], err) } numberedIRQs := parts[2:] stat.IRQ = make([]uint64, len(numberedIRQs)) for i, count := range numberedIRQs { if stat.IRQ[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (intr%d): %w", count, i, err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (intr%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "ctxt": if stat.ContextSwitches, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (ctxt): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (ctxt): %w", ErrFileParse, parts[1], err) } case parts[0] == "processes": if stat.ProcessCreated, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (processes): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (processes): %w", ErrFileParse, parts[1], err) } case parts[0] == "procs_running": if stat.ProcessesRunning, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (procs_running): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (procs_running): %w", ErrFileParse, parts[1], err) } case parts[0] == "procs_blocked": if stat.ProcessesBlocked, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (procs_blocked): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (procs_blocked): %w", ErrFileParse, parts[1], err) } case parts[0] == "softirq": softIRQStats, total, err := parseSoftIRQStat(line) @@ -228,16 +241,13 @@ func (fs FS) Stat() (Stat, error) { if cpuID == -1 { stat.CPUTotal = cpuStat } else { - for int64(len(stat.CPU)) <= cpuID { - stat.CPU = append(stat.CPU, CPUStat{}) - } stat.CPU[cpuID] = cpuStat } } } if err := scanner.Err(); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q: %w", fileName, err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q: %w", ErrFileParse, fileName, err) } return stat, nil diff --git a/test/performance/vendor/github.com/prometheus/procfs/swaps.go b/test/performance/vendor/github.com/prometheus/procfs/swaps.go index 15edc2212..fa00f555d 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/swaps.go +++ b/test/performance/vendor/github.com/prometheus/procfs/swaps.go @@ -64,7 +64,7 @@ func parseSwapString(swapString string) (*Swap, error) { swapFields := strings.Fields(swapString) swapLength := len(swapFields) if swapLength < 5 { - return nil, fmt.Errorf("too few fields in swap string: %s", swapString) + return nil, fmt.Errorf("%w: too few fields in swap string: %s", ErrFileParse, swapString) } swap := &Swap{ @@ -74,15 +74,15 @@ func parseSwapString(swapString string) (*Swap, error) { swap.Size, err = strconv.Atoi(swapFields[2]) if err != nil { - return nil, fmt.Errorf("invalid swap size: %s", swapFields[2]) + return nil, fmt.Errorf("%s: invalid swap size: %s: %w", ErrFileParse, swapFields[2], err) } swap.Used, err = strconv.Atoi(swapFields[3]) if err != nil { - return nil, fmt.Errorf("invalid swap used: %s", swapFields[3]) + return nil, fmt.Errorf("%s: invalid swap used: %s: %w", ErrFileParse, swapFields[3], err) } swap.Priority, err = strconv.Atoi(swapFields[4]) if err != nil { - return nil, fmt.Errorf("invalid swap priority: %s", swapFields[4]) + return nil, fmt.Errorf("%s: invalid swap priority: %s: %w", ErrFileParse, swapFields[4], err) } return swap, nil diff --git a/test/performance/vendor/github.com/prometheus/procfs/thread.go b/test/performance/vendor/github.com/prometheus/procfs/thread.go new file mode 100644 index 000000000..394762c73 --- /dev/null +++ b/test/performance/vendor/github.com/prometheus/procfs/thread.go @@ -0,0 +1,80 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "fmt" + "os" + "strconv" + + fsi "github.com/prometheus/procfs/internal/fs" +) + +// Provide access to /proc/PID/task/TID files, for thread specific values. Since +// such files have the same structure as /proc/PID/ ones, the data structures +// and the parsers for the latter may be reused. + +// AllThreads returns a list of all currently available threads under /proc/PID. +func AllThreads(pid int) (Procs, error) { + fs, err := NewFS(DefaultMountPoint) + if err != nil { + return Procs{}, err + } + return fs.AllThreads(pid) +} + +// AllThreads returns a list of all currently available threads for PID. +func (fs FS) AllThreads(pid int) (Procs, error) { + taskPath := fs.proc.Path(strconv.Itoa(pid), "task") + d, err := os.Open(taskPath) + if err != nil { + return Procs{}, err + } + defer d.Close() + + names, err := d.Readdirnames(-1) + if err != nil { + return Procs{}, fmt.Errorf("%s: could not read %q: %w", ErrFileRead, d.Name(), err) + } + + t := Procs{} + for _, n := range names { + tid, err := strconv.ParseInt(n, 10, 64) + if err != nil { + continue + } + + t = append(t, Proc{PID: int(tid), fs: FS{fsi.FS(taskPath), fs.real}}) + } + + return t, nil +} + +// Thread returns a process for a given PID, TID. +func (fs FS) Thread(pid, tid int) (Proc, error) { + taskPath := fs.proc.Path(strconv.Itoa(pid), "task") + if _, err := os.Stat(taskPath); err != nil { + return Proc{}, err + } + return Proc{PID: tid, fs: FS{fsi.FS(taskPath), fs.real}}, nil +} + +// Thread returns a process for a given TID of Proc. +func (proc Proc) Thread(tid int) (Proc, error) { + tfs := FS{fsi.FS(proc.path("task")), proc.fs.real} + if _, err := os.Stat(tfs.proc.Path(strconv.Itoa(tid))); err != nil { + return Proc{}, err + } + return Proc{PID: tid, fs: tfs}, nil +} diff --git a/test/performance/vendor/github.com/prometheus/procfs/vm.go b/test/performance/vendor/github.com/prometheus/procfs/vm.go index 20ceb77e2..51c49d89e 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/vm.go +++ b/test/performance/vendor/github.com/prometheus/procfs/vm.go @@ -26,7 +26,9 @@ import ( ) // The VM interface is described at -// https://www.kernel.org/doc/Documentation/sysctl/vm.txt +// +// https://www.kernel.org/doc/Documentation/sysctl/vm.txt +// // Each setting is exposed as a single file. // Each file contains one line with a single numerical value, except lowmem_reserve_ratio which holds an array // and numa_zonelist_order (deprecated) which is a string. @@ -84,7 +86,7 @@ func (fs FS) VM() (*VM, error) { return nil, err } if !file.Mode().IsDir() { - return nil, fmt.Errorf("%s is not a directory", path) + return nil, fmt.Errorf("%w: %s is not a directory", ErrFileRead, path) } files, err := os.ReadDir(path) diff --git a/test/performance/vendor/github.com/prometheus/procfs/zoneinfo.go b/test/performance/vendor/github.com/prometheus/procfs/zoneinfo.go index c745a4c04..ce5fefa5b 100644 --- a/test/performance/vendor/github.com/prometheus/procfs/zoneinfo.go +++ b/test/performance/vendor/github.com/prometheus/procfs/zoneinfo.go @@ -75,11 +75,11 @@ var nodeZoneRE = regexp.MustCompile(`(\d+), zone\s+(\w+)`) func (fs FS) Zoneinfo() ([]Zoneinfo, error) { data, err := os.ReadFile(fs.proc.Path("zoneinfo")) if err != nil { - return nil, fmt.Errorf("error reading zoneinfo %q: %w", fs.proc.Path("zoneinfo"), err) + return nil, fmt.Errorf("%s: error reading zoneinfo %q: %w", ErrFileRead, fs.proc.Path("zoneinfo"), err) } zoneinfo, err := parseZoneinfo(data) if err != nil { - return nil, fmt.Errorf("error parsing zoneinfo %q: %w", fs.proc.Path("zoneinfo"), err) + return nil, fmt.Errorf("%s: error parsing zoneinfo %q: %w", ErrFileParse, fs.proc.Path("zoneinfo"), err) } return zoneinfo, nil } diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/common/env.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/common/env.go new file mode 100644 index 000000000..4b5f4980c --- /dev/null +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/common/env.go @@ -0,0 +1,23 @@ +package common + +type EnvKeyType string + +// EnvKey is a context key that can be used to set programmatically the environment +// gopsutil relies on to perform calls against the OS. +// Example of use: +// +// ctx := context.WithValue(context.Background(), common.EnvKey, EnvMap{common.HostProcEnvKey: "/myproc"}) +// avg, err := load.AvgWithContext(ctx) +var EnvKey = EnvKeyType("env") + +const ( + HostProcEnvKey EnvKeyType = "HOST_PROC" + HostSysEnvKey EnvKeyType = "HOST_SYS" + HostEtcEnvKey EnvKeyType = "HOST_ETC" + HostVarEnvKey EnvKeyType = "HOST_VAR" + HostRunEnvKey EnvKeyType = "HOST_RUN" + HostDevEnvKey EnvKeyType = "HOST_DEV" + HostRootEnvKey EnvKeyType = "HOST_ROOT" +) + +type EnvMap map[EnvKeyType]string diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go index 7acb258d9..41f395e5e 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" + "github.com/shoenig/go-m1cpu" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" ) @@ -85,11 +86,15 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.CacheSize = int32(cacheSize) c.VendorID, _ = unix.Sysctl("machdep.cpu.vendor") - // Use the rated frequency of the CPU. This is a static value and does not - // account for low power or Turbo Boost modes. - cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") - if err == nil { - c.Mhz = float64(cpuFrequency) / 1000000.0 + if m1cpu.IsAppleSilicon() { + c.Mhz = float64(m1cpu.PCoreHz() / 1_000_000) + } else { + // Use the rated frequency of the CPU. This is a static value and does not + // account for low power or Turbo Boost modes. + cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") + if err == nil { + c.Mhz = float64(cpuFrequency) / 1000000.0 + } } return append(ret, c), nil diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go index 962d34300..1b64241ce 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go @@ -11,8 +11,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "github.com/tklauser/go-sysconf" + + "github.com/shirou/gopsutil/v3/internal/common" ) var ClocksPerSec = float64(100) @@ -95,7 +96,7 @@ func Times(percpu bool) ([]TimesStat, error) { } func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { - filename := common.HostProc("stat") + filename := common.HostProcWithContext(ctx, "stat") lines := []string{} if percpu { statlines, err := common.ReadLines(filename) @@ -125,17 +126,17 @@ func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { return ret, nil } -func sysCPUPath(cpu int32, relPath string) string { - return common.HostSys(fmt.Sprintf("devices/system/cpu/cpu%d", cpu), relPath) +func sysCPUPath(ctx context.Context, cpu int32, relPath string) string { + return common.HostSysWithContext(ctx, fmt.Sprintf("devices/system/cpu/cpu%d", cpu), relPath) } -func finishCPUInfo(c *InfoStat) { +func finishCPUInfo(ctx context.Context, c *InfoStat) { var lines []string var err error var value float64 if len(c.CoreID) == 0 { - lines, err = common.ReadLines(sysCPUPath(c.CPU, "topology/core_id")) + lines, err = common.ReadLines(sysCPUPath(ctx, c.CPU, "topology/core_id")) if err == nil { c.CoreID = lines[0] } @@ -144,7 +145,7 @@ func finishCPUInfo(c *InfoStat) { // override the value of c.Mhz with cpufreq/cpuinfo_max_freq regardless // of the value from /proc/cpuinfo because we want to report the maximum // clock-speed of the CPU for c.Mhz, matching the behaviour of Windows - lines, err = common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq")) + lines, err = common.ReadLines(sysCPUPath(ctx, c.CPU, "cpufreq/cpuinfo_max_freq")) // if we encounter errors below such as there are no cpuinfo_max_freq file, // we just ignore. so let Mhz is 0. if err != nil || len(lines) == 0 { @@ -172,7 +173,7 @@ func Info() ([]InfoStat, error) { } func InfoWithContext(ctx context.Context) ([]InfoStat, error) { - filename := common.HostProc("cpuinfo") + filename := common.HostProcWithContext(ctx, "cpuinfo") lines, _ := common.ReadLines(filename) var ret []InfoStat @@ -192,7 +193,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { processorName = value case "processor", "cpu number": if c.CPU >= 0 { - finishCPUInfo(&c) + finishCPUInfo(ctx, &c) ret = append(ret, c) } c = InfoStat{Cores: 1, ModelName: processorName} @@ -300,7 +301,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { } } if c.CPU >= 0 { - finishCPUInfo(&c) + finishCPUInfo(ctx, &c) ret = append(ret, c) } return ret, nil @@ -389,7 +390,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { if logical { ret := 0 // https://github.com/giampaolo/psutil/blob/d01a9eaa35a8aadf6c519839e987a49d8be2d891/psutil/_pslinux.py#L599 - procCpuinfo := common.HostProc("cpuinfo") + procCpuinfo := common.HostProcWithContext(ctx, "cpuinfo") lines, err := common.ReadLines(procCpuinfo) if err == nil { for _, line := range lines { @@ -403,7 +404,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { } } if ret == 0 { - procStat := common.HostProc("stat") + procStat := common.HostProcWithContext(ctx, "stat") lines, err = common.ReadLines(procStat) if err != nil { return 0, err @@ -424,7 +425,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { // https://github.com/giampaolo/psutil/pull/1727#issuecomment-707624964 // https://lkml.org/lkml/2019/2/26/41 for _, glob := range []string{"devices/system/cpu/cpu[0-9]*/topology/core_cpus_list", "devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list"} { - if files, err := filepath.Glob(common.HostSys(glob)); err == nil { + if files, err := filepath.Glob(common.HostSysWithContext(ctx, glob)); err == nil { for _, file := range files { lines, err := common.ReadLines(file) if err != nil || len(lines) != 1 { @@ -439,7 +440,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { } } // https://github.com/giampaolo/psutil/blob/122174a10b75c9beebe15f6c07dcf3afbe3b120d/psutil/_pslinux.py#L631-L652 - filename := common.HostProc("cpuinfo") + filename := common.HostProcWithContext(ctx, "cpuinfo") lines, err := common.ReadLines(filename) if err != nil { return 0, err diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk.go index dd4cc1d5f..0d4b25345 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk.go @@ -9,6 +9,8 @@ import ( var invoke common.Invoker = common.Invoke{} +type Warnings = common.Warnings + type UsageStat struct { Path string `json:"path"` Fstype string `json:"fstype"` diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go index 933cb0454..9362d9e5d 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go @@ -6,8 +6,9 @@ package disk import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) // PartitionsWithContext returns disk partition. diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go index b6a3adcf5..2a8c50ae4 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go @@ -16,8 +16,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) const ( @@ -259,10 +260,10 @@ func readMountFile(root string) (lines []string, useMounts bool, filename string func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) { // by default, try "/proc/1/..." first - root := common.HostProc(path.Join("1")) + root := common.HostProcWithContext(ctx, path.Join("1")) // force preference for dirname of HOST_PROC_MOUNTINFO, if set #1271 - hpmPath := os.Getenv("HOST_PROC_MOUNTINFO") + hpmPath := common.HostProcMountInfoWithContext(ctx) if hpmPath != "" { root = filepath.Dir(hpmPath) } @@ -273,13 +274,13 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro return nil, err } // fallback to "/proc/self/..." #1159 - lines, useMounts, filename, err = readMountFile(common.HostProc(path.Join("self"))) + lines, useMounts, filename, err = readMountFile(common.HostProcWithContext(ctx, path.Join("self"))) if err != nil { return nil, err } } - fs, err := getFileSystems() + fs, err := getFileSystems(ctx) if err != nil && !all { return nil, err } @@ -341,7 +342,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro } if strings.HasPrefix(d.Device, "/dev/mapper/") { - devpath, err := filepath.EvalSymlinks(common.HostDev(strings.Replace(d.Device, "/dev", "", 1))) + devpath, err := filepath.EvalSymlinks(common.HostDevWithContext(ctx, strings.Replace(d.Device, "/dev", "", 1))) if err == nil { d.Device = devpath } @@ -350,7 +351,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro // /dev/root is not the real device name // so we get the real device name from its major/minor number if d.Device == "/dev/root" { - devpath, err := os.Readlink(common.HostSys("/dev/block/" + blockDeviceID)) + devpath, err := os.Readlink(common.HostSysWithContext(ctx, "/dev/block/"+blockDeviceID)) if err == nil { d.Device = strings.Replace(d.Device, "root", filepath.Base(devpath), 1) } @@ -363,8 +364,8 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro } // getFileSystems returns supported filesystems from /proc/filesystems -func getFileSystems() ([]string, error) { - filename := common.HostProc("filesystems") +func getFileSystems(ctx context.Context) ([]string, error) { + filename := common.HostProcWithContext(ctx, "filesystems") lines, err := common.ReadLines(filename) if err != nil { return nil, err @@ -386,7 +387,7 @@ func getFileSystems() ([]string, error) { } func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) { - filename := common.HostProc("diskstats") + filename := common.HostProcWithContext(ctx, "diskstats") lines, err := common.ReadLines(filename) if err != nil { return nil, err @@ -491,7 +492,7 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) { minor := unix.Minor(uint64(stat.Rdev)) // Try to get the serial from udev data - udevDataPath := common.HostRun(fmt.Sprintf("udev/data/b%d:%d", major, minor)) + udevDataPath := common.HostRunWithContext(ctx, fmt.Sprintf("udev/data/b%d:%d", major, minor)) if udevdata, err := ioutil.ReadFile(udevDataPath); err == nil { scanner := bufio.NewScanner(bytes.NewReader(udevdata)) for scanner.Scan() { @@ -504,7 +505,7 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) { // Try to get the serial from sysfs, look at the disk device (minor 0) directly // because if it is a partition it is not going to contain any device information - devicePath := common.HostSys(fmt.Sprintf("dev/block/%d:0/device", major)) + devicePath := common.HostSysWithContext(ctx, fmt.Sprintf("dev/block/%d:0/device", major)) model, _ := ioutil.ReadFile(filepath.Join(devicePath, "model")) serial, _ := ioutil.ReadFile(filepath.Join(devicePath, "serial")) if len(model) > 0 && len(serial) > 0 { @@ -515,7 +516,7 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) { func LabelWithContext(ctx context.Context, name string) (string, error) { // Try label based on devicemapper name - dmname_filename := common.HostSys(fmt.Sprintf("block/%s/dm/name", name)) + dmname_filename := common.HostSysWithContext(ctx, fmt.Sprintf("block/%s/dm/name", name)) if !common.PathExists(dmname_filename) { return "", nil diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go index 5dfd1ca98..8a1a28d69 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go @@ -7,6 +7,7 @@ import ( "bytes" "context" "fmt" + "sync" "syscall" "unsafe" @@ -15,8 +16,6 @@ import ( "golang.org/x/sys/windows/registry" ) -type Warnings = common.Warnings - var ( procGetDiskFreeSpaceExW = common.Modkernel32.NewProc("GetDiskFreeSpaceExW") procGetLogicalDriveStringsW = common.Modkernel32.NewProc("GetLogicalDriveStringsW") @@ -90,12 +89,20 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro var ret []PartitionStat retChan := make(chan []PartitionStat) errChan := make(chan error) - defer close(retChan) - defer close(errChan) - lpBuffer := make([]byte, 254) + var waitgrp sync.WaitGroup + waitgrp.Add(1) + defer waitgrp.Done() + f := func() { + defer func() { + waitgrp.Wait() + // fires when this func and the outside func finishes. + close(errChan) + close(retChan) + }() + diskret, _, err := procGetLogicalDriveStringsW.Call( uintptr(len(lpBuffer)), uintptr(unsafe.Pointer(&lpBuffer[0]))) diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host.go index f363eed83..c7e84e3a5 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host.go @@ -11,6 +11,8 @@ import ( "github.com/shirou/gopsutil/v3/internal/common" ) +type Warnings = common.Warnings + var invoke common.Invoker = common.Invoke{} // A HostInfoStat describes the host status. diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go index 2f20fc616..1be2e8533 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go @@ -13,9 +13,10 @@ import ( "strings" "unsafe" + "golang.org/x/sys/unix" + "github.com/shirou/gopsutil/v3/internal/common" "github.com/shirou/gopsutil/v3/process" - "golang.org/x/sys/unix" ) // from utmpx.h diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go index 9dc63322b..62a4b3ca9 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go @@ -15,11 +15,10 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" -) -type Warnings = common.Warnings + "github.com/shirou/gopsutil/v3/internal/common" +) type lsbStruct struct { ID string @@ -36,9 +35,9 @@ const ( ) func HostIDWithContext(ctx context.Context) (string, error) { - sysProductUUID := common.HostSys("class/dmi/id/product_uuid") - machineID := common.HostEtc("machine-id") - procSysKernelRandomBootID := common.HostProc("sys/kernel/random/boot_id") + sysProductUUID := common.HostSysWithContext(ctx, "class/dmi/id/product_uuid") + machineID := common.HostEtcWithContext(ctx, "machine-id") + procSysKernelRandomBootID := common.HostProcWithContext(ctx, "sys/kernel/random/boot_id") switch { // In order to read this file, needs to be supported by kernel/arch and run as root // so having fallback is important @@ -68,7 +67,7 @@ func HostIDWithContext(ctx context.Context) (string, error) { } func numProcs(ctx context.Context) (uint64, error) { - return common.NumProcs() + return common.NumProcsWithContext(ctx) } func BootTimeWithContext(ctx context.Context) (uint64, error) { @@ -84,7 +83,7 @@ func UptimeWithContext(ctx context.Context) (uint64, error) { } func UsersWithContext(ctx context.Context) ([]UserStat, error) { - utmpfile := common.HostVar("run/utmp") + utmpfile := common.HostVarWithContext(ctx, "run/utmp") file, err := os.Open(utmpfile) if err != nil { @@ -125,10 +124,10 @@ func UsersWithContext(ctx context.Context) ([]UserStat, error) { return ret, nil } -func getlsbStruct() (*lsbStruct, error) { +func getlsbStruct(ctx context.Context) (*lsbStruct, error) { ret := &lsbStruct{} - if common.PathExists(common.HostEtc("lsb-release")) { - contents, err := common.ReadLines(common.HostEtc("lsb-release")) + if common.PathExists(common.HostEtcWithContext(ctx, "lsb-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "lsb-release")) if err != nil { return ret, err // return empty } @@ -176,31 +175,31 @@ func getlsbStruct() (*lsbStruct, error) { } func PlatformInformationWithContext(ctx context.Context) (platform string, family string, version string, err error) { - lsb, err := getlsbStruct() + lsb, err := getlsbStruct(ctx) if err != nil { lsb = &lsbStruct{} } - if common.PathExistsWithContents(common.HostEtc("oracle-release")) { + if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "oracle-release")) { platform = "oracle" - contents, err := common.ReadLines(common.HostEtc("oracle-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "oracle-release")) if err == nil { version = getRedhatishVersion(contents) } - } else if common.PathExistsWithContents(common.HostEtc("enterprise-release")) { + } else if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "enterprise-release")) { platform = "oracle" - contents, err := common.ReadLines(common.HostEtc("enterprise-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "enterprise-release")) if err == nil { version = getRedhatishVersion(contents) } - } else if common.PathExistsWithContents(common.HostEtc("slackware-version")) { + } else if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "slackware-version")) { platform = "slackware" - contents, err := common.ReadLines(common.HostEtc("slackware-version")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "slackware-version")) if err == nil { version = getSlackwareVersion(contents) } - } else if common.PathExistsWithContents(common.HostEtc("debian_version")) { + } else if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "debian_version")) { if lsb.ID == "Ubuntu" { platform = "ubuntu" version = lsb.Release @@ -210,59 +209,62 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil } else if lsb.ID == "Kylin" { platform = "Kylin" version = lsb.Release + } else if lsb.ID == `"Cumulus Linux"` { + platform = "cumuluslinux" + version = lsb.Release } else { if common.PathExistsWithContents("/usr/bin/raspi-config") { platform = "raspbian" } else { platform = "debian" } - contents, err := common.ReadLines(common.HostEtc("debian_version")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "debian_version")) if err == nil && len(contents) > 0 && contents[0] != "" { version = contents[0] } } - } else if common.PathExists(common.HostEtc("neokylin-release")) { - contents, err := common.ReadLines(common.HostEtc("neokylin-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "neokylin-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "neokylin-release")) if err == nil { version = getRedhatishVersion(contents) platform = getRedhatishPlatform(contents) } - } else if common.PathExists(common.HostEtc("redhat-release")) { - contents, err := common.ReadLines(common.HostEtc("redhat-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "redhat-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "redhat-release")) if err == nil { version = getRedhatishVersion(contents) platform = getRedhatishPlatform(contents) } - } else if common.PathExists(common.HostEtc("system-release")) { - contents, err := common.ReadLines(common.HostEtc("system-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "system-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "system-release")) if err == nil { version = getRedhatishVersion(contents) platform = getRedhatishPlatform(contents) } - } else if common.PathExists(common.HostEtc("gentoo-release")) { + } else if common.PathExists(common.HostEtcWithContext(ctx, "gentoo-release")) { platform = "gentoo" - contents, err := common.ReadLines(common.HostEtc("gentoo-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "gentoo-release")) if err == nil { version = getRedhatishVersion(contents) } - } else if common.PathExists(common.HostEtc("SuSE-release")) { - contents, err := common.ReadLines(common.HostEtc("SuSE-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "SuSE-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "SuSE-release")) if err == nil { version = getSuseVersion(contents) platform = getSusePlatform(contents) } // TODO: slackware detecion - } else if common.PathExists(common.HostEtc("arch-release")) { + } else if common.PathExists(common.HostEtcWithContext(ctx, "arch-release")) { platform = "arch" version = lsb.Release - } else if common.PathExists(common.HostEtc("alpine-release")) { + } else if common.PathExists(common.HostEtcWithContext(ctx, "alpine-release")) { platform = "alpine" - contents, err := common.ReadLines(common.HostEtc("alpine-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "alpine-release")) if err == nil && len(contents) > 0 && contents[0] != "" { version = contents[0] } - } else if common.PathExists(common.HostEtc("os-release")) { - p, v, err := common.GetOSRelease() + } else if common.PathExists(common.HostEtcWithContext(ctx, "os-release")) { + p, v, err := common.GetOSReleaseWithContext(ctx) if err == nil { platform = p version = v @@ -287,7 +289,7 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil platform = strings.Trim(platform, `"`) switch platform { - case "debian", "ubuntu", "linuxmint", "raspbian": + case "debian", "ubuntu", "linuxmint", "raspbian", "Kylin", "cumuluslinux": family = "debian" case "fedora": family = "fedora" @@ -388,14 +390,14 @@ func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, err // Only the temp*_input file provides current temperature // value in millidegree Celsius as reported by the temperature to the device: // https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface - if files, err = filepath.Glob(common.HostSys("/class/hwmon/hwmon*/temp*_input")); err != nil { + if files, err = filepath.Glob(common.HostSysWithContext(ctx, "/class/hwmon/hwmon*/temp*_input")); err != nil { return temperatures, err } if len(files) == 0 { // CentOS has an intermediate /device directory: // https://github.com/giampaolo/psutil/issues/971 - if files, err = filepath.Glob(common.HostSys("/class/hwmon/hwmon*/device/temp*_input")); err != nil { + if files, err = filepath.Glob(common.HostSysWithContext(ctx, "/class/hwmon/hwmon*/device/temp*_input")); err != nil { return temperatures, err } } @@ -403,7 +405,7 @@ func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, err var warns Warnings if len(files) == 0 { // handle distributions without hwmon, like raspbian #391, parse legacy thermal_zone files - files, err = filepath.Glob(common.HostSys("/class/thermal/thermal_zone*/")) + files, err = filepath.Glob(common.HostSysWithContext(ctx, "/class/thermal/thermal_zone*/")) if err != nil { return temperatures, err } diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go index c1e96ca7d..9bfece362 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go @@ -25,6 +25,8 @@ import ( "strconv" "strings" "time" + + "github.com/shirou/gopsutil/v3/common" ) var ( @@ -321,6 +323,23 @@ func PathExistsWithContents(filename string) bool { return info.Size() > 4 // at least 4 bytes } +// GetEnvWithContext retrieves the environment variable key. If it does not exist it returns the default. +// The context may optionally contain a map superseding os.EnvKey. +func GetEnvWithContext(ctx context.Context, key string, dfault string, combineWith ...string) string { + var value string + if env, ok := ctx.Value(common.EnvKey).(common.EnvMap); ok { + value = env[common.EnvKeyType(key)] + } + if value == "" { + value = os.Getenv(key) + } + if value == "" { + value = dfault + } + + return combine(value, combineWith) +} + // GetEnv retrieves the environment variable key. If it does not exist it returns the default. func GetEnv(key string, dfault string, combineWith ...string) string { value := os.Getenv(key) @@ -328,6 +347,10 @@ func GetEnv(key string, dfault string, combineWith ...string) string { value = dfault } + return combine(value, combineWith) +} + +func combine(value string, combineWith []string) string { switch len(combineWith) { case 0: return value @@ -369,6 +392,38 @@ func HostRoot(combineWith ...string) string { return GetEnv("HOST_ROOT", "/", combineWith...) } +func HostProcWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_PROC", "/proc", combineWith...) +} + +func HostProcMountInfoWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_PROC_MOUNTINFO", "", combineWith...) +} + +func HostSysWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_SYS", "/sys", combineWith...) +} + +func HostEtcWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_ETC", "/etc", combineWith...) +} + +func HostVarWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_VAR", "/var", combineWith...) +} + +func HostRunWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_RUN", "/run", combineWith...) +} + +func HostDevWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_DEV", "/dev", combineWith...) +} + +func HostRootWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_ROOT", "/", combineWith...) +} + // getSysctrlEnv sets LC_ALL=C in a list of env vars for use when running // sysctl commands (see DoSysctrl). func getSysctrlEnv(env []string) []string { diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go index fa6373b55..b58edbeb0 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go @@ -31,7 +31,11 @@ func DoSysctrl(mib string) ([]string, error) { } func NumProcs() (uint64, error) { - f, err := os.Open(HostProc()) + return NumProcsWithContext(context.Background()) +} + +func NumProcsWithContext(ctx context.Context) (uint64, error) { + f, err := os.Open(HostProcWithContext(ctx)) if err != nil { return 0, err } @@ -67,7 +71,7 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) { statFile = "uptime" } - filename := HostProc(statFile) + filename := HostProcWithContext(ctx, statFile) lines, err := ReadLines(filename) if os.IsPermission(err) { var info syscall.Sysinfo_t @@ -139,7 +143,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } cachedVirtMutex.RUnlock() - filename := HostProc("xen") + filename := HostProcWithContext(ctx, "xen") if PathExists(filename) { system = "xen" role = "guest" // assume guest @@ -154,7 +158,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc("modules") + filename = HostProcWithContext(ctx, "modules") if PathExists(filename) { contents, err := ReadLines(filename) if err == nil { @@ -177,7 +181,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc("cpuinfo") + filename = HostProcWithContext(ctx, "cpuinfo") if PathExists(filename) { contents, err := ReadLines(filename) if err == nil { @@ -190,7 +194,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc("bus/pci/devices") + filename = HostProcWithContext(ctx, "bus/pci/devices") if PathExists(filename) { contents, err := ReadLines(filename) if err == nil { @@ -200,7 +204,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc() + filename = HostProcWithContext(ctx) if PathExists(filepath.Join(filename, "bc", "0")) { system = "openvz" role = "host" @@ -251,15 +255,15 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - if PathExists(HostEtc("os-release")) { - p, _, err := GetOSRelease() + if PathExists(HostEtcWithContext(ctx, "os-release")) { + p, _, err := GetOSReleaseWithContext(ctx) if err == nil && p == "coreos" { system = "rkt" // Is it true? role = "host" } } - if PathExists(HostRoot(".dockerenv")) { + if PathExists(HostRootWithContext(ctx, ".dockerenv")) { system = "docker" role = "guest" } @@ -278,7 +282,11 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } func GetOSRelease() (platform string, version string, err error) { - contents, err := ReadLines(HostEtc("os-release")) + return GetOSReleaseWithContext(context.Background()) +} + +func GetOSReleaseWithContext(ctx context.Context) (platform string, version string, err error) { + contents, err := ReadLines(HostEtcWithContext(ctx, "os-release")) if err != nil { return "", "", nil // return empty } diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go index 8c35b1722..9bed2419e 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go @@ -11,6 +11,9 @@ func Sleep(ctx context.Context, interval time.Duration) error { timer := time.NewTimer(interval) select { case <-ctx.Done(): + if !timer.Stop() { + <-timer.C + } return ctx.Err() case <-timer.C: return nil diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/load/load_linux.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/load/load_linux.go index debf0733c..0298c8bed 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/load/load_linux.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/load/load_linux.go @@ -18,7 +18,7 @@ func Avg() (*AvgStat, error) { } func AvgWithContext(ctx context.Context) (*AvgStat, error) { - stat, err := fileAvgWithContext() + stat, err := fileAvgWithContext(ctx) if err != nil { stat, err = sysinfoAvgWithContext() } @@ -40,8 +40,8 @@ func sysinfoAvgWithContext() (*AvgStat, error) { }, nil } -func fileAvgWithContext() (*AvgStat, error) { - values, err := readLoadAvgFromFile() +func fileAvgWithContext(ctx context.Context) (*AvgStat, error) { + values, err := readLoadAvgFromFile(ctx) if err != nil { return nil, err } @@ -75,7 +75,7 @@ func Misc() (*MiscStat, error) { } func MiscWithContext(ctx context.Context) (*MiscStat, error) { - filename := common.HostProc("stat") + filename := common.HostProcWithContext(ctx, "stat") out, err := ioutil.ReadFile(filename) if err != nil { return nil, err @@ -107,7 +107,7 @@ func MiscWithContext(ctx context.Context) (*MiscStat, error) { } - procsTotal, err := getProcsTotal() + procsTotal, err := getProcsTotal(ctx) if err != nil { return ret, err } @@ -116,16 +116,16 @@ func MiscWithContext(ctx context.Context) (*MiscStat, error) { return ret, nil } -func getProcsTotal() (int64, error) { - values, err := readLoadAvgFromFile() +func getProcsTotal(ctx context.Context) (int64, error) { + values, err := readLoadAvgFromFile(ctx) if err != nil { return 0, err } return strconv.ParseInt(strings.Split(values[3], "/")[1], 10, 64) } -func readLoadAvgFromFile() ([]string, error) { - loadavgFilename := common.HostProc("loadavg") +func readLoadAvgFromFile(ctx context.Context) ([]string, error) { + loadavgFilename := common.HostProcWithContext(ctx, "loadavg") line, err := ioutil.ReadFile(loadavgFilename) if err != nil { return nil, err diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go index 0527dd93c..a05a0faba 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go @@ -8,8 +8,9 @@ import ( "fmt" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) func getHwMemsize() (uint64, error) { diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go index 9a5d693b1..361d06bcc 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go @@ -14,8 +14,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) type VirtualMemoryExStat struct { @@ -36,7 +37,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) { } func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { - vm, _, err := fillFromMeminfoWithContext() + vm, _, err := fillFromMeminfoWithContext(ctx) if err != nil { return nil, err } @@ -48,15 +49,15 @@ func VirtualMemoryEx() (*VirtualMemoryExStat, error) { } func VirtualMemoryExWithContext(ctx context.Context) (*VirtualMemoryExStat, error) { - _, vmEx, err := fillFromMeminfoWithContext() + _, vmEx, err := fillFromMeminfoWithContext(ctx) if err != nil { return nil, err } return vmEx, nil } -func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, error) { - filename := common.HostProc("meminfo") +func fillFromMeminfoWithContext(ctx context.Context) (*VirtualMemoryStat, *VirtualMemoryExStat, error) { + filename := common.HostProcWithContext(ctx, "meminfo") lines, _ := common.ReadLines(filename) // flag if MemAvailable is in /proc/meminfo (kernel 3.14+) @@ -153,13 +154,13 @@ func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, err return ret, retEx, err } retEx.Unevictable = t * 1024 - case "WriteBack": + case "Writeback": t, err := strconv.ParseUint(value, 10, 64) if err != nil { return ret, retEx, err } ret.WriteBack = t * 1024 - case "WriteBackTmp": + case "WritebackTmp": t, err := strconv.ParseUint(value, 10, 64) if err != nil { return ret, retEx, err @@ -317,7 +318,7 @@ func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, err if !memavail { if activeFile && inactiveFile && sReclaimable { - ret.Available = calculateAvailVmem(ret, retEx) + ret.Available = calculateAvailVmem(ctx, ret, retEx) } else { ret.Available = ret.Cached + ret.Free } @@ -350,7 +351,7 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { } else { ret.UsedPercent = 0 } - filename := common.HostProc("vmstat") + filename := common.HostProcWithContext(ctx, "vmstat") lines, _ := common.ReadLines(filename) for _, l := range lines { fields := strings.Fields(l) @@ -402,10 +403,10 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { // calculateAvailVmem is a fallback under kernel 3.14 where /proc/meminfo does not provide // "MemAvailable:" column. It reimplements an algorithm from the link below // https://github.com/giampaolo/psutil/pull/890 -func calculateAvailVmem(ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 { +func calculateAvailVmem(ctx context.Context, ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 { var watermarkLow uint64 - fn := common.HostProc("zoneinfo") + fn := common.HostProcWithContext(ctx, "zoneinfo") lines, err := common.ReadLines(fn) if err != nil { return ret.Free + ret.Cached // fallback under kernel 2.6.13 @@ -457,18 +458,18 @@ func SwapDevices() ([]*SwapDevice, error) { } func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) { - swapsFilePath := common.HostProc(swapsFilename) + swapsFilePath := common.HostProcWithContext(ctx, swapsFilename) f, err := os.Open(swapsFilePath) if err != nil { return nil, err } defer f.Close() - return parseSwapsFile(f) + return parseSwapsFile(ctx, f) } -func parseSwapsFile(r io.Reader) ([]*SwapDevice, error) { - swapsFilePath := common.HostProc(swapsFilename) +func parseSwapsFile(ctx context.Context, r io.Reader) ([]*SwapDevice, error) { + swapsFilePath := common.HostProcWithContext(ctx, swapsFilename) scanner := bufio.NewScanner(r) if !scanner.Scan() { if err := scanner.Err(); err != nil { diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go index 1c8d4f4e3..8a7b63744 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go @@ -259,7 +259,7 @@ func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) { } func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) { - return IOCounters(pernic) + return IOCountersWithContext(ctx, pernic) } func FilterCounters() ([]FilterStat, error) { @@ -278,7 +278,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for Darwin diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go index 7f31851ea..bf8baf094 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go @@ -115,7 +115,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for FreeBSD diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go index c7cd0db18..de0ea7345 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go @@ -50,7 +50,7 @@ func IOCounters(pernic bool) ([]IOCountersStat, error) { } func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) { - filename := common.HostProc("net/dev") + filename := common.HostProcWithContext(ctx, "net/dev") return IOCountersByFileWithContext(ctx, pernic, filename) } @@ -157,7 +157,7 @@ var netProtocols = []string{ "udplite", } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Available protocols: @@ -177,7 +177,7 @@ func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoC protos[p] = true } - filename := common.HostProc("net/snmp") + filename := common.HostProcWithContext(ctx, "net/snmp") lines, err := common.ReadLines(filename) if err != nil { return nil, err @@ -230,8 +230,8 @@ func FilterCounters() ([]FilterStat, error) { } func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) { - countfile := common.HostProc("sys/net/netfilter/nf_conntrack_count") - maxfile := common.HostProc("sys/net/netfilter/nf_conntrack_max") + countfile := common.HostProcWithContext(ctx, "sys/net/netfilter/nf_conntrack_count") + maxfile := common.HostProcWithContext(ctx, "sys/net/netfilter/nf_conntrack_max") count, err := common.ReadInts(countfile) if err != nil { @@ -260,7 +260,7 @@ func ConntrackStats(percpu bool) ([]ConntrackStat, error) { // ConntrackStatsWithContext returns more detailed info about the conntrack table func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) { - return conntrackStatsFromFile(common.HostProc("net/stat/nf_conntrack"), percpu) + return conntrackStatsFromFile(common.HostProcWithContext(ctx, "net/stat/nf_conntrack"), percpu) } // conntrackStatsFromFile returns more detailed info about the conntrack table @@ -459,7 +459,7 @@ func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, p if !ok { return nil, fmt.Errorf("invalid kind, %s", kind) } - root := common.HostProc() + root := common.HostProcWithContext(ctx) var err error var inodes map[string][]inodeMap if pid == 0 { @@ -531,7 +531,7 @@ func statsFromInodesWithContext(ctx context.Context, root string, pid int32, tma if !skipUids { // fetch process owner Real, effective, saved set, and filesystem UIDs proc := process{Pid: conn.Pid} - conn.Uids, _ = proc.getUids() + conn.Uids, _ = proc.getUids(ctx) } ret = append(ret, conn) @@ -599,7 +599,7 @@ func Pids() ([]int32, error) { func PidsWithContext(ctx context.Context) ([]int32, error) { var ret []int32 - d, err := os.Open(common.HostProc()) + d, err := os.Open(common.HostProcWithContext(ctx)) if err != nil { return nil, err } @@ -631,8 +631,8 @@ type process struct { } // Uids returns user ids of the process as a slice of the int -func (p *process) getUids() ([]int32, error) { - err := p.fillFromStatus() +func (p *process) getUids(ctx context.Context) ([]int32, error) { + err := p.fillFromStatus(ctx) if err != nil { return []int32{}, err } @@ -640,9 +640,9 @@ func (p *process) getUids() ([]int32, error) { } // Get status from /proc/(pid)/status -func (p *process) fillFromStatus() error { +func (p *process) fillFromStatus(ctx context.Context) error { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "status") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "status") contents, err := ioutil.ReadFile(statPath) if err != nil { return err diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go index 5f066a09f..cf48f53e7 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go @@ -164,7 +164,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for OpenBSD diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go index 68b26bdcd..5d384342f 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go @@ -338,7 +338,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for Windows diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process.go index 0ca26c210..1a7fe1b80 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process.go @@ -335,7 +335,7 @@ func (p *Process) MemoryPercentWithContext(ctx context.Context) (float32, error) return (100 * float32(used) / float32(total)), nil } -// CPU_Percent returns how many percent of the CPU time this process uses +// CPUPercent returns how many percent of the CPU time this process uses func (p *Process) CPUPercent() (float64, error) { return p.CPUPercentWithContext(context.Background()) } @@ -507,7 +507,7 @@ func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { return p.MemoryInfoExWithContext(context.Background()) } -// PageFaultsInfo returns the process's page fault counters. +// PageFaults returns the process's page fault counters. func (p *Process) PageFaults() (*PageFaultsStat, error) { return p.PageFaultsWithContext(context.Background()) } @@ -530,7 +530,7 @@ func (p *Process) Connections() ([]net.ConnectionStat, error) { return p.ConnectionsWithContext(context.Background()) } -// Connections returns a slice of net.ConnectionStat used by the process at most `max`. +// ConnectionsMax returns a slice of net.ConnectionStat used by the process at most `max`. func (p *Process) ConnectionsMax(max int) ([]net.ConnectionStat, error) { return p.ConnectionsMaxWithContext(context.Background(), max) } diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go index 61b340b63..55c31962a 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go @@ -10,10 +10,11 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/net" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" + "github.com/shirou/gopsutil/v3/net" ) // copied from sys/sysctl.h diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go index 779f8126a..a123ccf9b 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go @@ -69,7 +69,13 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) { } func (p *Process) ExeWithContext(ctx context.Context) (string, error) { - return "", common.ErrNotImplementedError + mib := []int32{CTLKern, KernProc, KernProcPathname, p.Pid} + buf, _, err := common.CallSyscall(mib) + if err != nil { + return "", err + } + + return strings.Trim(string(buf), "\x00"), nil } func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go index d5b5bc329..29c447390 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go @@ -16,11 +16,12 @@ import ( "strconv" "strings" + "github.com/tklauser/go-sysconf" + "golang.org/x/sys/unix" + "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/internal/common" "github.com/shirou/gopsutil/v3/net" - "github.com/tklauser/go-sysconf" - "golang.org/x/sys/unix" ) var pageSize = uint64(os.Getpagesize()) @@ -100,7 +101,7 @@ func (p *Process) TgidWithContext(ctx context.Context) (int32, error) { } func (p *Process) ExeWithContext(ctx context.Context) (string, error) { - return p.fillFromExeWithContext() + return p.fillFromExeWithContext(ctx) } func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { @@ -120,7 +121,7 @@ func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) { } func (p *Process) CwdWithContext(ctx context.Context) (string, error) { - return p.fillFromCwdWithContext() + return p.fillFromCwdWithContext(ctx) } func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) { @@ -134,7 +135,7 @@ func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) { func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) { // see https://github.com/shirou/gopsutil/issues/596#issuecomment-432707831 for implementation details pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "stat") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "stat") contents, err := ioutil.ReadFile(statPath) if err != nil { return false, err @@ -202,7 +203,7 @@ func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) { } func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) { - rlimits, err := p.fillFromLimitsWithContext() + rlimits, err := p.fillFromLimitsWithContext(ctx) if !gatherUsed || err != nil { return rlimits, err } @@ -257,7 +258,7 @@ func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ( } func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) { - return p.fillFromIOWithContext() + return p.fillFromIOWithContext(ctx) } func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) { @@ -283,7 +284,7 @@ func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) { ret := make(map[int32]*cpu.TimesStat) - taskPath := common.HostProc(strconv.Itoa(int(p.Pid)), "task") + taskPath := common.HostProcWithContext(ctx, strconv.Itoa(int(p.Pid)), "task") tids, err := readPidsFromDir(taskPath) if err != nil { @@ -314,7 +315,7 @@ func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) { } func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) { - meminfo, _, err := p.fillFromStatmWithContext() + meminfo, _, err := p.fillFromStatmWithContext(ctx) if err != nil { return nil, err } @@ -322,7 +323,7 @@ func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, e } func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) { - _, memInfoEx, err := p.fillFromStatmWithContext() + _, memInfoEx, err := p.fillFromStatmWithContext(ctx) if err != nil { return nil, err } @@ -380,12 +381,12 @@ func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) { pid := p.Pid var ret []MemoryMapsStat - smapsPath := common.HostProc(strconv.Itoa(int(pid)), "smaps") + smapsPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "smaps") if grouped { ret = make([]MemoryMapsStat, 1) // If smaps_rollup exists (require kernel >= 4.15), then we will use it // for pre-summed memory information for a process. - smapsRollupPath := common.HostProc(strconv.Itoa(int(pid)), "smaps_rollup") + smapsRollupPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "smaps_rollup") if _, err := os.Stat(smapsRollupPath); !os.IsNotExist(err) { smapsPath = smapsRollupPath } @@ -481,7 +482,7 @@ func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]M } func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) { - environPath := common.HostProc(strconv.Itoa(int(p.Pid)), "environ") + environPath := common.HostProcWithContext(ctx, strconv.Itoa(int(p.Pid)), "environ") environContent, err := ioutil.ReadFile(environPath) if err != nil { @@ -507,9 +508,9 @@ func limitToUint(val string) (uint64, error) { } // Get num_fds from /proc/(pid)/limits -func (p *Process) fillFromLimitsWithContext() ([]RlimitStat, error) { +func (p *Process) fillFromLimitsWithContext(ctx context.Context) ([]RlimitStat, error) { pid := p.Pid - limitsFile := common.HostProc(strconv.Itoa(int(pid)), "limits") + limitsFile := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "limits") d, err := os.Open(limitsFile) if err != nil { return nil, err @@ -602,7 +603,7 @@ func (p *Process) fillFromLimitsWithContext() ([]RlimitStat, error) { // Get list of /proc/(pid)/fd files func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []string, error) { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "fd") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "fd") d, err := os.Open(statPath) if err != nil { return statPath, []string{}, err @@ -642,9 +643,9 @@ func (p *Process) fillFromfdWithContext(ctx context.Context) (int32, []*OpenFile } // Get cwd from /proc/(pid)/cwd -func (p *Process) fillFromCwdWithContext() (string, error) { +func (p *Process) fillFromCwdWithContext(ctx context.Context) (string, error) { pid := p.Pid - cwdPath := common.HostProc(strconv.Itoa(int(pid)), "cwd") + cwdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cwd") cwd, err := os.Readlink(cwdPath) if err != nil { return "", err @@ -653,9 +654,9 @@ func (p *Process) fillFromCwdWithContext() (string, error) { } // Get exe from /proc/(pid)/exe -func (p *Process) fillFromExeWithContext() (string, error) { +func (p *Process) fillFromExeWithContext(ctx context.Context) (string, error) { pid := p.Pid - exePath := common.HostProc(strconv.Itoa(int(pid)), "exe") + exePath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "exe") exe, err := os.Readlink(exePath) if err != nil { return "", err @@ -666,7 +667,7 @@ func (p *Process) fillFromExeWithContext() (string, error) { // Get cmdline from /proc/(pid)/cmdline func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return "", err @@ -680,7 +681,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return nil, err @@ -701,9 +702,9 @@ func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string } // Get IO status from /proc/(pid)/io -func (p *Process) fillFromIOWithContext() (*IOCountersStat, error) { +func (p *Process) fillFromIOWithContext(ctx context.Context) (*IOCountersStat, error) { pid := p.Pid - ioPath := common.HostProc(strconv.Itoa(int(pid)), "io") + ioPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "io") ioline, err := ioutil.ReadFile(ioPath) if err != nil { return nil, err @@ -737,9 +738,9 @@ func (p *Process) fillFromIOWithContext() (*IOCountersStat, error) { } // Get memory info from /proc/(pid)/statm -func (p *Process) fillFromStatmWithContext() (*MemoryInfoStat, *MemoryInfoExStat, error) { +func (p *Process) fillFromStatmWithContext(ctx context.Context) (*MemoryInfoStat, *MemoryInfoExStat, error) { pid := p.Pid - memPath := common.HostProc(strconv.Itoa(int(pid)), "statm") + memPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "statm") contents, err := ioutil.ReadFile(memPath) if err != nil { return nil, nil, err @@ -790,7 +791,7 @@ func (p *Process) fillFromStatmWithContext() (*MemoryInfoStat, *MemoryInfoExStat // Get name from /proc/(pid)/comm or /proc/(pid)/status func (p *Process) fillNameWithContext(ctx context.Context) error { - err := p.fillFromCommWithContext() + err := p.fillFromCommWithContext(ctx) if err == nil && p.name != "" && len(p.name) < 15 { return nil } @@ -798,9 +799,9 @@ func (p *Process) fillNameWithContext(ctx context.Context) error { } // Get name from /proc/(pid)/comm -func (p *Process) fillFromCommWithContext() error { +func (p *Process) fillFromCommWithContext(ctx context.Context) error { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "comm") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "comm") contents, err := ioutil.ReadFile(statPath) if err != nil { return err @@ -817,7 +818,7 @@ func (p *Process) fillFromStatus() error { func (p *Process) fillFromStatusWithContext(ctx context.Context) error { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "status") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "status") contents, err := ioutil.ReadFile(statPath) if err != nil { return err @@ -1022,9 +1023,9 @@ func (p *Process) fillFromTIDStatWithContext(ctx context.Context, tid int32) (ui var statPath string if tid == -1 { - statPath = common.HostProc(strconv.Itoa(int(pid)), "stat") + statPath = common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "stat") } else { - statPath = common.HostProc(strconv.Itoa(int(pid)), "task", strconv.Itoa(int(tid)), "stat") + statPath = common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "task", strconv.Itoa(int(tid)), "stat") } contents, err := ioutil.ReadFile(statPath) @@ -1128,7 +1129,7 @@ func (p *Process) fillFromStatWithContext(ctx context.Context) (uint64, int32, * } func pidsWithContext(ctx context.Context) ([]int32, error) { - return readPidsFromDir(common.HostProc()) + return readPidsFromDir(common.HostProcWithContext(ctx)) } func ProcessesWithContext(ctx context.Context) ([]*Process, error) { diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go index 88e2bff53..a01f9ecfc 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go @@ -14,8 +14,9 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) type Signal = syscall.Signal @@ -108,8 +109,8 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) { return false, err } - if isMount(common.HostProc()) { // if //proc exists and is mounted, check if //proc/ folder exists - _, err := os.Stat(common.HostProc(strconv.Itoa(int(pid)))) + if isMount(common.HostProcWithContext(ctx)) { // if //proc exists and is mounted, check if //proc/ folder exists + _, err := os.Stat(common.HostProcWithContext(ctx, strconv.Itoa(int(pid)))) if os.IsNotExist(err) { return false, nil } @@ -121,7 +122,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) { if err == nil { return true, nil } - if err.Error() == "os: process already finished" { + if errors.Is(err, os.ErrProcessDone) { return false, nil } var errno syscall.Errno diff --git a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go index 4f10a67bc..ad1c3cfc1 100644 --- a/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go +++ b/test/performance/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go @@ -30,7 +30,7 @@ type MemoryMapsStat struct { type MemoryInfoExStat struct{} func pidsWithContext(ctx context.Context) ([]int32, error) { - return readPidsFromDir(common.HostProc()) + return readPidsFromDir(common.HostProcWithContext(ctx)) } func ProcessesWithContext(ctx context.Context) ([]*Process, error) { @@ -199,7 +199,7 @@ func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) { func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []string, error) { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "fd") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "fd") d, err := os.Open(statPath) if err != nil { return statPath, []string{}, err @@ -211,7 +211,7 @@ func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []stri func (p *Process) fillFromPathCwdWithContext(ctx context.Context) (string, error) { pid := p.Pid - cwdPath := common.HostProc(strconv.Itoa(int(pid)), "path", "cwd") + cwdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "path", "cwd") cwd, err := os.Readlink(cwdPath) if err != nil { return "", err @@ -221,7 +221,7 @@ func (p *Process) fillFromPathCwdWithContext(ctx context.Context) (string, error func (p *Process) fillFromPathAOutWithContext(ctx context.Context) (string, error) { pid := p.Pid - cwdPath := common.HostProc(strconv.Itoa(int(pid)), "path", "a.out") + cwdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "path", "a.out") exe, err := os.Readlink(cwdPath) if err != nil { return "", err @@ -231,7 +231,7 @@ func (p *Process) fillFromPathAOutWithContext(ctx context.Context) (string, erro func (p *Process) fillFromExecnameWithContext(ctx context.Context) (string, error) { pid := p.Pid - execNamePath := common.HostProc(strconv.Itoa(int(pid)), "execname") + execNamePath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "execname") exe, err := ioutil.ReadFile(execNamePath) if err != nil { return "", err @@ -241,7 +241,7 @@ func (p *Process) fillFromExecnameWithContext(ctx context.Context) (string, erro func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return "", err @@ -258,7 +258,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return nil, err diff --git a/test/performance/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml b/test/performance/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml new file mode 100644 index 000000000..dc6fefb97 --- /dev/null +++ b/test/performance/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml @@ -0,0 +1,12 @@ +run: + timeout: 5m +linters: + enable: + - gofmt + - errcheck + - errname + - errorlint + - bodyclose + - durationcheck + - whitespace + diff --git a/test/performance/vendor/github.com/shoenig/go-m1cpu/LICENSE b/test/performance/vendor/github.com/shoenig/go-m1cpu/LICENSE new file mode 100644 index 000000000..e87a115e4 --- /dev/null +++ b/test/performance/vendor/github.com/shoenig/go-m1cpu/LICENSE @@ -0,0 +1,363 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. + diff --git a/test/performance/vendor/github.com/shoenig/go-m1cpu/Makefile b/test/performance/vendor/github.com/shoenig/go-m1cpu/Makefile new file mode 100644 index 000000000..28d786397 --- /dev/null +++ b/test/performance/vendor/github.com/shoenig/go-m1cpu/Makefile @@ -0,0 +1,12 @@ +SHELL = bash + +default: test + +.PHONY: test +test: + @echo "--> Running Tests ..." + @go test -v -race ./... + +vet: + @echo "--> Vet Go sources ..." + @go vet ./... diff --git a/test/performance/vendor/github.com/shoenig/go-m1cpu/README.md b/test/performance/vendor/github.com/shoenig/go-m1cpu/README.md new file mode 100644 index 000000000..399657acf --- /dev/null +++ b/test/performance/vendor/github.com/shoenig/go-m1cpu/README.md @@ -0,0 +1,66 @@ +# m1cpu + +[![Go Reference](https://pkg.go.dev/badge/github.com/shoenig/go-m1cpu.svg)](https://pkg.go.dev/github.com/shoenig/go-m1cpu) +[![MPL License](https://img.shields.io/github/license/shoenig/go-m1cpu?color=g&style=flat-square)](https://github.com/shoenig/go-m1cpu/blob/main/LICENSE) +[![Run CI Tests](https://github.com/shoenig/go-m1cpu/actions/workflows/ci.yaml/badge.svg)](https://github.com/shoenig/go-m1cpu/actions/workflows/ci.yaml) + +The `go-m1cpu` module is a library for inspecting Apple Silicon CPUs in Go. + +Use the `m1cpu` Go package for looking up the CPU frequency for Apple M1 and M2 CPUs. + +# Install + +```shell +go get github.com/shoenig/go-m1cpu@latest +``` + +# CGO + +This package requires the use of [CGO](https://go.dev/blog/cgo). + +Extracting the CPU properties is done via Apple's [IOKit](https://developer.apple.com/documentation/iokit?language=objc) +framework, which is accessible only through system C libraries. + +# Example + +Simple Go program to print Apple Silicon M1/M2 CPU speeds. + +```go +package main + +import ( + "fmt" + + "github.com/shoenig/go-m1cpu" +) + +func main() { + fmt.Println("Apple Silicon", m1cpu.IsAppleSilicon()) + + fmt.Println("pCore GHz", m1cpu.PCoreGHz()) + fmt.Println("eCore GHz", m1cpu.ECoreGHz()) + + fmt.Println("pCore Hz", m1cpu.PCoreHz()) + fmt.Println("eCore Hz", m1cpu.ECoreHz()) +} +``` + +Using `go test` to print out available information. + +``` +➜ go test -v -run Show +=== RUN Test_Show + cpu_test.go:42: pCore Hz 3504000000 + cpu_test.go:43: eCore Hz 2424000000 + cpu_test.go:44: pCore GHz 3.504 + cpu_test.go:45: eCore GHz 2.424 + cpu_test.go:46: pCore count 8 + cpu_test.go:47: eCoreCount 4 + cpu_test.go:50: pCore Caches 196608 131072 16777216 + cpu_test.go:53: eCore Caches 131072 65536 4194304 +--- PASS: Test_Show (0.00s) +``` + +# License + +Open source under the [MPL](LICENSE) diff --git a/test/performance/vendor/github.com/shoenig/go-m1cpu/cpu.go b/test/performance/vendor/github.com/shoenig/go-m1cpu/cpu.go new file mode 100644 index 000000000..502a8cce9 --- /dev/null +++ b/test/performance/vendor/github.com/shoenig/go-m1cpu/cpu.go @@ -0,0 +1,213 @@ +//go:build darwin && arm64 && cgo + +package m1cpu + +// #cgo LDFLAGS: -framework CoreFoundation -framework IOKit +// #include +// #include +// #include +// #include +// +// #if !defined(MAC_OS_VERSION_12_0) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0 +// #define kIOMainPortDefault kIOMasterPortDefault +// #endif +// +// #define HzToGHz(hz) ((hz) / 1000000000.0) +// +// UInt64 global_pCoreHz; +// UInt64 global_eCoreHz; +// int global_pCoreCount; +// int global_eCoreCount; +// int global_pCoreL1InstCacheSize; +// int global_eCoreL1InstCacheSize; +// int global_pCoreL1DataCacheSize; +// int global_eCoreL1DataCacheSize; +// int global_pCoreL2CacheSize; +// int global_eCoreL2CacheSize; +// char global_brand[32]; +// +// UInt64 getFrequency(CFTypeRef typeRef) { +// CFDataRef cfData = typeRef; +// +// CFIndex size = CFDataGetLength(cfData); +// UInt8 buf[size]; +// CFDataGetBytes(cfData, CFRangeMake(0, size), buf); +// +// UInt8 b1 = buf[size-5]; +// UInt8 b2 = buf[size-6]; +// UInt8 b3 = buf[size-7]; +// UInt8 b4 = buf[size-8]; +// +// UInt64 pCoreHz = 0x00000000FFFFFFFF & ((b1<<24) | (b2 << 16) | (b3 << 8) | (b4)); +// return pCoreHz; +// } +// +// int sysctl_int(const char * name) { +// int value = -1; +// size_t size = 8; +// sysctlbyname(name, &value, &size, NULL, 0); +// return value; +// } +// +// void sysctl_string(const char * name, char * dest) { +// size_t size = 32; +// sysctlbyname(name, dest, &size, NULL, 0); +// } +// +// void initialize() { +// global_pCoreCount = sysctl_int("hw.perflevel0.physicalcpu"); +// global_eCoreCount = sysctl_int("hw.perflevel1.physicalcpu"); +// global_pCoreL1InstCacheSize = sysctl_int("hw.perflevel0.l1icachesize"); +// global_eCoreL1InstCacheSize = sysctl_int("hw.perflevel1.l1icachesize"); +// global_pCoreL1DataCacheSize = sysctl_int("hw.perflevel0.l1dcachesize"); +// global_eCoreL1DataCacheSize = sysctl_int("hw.perflevel1.l1dcachesize"); +// global_pCoreL2CacheSize = sysctl_int("hw.perflevel0.l2cachesize"); +// global_eCoreL2CacheSize = sysctl_int("hw.perflevel1.l2cachesize"); +// sysctl_string("machdep.cpu.brand_string", global_brand); +// +// CFMutableDictionaryRef matching = IOServiceMatching("AppleARMIODevice"); +// io_iterator_t iter; +// IOServiceGetMatchingServices(kIOMainPortDefault, matching, &iter); +// +// const size_t bufsize = 512; +// io_object_t obj; +// while ((obj = IOIteratorNext(iter))) { +// char class[bufsize]; +// IOObjectGetClass(obj, class); +// char name[bufsize]; +// IORegistryEntryGetName(obj, name); +// +// if (strncmp(name, "pmgr", bufsize) == 0) { +// CFTypeRef pCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states5-sram"), kCFAllocatorDefault, 0); +// CFTypeRef eCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states1-sram"), kCFAllocatorDefault, 0); +// +// long long pCoreHz = getFrequency(pCoreRef); +// long long eCoreHz = getFrequency(eCoreRef); +// +// global_pCoreHz = pCoreHz; +// global_eCoreHz = eCoreHz; +// return; +// } +// } +// } +// +// UInt64 eCoreHz() { +// return global_eCoreHz; +// } +// +// UInt64 pCoreHz() { +// return global_pCoreHz; +// } +// +// Float64 eCoreGHz() { +// return HzToGHz(global_eCoreHz); +// } +// +// Float64 pCoreGHz() { +// return HzToGHz(global_pCoreHz); +// } +// +// int pCoreCount() { +// return global_pCoreCount; +// } +// +// int eCoreCount() { +// return global_eCoreCount; +// } +// +// int pCoreL1InstCacheSize() { +// return global_pCoreL1InstCacheSize; +// } +// +// int pCoreL1DataCacheSize() { +// return global_pCoreL1DataCacheSize; +// } +// +// int pCoreL2CacheSize() { +// return global_pCoreL2CacheSize; +// } +// +// int eCoreL1InstCacheSize() { +// return global_eCoreL1InstCacheSize; +// } +// +// int eCoreL1DataCacheSize() { +// return global_eCoreL1DataCacheSize; +// } +// +// int eCoreL2CacheSize() { +// return global_eCoreL2CacheSize; +// } +// +// char * modelName() { +// return global_brand; +// } +import "C" + +func init() { + C.initialize() +} + +// IsAppleSilicon returns true on this platform. +func IsAppleSilicon() bool { + return true +} + +// PCoreHZ returns the max frequency in Hertz of the P-Core of an Apple Silicon CPU. +func PCoreHz() uint64 { + return uint64(C.pCoreHz()) +} + +// ECoreHZ returns the max frequency in Hertz of the E-Core of an Apple Silicon CPU. +func ECoreHz() uint64 { + return uint64(C.eCoreHz()) +} + +// PCoreGHz returns the max frequency in Gigahertz of the P-Core of an Apple Silicon CPU. +func PCoreGHz() float64 { + return float64(C.pCoreGHz()) +} + +// ECoreGHz returns the max frequency in Gigahertz of the E-Core of an Apple Silicon CPU. +func ECoreGHz() float64 { + return float64(C.eCoreGHz()) +} + +// PCoreCount returns the number of physical P (performance) cores. +func PCoreCount() int { + return int(C.pCoreCount()) +} + +// ECoreCount returns the number of physical E (efficiency) cores. +func ECoreCount() int { + return int(C.eCoreCount()) +} + +// PCoreCacheSize returns the sizes of the P (performance) core cache sizes +// in the order of +// +// - L1 instruction cache +// - L1 data cache +// - L2 cache +func PCoreCache() (int, int, int) { + return int(C.pCoreL1InstCacheSize()), + int(C.pCoreL1DataCacheSize()), + int(C.pCoreL2CacheSize()) +} + +// ECoreCacheSize returns the sizes of the E (efficiency) core cache sizes +// in the order of +// +// - L1 instruction cache +// - L1 data cache +// - L2 cache +func ECoreCache() (int, int, int) { + return int(C.eCoreL1InstCacheSize()), + int(C.eCoreL1DataCacheSize()), + int(C.eCoreL2CacheSize()) +} + +// ModelName returns the model name of the CPU. +func ModelName() string { + return C.GoString(C.modelName()) +} diff --git a/test/performance/vendor/github.com/shoenig/go-m1cpu/incompatible.go b/test/performance/vendor/github.com/shoenig/go-m1cpu/incompatible.go new file mode 100644 index 000000000..d425025aa --- /dev/null +++ b/test/performance/vendor/github.com/shoenig/go-m1cpu/incompatible.go @@ -0,0 +1,53 @@ +//go:build !darwin || !arm64 || !cgo + +package m1cpu + +// IsAppleSilicon return false on this platform. +func IsAppleSilicon() bool { + return false +} + +// PCoreHZ requires darwin/arm64 +func PCoreHz() uint64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreHZ requires darwin/arm64 +func ECoreHz() uint64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreGHz requires darwin/arm64 +func PCoreGHz() float64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreGHz requires darwin/arm64 +func ECoreGHz() float64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreCount requires darwin/arm64 +func PCoreCount() int { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreCount requires darwin/arm64 +func ECoreCount() int { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreCacheSize requires darwin/arm64 +func PCoreCache() (int, int, int) { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreCacheSize requires darwin/arm64 +func ECoreCache() (int, int, int) { + panic("m1cpu: not a darwin/arm64 system") +} + +// ModelName requires darwin/arm64 +func ModelName() string { + panic("m1cpu: not a darwin/arm64 system") +} diff --git a/test/performance/vendor/github.com/yusufpapurcu/wmi/README.md b/test/performance/vendor/github.com/yusufpapurcu/wmi/README.md index c4a432d6d..426d1a46b 100644 --- a/test/performance/vendor/github.com/yusufpapurcu/wmi/README.md +++ b/test/performance/vendor/github.com/yusufpapurcu/wmi/README.md @@ -4,10 +4,3 @@ wmi Package wmi provides a WQL interface to Windows WMI. Note: It interfaces with WMI on the local machine, therefore it only runs on Windows. - ---- - -NOTE: This project is no longer being actively maintained. If you would like -to become its new owner, please contact tlimoncelli at stack over flow dot com. - ---- diff --git a/test/performance/vendor/github.com/yusufpapurcu/wmi/swbemservices.go b/test/performance/vendor/github.com/yusufpapurcu/wmi/swbemservices.go index 3ff875630..a250c846d 100644 --- a/test/performance/vendor/github.com/yusufpapurcu/wmi/swbemservices.go +++ b/test/performance/vendor/github.com/yusufpapurcu/wmi/swbemservices.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package wmi diff --git a/test/performance/vendor/github.com/yusufpapurcu/wmi/wmi.go b/test/performance/vendor/github.com/yusufpapurcu/wmi/wmi.go index b4bb4f090..26c3581c9 100644 --- a/test/performance/vendor/github.com/yusufpapurcu/wmi/wmi.go +++ b/test/performance/vendor/github.com/yusufpapurcu/wmi/wmi.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows /* @@ -20,7 +21,6 @@ Example code to print names of running processes: println(i, v.Name) } } - */ package wmi @@ -338,11 +338,6 @@ func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismat f := v.Field(i) of := f isPtr := f.Kind() == reflect.Ptr - if isPtr { - ptr := reflect.New(f.Type().Elem()) - f.Set(ptr) - f = f.Elem() - } n := v.Type().Field(i).Name if n[0] < 'A' || n[0] > 'Z' { continue @@ -367,6 +362,12 @@ func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismat } defer prop.Clear() + if isPtr && !(c.PtrNil && prop.VT == 0x1) { + ptr := reflect.New(f.Type().Elem()) + f.Set(ptr) + f = f.Elem() + } + if prop.VT == 0x1 { //VT_NULL continue } diff --git a/test/performance/vendor/modules.txt b/test/performance/vendor/modules.txt index c3da2bc99..53eb4fa2a 100644 --- a/test/performance/vendor/modules.txt +++ b/test/performance/vendor/modules.txt @@ -178,8 +178,8 @@ github.com/nginxinc/nginx-go-crossplane # github.com/nginxinc/nginx-plus-go-client v0.10.0 ## explicit; go 1.18 github.com/nginxinc/nginx-plus-go-client/client -# github.com/nginxinc/nginx-prometheus-exporter v0.10.0 -## explicit; go 1.17 +# github.com/nginxinc/nginx-prometheus-exporter v0.11.0 +## explicit; go 1.19 github.com/nginxinc/nginx-prometheus-exporter/client # github.com/nxadm/tail v1.4.8 ## explicit; go 1.13 @@ -204,22 +204,22 @@ github.com/pmezard/go-difflib/difflib # github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c ## explicit; go 1.14 github.com/power-devops/perfstat -# github.com/prometheus/client_golang v1.13.0 +# github.com/prometheus/client_golang v1.16.0 ## explicit; go 1.17 github.com/prometheus/client_golang/prometheus github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/promauto github.com/prometheus/client_golang/prometheus/promhttp -# github.com/prometheus/client_model v0.3.0 -## explicit; go 1.9 +# github.com/prometheus/client_model v0.4.0 +## explicit; go 1.18 github.com/prometheus/client_model/go -# github.com/prometheus/common v0.37.0 -## explicit; go 1.16 +# github.com/prometheus/common v0.44.0 +## explicit; go 1.18 github.com/prometheus/common/expfmt github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg github.com/prometheus/common/model -# github.com/prometheus/procfs v0.8.0 -## explicit; go 1.17 +# github.com/prometheus/procfs v0.11.0 +## explicit; go 1.19 github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util @@ -236,8 +236,9 @@ github.com/shirou/gopsutil/internal/common github.com/shirou/gopsutil/mem github.com/shirou/gopsutil/net github.com/shirou/gopsutil/process -# github.com/shirou/gopsutil/v3 v3.23.2 +# github.com/shirou/gopsutil/v3 v3.23.6 ## explicit; go 1.15 +github.com/shirou/gopsutil/v3/common github.com/shirou/gopsutil/v3/cpu github.com/shirou/gopsutil/v3/disk github.com/shirou/gopsutil/v3/host @@ -246,6 +247,9 @@ github.com/shirou/gopsutil/v3/load github.com/shirou/gopsutil/v3/mem github.com/shirou/gopsutil/v3/net github.com/shirou/gopsutil/v3/process +# github.com/shoenig/go-m1cpu v0.1.6 +## explicit; go 1.20 +github.com/shoenig/go-m1cpu # github.com/sirupsen/logrus v1.9.3 ## explicit; go 1.13 github.com/sirupsen/logrus @@ -300,7 +304,7 @@ github.com/trivago/grok # github.com/vardius/message-bus v1.1.5 ## explicit; go 1.12 github.com/vardius/message-bus -# github.com/yusufpapurcu/wmi v1.2.2 +# github.com/yusufpapurcu/wmi v1.2.3 ## explicit; go 1.16 github.com/yusufpapurcu/wmi # go.uber.org/atomic v1.11.0 diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufcli/bufcli.go b/vendor/github.com/bufbuild/buf/private/buf/bufcli/bufcli.go index 319f78c55..25cf10d86 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufcli/bufcli.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufcli/bufcli.go @@ -38,6 +38,7 @@ import ( "github.com/bufbuild/buf/private/bufpkg/bufmodule" "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild" "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" "github.com/bufbuild/buf/private/bufpkg/buftransport" "github.com/bufbuild/buf/private/gen/data/datawkt" registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" @@ -47,7 +48,6 @@ import ( "github.com/bufbuild/buf/private/pkg/app/appname" "github.com/bufbuild/buf/private/pkg/command" "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/buf/private/pkg/filelock" "github.com/bufbuild/buf/private/pkg/git" "github.com/bufbuild/buf/private/pkg/httpauth" "github.com/bufbuild/buf/private/pkg/netrc" @@ -57,6 +57,7 @@ import ( "github.com/bufbuild/buf/private/pkg/stringutil" "github.com/bufbuild/buf/private/pkg/transport/http/httpclient" "github.com/bufbuild/connect-go" + otelconnect "github.com/bufbuild/connect-opentelemetry-go" "github.com/spf13/pflag" "go.uber.org/zap" "golang.org/x/term" @@ -64,7 +65,7 @@ import ( const ( // Version is the CLI version of buf. - Version = "1.18.0" + Version = "1.23.1" inputHTTPSUsernameEnvKey = "BUF_INPUT_HTTPS_USERNAME" inputHTTPSPasswordEnvKey = "BUF_INPUT_HTTPS_PASSWORD" @@ -76,8 +77,6 @@ const ( // AlphaEnableWASMEnvKey is an env var to enable WASM local plugin execution AlphaEnableWASMEnvKey = "BUF_ALPHA_ENABLE_WASM" - // BetaEnableTamperProofingEnvKey is an env var to enable tamper proofing - BetaEnableTamperProofingEnvKey = "BUF_BETA_ENABLE_TAMPER_PROOFING" inputHashtagFlagName = "__hashtag__" inputHashtagFlagShortName = "#" @@ -163,7 +162,7 @@ var ( // // Normalized. // This directory replaces the use of v1CacheModuleDataRelDirPath, v1CacheModuleLockRelDirPath, and - // v1CacheModuleSumRelDirPath for modules which support tamper proofing. + // v1CacheModuleSumRelDirPath with a cache implementation using content addressable storage. v2CacheModuleRelDirPath = normalpath.Join("v2", "module") // allVisibiltyStrings are the possible options that a user can set the visibility flag with. @@ -279,7 +278,18 @@ func BindVisibility(flagSet *pflag.FlagSet, addr *string, flagName string) { addr, flagName, "", - fmt.Sprintf(`The repository's visibility setting. Must be one of %s.`, stringutil.SliceToString(allVisibiltyStrings)), + fmt.Sprintf(`The repository's visibility setting. Must be one of %s`, stringutil.SliceToString(allVisibiltyStrings)), + ) +} + +// BindCreateVisibility binds the create-visibility flag. Kept in this package +// so we can keep allVisibilityStrings private. +func BindCreateVisibility(flagSet *pflag.FlagSet, addr *string, flagName string, createFlagName string) { + flagSet.StringVar( + addr, + flagName, + "", + fmt.Sprintf(`The repository's visibility setting, if created. Must be set if --%s is set. Must be one of %s`, createFlagName, stringutil.SliceToString(allVisibiltyStrings)), ) } @@ -362,7 +372,7 @@ func GetInputValue( // WarnAlphaCommand prints a warning for a alpha command unless the alphaSuppressWarningsEnvKey // environment variable is set. -func WarnAlphaCommand(ctx context.Context, container appflag.Container) { +func WarnAlphaCommand(_ context.Context, container appflag.Container) { if container.Env(alphaSuppressWarningsEnvKey) == "" { container.Logger().Warn("This command is in alpha. It is hidden for a reason. This command is purely for development purposes, and may never even be promoted to beta, do not rely on this command's functionality. To suppress this warning, set " + alphaSuppressWarningsEnvKey + "=1") } @@ -370,7 +380,7 @@ func WarnAlphaCommand(ctx context.Context, container appflag.Container) { // WarnBetaCommand prints a warning for a beta command unless the betaSuppressWarningsEnvKey // environment variable is set. -func WarnBetaCommand(ctx context.Context, container appflag.Container) { +func WarnBetaCommand(_ context.Context, container appflag.Container) { if container.Env(betaSuppressWarningsEnvKey) == "" { container.Logger().Warn("This command is in beta. It is unstable and likely to change. To suppress this warning, set " + betaSuppressWarningsEnvKey + "=1") } @@ -403,10 +413,9 @@ func NewWireImageConfigReader( return bufwire.NewImageConfigReader( logger, storageosProvider, - newFetchReader(logger, storageosProvider, runner, moduleResolver, moduleReader), + NewFetchReader(logger, storageosProvider, runner, moduleResolver, moduleReader), bufmodulebuild.NewModuleBucketBuilder(), - bufmodulebuild.NewModuleFileSetBuilder(logger, moduleReader), - bufimagebuild.NewBuilder(logger), + bufimagebuild.NewBuilder(logger, moduleReader), ), nil } @@ -429,7 +438,7 @@ func NewWireModuleConfigReader( return bufwire.NewModuleConfigReader( logger, storageosProvider, - newFetchReader(logger, storageosProvider, runner, moduleResolver, moduleReader), + NewFetchReader(logger, storageosProvider, runner, moduleResolver, moduleReader), bufmodulebuild.NewModuleBucketBuilder(), ), nil } @@ -451,7 +460,7 @@ func NewWireModuleConfigReaderForModuleReader( return bufwire.NewModuleConfigReader( logger, storageosProvider, - newFetchReader(logger, storageosProvider, runner, moduleResolver, moduleReader), + NewFetchReader(logger, storageosProvider, runner, moduleResolver, moduleReader), bufmodulebuild.NewModuleBucketBuilder(), ), nil } @@ -475,10 +484,9 @@ func NewWireFileLister( return bufwire.NewFileLister( logger, storageosProvider, - newFetchReader(logger, storageosProvider, runner, moduleResolver, moduleReader), + NewFetchReader(logger, storageosProvider, runner, moduleResolver, moduleReader), bufmodulebuild.NewModuleBucketBuilder(), - bufmodulebuild.NewModuleFileSetBuilder(logger, moduleReader), - bufimagebuild.NewBuilder(logger), + bufimagebuild.NewBuilder(logger, moduleReader), ), nil } @@ -530,108 +538,37 @@ func NewModuleReaderAndCreateCacheDirs( container appflag.Container, clientConfig *connectclient.Config, ) (bufmodule.ModuleReader, error) { - return newModuleReaderAndCreateCacheDirs( - container, - clientConfig, - ) -} - -// NewModuleReaderAndCreateCacheDirsWithExternalPaths returns a new ModuleReader while creating the -// required cache directories, and configures the cache to preserve external paths. -// -// WARNING - this should only be used by systems like the LSP - leaking external paths from the module -// cache is otherwise dangerous and requires manager approval. -func NewModuleReaderAndCreateCacheDirsWithExternalPaths( - container appflag.Container, - clientConfig *connectclient.Config, -) (bufmodule.ModuleReader, error) { - return newModuleReaderAndCreateCacheDirs( - container, - clientConfig, - bufmodulecache.ModuleReaderWithExternalPaths(), - ) + return newModuleReaderAndCreateCacheDirs(container, clientConfig) } func newModuleReaderAndCreateCacheDirs( container appflag.Container, clientConfig *connectclient.Config, - cacheModuleReaderOpts ...bufmodulecache.ModuleReaderOption, ) (bufmodule.ModuleReader, error) { - cacheModuleDataDirPathV1 := normalpath.Join(container.CacheDirPath(), v1CacheModuleDataRelDirPath) - cacheModuleLockDirPathV1 := normalpath.Join(container.CacheDirPath(), v1CacheModuleLockRelDirPath) - cacheModuleSumDirPathV1 := normalpath.Join(container.CacheDirPath(), v1CacheModuleSumRelDirPath) cacheModuleDirPathV2 := normalpath.Join(container.CacheDirPath(), v2CacheModuleRelDirPath) - // Check if tamper proofing env var is enabled - tamperProofingEnabled, err := IsBetaTamperProofingEnabled(container) - if err != nil { - return nil, err - } - var cacheDirsToCreate []string - if tamperProofingEnabled { - cacheDirsToCreate = append(cacheDirsToCreate, cacheModuleDirPathV2) - } else { - cacheDirsToCreate = append( - cacheDirsToCreate, - cacheModuleDataDirPathV1, - cacheModuleLockDirPathV1, - cacheModuleSumDirPathV1, - ) - } - if err := checkExistingCacheDirs(container.CacheDirPath(), cacheDirsToCreate...); err != nil { + if err := checkExistingCacheDirs(container.CacheDirPath(), cacheModuleDirPathV2); err != nil { return nil, err } - if err := createCacheDirs(cacheDirsToCreate...); err != nil { + if err := createCacheDirs(cacheModuleDirPathV2); err != nil { return nil, err } - var moduleReaderOpts []bufapimodule.ModuleReaderOption - if tamperProofingEnabled { - moduleReaderOpts = append(moduleReaderOpts, bufapimodule.WithTamperProofing()) - } delegateReader := bufapimodule.NewModuleReader( bufapimodule.NewDownloadServiceClientFactory(clientConfig), - moduleReaderOpts..., ) repositoryClientFactory := bufmodulecache.NewRepositoryServiceClientFactory(clientConfig) storageosProvider := storageos.NewProvider(storageos.ProviderWithSymlinks()) var moduleReader bufmodule.ModuleReader - if tamperProofingEnabled { - casModuleBucket, err := storageosProvider.NewReadWriteBucket(cacheModuleDirPathV2) - if err != nil { - return nil, err - } - moduleReader = bufmodulecache.NewCASModuleReader( - container.Logger(), - container.VerbosePrinter(), - casModuleBucket, - delegateReader, - repositoryClientFactory, - ) - } else { - // do NOT want to enable symlinks for our cache - dataReadWriteBucket, err := storageosProvider.NewReadWriteBucket(cacheModuleDataDirPathV1) - if err != nil { - return nil, err - } - // do NOT want to enable symlinks for our cache - sumReadWriteBucket, err := storageosProvider.NewReadWriteBucket(cacheModuleSumDirPathV1) - if err != nil { - return nil, err - } - fileLocker, err := filelock.NewLocker(cacheModuleLockDirPathV1) - if err != nil { - return nil, err - } - moduleReader = bufmodulecache.NewModuleReader( - container.Logger(), - container.VerbosePrinter(), - fileLocker, - dataReadWriteBucket, - sumReadWriteBucket, - delegateReader, - repositoryClientFactory, - cacheModuleReaderOpts..., - ) + casModuleBucket, err := storageosProvider.NewReadWriteBucket(cacheModuleDirPathV2) + if err != nil { + return nil, err } + moduleReader = bufmodulecache.NewModuleReader( + container.Logger(), + container.VerbosePrinter(), + casModuleBucket, + delegateReader, + repositoryClientFactory, + ) return moduleReader, nil } @@ -653,17 +590,16 @@ func newConnectClientConfigWithOptions(container appflag.Container, opts ...conn client := httpclient.NewClient(config.TLS) options := []connectclient.ConfigOption{ connectclient.WithAddressMapper(func(address string) string { - if buftransport.IsAPISubdomainEnabled(container) { - address = buftransport.PrependAPISubdomain(address) - } if config.TLS == nil { return buftransport.PrependHTTP(address) } return buftransport.PrependHTTPS(address) }), - connectclient.WithInterceptors( - []connect.Interceptor{bufconnect.NewSetCLIVersionInterceptor(Version)}, - ), + connectclient.WithInterceptors([]connect.Interceptor{ + bufconnect.NewSetCLIVersionInterceptor(Version), + bufconnect.NewCLIWarningInterceptor(container), + otelconnect.NewInterceptor(), + }), } options = append(options, opts...) @@ -702,7 +638,27 @@ func NewConnectClientConfigWithToken(container appflag.Container, token string) ) } -// PromptUserForDelete is used to receieve user confirmation that a specific +// NewFetchReader creates a new buffetch.Reader with the default HTTP client +// and git cloner. +func NewFetchReader( + logger *zap.Logger, + storageosProvider storageos.Provider, + runner command.Runner, + moduleResolver bufmodule.ModuleResolver, + moduleReader bufmodule.ModuleReader, +) buffetch.Reader { + return buffetch.NewReader( + logger, + storageosProvider, + defaultHTTPClient, + defaultHTTPAuthenticator, + git.NewCloner(logger, storageosProvider, runner, defaultGitClonerOptions), + moduleResolver, + moduleReader, + ) +} + +// PromptUserForDelete is used to receive user confirmation that a specific // entity should be deleted. If the user's answer does not match the expected // answer, an error is returned. // ErrNotATTY is returned if the input containers Stdin is not a terminal. @@ -876,7 +832,8 @@ func WellKnownTypeImage(ctx context.Context, logger *zap.Logger, wellKnownType s if err != nil { return nil, err } - module, err := bufmodulebuild.BuildForBucket( + + module, err := bufmodulebuild.NewModuleBucketBuilder().BuildForBucket( ctx, datawkt.ReadBucket, sourceConfig.Build, @@ -884,7 +841,7 @@ func WellKnownTypeImage(ctx context.Context, logger *zap.Logger, wellKnownType s if err != nil { return nil, err } - image, _, err := bufimagebuild.NewBuilder(logger).Build(ctx, bufmodule.NewModuleFileSet(module, nil)) + image, _, err := bufimagebuild.NewBuilder(logger, bufmodule.NewNopModuleReader()).Build(ctx, module) if err != nil { return nil, err } @@ -918,11 +875,6 @@ func VisibilityFlagToVisibilityAllowUnspecified(visibility string) (registryv1al } } -// IsBetaTamperProofingEnabled returns if BUF_BETA_ENABLE_TAMPER_PROOFING is set to true. -func IsBetaTamperProofingEnabled(container app.EnvContainer) (bool, error) { - return app.EnvBool(container, BetaEnableTamperProofingEnvKey, false) -} - // IsAlphaWASMEnabled returns an BUF_ALPHA_ENABLE_WASM is set to true. func IsAlphaWASMEnabled(container app.EnvContainer) (bool, error) { return app.EnvBool(container, AlphaEnableWASMEnvKey, false) @@ -938,6 +890,46 @@ func ValidateErrorFormatFlagLint(errorFormatString string, errorFormatFlagName s return validateErrorFormatFlag(buflint.AllFormatStrings, errorFormatString, errorFormatFlagName) } +// PackageVersionShortDescription returns the long description for the -version command. +func PackageVersionShortDescription(name string) string { + return fmt.Sprintf("Resolve module and %s plugin reference to a specific remote package version", name) +} + +// PackageVersionLongDescription returns the long description for the -version command. +func PackageVersionLongDescription(registryName, commandName, examplePlugin string) string { + return fmt.Sprintf(`This command returns the version of the %s asset to be used with the %s registry. +Examples: + +Get the version of the eliza module and the %s plugin for use with %s. + $ buf alpha package %s --module=buf.build/bufbuild/eliza --plugin=%s + v1.7.0-20230609151053-e682db0d9918.1 + +Use a specific module version and plugin version. + $ buf alpha package %s --module=buf.build/bufbuild/eliza:e682db0d99184be88b41c4405ea8a417 --plugin=%s:v1.0.0 + v1.0.0-20230609151053-e682db0d9918.1 +`, registryName, registryName, examplePlugin, registryName, commandName, examplePlugin, commandName, examplePlugin) +} + +// SelectReferenceForRemote receives a list of module references and selects one for remote +// operations. In most cases, all references will have the same remote, which will result in the +// first reference being selected. In cases in which there is a mix of remotes, the first reference +// with a remote different than "buf.build" will be selected. This func is useful for targeting +// single-tenant BSR addresses. +func SelectReferenceForRemote(references []bufmoduleref.ModuleReference) bufmoduleref.ModuleReference { + if len(references) == 0 { + return nil + } + for _, ref := range references { + if ref == nil { + continue + } + if ref.Remote() != bufconnect.DefaultRemote { + return ref + } + } + return references[0] +} + func validateErrorFormatFlag(validFormatStrings []string, errorFormatString string, errorFormatFlagName string) error { for _, formatString := range validFormatStrings { if errorFormatString == formatString { @@ -1011,26 +1003,6 @@ func promptUser(container app.Container, prompt string, isPassword bool) (string return "", NewTooManyEmptyAnswersError(userPromptAttempts) } -// newFetchReader creates a new buffetch.Reader with the default HTTP client -// and git cloner. -func newFetchReader( - logger *zap.Logger, - storageosProvider storageos.Provider, - runner command.Runner, - moduleResolver bufmodule.ModuleResolver, - moduleReader bufmodule.ModuleReader, -) buffetch.Reader { - return buffetch.NewReader( - logger, - storageosProvider, - defaultHTTPClient, - defaultHTTPAuthenticator, - git.NewCloner(logger, storageosProvider, runner, defaultGitClonerOptions), - moduleResolver, - moduleReader, - ) -} - // newFetchSourceReader creates a new buffetch.SourceReader with the default HTTP client // and git cloner. func newFetchSourceReader( diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufcli/errors.go b/vendor/github.com/bufbuild/buf/private/buf/bufcli/errors.go index a877f2574..8da9acb7b 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufcli/errors.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufcli/errors.go @@ -19,11 +19,9 @@ import ( "errors" "fmt" "net" - "strings" "github.com/bufbuild/buf/private/bufpkg/bufconnect" "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" - "github.com/bufbuild/buf/private/bufpkg/buftransport" "github.com/bufbuild/buf/private/pkg/app" "github.com/bufbuild/buf/private/pkg/app/appflag" "github.com/bufbuild/connect-go" @@ -95,11 +93,6 @@ func NewErrorInterceptor() appflag.Interceptor { } } -// NewModuleRefError is used when the client fails to parse a module ref. -func NewModuleRefError(moduleRef string) error { - return fmt.Errorf("could not parse %q as a module; please verify this is a valid reference", moduleRef) -} - // NewTooManyEmptyAnswersError is used when the user does not answer a prompt in // the given number of attempts. func NewTooManyEmptyAnswersError(attempts int) error { @@ -152,18 +145,6 @@ func NewUnimplementedRemoteError(err error, remote string, moduleIdentity string return fmt.Errorf("%w. Are you sure %q (derived from module name %q) is a Buf Schema Registry?", err, remote, moduleIdentity) } -// NewPluginNotFoundError informs the user that a plugin with -// that owner and name does not exist. -func NewPluginNotFoundError(owner string, name string) error { - return fmt.Errorf("the plugin %s/%s does not exist", owner, name) -} - -// NewTemplateNotFoundError informs the user that a template with -// that owner and name does not exist. -func NewTemplateNotFoundError(owner string, name string) error { - return fmt.Errorf("the template %s/%s does not exist", owner, name) -} - // wrapError is used when a CLI command fails, regardless of its error code. // Note that this function will wrap the error so that the underlying error // can be recovered via 'errors.Is'. @@ -191,8 +172,7 @@ func wrapError(err error) error { // If the returned error is Unavailable, then determine if this is a DNS error. If so, get the address used // so that we can display a more helpful error message. if dnsError := (&net.DNSError{}); errors.As(err, &dnsError) && dnsError.IsNotFound { - // The subdomain is added internally during transport so trim it off when showing the user the invalid address that they entered - return fmt.Errorf(`%s Are you sure "%s" is a valid remote address?`, msg, strings.TrimPrefix(dnsError.Name, buftransport.APISubdomain+".")) + return fmt.Errorf(`%s Are you sure "%s" is a valid remote address?`, msg, dnsError.Name) } return errors.New(msg) diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufcurl/invoker.go b/vendor/github.com/bufbuild/buf/private/buf/bufcurl/invoker.go index 5084d98c0..3ebb7fa23 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufcurl/invoker.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufcurl/invoker.go @@ -70,12 +70,13 @@ func (p protoCodec) Unmarshal(bytes []byte, a any) error { type invokeClient = connect.Client[dynamicpb.Message, deferredMessage] type invoker struct { - md protoreflect.MethodDescriptor - res protoencoding.Resolver - client *invokeClient - output io.Writer - errOutput io.Writer - printer verbose.Printer + md protoreflect.MethodDescriptor + res protoencoding.Resolver + emitDefaults bool + client *invokeClient + output io.Writer + errOutput io.Writer + printer verbose.Printer } // NewInvoker creates a new invoker for invoking the method described by the @@ -83,18 +84,19 @@ type invoker struct { // in JSON format. The given resolver is used to resolve Any messages and // extensions that appear in the input or output. Other parameters are used // to create a Connect client, for issuing the RPC. -func NewInvoker(container appflag.Container, md protoreflect.MethodDescriptor, res protoencoding.Resolver, httpClient connect.HTTPClient, opts []connect.ClientOption, url string, out io.Writer) Invoker { +func NewInvoker(container appflag.Container, md protoreflect.MethodDescriptor, res protoencoding.Resolver, emitDefaults bool, httpClient connect.HTTPClient, opts []connect.ClientOption, url string, out io.Writer) Invoker { opts = append(opts, connect.WithCodec(protoCodec{})) // TODO: could also provide custom compressor implementations that could give us // optics into when request and response messages are compressed (which could be // useful to include in verbose output). return &invoker{ - md: md, - res: res, - output: out, - printer: container.VerbosePrinter(), - errOutput: container.Stderr(), - client: connect.NewClient[dynamicpb.Message, deferredMessage](httpClient, url, opts...), + md: md, + res: res, + emitDefaults: emitDefaults, + output: out, + printer: container.VerbosePrinter(), + errOutput: container.Stderr(), + client: connect.NewClient[dynamicpb.Message, deferredMessage](httpClient, url, opts...), } } @@ -279,9 +281,16 @@ func (inv *invoker) handleResponse(data []byte, msg *dynamicpb.Message) error { if err := protoencoding.NewWireUnmarshaler(inv.res).Unmarshal(data, msg); err != nil { return err } - // If we want to add a pretty-print option, we should perhaps make this a flag - // and use protoencoding.NewJSONMarshalerIndent - outputBytes, err := protoencoding.NewJSONMarshaler(inv.res).Marshal(msg) + jsonMarshalerOptions := []protoencoding.JSONMarshalerOption{ + protoencoding.JSONMarshalerWithIndent(), + } + if inv.emitDefaults { + jsonMarshalerOptions = append( + jsonMarshalerOptions, + protoencoding.JSONMarshalerWithEmitUnpopulated(), + ) + } + outputBytes, err := protoencoding.NewJSONMarshaler(inv.res, jsonMarshalerOptions...).Marshal(msg) if err != nil { return err } diff --git a/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/errors.go b/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/errors.go index d0cd27f72..1c9cd4ac1 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/errors.go +++ b/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/errors.go @@ -111,6 +111,14 @@ func NewInvalidPathError(format string, path string) error { return fmt.Errorf("invalid %spath: %q", format, path) } +// NewProtoFileCannotBeDevPathError is a fetch error. +func NewProtoFileCannotBeDevPathError(format string, path string) error { + if format != "" { + format = format + " " + } + return fmt.Errorf("invalid %spath: %q (protofiles cannot be read or written to or from stdio)", format, path) +} + // NewRealCleanPathError is a fetch error. func NewRealCleanPathError(path string) error { return fmt.Errorf("could not clean relative path %q", path) diff --git a/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/proto_file_ref.go b/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/proto_file_ref.go index e00bf62b5..90a398957 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/proto_file_ref.go +++ b/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/proto_file_ref.go @@ -14,6 +14,8 @@ package internal +import "github.com/bufbuild/buf/private/pkg/app" + var ( _ ParsedProtoFileRef = &protoFileRef{} ) @@ -24,12 +26,15 @@ type protoFileRef struct { includePackageFiles bool } -func newProtoFileRef(format string, path string, includePackageFiles bool) *protoFileRef { +func newProtoFileRef(format string, path string, includePackageFiles bool) (*protoFileRef, error) { + if app.IsDevPath(path) || path == "-" { + return nil, NewProtoFileCannotBeDevPathError(format, path) + } return &protoFileRef{ format: format, path: path, includePackageFiles: includePackageFiles, - } + }, nil } func (s *protoFileRef) Format() string { diff --git a/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/ref_parser.go b/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/ref_parser.go index c6920735b..49071108c 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/ref_parser.go +++ b/vendor/github.com/bufbuild/buf/private/buf/buffetch/internal/ref_parser.go @@ -94,7 +94,7 @@ func (a *refParser) getParsedRef( return getArchiveRef(rawRef, archiveFormatInfo.archiveType, archiveFormatInfo.defaultCompressionType) } if protoFileOK { - return getProtoFileRef(rawRef), nil + return getProtoFileRef(rawRef) } if dirOK { return getDirRef(rawRef) @@ -342,7 +342,7 @@ func getGitRefName(path string, branch string, tag string, ref string) (git.Name return git.NewTagName(tag), nil } -func getProtoFileRef(rawRef *RawRef) ParsedProtoFileRef { +func getProtoFileRef(rawRef *RawRef) (ParsedProtoFileRef, error) { return newProtoFileRef( rawRef.Format, rawRef.Path, diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufformat/formatter.go b/vendor/github.com/bufbuild/buf/private/buf/bufformat/formatter.go index 010aad945..43db5e87d 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufformat/formatter.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufformat/formatter.go @@ -18,6 +18,7 @@ import ( "errors" "fmt" "io" + "reflect" "sort" "strings" "unicode" @@ -253,12 +254,40 @@ func (f *formatter) writeFileHeader() { f.writePackage(packageNode) } sort.Slice(importNodes, func(i, j int) bool { - return importNodes[i].Name.AsString() < importNodes[j].Name.AsString() + iName := importNodes[i].Name.AsString() + jName := importNodes[j].Name.AsString() + // sort by public > None > weak + iOrder := importSortOrder(importNodes[i]) + jOrder := importSortOrder(importNodes[j]) + + if iName < jName { + return true + } + if iName > jName { + return false + } + if iOrder > jOrder { + return true + } + if iOrder < jOrder { + return false + } + + // put commented import first + return !f.importHasComment(importNodes[j]) }) for i, importNode := range importNodes { if i == 0 && f.previousNode != nil && !f.leadingCommentsContainBlankLine(importNode) { f.P("") } + + // since the imports are sorted, this will skip write imports + // if they have appear before and dont have comment + if i > 0 && importNode.Name.AsString() == importNodes[i-1].Name.AsString() && + !f.importHasComment(importNode) { + continue + } + f.writeImport(importNode, i > 0) } sort.Slice(optionNodes, func(i, j int) bool { @@ -2197,6 +2226,45 @@ func (f *formatter) leadingCommentsContainBlankLine(n ast.Node) bool { return newlineCount(info.LeadingWhitespace()) > 1 } +func (f *formatter) importHasComment(importNode *ast.ImportNode) bool { + if f.nodeHasComment(importNode) { + return true + } + if importNode == nil { + return false + } + + return f.nodeHasComment(importNode.Keyword) || + f.nodeHasComment(importNode.Name) || + f.nodeHasComment(importNode.Semicolon) || + f.nodeHasComment(importNode.Public) || + f.nodeHasComment(importNode.Weak) +} + +func (f *formatter) nodeHasComment(node ast.Node) bool { + // when node != nil, node's value could be nil, see: https://go.dev/doc/faq#nil_error + if node == nil || reflect.ValueOf(node).IsNil() { + return false + } + + nodeinfo := f.fileNode.NodeInfo(node) + return nodeinfo.LeadingComments().Len() > 0 || + nodeinfo.TrailingComments().Len() > 0 +} + +// importSortOrder maps import types to a sort order number, so it can be compared and sorted. +// `import`=3, `import public`=2, `import weak`=1 +func importSortOrder(node *ast.ImportNode) int { + switch { + case node.Public != nil: + return 2 + case node.Weak != nil: + return 1 + default: + return 3 + } +} + // stringForOptionName returns the string representation of the given option name node. // This is used for sorting file-level options. func stringForOptionName(optionNameNode *ast.OptionNameNode) string { diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufprint/bufprint.go b/vendor/github.com/bufbuild/buf/private/buf/bufprint/bufprint.go index 487c049fc..f1e6ba0ed 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufprint/bufprint.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufprint/bufprint.go @@ -46,7 +46,7 @@ type Format int // ParseFormat parses the format. // -// If the empty string is provided, this is interpeted as FormatText. +// If the empty string is provided, this is interpreted as FormatText. func ParseFormat(s string) (Format, error) { switch s { case "", "text": @@ -139,50 +139,7 @@ func NewRepositoryDraftPrinter(writer io.Writer) RepositoryDraftPrinter { return newRepositoryDraftPrinter(writer) } -// PluginPrinter is a printer for plugins. -type PluginPrinter interface { - PrintPlugin(ctx context.Context, format Format, plugin *registryv1alpha1.Plugin) error - PrintPlugins(ctx context.Context, format Format, nextPageToken string, plugins ...*registryv1alpha1.Plugin) error -} - -// NewPluginPrinter returns a new PluginPrinter. -func NewPluginPrinter(writer io.Writer) PluginPrinter { - return newPluginPrinter(writer) -} - -// PluginVersionPrinter is a printer for PluginVersions. -type PluginVersionPrinter interface { - PrintPluginVersions(ctx context.Context, format Format, nextPageToken string, pluginVersions ...*registryv1alpha1.PluginVersion) error -} - -// NewPluginVersionPrinter returns a new NewPluginVersionPrinter. -func NewPluginVersionPrinter(writer io.Writer) PluginVersionPrinter { - return newPluginVersionPrinter(writer) -} - -// TemplatePrinter is a printer for Templates. -type TemplatePrinter interface { - PrintTemplate(ctx context.Context, format Format, template *registryv1alpha1.Template) error - PrintTemplates(ctx context.Context, format Format, nextPageToken string, templates ...*registryv1alpha1.Template) error -} - -// NewTemplatePrinter returns a new NewTemplatePrinter. -func NewTemplatePrinter(writer io.Writer) TemplatePrinter { - return newTemplatePrinter(writer) -} - -// TemplateVersionPrinter is a printer for TemplateVersions. -type TemplateVersionPrinter interface { - PrintTemplateVersion(ctx context.Context, format Format, templateVersion *registryv1alpha1.TemplateVersion) error - PrintTemplateVersions(ctx context.Context, format Format, nextPageToken string, templateVersions ...*registryv1alpha1.TemplateVersion) error -} - -// NewTemplateVersionPrinter returns a new NewTemplateVersionPrinter. -func NewTemplateVersionPrinter(writer io.Writer) TemplateVersionPrinter { - return newTemplateVersionPrinter(writer) -} - -// TokenPrinter is a printer Tokens. +// TokenPrinter is a token printer. // // TODO: update to same format as other printers. type TokenPrinter interface { @@ -238,7 +195,7 @@ func WithTabWriter( // printProtoMessageJSON prints the Protobuf message as JSON. func printProtoMessageJSON(writer io.Writer, message proto.Message) error { - data, err := protoencoding.NewJSONMarshalerIndent(nil).Marshal(message) + data, err := protoencoding.NewJSONMarshaler(nil, protoencoding.JSONMarshalerWithIndent()).Marshal(message) if err != nil { return err } diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufprint/plugin_printer.go b/vendor/github.com/bufbuild/buf/private/buf/bufprint/plugin_printer.go deleted file mode 100644 index 471b1a7a9..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/bufprint/plugin_printer.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 bufprint - -import ( - "context" - "encoding/json" - "fmt" - "io" - - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" -) - -type pluginPrinter struct { - writer io.Writer -} - -func newPluginPrinter( - writer io.Writer, -) *pluginPrinter { - return &pluginPrinter{ - writer: writer, - } -} - -func (p *pluginPrinter) PrintPlugin(ctx context.Context, format Format, plugin *registryv1alpha1.Plugin) error { - switch format { - case FormatText: - return p.printPluginsText(ctx, plugin) - case FormatJSON: - return json.NewEncoder(p.writer).Encode( - registryPluginToOutputPlugin(plugin), - ) - default: - return fmt.Errorf("unknown format: %v", format) - } -} - -func (p *pluginPrinter) PrintPlugins(ctx context.Context, format Format, nextPageToken string, plugins ...*registryv1alpha1.Plugin) error { - switch format { - case FormatText: - return p.printPluginsText(ctx, plugins...) - case FormatJSON: - outputPlugins := make([]outputPlugin, 0, len(plugins)) - for _, plugin := range plugins { - outputPlugins = append(outputPlugins, registryPluginToOutputPlugin(plugin)) - } - return json.NewEncoder(p.writer).Encode(paginationWrapper{ - NextPage: nextPageToken, - Results: outputPlugins, - }) - default: - return fmt.Errorf("unknown format: %v", format) - } -} - -func (p *pluginPrinter) printPluginsText(ctx context.Context, plugins ...*registryv1alpha1.Plugin) error { - if len(plugins) == 0 { - return nil - } - return WithTabWriter( - p.writer, - []string{ - "Owner", - "Name", - }, - func(tabWriter TabWriter) error { - for _, plugin := range plugins { - if err := tabWriter.Write( - plugin.Owner, - plugin.Name, - ); err != nil { - return err - } - } - return nil - }, - ) -} - -type outputPlugin struct { - Name string `json:"name,omitempty"` - Owner string `json:"owner,omitempty"` - Visibility string `json:"visibility,omitempty"` -} - -func registryPluginToOutputPlugin(plugin *registryv1alpha1.Plugin) outputPlugin { - return outputPlugin{ - Name: plugin.Name, - Owner: plugin.Owner, - Visibility: plugin.Visibility.String(), - } -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufprint/plugin_version_printer.go b/vendor/github.com/bufbuild/buf/private/buf/bufprint/plugin_version_printer.go deleted file mode 100644 index 766747d4c..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/bufprint/plugin_version_printer.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 bufprint - -import ( - "context" - "encoding/json" - "fmt" - "io" - - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" -) - -type pluginVersionPrinter struct { - writer io.Writer -} - -func newPluginVersionPrinter( - writer io.Writer, -) *pluginVersionPrinter { - return &pluginVersionPrinter{ - writer: writer, - } -} - -func (p *pluginVersionPrinter) PrintPluginVersions(ctx context.Context, format Format, nextPageToken string, pluginVersions ...*registryv1alpha1.PluginVersion) error { - switch format { - case FormatText: - return p.printPluginVersionsText(ctx, pluginVersions...) - case FormatJSON: - outputPlugins := make([]outputPluginVersion, 0, len(pluginVersions)) - for _, pluginVersion := range pluginVersions { - outputPlugins = append( - outputPlugins, - registryPluginVersionToOutputPluginVersion(pluginVersion), - ) - } - return json.NewEncoder(p.writer).Encode(paginationWrapper{ - NextPage: nextPageToken, - Results: outputPlugins, - }) - default: - return fmt.Errorf("unknown format: %v", format) - } -} - -func (p *pluginVersionPrinter) printPluginVersionsText(ctx context.Context, plugins ...*registryv1alpha1.PluginVersion) error { - if len(plugins) == 0 { - return nil - } - return WithTabWriter( - p.writer, - []string{ - "Name", - "Plugin Name", - "Plugin Owner", - "Container Image Digest", - }, - func(tabWriter TabWriter) error { - for _, plugin := range plugins { - if err := tabWriter.Write( - plugin.Name, - plugin.PluginName, - plugin.PluginOwner, - plugin.ContainerImageDigest, - ); err != nil { - return err - } - } - return nil - }, - ) -} - -type outputPluginVersion struct { - Name string `json:"name,omitempty"` - PluginName string `json:"plugin_name,omitempty"` - PluginOwner string `json:"plugin_owner,omitempty"` - ContainerImageDigest string `json:"container_image_digest,omitempty"` -} - -func registryPluginVersionToOutputPluginVersion(pluginVersion *registryv1alpha1.PluginVersion) outputPluginVersion { - return outputPluginVersion{ - Name: pluginVersion.Name, - PluginName: pluginVersion.PluginName, - PluginOwner: pluginVersion.PluginOwner, - ContainerImageDigest: pluginVersion.ContainerImageDigest, - } -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufprint/template_printer.go b/vendor/github.com/bufbuild/buf/private/buf/bufprint/template_printer.go deleted file mode 100644 index 3dc383482..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/bufprint/template_printer.go +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 bufprint - -import ( - "context" - "encoding/json" - "fmt" - "io" - - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" -) - -type templatePrinter struct { - writer io.Writer -} - -func newTemplatePrinter(writer io.Writer) *templatePrinter { - return &templatePrinter{ - writer: writer, - } -} - -func (t *templatePrinter) PrintTemplate(ctx context.Context, format Format, template *registryv1alpha1.Template) error { - switch format { - case FormatText: - return t.printTemplatesText(ctx, template) - case FormatJSON: - return json.NewEncoder(t.writer).Encode( - registryTemplateToOutputTemplate(template), - ) - default: - return fmt.Errorf("unknown format: %v", format) - } -} - -func (t *templatePrinter) PrintTemplates(ctx context.Context, format Format, nextPageToken string, templates ...*registryv1alpha1.Template) error { - switch format { - case FormatText: - return t.printTemplatesText(ctx, templates...) - case FormatJSON: - outputTemplates := make([]outputTemplate, 0, len(templates)) - for _, template := range templates { - outputTemplates = append(outputTemplates, registryTemplateToOutputTemplate(template)) - } - return json.NewEncoder(t.writer).Encode(paginationWrapper{ - NextPage: nextPageToken, - Results: outputTemplates, - }) - default: - return fmt.Errorf("unknown format: %v", format) - } -} - -func (t *templatePrinter) printTemplatesText(ctx context.Context, templates ...*registryv1alpha1.Template) error { - if len(templates) == 0 { - return nil - } - return WithTabWriter( - t.writer, - []string{ - "Owner", - "Name", - }, - func(tabWriter TabWriter) error { - for _, template := range templates { - if err := tabWriter.Write( - template.Owner, - template.Name, - ); err != nil { - return err - } - } - return nil - }, - ) -} - -type outputTemplate struct { - Name string `json:"name,omitempty"` - Owner string `json:"owner,omitempty"` - Visibility string `json:"visibility,omitempty"` -} - -func registryTemplateToOutputTemplate(template *registryv1alpha1.Template) outputTemplate { - return outputTemplate{ - Name: template.Name, - Owner: template.Owner, - Visibility: template.Visibility.String(), - } -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufprint/template_version_printer.go b/vendor/github.com/bufbuild/buf/private/buf/bufprint/template_version_printer.go deleted file mode 100644 index de62d0064..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/bufprint/template_version_printer.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 bufprint - -import ( - "context" - "encoding/json" - "fmt" - "io" - - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" -) - -type templateVersionPrinter struct { - writer io.Writer -} - -func newTemplateVersionPrinter(writer io.Writer) *templateVersionPrinter { - return &templateVersionPrinter{ - writer: writer, - } -} - -func (t *templateVersionPrinter) PrintTemplateVersion(ctx context.Context, format Format, templateVersion *registryv1alpha1.TemplateVersion) error { - switch format { - case FormatText: - return t.printTemplateVersionsText(ctx, templateVersion) - case FormatJSON: - return json.NewEncoder(t.writer).Encode( - registryTemplateVersionToOutputTemplateVersion(templateVersion), - ) - default: - return fmt.Errorf("unknown format: %v", format) - } -} - -func (t *templateVersionPrinter) PrintTemplateVersions(ctx context.Context, format Format, nextPageToken string, templateVersions ...*registryv1alpha1.TemplateVersion) error { - switch format { - case FormatText: - return t.printTemplateVersionsText(ctx, templateVersions...) - case FormatJSON: - outputTemplateVersions := make([]outputTemplateVersion, 0, len(templateVersions)) - for _, templateVersion := range templateVersions { - outputTemplateVersions = append(outputTemplateVersions, registryTemplateVersionToOutputTemplateVersion(templateVersion)) - } - return json.NewEncoder(t.writer).Encode(paginationWrapper{ - NextPage: nextPageToken, - Results: outputTemplateVersions, - }) - default: - return fmt.Errorf("unknown format: %v", format) - } -} - -func (t *templateVersionPrinter) printTemplateVersionsText(ctx context.Context, templateVersions ...*registryv1alpha1.TemplateVersion) error { - if len(templateVersions) == 0 { - return nil - } - return WithTabWriter( - t.writer, - []string{ - "Name", - "Template Owner", - "Template Name", - }, - func(tabWriter TabWriter) error { - for _, templateVersion := range templateVersions { - if err := tabWriter.Write( - templateVersion.Name, - templateVersion.TemplateName, - templateVersion.TemplateOwner, - ); err != nil { - return err - } - } - return nil - }, - ) -} - -type outputTemplateVersion struct { - Name string `json:"name,omitempty"` - TemplateOwner string `json:"template_owner,omitempty"` - TemplateName string `json:"template_name,omitempty"` -} - -func registryTemplateVersionToOutputTemplateVersion(templateVersion *registryv1alpha1.TemplateVersion) outputTemplateVersion { - return outputTemplateVersion{ - Name: templateVersion.Name, - TemplateOwner: templateVersion.TemplateOwner, - TemplateName: templateVersion.TemplateName, - } -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufsync/bufsync.go b/vendor/github.com/bufbuild/buf/private/buf/bufsync/bufsync.go new file mode 100644 index 000000000..7734809ff --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/bufsync/bufsync.go @@ -0,0 +1,173 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 bufsync + +import ( + "context" + "fmt" + + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/pkg/git" + "github.com/bufbuild/buf/private/pkg/storage" + "github.com/bufbuild/buf/private/pkg/storage/storagegit" + "go.uber.org/zap" +) + +// ErrorHandler handles errors reported by the Syncer. If a non-nil +// error is returned by the handler, sync will abort in a partially-synced +// state. +type ErrorHandler interface { + // InvalidModuleConfig is invoked by Syncer upon encountering a module + // with an invalid module config. + // + // Returning an error will abort sync. + InvalidModuleConfig( + module Module, + commit git.Commit, + err error, + ) error + // BuildFailure is invoked by Syncer upon encountering a module that fails + // build. + // + // Returning an error will abort sync. + BuildFailure( + module Module, + commit git.Commit, + err error, + ) error + // InvalidSyncPoint is invoked by Syncer upon encountering a module's branch + // sync point that is invalid. A typical example is either a sync point that + // point to a commit that cannot be found anymore, or the commit itself has + // been corrupted. + // + // Returning an error will abort sync. + InvalidSyncPoint( + module Module, + branch string, + syncPoint git.Hash, + err error, + ) error + // SyncPointNotEncountered is invoked by Syncer upon syncing a module on a + // branch where a sync point was resolved and validated, but was not + // encountered during sync. + // + // Returning an error will abort sync. + SyncPointNotEncountered( + module Module, + branch string, + syncPoint git.Hash, + ) error +} + +// Module is a module that will be synced by Syncer. +type Module interface { + // Dir is the path to the module relative to the repository root. + Dir() string + // RemoteIdentity is the identity of the remote module that the + // local module is synced to. + RemoteIdentity() bufmoduleref.ModuleIdentity + // String is the string representation of this module. + String() string +} + +// NewModule constructs a new module that can be synced with a Syncer. +func NewModule(dir string, identityOverride bufmoduleref.ModuleIdentity) (Module, error) { + return newSyncableModule( + dir, + identityOverride, + ) +} + +// Syncer syncs a modules in a git.Repository. +type Syncer interface { + // Sync syncs the repository using the provided SyncFunc. It processes + // commits in reverse topological order, loads any configured named + // modules, extracts any Git metadata for that commit, and invokes + // SyncFunc with a ModuleCommit. + // + // Only commits/branches belonging to the remote named 'origin' are + // processed. All tags are processed. + Sync(context.Context, SyncFunc) error +} + +// NewSyncer creates a new Syncer. +func NewSyncer( + logger *zap.Logger, + repo git.Repository, + storageGitProvider storagegit.Provider, + errorHandler ErrorHandler, + options ...SyncerOption, +) (Syncer, error) { + return newSyncer( + logger, + repo, + storageGitProvider, + errorHandler, + options..., + ) +} + +// SyncerOption configures the creation of a new Syncer. +type SyncerOption func(*syncer) error + +// SyncerWithModule configures a Syncer to sync the specified module. +// +// This option can be provided multiple times to sync multiple distinct modules. +func SyncerWithModule(module Module) SyncerOption { + return func(s *syncer) error { + for _, existingModule := range s.modulesToSync { + if existingModule.String() == module.String() { + return fmt.Errorf("duplicate module %s", module) + } + } + s.modulesToSync = append(s.modulesToSync, module) + return nil + } +} + +// SyncerWithResumption configures a Syncer with a resumption using a SyncPointResolver. +func SyncerWithResumption(resolver SyncPointResolver) SyncerOption { + return func(s *syncer) error { + s.syncPointResolver = resolver + return nil + } +} + +// SyncFunc is invoked by Syncer to process a sync point. If an error is returned, +// sync will abort. +type SyncFunc func(ctx context.Context, commit ModuleCommit) error + +// SyncPointResolver is invoked by Syncer to resolve a syncpoint for a particular module +// at a particular branch. If no syncpoint is found, this function returns nil. If an error +// is returned, sync will abort. +type SyncPointResolver func( + ctx context.Context, + identity bufmoduleref.ModuleIdentity, + branch string, +) (git.Hash, error) + +// ModuleCommit is a module at a particular commit. +type ModuleCommit interface { + // Identity is the identity of the module, accounting for any configured override. + Identity() bufmoduleref.ModuleIdentity + // Bucket is the bucket for the module. + Bucket() storage.ReadBucket + // Commit is the commit that the module is sourced from. + Commit() git.Commit + // Branch is the git branch that this module is sourced from. + Branch() string + // Tags are the git tags associated with Commit. + Tags() []string +} diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufsync/module_commit.go b/vendor/github.com/bufbuild/buf/private/buf/bufsync/module_commit.go new file mode 100644 index 000000000..dc353270f --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/bufsync/module_commit.go @@ -0,0 +1,65 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 bufsync + +import ( + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/pkg/git" + "github.com/bufbuild/buf/private/pkg/storage" +) + +type moduleCommit struct { + identity bufmoduleref.ModuleIdentity + bucket storage.ReadBucket + commit git.Commit + branch string + tags []string +} + +func newModuleCommit( + identity bufmoduleref.ModuleIdentity, + bucket storage.ReadBucket, + commit git.Commit, + branch string, + tags []string, +) ModuleCommit { + return &moduleCommit{ + identity: identity, + bucket: bucket, + commit: commit, + branch: branch, + tags: tags, + } +} + +func (m *moduleCommit) Identity() bufmoduleref.ModuleIdentity { + return m.identity +} + +func (m *moduleCommit) Bucket() storage.ReadBucket { + return m.bucket +} + +func (m *moduleCommit) Commit() git.Commit { + return m.commit +} + +func (m *moduleCommit) Branch() string { + return m.branch +} + +func (m *moduleCommit) Tags() []string { + return m.tags +} diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufsync/syncable_module.go b/vendor/github.com/bufbuild/buf/private/buf/bufsync/syncable_module.go new file mode 100644 index 000000000..270fa8e04 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/bufsync/syncable_module.go @@ -0,0 +1,55 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 bufsync + +import ( + "fmt" + + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/pkg/normalpath" +) + +type syncableModule struct { + dir string + remoteIdentity bufmoduleref.ModuleIdentity + formatted string +} + +func newSyncableModule( + dir string, + remoteIdentity bufmoduleref.ModuleIdentity, +) (Module, error) { + normalized, err := normalpath.NormalizeAndValidate(dir) + if err != nil { + return nil, err + } + return &syncableModule{ + dir: normalized, + remoteIdentity: remoteIdentity, + formatted: fmt.Sprintf("%s:%s", dir, remoteIdentity.IdentityString()), + }, nil +} + +func (s *syncableModule) Dir() string { + return s.dir +} + +func (s *syncableModule) RemoteIdentity() bufmoduleref.ModuleIdentity { + return s.remoteIdentity +} + +func (s *syncableModule) String() string { + return s.formatted +} diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufsync/syncer.go b/vendor/github.com/bufbuild/buf/private/buf/bufsync/syncer.go new file mode 100644 index 000000000..1390e2b8f --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/bufsync/syncer.go @@ -0,0 +1,234 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 bufsync + +import ( + "context" + "fmt" + + "github.com/bufbuild/buf/private/bufpkg/bufconfig" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild" + "github.com/bufbuild/buf/private/pkg/git" + "github.com/bufbuild/buf/private/pkg/storage" + "github.com/bufbuild/buf/private/pkg/storage/storagegit" + "go.uber.org/zap" +) + +type syncer struct { + logger *zap.Logger + repo git.Repository + storageGitProvider storagegit.Provider + errorHandler ErrorHandler + modulesToSync []Module + syncPointResolver SyncPointResolver + + knownTagsByCommitHash map[string][]string +} + +func newSyncer( + logger *zap.Logger, + repo git.Repository, + storageGitProvider storagegit.Provider, + errorHandler ErrorHandler, + options ...SyncerOption, +) (Syncer, error) { + s := &syncer{ + logger: logger, + repo: repo, + storageGitProvider: storageGitProvider, + } + for _, opt := range options { + if err := opt(s); err != nil { + return nil, err + } + } + return s, nil +} + +// resolveSyncPoints resolves sync points for all known modules for the specified branch, +// returning all modules for which sync points were found, along with their sync points. +// +// If a SyncPointResolver is not configured, this returns an empty map immediately. +func (s *syncer) resolveSyncPoints(ctx context.Context, branch string) (map[Module]git.Hash, error) { + syncPoints := map[Module]git.Hash{} + // If resumption is not enabled, we can bail early. + if s.syncPointResolver == nil { + return syncPoints, nil + } + for _, module := range s.modulesToSync { + syncPoint, err := s.resolveSyncPoint(ctx, module, branch) + if err != nil { + return nil, err + } + if syncPoint != nil { + s.logger.Debug( + "resolved sync point, will sync after this commit", + zap.String("branch", branch), + zap.Stringer("module", module), + zap.Stringer("syncPoint", syncPoint), + ) + syncPoints[module] = syncPoint + } else { + s.logger.Debug( + "no sync point, syncing from the beginning", + zap.String("branch", branch), + zap.Stringer("module", module), + ) + } + } + return syncPoints, nil +} + +// resolveSyncPoint resolves a sync point for a particular module and branch. It assumes +// that a SyncPointResolver is configured. +func (s *syncer) resolveSyncPoint(ctx context.Context, module Module, branch string) (git.Hash, error) { + syncPoint, err := s.syncPointResolver(ctx, module.RemoteIdentity(), branch) + if err != nil { + return nil, fmt.Errorf("resolve syncPoint for module %s: %w", module.RemoteIdentity(), err) + } + if syncPoint == nil { + return nil, nil + } + // Validate that the commit pointed to by the sync point exists. + if _, err := s.repo.Objects().Commit(syncPoint); err != nil { + return nil, s.errorHandler.InvalidSyncPoint(module, branch, syncPoint, err) + } + return syncPoint, nil +} + +func (s *syncer) Sync(ctx context.Context, syncFunc SyncFunc) error { + s.knownTagsByCommitHash = map[string][]string{} + if err := s.repo.ForEachTag(func(tag string, commitHash git.Hash) error { + s.knownTagsByCommitHash[commitHash.Hex()] = append(s.knownTagsByCommitHash[commitHash.Hex()], tag) + return nil + }); err != nil { + return fmt.Errorf("load tags: %w", err) + } + // TODO: sync other branches + for _, branch := range []string{s.repo.BaseBranch()} { + syncPoints, err := s.resolveSyncPoints(ctx, branch) + if err != nil { + return err + } + // We sync all modules in a commit before advancing to the next commit so that + // inter-module dependencies across commits can be resolved. + if err := s.repo.ForEachCommit(branch, func(commit git.Commit) error { + for _, module := range s.modulesToSync { + if syncPoint := syncPoints[module]; syncPoint != nil { + // This module has a sync point. We need to check if we've encountered the sync point. + if syncPoint.Hex() == commit.Hash().Hex() { + // We have found the syncPoint! We can resume syncing _after_ this point. + delete(syncPoints, module) + s.logger.Debug( + "syncPoint encountered, skipping commit", + zap.Stringer("commit", commit.Hash()), + zap.Stringer("module", module), + zap.Stringer("syncPoint", syncPoint), + ) + } else { + // We have not encountered the syncPoint yet. Skip this commit and keep looking + // for the syncPoint. + s.logger.Debug( + "syncPoint not encountered, skipping commit", + zap.Stringer("commit", commit.Hash()), + zap.Stringer("module", module), + zap.Stringer("syncPoint", syncPoint), + ) + } + continue + } + if err := s.visitCommit(ctx, module, branch, commit, syncFunc); err != nil { + return fmt.Errorf("process commit %s (%s): %w", commit.Hash().Hex(), branch, err) + } + } + return nil + }); err != nil { + return fmt.Errorf("process commits: %w", err) + } + // If we have any sync points left, they were not encountered during sync, which is unexpected behavior. + for module, syncPoint := range syncPoints { + if err := s.errorHandler.SyncPointNotEncountered(module, branch, syncPoint); err != nil { + return err + } + } + } + return nil +} + +// visitCommit looks for the module in the commit, and if found tries to validate it. +// If it is valid, it invokes `syncFunc`. +// +// It does not return errors on invalid modules, but it will return any errors from +// `syncFunc` as those may be transient. +func (s *syncer) visitCommit( + ctx context.Context, + module Module, + branch string, + commit git.Commit, + syncFunc SyncFunc, +) error { + sourceBucket, err := s.storageGitProvider.NewReadBucket( + commit.Tree(), + storagegit.ReadBucketWithSymlinksIfSupported(), + ) + if err != nil { + return err + } + sourceBucket = storage.MapReadBucket(sourceBucket, storage.MapOnPrefix(module.Dir())) + foundModule, err := bufconfig.ExistingConfigFilePath(ctx, sourceBucket) + if err != nil { + return err + } + if foundModule == "" { + // We did not find a module. Carry on to the next commit. + s.logger.Debug( + "module not found, skipping commit", + zap.Stringer("commit", commit.Hash()), + zap.Stringer("module", module), + ) + return nil + } + sourceConfig, err := bufconfig.GetConfigForBucket(ctx, sourceBucket) + if err != nil { + return s.errorHandler.InvalidModuleConfig(module, commit, err) + } + if sourceConfig.ModuleIdentity == nil { + // Unnamed module. Carry on. + s.logger.Debug( + "unnamed module, skipping commit", + zap.Stringer("commit", commit.Hash()), + zap.Stringer("module", module), + ) + return nil + } + builtModule, err := bufmodulebuild.NewModuleBucketBuilder().BuildForBucket( + ctx, + sourceBucket, + sourceConfig.Build, + ) + if err != nil { + return s.errorHandler.BuildFailure(module, commit, err) + } + return syncFunc( + ctx, + newModuleCommit( + module.RemoteIdentity(), + builtModule.Bucket, + commit, + branch, + s.knownTagsByCommitHash[commit.Hash().Hex()], + ), + ) +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/filelock/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/bufsync/usage.gen.go similarity index 97% rename from vendor/github.com/bufbuild/buf/private/pkg/filelock/usage.gen.go rename to vendor/github.com/bufbuild/buf/private/buf/bufsync/usage.gen.go index 6578f240d..c4e76bb5e 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/filelock/usage.gen.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufsync/usage.gen.go @@ -14,6 +14,6 @@ // Generated. DO NOT EDIT. -package filelock +package bufsync import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufwire/bufwire.go b/vendor/github.com/bufbuild/buf/private/buf/bufwire/bufwire.go index 968af9da8..003d3a2c7 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufwire/bufwire.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufwire/bufwire.go @@ -64,7 +64,6 @@ func NewImageConfigReader( storageosProvider storageos.Provider, fetchReader buffetch.Reader, moduleBucketBuilder bufmodulebuild.ModuleBucketBuilder, - moduleFileSetBuilder bufmodulebuild.ModuleFileSetBuilder, imageBuilder bufimagebuild.Builder, ) ImageConfigReader { return newImageConfigReader( @@ -72,27 +71,32 @@ func NewImageConfigReader( storageosProvider, fetchReader, moduleBucketBuilder, - moduleFileSetBuilder, imageBuilder, ) } -// ModuleConfig is an module and configuration. +// ModuleConfig is a Module and configuration. type ModuleConfig interface { Module() bufmodule.Module Config() *bufconfig.Config +} + +// ModuleConfigSet is a set of ModuleConfigs with a potentially associated Workspace. +type ModuleConfigSet interface { + ModuleConfigs() []ModuleConfig + // Optional. May be nil. Workspace() bufmodule.Workspace } // ModuleConfigReader is a ModuleConfig reader. type ModuleConfigReader interface { - // GetModuleConfigs gets the ModuleConfig for the fetch value. + // GetModuleConfigSet gets the ModuleConfigSet for the fetch value. // // If externalDirOrFilePaths is empty, this builds all files under Buf control. // - // Note that as opposed to ModuleReader, this will return a Module for either + // Note that as opposed to ModuleReader, this will return Modules for either // a source or module reference, not just a module reference. - GetModuleConfigs( + GetModuleConfigSet( ctx context.Context, container app.EnvStdinContainer, sourceOrModuleRef buffetch.SourceOrModuleRef, @@ -100,7 +104,7 @@ type ModuleConfigReader interface { externalDirOrFilePaths []string, externalExcludeDirOrFilePaths []string, externalDirOrFilePathsAllowNotExist bool, - ) ([]ModuleConfig, error) + ) (ModuleConfigSet, error) } // NewModuleConfigReader returns a new ModuleConfigReader @@ -140,7 +144,6 @@ func NewFileLister( storageosProvider storageos.Provider, fetchReader buffetch.Reader, moduleBucketBuilder bufmodulebuild.ModuleBucketBuilder, - moduleFileSetBuilder bufmodulebuild.ModuleFileSetBuilder, imageBuilder bufimagebuild.Builder, ) FileLister { return newFileLister( @@ -148,7 +151,6 @@ func NewFileLister( storageosProvider, fetchReader, moduleBucketBuilder, - moduleFileSetBuilder, imageBuilder, ) } diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufwire/file_lister.go b/vendor/github.com/bufbuild/buf/private/buf/bufwire/file_lister.go index 30c93deff..7e8cee376 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufwire/file_lister.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufwire/file_lister.go @@ -49,7 +49,6 @@ func newFileLister( storageosProvider storageos.Provider, fetchReader buffetch.Reader, moduleBucketBuilder bufmodulebuild.ModuleBucketBuilder, - moduleFileSetBuilder bufmodulebuild.ModuleFileSetBuilder, imageBuilder bufimagebuild.Builder, ) *fileLister { return &fileLister{ @@ -66,7 +65,6 @@ func newFileLister( storageosProvider, fetchReader, moduleBucketBuilder, - moduleFileSetBuilder, imageBuilder, ), } @@ -258,7 +256,7 @@ func (e *fileLister) sourceFileInfosForDirectory( if err != nil { return nil, err } - module, err := bufmodulebuild.BuildForBucket( + module, err := bufmodulebuild.NewModuleBucketBuilder().BuildForBucket( ctx, mappedReadBucket, config.Build, diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufwire/image_config_reader.go b/vendor/github.com/bufbuild/buf/private/buf/bufwire/image_config_reader.go index 4abed65fc..26e624812 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufwire/image_config_reader.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufwire/image_config_reader.go @@ -28,20 +28,17 @@ import ( "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild" "github.com/bufbuild/buf/private/pkg/app" "github.com/bufbuild/buf/private/pkg/storage/storageos" - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/codes" "go.uber.org/zap" ) type imageConfigReader struct { - logger *zap.Logger - storageosProvider storageos.Provider - fetchReader buffetch.Reader - moduleBucketBuilder bufmodulebuild.ModuleBucketBuilder - moduleFileSetBuilder bufmodulebuild.ModuleFileSetBuilder - imageBuilder bufimagebuild.Builder - moduleConfigReader *moduleConfigReader - imageReader *imageReader + logger *zap.Logger + storageosProvider storageos.Provider + fetchReader buffetch.Reader + moduleBucketBuilder bufmodulebuild.ModuleBucketBuilder + imageBuilder bufimagebuild.Builder + moduleConfigReader *moduleConfigReader + imageReader *imageReader } func newImageConfigReader( @@ -49,16 +46,14 @@ func newImageConfigReader( storageosProvider storageos.Provider, fetchReader buffetch.Reader, moduleBucketBuilder bufmodulebuild.ModuleBucketBuilder, - moduleFileSetBuilder bufmodulebuild.ModuleFileSetBuilder, imageBuilder bufimagebuild.Builder, ) *imageConfigReader { return &imageConfigReader{ - logger: logger.Named("bufwire"), - storageosProvider: storageosProvider, - fetchReader: fetchReader, - moduleBucketBuilder: moduleBucketBuilder, - moduleFileSetBuilder: moduleFileSetBuilder, - imageBuilder: imageBuilder, + logger: logger.Named("bufwire"), + storageosProvider: storageosProvider, + fetchReader: fetchReader, + moduleBucketBuilder: moduleBucketBuilder, + imageBuilder: imageBuilder, moduleConfigReader: newModuleConfigReader( logger, storageosProvider, @@ -132,7 +127,7 @@ func (i *imageConfigReader) getSourceOrModuleImageConfigs( externalDirOrFilePathsAllowNotExist bool, excludeSourceCodeInfo bool, ) ([]ImageConfig, []bufanalysis.FileAnnotation, error) { - moduleConfigs, err := i.moduleConfigReader.GetModuleConfigs( + moduleConfigSet, err := i.moduleConfigReader.GetModuleConfigSet( ctx, container, sourceOrModuleRef, @@ -144,31 +139,31 @@ func (i *imageConfigReader) getSourceOrModuleImageConfigs( if err != nil { return nil, nil, err } + moduleConfigs := moduleConfigSet.ModuleConfigs() imageConfigs := make([]ImageConfig, 0, len(moduleConfigs)) var allFileAnnotations []bufanalysis.FileAnnotation for _, moduleConfig := range moduleConfigs { - moduleFileSet, err := i.moduleFileSetBuilder.Build( - ctx, - moduleConfig.Module(), - bufmodulebuild.WithWorkspace(moduleConfig.Workspace()), - ) - if err != nil { - return nil, nil, err - } - targetFileInfos, err := moduleFileSet.TargetFileInfos(ctx) + targetFileInfos, err := moduleConfig.Module().TargetFileInfos(ctx) if err != nil { return nil, nil, err } if len(targetFileInfos) == 0 { - // This ModuleFileSet doesn't have any targets, so we shouldn't build + // This Module doesn't have any targets, so we shouldn't build // an image for it. continue } + buildOpts := []bufimagebuild.BuildOption{ + bufimagebuild.WithExpectedDirectDependencies(moduleConfig.Module().DeclaredDirectDependencies()), + bufimagebuild.WithWorkspace(moduleConfigSet.Workspace()), + } + if excludeSourceCodeInfo { + buildOpts = append(buildOpts, bufimagebuild.WithExcludeSourceCodeInfo()) + } imageConfig, fileAnnotations, err := i.buildModule( ctx, moduleConfig.Config(), - moduleFileSet, - excludeSourceCodeInfo, + moduleConfig.Module(), + buildOpts..., ) if err != nil { return nil, nil, err @@ -238,23 +233,15 @@ func (i *imageConfigReader) getImageImageConfig( func (i *imageConfigReader) buildModule( ctx context.Context, config *bufconfig.Config, - moduleFileSet bufmodule.ModuleFileSet, - excludeSourceCodeInfo bool, + module bufmodule.Module, + buildOpts ...bufimagebuild.BuildOption, ) (ImageConfig, []bufanalysis.FileAnnotation, error) { - ctx, span := otel.GetTracerProvider().Tracer("bufbuild/buf").Start(ctx, "build_module") - defer span.End() - var options []bufimagebuild.BuildOption - if excludeSourceCodeInfo { - options = append(options, bufimagebuild.WithExcludeSourceCodeInfo()) - } image, fileAnnotations, err := i.imageBuilder.Build( ctx, - moduleFileSet, - options..., + module, + buildOpts..., ) if err != nil { - span.RecordError(err) - span.SetStatus(codes.Error, err.Error()) return nil, nil, err } if len(fileAnnotations) > 0 { @@ -270,6 +257,15 @@ func (i *imageConfigReader) buildModule( // The image merge is needed because if the `include_package_files=true` option is set, we // need to gather all the files for the package, including files spread out across workspace // directories, which would result in multiple image configs. +// +// As a reminder, with ProtoFileRefs, we actually return an Image that contains all the files +// in the same package as the referenced file. filterImageConfigs deals with an edge case where +// files from the same package are split across multiple Images, i.e. in a workspace. Obviously, +// this is bad Protobuf design, but this is possible. +// +// TODO: Make a function such as bufimage.MergeImagesWithOnlyPaths([]bufimage.Image, options) that +// takes an option that includes files within the package. Even better, create functions such that +// you can do bufimage.ImageWithOnlyPackages, bufimage.ImageWithOnlyPaths, and then reuse bufimage.MergeImage? func filterImageConfigs(imageConfigs []ImageConfig, protoFileRef buffetch.ProtoFileRef) ([]ImageConfig, error) { var pkg string var path string @@ -290,10 +286,15 @@ func filterImageConfigs(imageConfigs []ImageConfig, protoFileRef buffetch.ProtoF } images = append(images, imageConfig.Image()) } + if path == "" { + return nil, errors.New("did not find a matching image file for the ProtoFileRef") + } image, err := bufimage.MergeImages(images...) if err != nil { return nil, err } + // If include_package_files is set, we then need to go get the rest of the files for the package, + // and see comment on Godoc. Otherwise, we just return an image that contains the given file. var paths []string if protoFileRef.IncludePackageFiles() { for _, imageFile := range image.Files() { diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config.go b/vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config.go index d9d59c63e..37cc35576 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config.go @@ -20,16 +20,14 @@ import ( ) type moduleConfig struct { - module bufmodule.Module - config *bufconfig.Config - workspace bufmodule.Workspace + module bufmodule.Module + config *bufconfig.Config } -func newModuleConfig(module bufmodule.Module, config *bufconfig.Config, workspace bufmodule.Workspace) *moduleConfig { +func newModuleConfig(module bufmodule.Module, config *bufconfig.Config) *moduleConfig { return &moduleConfig{ - module: module, - config: config, - workspace: workspace, + module: module, + config: config, } } @@ -40,7 +38,3 @@ func (m *moduleConfig) Module() bufmodule.Module { func (m *moduleConfig) Config() *bufconfig.Config { return m.config } - -func (m *moduleConfig) Workspace() bufmodule.Workspace { - return m.workspace -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config_reader.go b/vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config_reader.go index abfed54ae..014fbd80d 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config_reader.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config_reader.go @@ -61,7 +61,7 @@ func newModuleConfigReader( } } -func (m *moduleConfigReader) GetModuleConfigs( +func (m *moduleConfigReader) GetModuleConfigSet( ctx context.Context, container app.EnvStdinContainer, sourceOrModuleRef buffetch.SourceOrModuleRef, @@ -69,7 +69,7 @@ func (m *moduleConfigReader) GetModuleConfigs( externalDirOrFilePaths []string, externalExcludeDirOrFilePaths []string, externalDirOrFilePathsAllowNotExist bool, -) (_ []ModuleConfig, retErr error) { +) (_ ModuleConfigSet, retErr error) { ctx, span := m.tracer.Start(ctx, "get_module_config") defer span.End() defer func() { @@ -79,10 +79,10 @@ func (m *moduleConfigReader) GetModuleConfigs( } }() // We construct a new WorkspaceBuilder here so that the cache is only used for a single call. - workspaceBuilder := bufwork.NewWorkspaceBuilder(m.moduleBucketBuilder) + workspaceBuilder := bufwork.NewWorkspaceBuilder() switch t := sourceOrModuleRef.(type) { case buffetch.ProtoFileRef: - return m.getProtoFileModuleSourceConfigs( + return m.getProtoFileModuleSourceConfigSet( ctx, container, t, @@ -93,7 +93,7 @@ func (m *moduleConfigReader) GetModuleConfigs( externalDirOrFilePathsAllowNotExist, ) case buffetch.SourceRef: - return m.getSourceModuleConfigs( + return m.getSourceModuleConfigSet( ctx, container, t, @@ -116,15 +116,18 @@ func (m *moduleConfigReader) GetModuleConfigs( if err != nil { return nil, err } - return []ModuleConfig{ - moduleConfig, - }, nil + return newModuleConfigSet( + []ModuleConfig{ + moduleConfig, + }, + nil, + ), nil default: return nil, fmt.Errorf("invalid ref: %T", sourceOrModuleRef) } } -func (m *moduleConfigReader) getSourceModuleConfigs( +func (m *moduleConfigReader) getSourceModuleConfigSet( ctx context.Context, container app.EnvStdinContainer, sourceRef buffetch.SourceRef, @@ -133,7 +136,7 @@ func (m *moduleConfigReader) getSourceModuleConfigs( externalDirOrFilePaths []string, externalExcludeDirOrFilePaths []string, externalDirOrFilePathsAllowNotExist bool, -) (_ []ModuleConfig, retErr error) { +) (_ ModuleConfigSet, retErr error) { readBucketCloser, err := m.fetchReader.GetSourceBucket(ctx, container, sourceRef) if err != nil { return nil, err @@ -146,7 +149,7 @@ func (m *moduleConfigReader) getSourceModuleConfigs( return nil, err } if existingConfigFilePath != "" { - return m.getWorkspaceModuleConfigs( + return m.getWorkspaceModuleConfigSet( ctx, sourceRef, workspaceBuilder, @@ -176,9 +179,12 @@ func (m *moduleConfigReader) getSourceModuleConfigs( if err != nil { return nil, err } - return []ModuleConfig{ - moduleConfig, - }, nil + return newModuleConfigSet( + []ModuleConfig{ + moduleConfig, + }, + nil, + ), nil } func (m *moduleConfigReader) getModuleModuleConfig( @@ -240,10 +246,10 @@ func (m *moduleConfigReader) getModuleModuleConfig( if err != nil { return nil, err } - return newModuleConfig(module, config, nil /* Workspaces aren't supported for ModuleRefs */), nil + return newModuleConfig(module, config), nil } -func (m *moduleConfigReader) getProtoFileModuleSourceConfigs( +func (m *moduleConfigReader) getProtoFileModuleSourceConfigSet( ctx context.Context, container app.EnvStdinContainer, protoFileRef buffetch.ProtoFileRef, @@ -252,7 +258,7 @@ func (m *moduleConfigReader) getProtoFileModuleSourceConfigs( externalDirOrFilePaths []string, externalExcludeDirOrFilePaths []string, externalDirOrFilePathsAllowNotExist bool, -) (_ []ModuleConfig, retErr error) { +) (_ ModuleConfigSet, retErr error) { readBucketCloser, err := m.fetchReader.GetSourceBucket(ctx, container, protoFileRef) if err != nil { return nil, err @@ -296,7 +302,7 @@ func (m *moduleConfigReader) getProtoFileModuleSourceConfigs( } } } - return m.getWorkspaceModuleConfigs( + return m.getWorkspaceModuleConfigSet( ctx, protoFileRef, workspaceBuilder, @@ -326,12 +332,15 @@ func (m *moduleConfigReader) getProtoFileModuleSourceConfigs( if err != nil { return nil, err } - return []ModuleConfig{ - moduleConfig, - }, nil + return newModuleConfigSet( + []ModuleConfig{ + moduleConfig, + }, + nil, + ), nil } -func (m *moduleConfigReader) getWorkspaceModuleConfigs( +func (m *moduleConfigReader) getWorkspaceModuleConfigSet( ctx context.Context, sourceRef buffetch.SourceRef, workspaceBuilder bufwork.WorkspaceBuilder, @@ -342,28 +351,26 @@ func (m *moduleConfigReader) getWorkspaceModuleConfigs( externalDirOrFilePaths []string, externalExcludeDirOrFilePaths []string, externalDirOrFilePathsAllowNotExist bool, -) ([]ModuleConfig, error) { +) (ModuleConfigSet, error) { workspaceConfig, err := bufwork.GetConfigForBucket(ctx, readBucket, relativeRootPath) if err != nil { return nil, err } + workspace, err := workspaceBuilder.BuildWorkspace( + ctx, + workspaceConfig, + readBucket, + relativeRootPath, + subDirPath, // this is used to only apply the config override to this directory + configOverride, + externalDirOrFilePaths, + externalExcludeDirOrFilePaths, + externalDirOrFilePathsAllowNotExist, + ) + if err != nil { + return nil, err + } if subDirPath != "." { - // There's only a single ModuleConfig based on the subDirPath, - // so we only need to create a single workspace. - workspace, err := workspaceBuilder.BuildWorkspace( - ctx, - workspaceConfig, - readBucket, - relativeRootPath, - subDirPath, - configOverride, - externalDirOrFilePaths, - externalExcludeDirOrFilePaths, - externalDirOrFilePathsAllowNotExist, - ) - if err != nil { - return nil, err - } moduleConfig, err := m.getSourceModuleConfig( ctx, sourceRef, @@ -381,9 +388,12 @@ func (m *moduleConfigReader) getWorkspaceModuleConfigs( if err != nil { return nil, err } - return []ModuleConfig{ - moduleConfig, - }, nil + return newModuleConfigSet( + []ModuleConfig{ + moduleConfig, + }, + workspace, + ), nil } if configOverride != "" { return nil, errors.New("the --config flag is not compatible with workspaces") @@ -427,20 +437,6 @@ func (m *moduleConfigReader) getWorkspaceModuleConfigs( for excludeFileOrDirPath, subDirRelExcludePath := range externalExcludeToSubDirRelExcludePaths { externalExcludePathToRelPaths[excludeFileOrDirPath] = subDirRelExcludePath } - workspace, err := workspaceBuilder.BuildWorkspace( - ctx, - workspaceConfig, - readBucket, - relativeRootPath, - directory, - configOverride, - externalDirOrFilePaths, - externalExcludeDirOrFilePaths, - externalDirOrFilePathsAllowNotExist, - ) - if err != nil { - return nil, err - } moduleConfig, err := m.getSourceModuleConfig( ctx, sourceRef, @@ -473,7 +469,7 @@ func (m *moduleConfigReader) getWorkspaceModuleConfigs( } } } - return moduleConfigs, nil + return newModuleConfigSet(moduleConfigs, workspace), nil } func (m *moduleConfigReader) getSourceModuleConfig( @@ -489,51 +485,6 @@ func (m *moduleConfigReader) getSourceModuleConfig( externalDirOrFilePaths []string, externalExcludeDirOrFilePaths []string, externalDirOrFilePathsAllowNotExist bool, -) (ModuleConfig, error) { - moduleConfig, err := m.getModuleConfig( - ctx, - sourceRef, - readBucket, - relativeRootPath, - subDirPath, - configOverride, - workspaceBuilder, - workspaceConfig, - workspace, - externalDirOrFilePaths, - externalExcludeDirOrFilePaths, - externalDirOrFilePathsAllowNotExist, - ) - if err != nil { - return nil, err - } - if missingReferences := detectMissingDependencies( - moduleConfig.Config().Build.DependencyModuleReferences, - moduleConfig.Module().DependencyModulePins(), - ); len(missingReferences) > 0 { - var builder strings.Builder - _, _ = builder.WriteString(`Specified deps are not covered in your buf.lock, run "buf mod update":`) - for _, moduleReference := range missingReferences { - _, _ = builder.WriteString("\n\t- " + moduleReference.IdentityString()) - } - m.logger.Warn(builder.String()) - } - return moduleConfig, nil -} - -func (m *moduleConfigReader) getModuleConfig( - ctx context.Context, - sourceRef buffetch.SourceRef, - readBucket storage.ReadBucket, - relativeRootPath string, - subDirPath string, - configOverride string, - workspaceBuilder bufwork.WorkspaceBuilder, - workspaceConfig *bufwork.Config, - workspace bufmodule.Workspace, - externalDirOrFilePaths []string, - externalExcludeDirOrFilePaths []string, - externalDirOrFilePathsAllowNotExist bool, ) (ModuleConfig, error) { if module, moduleConfig, ok := workspaceBuilder.GetModuleConfig(subDirPath); ok { // The module was already built while we were constructing the workspace. @@ -550,7 +501,7 @@ func (m *moduleConfigReader) getModuleConfig( } } } - return newModuleConfig(module, moduleConfig, workspace), nil + return newModuleConfig(module, moduleConfig), nil } mappedReadBucket := readBucket if subDirPath != "." { @@ -667,7 +618,7 @@ func (m *moduleConfigReader) getModuleConfig( } buildOptions = append(buildOptions, bufmodulebuild.WithExcludePaths(bucketRelPaths)) } - module, err := bufmodulebuild.BuildForBucket( + module, err := bufmodulebuild.NewModuleBucketBuilder().BuildForBucket( ctx, mappedReadBucket, moduleConfig.Build, @@ -676,7 +627,19 @@ func (m *moduleConfigReader) getModuleConfig( if err != nil { return nil, err } - return newModuleConfig(module, moduleConfig, workspace), nil + if missingReferences := detectMissingDependencies( + moduleConfig.Build.DependencyModuleReferences, + module.DependencyModulePins(), + workspace, + ); len(missingReferences) > 0 { + var builder strings.Builder + _, _ = builder.WriteString(`Specified deps are not covered in your buf.lock, run "buf mod update":`) + for _, moduleReference := range missingReferences { + _, _ = builder.WriteString("\n\t- " + moduleReference.IdentityString()) + } + m.logger.Warn(builder.String()) + } + return newModuleConfig(module, moduleConfig), nil } func workspaceDirectoryEqualsOrContainsSubDirPath(workspaceConfig *bufwork.Config, subDirPath string) bool { @@ -691,7 +654,11 @@ func workspaceDirectoryEqualsOrContainsSubDirPath(workspaceConfig *bufwork.Confi return false } -func detectMissingDependencies(references []bufmoduleref.ModuleReference, pins []bufmoduleref.ModulePin) []bufmoduleref.ModuleReference { +func detectMissingDependencies( + references []bufmoduleref.ModuleReference, + pins []bufmoduleref.ModulePin, + workspace bufmodule.Workspace, +) []bufmoduleref.ModuleReference { pinSet := make(map[string]struct{}) for _, pin := range pins { pinSet[pin.IdentityString()] = struct{}{} @@ -700,7 +667,13 @@ func detectMissingDependencies(references []bufmoduleref.ModuleReference, pins [ var missingReferences []bufmoduleref.ModuleReference for _, reference := range references { if _, ok := pinSet[reference.IdentityString()]; !ok { - missingReferences = append(missingReferences, reference) + if workspace != nil { + if _, ok := workspace.GetModule(reference); !ok { + missingReferences = append(missingReferences, reference) + } + } else { + missingReferences = append(missingReferences, reference) + } } } return missingReferences diff --git a/vendor/github.com/bufbuild/buf/private/pkg/filelock/nop_locker.go b/vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config_set.go similarity index 54% rename from vendor/github.com/bufbuild/buf/private/pkg/filelock/nop_locker.go rename to vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config_set.go index 77adbb951..bc011348a 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/filelock/nop_locker.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufwire/module_config_set.go @@ -12,22 +12,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -package filelock +package bufwire import ( - "context" + "github.com/bufbuild/buf/private/bufpkg/bufmodule" ) -type nopLocker struct{} +type moduleConfigSet struct { + moduleConfigs []ModuleConfig + workspace bufmodule.Workspace +} -func newNopLocker() *nopLocker { - return &nopLocker{} +func newModuleConfigSet(moduleConfigs []ModuleConfig, workspace bufmodule.Workspace) *moduleConfigSet { + return &moduleConfigSet{ + moduleConfigs: moduleConfigs, + workspace: workspace, + } } -func (l *nopLocker) Lock(ctx context.Context, path string, options ...LockOption) (Unlocker, error) { - return newNopUnlocker(), nil +func (m *moduleConfigSet) ModuleConfigs() []ModuleConfig { + return m.moduleConfigs } -func (l *nopLocker) RLock(ctx context.Context, path string, options ...LockOption) (Unlocker, error) { - return newNopUnlocker(), nil +func (m *moduleConfigSet) Workspace() bufmodule.Workspace { + return m.workspace } diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufwire/proto_encoding_writer.go b/vendor/github.com/bufbuild/buf/private/buf/bufwire/proto_encoding_writer.go index 6e0ef7624..ca9d44cbe 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufwire/proto_encoding_writer.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufwire/proto_encoding_writer.go @@ -64,7 +64,7 @@ func (p *protoEncodingWriter) PutMessage( case bufconvert.MessageEncodingBin: marshaler = protoencoding.NewWireMarshaler() case bufconvert.MessageEncodingJSON: - marshaler = protoencoding.NewJSONMarshalerIndent(resolver) + marshaler = protoencoding.NewJSONMarshaler(resolver) default: return errors.New("unknown message encoding type") } diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufwork/bufwork.go b/vendor/github.com/bufbuild/buf/private/buf/bufwork/bufwork.go index cf45bad80..2ee498aed 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufwork/bufwork.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufwork/bufwork.go @@ -98,7 +98,15 @@ var ( // WorkspaceBuilder builds workspaces. A single WorkspaceBuilder should NOT be persisted // acorss calls because the WorkspaceBuilder caches the modules used in each workspace. type WorkspaceBuilder interface { - // BuildWorkspace builds a bufmodule.Workspace for the given targetSubDirPath. + // BuildWorkspace builds a bufmodule.Workspace. + // + // The given targetSubDirPath is the only path that will have the configOverride applied to it. + // TODO: delete targetSubDirPath entirely. We are building a Workspace, we don't necessarily + // have a specific target directory within it. This would mean doing the config override at + // a higher level for any specific modules within the Workspace. The only thing in the config + // we care about is the build.excludes, so in theory we should be able to figure out a way + // to say "exclude these files from these modules when you are building". Even better, the + // WorkspaceBuilder has nothing to do with building modules. BuildWorkspace( ctx context.Context, workspaceConfig *Config, @@ -117,10 +125,8 @@ type WorkspaceBuilder interface { } // NewWorkspaceBuilder returns a new WorkspaceBuilder. -func NewWorkspaceBuilder( - moduleBucketBuilder bufmodulebuild.ModuleBucketBuilder, -) WorkspaceBuilder { - return newWorkspaceBuilder(moduleBucketBuilder) +func NewWorkspaceBuilder() WorkspaceBuilder { + return newWorkspaceBuilder() } // BuildOptionsForWorkspaceDirectory returns the bufmodulebuild.BuildOptions required for diff --git a/vendor/github.com/bufbuild/buf/private/buf/bufwork/workspace_builder.go b/vendor/github.com/bufbuild/buf/private/buf/bufwork/workspace_builder.go index 7bbdb582e..2b0fcdf66 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/bufwork/workspace_builder.go +++ b/vendor/github.com/bufbuild/buf/private/buf/bufwork/workspace_builder.go @@ -28,16 +28,12 @@ import ( ) type workspaceBuilder struct { - moduleBucketBuilder bufmodulebuild.ModuleBucketBuilder - moduleCache map[string]*cachedModule + moduleCache map[string]*cachedModule } -func newWorkspaceBuilder( - moduleBucketBuilder bufmodulebuild.ModuleBucketBuilder, -) *workspaceBuilder { +func newWorkspaceBuilder() *workspaceBuilder { return &workspaceBuilder{ - moduleBucketBuilder: moduleBucketBuilder, - moduleCache: make(map[string]*cachedModule), + moduleCache: make(map[string]*cachedModule), } } @@ -64,9 +60,6 @@ func (w *workspaceBuilder) BuildWorkspace( allModules := make([]bufmodule.Module, 0, len(workspaceConfig.Directories)) for _, directory := range workspaceConfig.Directories { if cachedModule, ok := w.moduleCache[directory]; ok { - if directory == targetSubDirPath { - continue - } // We've already built this module, so we can use the cached-equivalent. if moduleIdentity := cachedModule.moduleConfig.ModuleIdentity; moduleIdentity != nil { if _, ok := namedModules[moduleIdentity.IdentityString()]; ok { @@ -143,7 +136,7 @@ func (w *workspaceBuilder) BuildWorkspace( if err != nil { return nil, err } - module, err := bufmodulebuild.BuildForBucket( + module, err := bufmodulebuild.NewModuleBucketBuilder().BuildForBucket( ctx, readBucketForDirectory, moduleConfig.Build, @@ -161,12 +154,6 @@ func (w *workspaceBuilder) BuildWorkspace( module, moduleConfig, ) - if directory == targetSubDirPath { - // We don't want to include the module found at the targetSubDirPath - // since it would otherwise be included twice. Note that we include - // this check here so that the module is still built and cached upfront. - continue - } if moduleIdentity := moduleConfig.ModuleIdentity; moduleIdentity != nil { if _, ok := namedModules[moduleIdentity.IdentityString()]; ok { return nil, fmt.Errorf( @@ -180,9 +167,10 @@ func (w *workspaceBuilder) BuildWorkspace( allModules = append(allModules, module) } return bufmodule.NewWorkspace( + ctx, namedModules, allModules, - ), nil + ) } // GetModuleConfig returns the bufmodule.Module and *bufconfig.Config, associated with the given @@ -223,6 +211,18 @@ func validateWorkspaceDirectoryNonEmpty( // overlap in either direction. The last argument is only used for // error reporting. // +// This verifies that ie we do not mistakenly target a directory input that is +// within a Workspace, but is not listed as a directory in the Workspace, which +// could cause issues. If we say "we have a workspace with directory proto, but +// we are targeting proto/a", then we will still detect the buf.work.yaml and +// bring in all the directories within it, making them available for import, +// but potentially in two ways. If there was proto/a/a.proto, we could theoretically +// import it as both a/a.proto, and a.proto. +// +// TODO: See if the above explanation is nonsense. It should be nonsense if we +// did our job right here. And regardless, this shouldn't need to be validated +// at this level. +// // validateInputOverlap("foo", "bar", "buf.work.yaml") -> OK // validateInputOverlap("foo/bar", "foo", "buf.work.yaml") -> NOT OK // validateInputOverlap("foo", "foo/bar", "buf.work.yaml") -> NOT OK @@ -231,6 +231,15 @@ func validateInputOverlap( targetSubDirPath string, workspaceID string, ) error { + // If we are targeting the whole workspace and not a specific directory, + // we do not do this check. + // + // TODO: targetSubDirPath needs to be completely removed from WorkspaceBuilder + // and validateInputOverlap needs to be done somewhere else at a higher level, + // as the "target" is just a CLI argument concept, not a pure Workspace concept. + if targetSubDirPath == "." { + return nil + } if normalpath.ContainsPath(workspaceDirectory, targetSubDirPath, normalpath.Relative) { return fmt.Errorf( `failed to build input "%s" because it is contained by directory "%s" listed in %s`, diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/buf.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/buf.go index 88f7c5919..7a8de4f82 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/buf.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/buf.go @@ -19,13 +19,17 @@ import ( "time" "github.com/bufbuild/buf/private/buf/bufcli" - curatedplugindelete "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/plugindelete" - "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/pluginpush" + "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/goversion" + "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/mavenversion" + "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/npmversion" + "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/swiftversion" "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/protoc" "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokendelete" "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokenget" "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokenlist" + "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/repo/reposync" "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/workspace/workspacepush" + "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/graph" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/migratev1beta1" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/price" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/commit/commitget" @@ -35,10 +39,8 @@ import ( "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/organization/organizationcreate" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/organization/organizationdelete" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/organization/organizationget" - "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugincreate" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugindelete" - "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginlist" - "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginversion/pluginversionlist" + "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/repository/repositorycreate" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/repository/repositorydelete" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/repository/repositorydeprecate" @@ -48,11 +50,6 @@ import ( "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/repository/repositoryupdate" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/tag/tagcreate" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/tag/taglist" - "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatecreate" - "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatedelete" - "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatelist" - "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversioncreate" - "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversionlist" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/webhook/webhookcreate" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/webhook/webhookdelete" "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/webhook/webhooklist" @@ -95,10 +92,6 @@ func NewRootCommand(name string) *appcmd.Command { appflag.BuilderWithTimeout(120*time.Second), appflag.BuilderWithTracing(), ) - noTimeoutBuilder := appflag.NewBuilder( - name, - appflag.BuilderWithTracing(), - ) globalFlags := bufcli.NewGlobalFlags() return &appcmd.Command{ Use: name, @@ -142,10 +135,11 @@ func NewRootCommand(name string) *appcmd.Command { Use: "beta", Short: "Beta commands. Unstable and likely to change", SubCommands: []*appcmd.Command{ + graph.NewCommand("graph", builder), price.NewCommand("price", builder), stats.NewCommand("stats", builder), migratev1beta1.NewCommand("migrate-v1beta1", builder), - studioagent.NewCommand("studio-agent", noTimeoutBuilder), + studioagent.NewCommand("studio-agent", builder), { Use: "registry", Short: "Manage assets on the Buf Schema Registry", @@ -196,39 +190,6 @@ func NewRootCommand(name string) *appcmd.Command { draftlist.NewCommand("list", builder), }, }, - { - Use: "plugin", - Short: "Manage Protobuf plugins", - SubCommands: []*appcmd.Command{ - plugincreate.NewCommand("create", builder), - pluginlist.NewCommand("list", builder), - plugindelete.NewCommand("delete", builder), - { - Use: "version", - Short: "Manage Protobuf plugin versions", - SubCommands: []*appcmd.Command{ - pluginversionlist.NewCommand("list", builder), - }, - }, - }, - }, - { - Use: "template", - Short: "Manage Protobuf templates on the Buf Schema Registry", - SubCommands: []*appcmd.Command{ - templatecreate.NewCommand("create", builder), - templatelist.NewCommand("list", builder), - templatedelete.NewCommand("delete", builder), - { - Use: "version", - Short: "Manage Protobuf template versions", - SubCommands: []*appcmd.Command{ - templateversioncreate.NewCommand("create", builder), - templateversionlist.NewCommand("list", builder), - }, - }, - }, - }, { Use: "webhook", Short: "Manage webhooks for a repository on the Buf Schema Registry", @@ -238,6 +199,14 @@ func NewRootCommand(name string) *appcmd.Command { webhooklist.NewCommand("list", builder), }, }, + { + Use: "plugin", + Short: "Manage plugins on the Buf Schema Registry", + SubCommands: []*appcmd.Command{ + pluginpush.NewCommand("push", builder), + plugindelete.NewCommand("delete", builder), + }, + }, }, }, }, @@ -264,11 +233,20 @@ func NewRootCommand(name string) *appcmd.Command { }, }, { - Use: "plugin", - Short: "Manage plugins on the Buf Schema Registry", + Use: "package", + Short: "Manage remote packages", + SubCommands: []*appcmd.Command{ + goversion.NewCommand("go-version", builder), + mavenversion.NewCommand("maven-version", builder), + npmversion.NewCommand("npm-version", builder), + swiftversion.NewCommand("swift-version", builder), + }, + }, + { + Use: "repo", + Short: "Manage Git repositories", SubCommands: []*appcmd.Command{ - pluginpush.NewCommand("push", builder), - curatedplugindelete.NewCommand("delete", builder), + reposync.NewCommand("sync", builder), }, }, { diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/goversion/goversion.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/goversion/goversion.go new file mode 100644 index 000000000..2d45bdb12 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/goversion/goversion.go @@ -0,0 +1,124 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 goversion + +import ( + "context" + "fmt" + + "github.com/bufbuild/buf/private/buf/bufcli" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref" + "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" + registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" + "github.com/bufbuild/buf/private/pkg/app/appcmd" + "github.com/bufbuild/buf/private/pkg/app/appflag" + "github.com/bufbuild/buf/private/pkg/connectclient" + "github.com/bufbuild/connect-go" + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +const ( + pluginFlagName = "plugin" + moduleFlagName = "module" + registryName = "go" +) + +// NewCommand returns a new Command +func NewCommand( + name string, + builder appflag.Builder, +) *appcmd.Command { + flags := newFlags() + return &appcmd.Command{ + Use: name + " --module= --plugin=", + Short: bufcli.PackageVersionShortDescription(registryName), + Long: bufcli.PackageVersionLongDescription(registryName, name, "buf.build/bufbuild/connect-go"), + Args: cobra.NoArgs, + Run: builder.NewRunFunc( + func(ctx context.Context, container appflag.Container) error { + return run(ctx, container, flags) + }, + bufcli.NewErrorInterceptor(), + ), + BindFlags: flags.Bind, + } +} + +type flags struct { + Plugin string + Module string +} + +func newFlags() *flags { + return &flags{} +} + +func (f *flags) Bind(flagSet *pflag.FlagSet) { + flagSet.StringVar(&f.Module, moduleFlagName, "", "The module reference to resolve") + flagSet.StringVar(&f.Plugin, pluginFlagName, "", fmt.Sprintf("The %s plugin reference to resolve", registryName)) + _ = cobra.MarkFlagRequired(flagSet, moduleFlagName) + _ = cobra.MarkFlagRequired(flagSet, pluginFlagName) +} + +func run( + ctx context.Context, + container appflag.Container, + flags *flags, +) error { + bufcli.WarnAlphaCommand(ctx, container) + clientConfig, err := bufcli.NewConnectClientConfig(container) + if err != nil { + return err + } + moduleReference, err := bufmoduleref.ModuleReferenceForString(flags.Module) + if err != nil { + return appcmd.NewInvalidArgumentErrorf("failed parsing module reference: %s", err.Error()) + } + pluginIdentity, pluginVersion, err := bufpluginref.ParsePluginIdentityOptionalVersion(flags.Plugin) + if err != nil { + return appcmd.NewInvalidArgumentErrorf("failed parsing plugin reference: %s", err.Error()) + } + if pluginIdentity.Remote() != moduleReference.Remote() { + return appcmd.NewInvalidArgumentError("module and plugin must be from the same remote") + } + resolver := connectclient.Make( + clientConfig, + moduleReference.Remote(), + registryv1alpha1connect.NewResolveServiceClient, + ) + packageVersion, err := resolver.GetGoVersion(ctx, connect.NewRequest( + ®istryv1alpha1.GetGoVersionRequest{ + ModuleReference: ®istryv1alpha1.LocalModuleReference{ + Owner: moduleReference.Owner(), + Repository: moduleReference.Repository(), + Reference: moduleReference.Reference(), + }, + PluginReference: ®istryv1alpha1.GetRemotePackageVersionPlugin{ + Owner: pluginIdentity.Owner(), + Name: pluginIdentity.Plugin(), + Version: pluginVersion, + }, + }, + )) + if err != nil { + return err + } + if _, err := container.Stdout().Write([]byte(packageVersion.Msg.Version)); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginlist/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/goversion/usage.gen.go similarity index 97% rename from vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginlist/usage.gen.go rename to vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/goversion/usage.gen.go index 9023eb0d7..52fe11c25 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginlist/usage.gen.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/goversion/usage.gen.go @@ -14,6 +14,6 @@ // Generated. DO NOT EDIT. -package pluginlist +package goversion import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/mavenversion/mavenversion.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/mavenversion/mavenversion.go new file mode 100644 index 000000000..60ef30085 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/mavenversion/mavenversion.go @@ -0,0 +1,124 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 mavenversion + +import ( + "context" + "fmt" + + "github.com/bufbuild/buf/private/buf/bufcli" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref" + "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" + registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" + "github.com/bufbuild/buf/private/pkg/app/appcmd" + "github.com/bufbuild/buf/private/pkg/app/appflag" + "github.com/bufbuild/buf/private/pkg/connectclient" + "github.com/bufbuild/connect-go" + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +const ( + pluginFlagName = "plugin" + moduleFlagName = "module" + registryName = "maven" +) + +// NewCommand returns a new Command +func NewCommand( + name string, + builder appflag.Builder, +) *appcmd.Command { + flags := newFlags() + return &appcmd.Command{ + Use: name + " --module= --plugin=", + Short: bufcli.PackageVersionShortDescription(registryName), + Long: bufcli.PackageVersionLongDescription(registryName, name, "buf.build/bufbuild/connect-kotlin"), + Args: cobra.NoArgs, + Run: builder.NewRunFunc( + func(ctx context.Context, container appflag.Container) error { + return run(ctx, container, flags) + }, + bufcli.NewErrorInterceptor(), + ), + BindFlags: flags.Bind, + } +} + +type flags struct { + Plugin string + Module string +} + +func newFlags() *flags { + return &flags{} +} + +func (f *flags) Bind(flagSet *pflag.FlagSet) { + flagSet.StringVar(&f.Module, moduleFlagName, "", "The module reference to resolve") + flagSet.StringVar(&f.Plugin, pluginFlagName, "", fmt.Sprintf("The %s plugin reference to resolve", registryName)) + _ = cobra.MarkFlagRequired(flagSet, moduleFlagName) + _ = cobra.MarkFlagRequired(flagSet, pluginFlagName) +} + +func run( + ctx context.Context, + container appflag.Container, + flags *flags, +) error { + bufcli.WarnAlphaCommand(ctx, container) + clientConfig, err := bufcli.NewConnectClientConfig(container) + if err != nil { + return err + } + moduleReference, err := bufmoduleref.ModuleReferenceForString(flags.Module) + if err != nil { + return appcmd.NewInvalidArgumentErrorf("failed parsing module reference: %s", err.Error()) + } + pluginIdentity, pluginVersion, err := bufpluginref.ParsePluginIdentityOptionalVersion(flags.Plugin) + if err != nil { + return appcmd.NewInvalidArgumentErrorf("failed parsing plugin reference: %s", err.Error()) + } + if pluginIdentity.Remote() != moduleReference.Remote() { + return appcmd.NewInvalidArgumentError("module and plugin must be from the same remote") + } + resolver := connectclient.Make( + clientConfig, + moduleReference.Remote(), + registryv1alpha1connect.NewResolveServiceClient, + ) + packageVersion, err := resolver.GetMavenVersion(ctx, connect.NewRequest( + ®istryv1alpha1.GetMavenVersionRequest{ + ModuleReference: ®istryv1alpha1.LocalModuleReference{ + Owner: moduleReference.Owner(), + Repository: moduleReference.Repository(), + Reference: moduleReference.Reference(), + }, + PluginReference: ®istryv1alpha1.GetRemotePackageVersionPlugin{ + Owner: pluginIdentity.Owner(), + Name: pluginIdentity.Plugin(), + Version: pluginVersion, + }, + }, + )) + if err != nil { + return err + } + if _, err := container.Stdout().Write([]byte(packageVersion.Msg.Version)); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/plugindelete/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/mavenversion/usage.gen.go similarity index 97% rename from vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/plugindelete/usage.gen.go rename to vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/mavenversion/usage.gen.go index 6643dd458..53bec3681 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/plugindelete/usage.gen.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/mavenversion/usage.gen.go @@ -14,6 +14,6 @@ // Generated. DO NOT EDIT. -package plugindelete +package mavenversion import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/npmversion/npmversion.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/npmversion/npmversion.go new file mode 100644 index 000000000..0a8b4b1a2 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/npmversion/npmversion.go @@ -0,0 +1,124 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 npmversion + +import ( + "context" + "fmt" + + "github.com/bufbuild/buf/private/buf/bufcli" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref" + "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" + registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" + "github.com/bufbuild/buf/private/pkg/app/appcmd" + "github.com/bufbuild/buf/private/pkg/app/appflag" + "github.com/bufbuild/buf/private/pkg/connectclient" + "github.com/bufbuild/connect-go" + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +const ( + pluginFlagName = "plugin" + moduleFlagName = "module" + registryName = "npm" +) + +// NewCommand returns a new Command +func NewCommand( + name string, + builder appflag.Builder, +) *appcmd.Command { + flags := newFlags() + return &appcmd.Command{ + Use: name + " --module= --plugin=", + Short: bufcli.PackageVersionShortDescription(registryName), + Long: bufcli.PackageVersionLongDescription(registryName, name, "buf.build/bufbuild/connect-es"), + Args: cobra.NoArgs, + Run: builder.NewRunFunc( + func(ctx context.Context, container appflag.Container) error { + return run(ctx, container, flags) + }, + bufcli.NewErrorInterceptor(), + ), + BindFlags: flags.Bind, + } +} + +type flags struct { + Plugin string + Module string +} + +func newFlags() *flags { + return &flags{} +} + +func (f *flags) Bind(flagSet *pflag.FlagSet) { + flagSet.StringVar(&f.Module, moduleFlagName, "", "The module reference to resolve") + flagSet.StringVar(&f.Plugin, pluginFlagName, "", fmt.Sprintf("The %s plugin reference to resolve", registryName)) + _ = cobra.MarkFlagRequired(flagSet, moduleFlagName) + _ = cobra.MarkFlagRequired(flagSet, pluginFlagName) +} + +func run( + ctx context.Context, + container appflag.Container, + flags *flags, +) error { + bufcli.WarnAlphaCommand(ctx, container) + clientConfig, err := bufcli.NewConnectClientConfig(container) + if err != nil { + return err + } + moduleReference, err := bufmoduleref.ModuleReferenceForString(flags.Module) + if err != nil { + return appcmd.NewInvalidArgumentErrorf("failed parsing module reference: %s", err.Error()) + } + pluginIdentity, pluginVersion, err := bufpluginref.ParsePluginIdentityOptionalVersion(flags.Plugin) + if err != nil { + return appcmd.NewInvalidArgumentErrorf("failed parsing plugin reference: %s", err.Error()) + } + if pluginIdentity.Remote() != moduleReference.Remote() { + return appcmd.NewInvalidArgumentError("module and plugin must be from the same remote") + } + resolver := connectclient.Make( + clientConfig, + moduleReference.Remote(), + registryv1alpha1connect.NewResolveServiceClient, + ) + packageVersion, err := resolver.GetNPMVersion(ctx, connect.NewRequest( + ®istryv1alpha1.GetNPMVersionRequest{ + ModuleReference: ®istryv1alpha1.LocalModuleReference{ + Owner: moduleReference.Owner(), + Repository: moduleReference.Repository(), + Reference: moduleReference.Reference(), + }, + PluginReference: ®istryv1alpha1.GetRemotePackageVersionPlugin{ + Owner: pluginIdentity.Owner(), + Name: pluginIdentity.Plugin(), + Version: pluginVersion, + }, + }, + )) + if err != nil { + return err + } + if _, err := container.Stdout().Write([]byte(packageVersion.Msg.Version)); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugincreate/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/npmversion/usage.gen.go similarity index 97% rename from vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugincreate/usage.gen.go rename to vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/npmversion/usage.gen.go index 55e1845ac..f7a8a71b2 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugincreate/usage.gen.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/npmversion/usage.gen.go @@ -14,6 +14,6 @@ // Generated. DO NOT EDIT. -package plugincreate +package npmversion import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/swiftversion/swiftversion.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/swiftversion/swiftversion.go new file mode 100644 index 000000000..dedbfada0 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/swiftversion/swiftversion.go @@ -0,0 +1,124 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 swiftversion + +import ( + "context" + "fmt" + + "github.com/bufbuild/buf/private/buf/bufcli" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref" + "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" + registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" + "github.com/bufbuild/buf/private/pkg/app/appcmd" + "github.com/bufbuild/buf/private/pkg/app/appflag" + "github.com/bufbuild/buf/private/pkg/connectclient" + "github.com/bufbuild/connect-go" + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +const ( + pluginFlagName = "plugin" + moduleFlagName = "module" + registryName = "swift" +) + +// NewCommand returns a new Command +func NewCommand( + name string, + builder appflag.Builder, +) *appcmd.Command { + flags := newFlags() + return &appcmd.Command{ + Use: name + " --module= --plugin=", + Short: bufcli.PackageVersionShortDescription(registryName), + Long: bufcli.PackageVersionLongDescription(registryName, name, "buf.build/bufbuild/connect-swift"), + Args: cobra.NoArgs, + Run: builder.NewRunFunc( + func(ctx context.Context, container appflag.Container) error { + return run(ctx, container, flags) + }, + bufcli.NewErrorInterceptor(), + ), + BindFlags: flags.Bind, + } +} + +type flags struct { + Plugin string + Module string +} + +func newFlags() *flags { + return &flags{} +} + +func (f *flags) Bind(flagSet *pflag.FlagSet) { + flagSet.StringVar(&f.Module, moduleFlagName, "", "The module reference to resolve") + flagSet.StringVar(&f.Plugin, pluginFlagName, "", fmt.Sprintf("The %s plugin reference to resolve", registryName)) + _ = cobra.MarkFlagRequired(flagSet, moduleFlagName) + _ = cobra.MarkFlagRequired(flagSet, pluginFlagName) +} + +func run( + ctx context.Context, + container appflag.Container, + flags *flags, +) error { + bufcli.WarnAlphaCommand(ctx, container) + clientConfig, err := bufcli.NewConnectClientConfig(container) + if err != nil { + return err + } + moduleReference, err := bufmoduleref.ModuleReferenceForString(flags.Module) + if err != nil { + return appcmd.NewInvalidArgumentErrorf("failed parsing module reference: %s", err.Error()) + } + pluginIdentity, pluginVersion, err := bufpluginref.ParsePluginIdentityOptionalVersion(flags.Plugin) + if err != nil { + return appcmd.NewInvalidArgumentErrorf("failed parsing plugin reference: %s", err.Error()) + } + if pluginIdentity.Remote() != moduleReference.Remote() { + return appcmd.NewInvalidArgumentError("module and plugin must be from the same remote") + } + resolver := connectclient.Make( + clientConfig, + moduleReference.Remote(), + registryv1alpha1connect.NewResolveServiceClient, + ) + packageVersion, err := resolver.GetSwiftVersion(ctx, connect.NewRequest( + ®istryv1alpha1.GetSwiftVersionRequest{ + ModuleReference: ®istryv1alpha1.LocalModuleReference{ + Owner: moduleReference.Owner(), + Repository: moduleReference.Repository(), + Reference: moduleReference.Reference(), + }, + PluginReference: ®istryv1alpha1.GetRemotePackageVersionPlugin{ + Owner: pluginIdentity.Owner(), + Name: pluginIdentity.Plugin(), + Version: pluginVersion, + }, + }, + )) + if err != nil { + return err + } + if _, err := container.Stdout().Write([]byte(packageVersion.Msg.Version)); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatelist/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/swiftversion/usage.gen.go similarity index 97% rename from vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatelist/usage.gen.go rename to vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/swiftversion/usage.gen.go index 373c8291d..0a10db60e 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatelist/usage.gen.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/swiftversion/usage.gen.go @@ -14,6 +14,6 @@ // Generated. DO NOT EDIT. -package templatelist +package swiftversion import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/plugindelete/plugindelete.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/plugindelete/plugindelete.go deleted file mode 100644 index 8b5d9672b..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/plugindelete/plugindelete.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 plugindelete - -import ( - "context" - "fmt" - "strings" - - "github.com/bufbuild/buf/private/buf/bufcli" - "github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref" - "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" - "github.com/bufbuild/buf/private/pkg/app/appcmd" - "github.com/bufbuild/buf/private/pkg/app/appflag" - "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/connect-go" - "github.com/spf13/cobra" - "github.com/spf13/pflag" -) - -// NewCommand returns a new Command. -func NewCommand( - name string, - builder appflag.Builder, -) *appcmd.Command { - flags := newFlags() - return &appcmd.Command{ - Use: name + " ", - Short: "Delete a plugin from the registry", - Args: cobra.ExactArgs(1), - Run: builder.NewRunFunc( - func(ctx context.Context, container appflag.Container) error { - return run(ctx, container, flags) - }, - bufcli.NewErrorInterceptor(), - ), - BindFlags: flags.Bind, - } -} - -type flags struct{} - -func newFlags() *flags { - return &flags{} -} - -func (f *flags) Bind(flagSet *pflag.FlagSet) {} - -func run( - ctx context.Context, - container appflag.Container, - flags *flags, -) error { - bufcli.WarnAlphaCommand(ctx, container) - identity, version, _ := strings.Cut(container.Arg(0), ":") - pluginIdentity, err := bufpluginref.PluginIdentityForString(identity) - if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - if version != "" { - if err := bufpluginref.ValidatePluginVersion(version); err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - } - clientConfig, err := bufcli.NewConnectClientConfig(container) - if err != nil { - return err - } - service := connectclient.Make( - clientConfig, - pluginIdentity.Remote(), - registryv1alpha1connect.NewPluginCurationServiceClient, - ) - if _, err := service.DeleteCuratedPlugin( - ctx, - connect.NewRequest(®istryv1alpha1.DeleteCuratedPluginRequest{ - Owner: pluginIdentity.Owner(), - Name: pluginIdentity.Plugin(), - Version: version, - }), - ); err != nil { - if connect.CodeOf(err) == connect.CodeNotFound { - return fmt.Errorf("the plugin %s does not exist", container.Arg(0)) - } - return err - } - return nil -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/protoc/protoc.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/protoc/protoc.go index 85ca0c99e..8c668dbea 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/protoc/protoc.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/protoc/protoc.go @@ -127,24 +127,14 @@ func run( if err != nil { return err } - moduleFileSet, err := bufmodulebuild.NewModuleFileSetBuilder( - zap.NewNop(), - moduleReader, - ).Build( - ctx, - module, - ) - if err != nil { - return err - } var buildOptions []bufimagebuild.BuildOption // we always need source code info if we are doing generation if len(env.PluginNameToPluginInfo) == 0 && !env.IncludeSourceInfo { buildOptions = append(buildOptions, bufimagebuild.WithExcludeSourceCodeInfo()) } - image, fileAnnotations, err := bufimagebuild.NewBuilder(container.Logger()).Build( + image, fileAnnotations, err := bufimagebuild.NewBuilder(container.Logger(), moduleReader).Build( ctx, - moduleFileSet, + module, buildOptions..., ) if err != nil { diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/repo/reposync/reposync.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/repo/reposync/reposync.go new file mode 100644 index 000000000..e18d29558 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/repo/reposync/reposync.go @@ -0,0 +1,448 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 reposync + +import ( + "context" + "errors" + "fmt" + "strings" + + "github.com/bufbuild/buf/private/buf/bufcli" + "github.com/bufbuild/buf/private/buf/bufsync" + "github.com/bufbuild/buf/private/bufpkg/bufanalysis" + "github.com/bufbuild/buf/private/bufpkg/bufmanifest" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" + registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" + "github.com/bufbuild/buf/private/pkg/app/appcmd" + "github.com/bufbuild/buf/private/pkg/app/appflag" + "github.com/bufbuild/buf/private/pkg/command" + "github.com/bufbuild/buf/private/pkg/connectclient" + "github.com/bufbuild/buf/private/pkg/git" + "github.com/bufbuild/buf/private/pkg/manifest" + "github.com/bufbuild/buf/private/pkg/normalpath" + "github.com/bufbuild/buf/private/pkg/storage" + "github.com/bufbuild/buf/private/pkg/storage/storagegit" + "github.com/bufbuild/buf/private/pkg/stringutil" + "github.com/bufbuild/connect-go" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + "go.uber.org/zap" + "google.golang.org/protobuf/types/known/timestamppb" +) + +const ( + errorFormatFlagName = "error-format" + moduleFlagName = "module" + createFlagName = "create" + createVisibilityFlagName = "create-visibility" +) + +// NewCommand returns a new Command. +func NewCommand( + name string, + builder appflag.Builder, +) *appcmd.Command { + flags := newFlags() + return &appcmd.Command{ + Use: name, + Short: "Sync a Git repository to a registry", + Long: "Sync a Git repository's commits to a registry in topological order. " + + "Only commits belonging to the 'origin' remote are processed, which means that " + + "commits must be pushed to a remote. " + + "Only modules specified via '--module' are synced.", + Args: cobra.NoArgs, + Run: builder.NewRunFunc( + func(ctx context.Context, container appflag.Container) error { + return run(ctx, container, flags) + }, + bufcli.NewErrorInterceptor(), + ), + BindFlags: flags.Bind, + } +} + +type flags struct { + ErrorFormat string + Modules []string + Create bool + CreateVisibility string +} + +func newFlags() *flags { + return &flags{} +} + +func (f *flags) Bind(flagSet *pflag.FlagSet) { + flagSet.StringVar( + &f.ErrorFormat, + errorFormatFlagName, + "text", + fmt.Sprintf( + "The format for build errors printed to stderr. Must be one of %s", + stringutil.SliceToString(bufanalysis.AllFormatStrings), + ), + ) + // TODO: before we take this to beta, and as part of mult-module support, re-evaluate the UX of this flag + flagSet.StringArrayVar( + &f.Modules, + moduleFlagName, + nil, + "The module(s) to sync to the BSR; this must be in the format :", + ) + bufcli.BindCreateVisibility(flagSet, &f.CreateVisibility, createVisibilityFlagName, createFlagName) + flagSet.BoolVar( + &f.Create, + createFlagName, + false, + fmt.Sprintf("Create the repository if it does not exist. Must set a visibility using --%s", createVisibilityFlagName), + ) +} + +func run( + ctx context.Context, + container appflag.Container, + flags *flags, +) (retErr error) { + if err := bufcli.ValidateErrorFormatFlag(flags.ErrorFormat, errorFormatFlagName); err != nil { + return err + } + if flags.CreateVisibility != "" { + if !flags.Create { + return appcmd.NewInvalidArgumentErrorf("Cannot set --%s without --%s.", createVisibilityFlagName, createFlagName) + } + // We re-parse below as needed, but do not return an appcmd.NewInvalidArgumentError below as + // we expect validation to be handled here. + if _, err := bufcli.VisibilityFlagToVisibility(flags.CreateVisibility); err != nil { + return appcmd.NewInvalidArgumentError(err.Error()) + } + } else if flags.Create { + return appcmd.NewInvalidArgumentErrorf("--%s is required if --%s is set.", createVisibilityFlagName, createFlagName) + } + return sync( + ctx, + container, + flags.Modules, + // No need to pass `flags.Create`, this is not empty iff `flags.Create` + flags.CreateVisibility, + ) +} + +func sync( + ctx context.Context, + container appflag.Container, + modules []string, + createWithVisibility string, +) error { + // Assume that this command is run from the repository root. If not, `OpenRepository` will return + // a dir not found error. + repo, err := git.OpenRepository(git.DotGitDir, command.NewRunner()) + if err != nil { + return err + } + defer repo.Close() + storageProvider := storagegit.NewProvider( + repo.Objects(), + storagegit.ProviderWithSymlinks(), + ) + clientConfig, err := bufcli.NewConnectClientConfig(container) + if err != nil { + return fmt.Errorf("create connect client %w", err) + } + syncerOptions := []bufsync.SyncerOption{ + bufsync.SyncerWithResumption(syncPointResolver(clientConfig)), + } + for _, module := range modules { + var moduleIdentityOverride bufmoduleref.ModuleIdentity + colon := strings.IndexRune(module, ':') + if colon == -1 { + return appcmd.NewInvalidArgumentErrorf("module %s is missing an identity", module) + } + moduleIdentityOverride, err = bufmoduleref.ModuleIdentityForString(module[colon+1:]) + if err != nil { + return err + } + module = normalpath.Normalize(module[:colon]) + syncModule, err := bufsync.NewModule(module, moduleIdentityOverride) + if err != nil { + return err + } + syncerOptions = append(syncerOptions, bufsync.SyncerWithModule(syncModule)) + } + syncer, err := bufsync.NewSyncer( + container.Logger(), + repo, + storageProvider, + newErrorHandler(container.Logger()), + syncerOptions..., + ) + if err != nil { + return err + } + return syncer.Sync(ctx, func(ctx context.Context, commit bufsync.ModuleCommit) error { + syncPoint, err := pushOrCreate( + ctx, + clientConfig, + repo, + commit.Commit(), + commit.Branch(), + commit.Tags(), + commit.Identity(), + commit.Bucket(), + createWithVisibility, + ) + if err != nil { + // We failed to push. We fail hard on this because the error may be recoverable + // (i.e., the BSR may be down) and we should re-attempt this commit. + return fmt.Errorf( + "failed to push %s at %s: %w", + commit.Identity().IdentityString(), + commit.Commit().Hash(), + err, + ) + } + _, err = container.Stderr().Write([]byte( + fmt.Sprintf("%s:%s\n", commit.Identity().IdentityString(), syncPoint.BsrCommitName)), + ) + return err + }) +} + +func syncPointResolver(clientConfig *connectclient.Config) bufsync.SyncPointResolver { + return func(ctx context.Context, identity bufmoduleref.ModuleIdentity, branch string) (git.Hash, error) { + service := connectclient.Make(clientConfig, identity.Remote(), registryv1alpha1connect.NewSyncServiceClient) + syncPoint, err := service.GetGitSyncPoint(ctx, connect.NewRequest(®istryv1alpha1.GetGitSyncPointRequest{ + Owner: identity.Owner(), + Repository: identity.Repository(), + Branch: branch, + })) + if err != nil { + if connect.CodeOf(err) == connect.CodeNotFound { + // No syncpoint + return nil, nil + } + return nil, err + } + hash, err := git.NewHashFromHex(syncPoint.Msg.GetSyncPoint().GitCommitHash) + if err != nil { + return nil, fmt.Errorf( + "invalid sync point from BSR %q: %w", + syncPoint.Msg.GetSyncPoint().GetGitCommitHash(), + err, + ) + } + return hash, nil + } +} + +type syncErrorHandler struct { + logger *zap.Logger +} + +func newErrorHandler(logger *zap.Logger) bufsync.ErrorHandler { + return &syncErrorHandler{logger: logger} +} + +func (s *syncErrorHandler) BuildFailure(module bufsync.Module, commit git.Commit, err error) error { + // We failed to build the module. We can warn on this and carry on. + // Note that because of resumption, Syncer will typically only come + // across this commit once, we will not log this warning again. + s.logger.Warn( + "invalid module", + zap.Stringer("commit", commit.Hash()), + zap.Stringer("module", module), + zap.Error(err), + ) + return nil +} + +func (s *syncErrorHandler) InvalidModuleConfig(module bufsync.Module, commit git.Commit, err error) error { + // We found a module but the module config is invalid. We can warn on this + // and carry on. Note that because of resumption, Syncer will typically only come + // across this commit once, we will not log this warning again. + s.logger.Warn( + "invalid module", + zap.Stringer("commit", commit.Hash()), + zap.Stringer("module", module), + zap.Error(err), + ) + return nil +} + +func (s *syncErrorHandler) InvalidSyncPoint( + module bufsync.Module, + branch string, + syncPoint git.Hash, + err error, +) error { + // The most likely culprit for an invalid sync point is a rebase, where the last known + // commit has been garbage collected. In this case, let's present a better error message. + // + // We may want to provide a flag for sync to continue despite this, accumulating the error, + // and error at the end, so that other branches can continue to sync, but this branch is + // out of date. This is not trivial if the branch that's been rebased is a long-lived + // branch (like main) whose artifacts are consumed by other branches, as we may fail to + // sync those commits if we continue. So we now we simply error. + if errors.Is(err, git.ErrObjectNotFound) { + return fmt.Errorf( + "last synced commit %s was not found for module %s; did you rebase?", + syncPoint, + module, + ) + } + // Otherwise, we still want this to fail sync, let's bubble this up. + return err +} + +func (s *syncErrorHandler) SyncPointNotEncountered( + module bufsync.Module, + branch string, + syncPoint git.Hash, +) error { + // This can happen if the user rebased, but Git has not garbage collected the old commits, + // so the sync point was considered valid. Maybe there are other cases in which this can happen... + // This is a hard failure for now, but similar to InvalidSyncPoint, we can maybe accumulate + // these and error at the end, so that other branches continue to sync. + return fmt.Errorf( + "sync point %s for %s on branch %s was not encountered; did you rebase? Try running `git gc` and running sync again", + syncPoint, + module, + branch, + ) +} + +func pushOrCreate( + ctx context.Context, + clientConfig *connectclient.Config, + repo git.Repository, + commit git.Commit, + branch string, + tags []string, + moduleIdentity bufmoduleref.ModuleIdentity, + moduleBucket storage.ReadBucket, + createWithVisibility string, +) (*registryv1alpha1.GitSyncPoint, error) { + modulePin, err := push( + ctx, + clientConfig, + repo, + commit, + branch, + tags, + moduleIdentity, + moduleBucket, + ) + if err != nil { + // We rely on Push* returning a NotFound error to denote the repository is not created. + // This technically could be a NotFound error for some other entity than the repository + // in question, however if it is, then this Create call will just fail as the repository + // is already created, and there is no side effect. The 99% case is that a NotFound + // error is because the repository does not exist, and we want to avoid having to do + // a GetRepository RPC call for every call to push --create. + if createWithVisibility != "" && connect.CodeOf(err) == connect.CodeNotFound { + if err := create(ctx, clientConfig, moduleIdentity, createWithVisibility); err != nil { + return nil, err + } + return push( + ctx, + clientConfig, + repo, + commit, + branch, + tags, + moduleIdentity, + moduleBucket, + ) + } + return nil, err + } + return modulePin, nil +} + +func push( + ctx context.Context, + clientConfig *connectclient.Config, + repo git.Repository, + commit git.Commit, + branch string, + tags []string, + moduleIdentity bufmoduleref.ModuleIdentity, + moduleBucket storage.ReadBucket, +) (*registryv1alpha1.GitSyncPoint, error) { + service := connectclient.Make(clientConfig, moduleIdentity.Remote(), registryv1alpha1connect.NewSyncServiceClient) + m, blobSet, err := manifest.NewFromBucket(ctx, moduleBucket) + if err != nil { + return nil, err + } + bucketManifest, blobs, err := bufmanifest.ToProtoManifestAndBlobs(ctx, m, blobSet) + if err != nil { + return nil, err + } + if repo.BaseBranch() == branch { + // We are pushing a commit on the base branch of this repository. + // The BSR represents the base track as "main", and this is not configurable + // per module. + branch = bufmoduleref.Main + } + resp, err := service.SyncGitCommit(ctx, connect.NewRequest(®istryv1alpha1.SyncGitCommitRequest{ + Owner: moduleIdentity.Owner(), + Repository: moduleIdentity.Repository(), + Manifest: bucketManifest, + Blobs: blobs, + Hash: commit.Hash().Hex(), + Branch: branch, + Tags: tags, + Author: ®istryv1alpha1.GitIdentity{ + Name: commit.Author().Name(), + Email: commit.Author().Email(), + Time: timestamppb.New(commit.Author().Timestamp()), + }, + Commiter: ®istryv1alpha1.GitIdentity{ + Name: commit.Committer().Name(), + Email: commit.Committer().Email(), + Time: timestamppb.New(commit.Committer().Timestamp()), + }, + })) + if err != nil { + return nil, err + } + return resp.Msg.SyncPoint, nil +} + +func create( + ctx context.Context, + clientConfig *connectclient.Config, + moduleIdentity bufmoduleref.ModuleIdentity, + visibility string, +) error { + service := connectclient.Make(clientConfig, moduleIdentity.Remote(), registryv1alpha1connect.NewRepositoryServiceClient) + visiblity, err := bufcli.VisibilityFlagToVisibility(visibility) + if err != nil { + return err + } + fullName := moduleIdentity.Owner() + "/" + moduleIdentity.Repository() + _, err = service.CreateRepositoryByFullName( + ctx, + connect.NewRequest(®istryv1alpha1.CreateRepositoryByFullNameRequest{ + FullName: fullName, + Visibility: visiblity, + }), + ) + if err != nil && connect.CodeOf(err) == connect.CodeAlreadyExists { + return connect.NewError(connect.CodeInternal, fmt.Errorf("expected repository %s to be missing but found the repository to already exist", fullName)) + } + return err +} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/repo/reposync/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/repo/reposync/usage.gen.go new file mode 100644 index 000000000..37f15e278 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/repo/reposync/usage.gen.go @@ -0,0 +1,19 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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. + +// Generated. DO NOT EDIT. + +package reposync + +import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/graph/graph.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/graph/graph.go new file mode 100644 index 000000000..4bb34c540 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/graph/graph.go @@ -0,0 +1,186 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 graph + +import ( + "context" + "fmt" + + "github.com/bufbuild/buf/private/buf/bufcli" + "github.com/bufbuild/buf/private/buf/buffetch" + "github.com/bufbuild/buf/private/buf/bufwire" + "github.com/bufbuild/buf/private/bufpkg/bufanalysis" + "github.com/bufbuild/buf/private/bufpkg/bufapimodule" + "github.com/bufbuild/buf/private/bufpkg/bufgraph" + "github.com/bufbuild/buf/private/bufpkg/bufmodule" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild" + "github.com/bufbuild/buf/private/pkg/app/appcmd" + "github.com/bufbuild/buf/private/pkg/app/appflag" + "github.com/bufbuild/buf/private/pkg/command" + "github.com/bufbuild/buf/private/pkg/stringutil" + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +const ( + errorFormatFlagName = "error-format" + configFlagName = "config" + disableSymlinksFlagName = "disable-symlinks" +) + +// NewCommand returns a new Command. +func NewCommand( + name string, + builder appflag.Builder, +) *appcmd.Command { + flags := newFlags() + return &appcmd.Command{ + Use: name + " ", + Short: "Print the dependency graph in DOT format", + Long: bufcli.GetSourceOrModuleLong(`the source or module to print for`), + Args: cobra.MaximumNArgs(1), + Run: builder.NewRunFunc( + func(ctx context.Context, container appflag.Container) error { + return run(ctx, container, flags) + }, + bufcli.NewErrorInterceptor(), + ), + BindFlags: flags.Bind, + } +} + +type flags struct { + ErrorFormat string + Config string + DisableSymlinks bool + // special + InputHashtag string +} + +func newFlags() *flags { + return &flags{} +} + +func (f *flags) Bind(flagSet *pflag.FlagSet) { + bufcli.BindInputHashtag(flagSet, &f.InputHashtag) + bufcli.BindDisableSymlinks(flagSet, &f.DisableSymlinks, disableSymlinksFlagName) + flagSet.StringVar( + &f.ErrorFormat, + errorFormatFlagName, + "text", + fmt.Sprintf( + "The format for build errors printed to stderr. Must be one of %s", + stringutil.SliceToString(bufanalysis.AllFormatStrings), + ), + ) + flagSet.StringVar( + &f.Config, + configFlagName, + "", + `The file or data to use to use for configuration`, + ) +} + +func run( + ctx context.Context, + container appflag.Container, + flags *flags, +) error { + if err := bufcli.ValidateErrorFormatFlag(flags.ErrorFormat, errorFormatFlagName); err != nil { + return err + } + input, err := bufcli.GetInputValue(container, flags.InputHashtag, ".") + if err != nil { + return err + } + sourceOrModuleRef, err := buffetch.NewRefParser(container.Logger()).GetSourceOrModuleRef(ctx, input) + if err != nil { + return err + } + storageosProvider := bufcli.NewStorageosProvider(flags.DisableSymlinks) + runner := command.NewRunner() + clientConfig, err := bufcli.NewConnectClientConfig(container) + if err != nil { + return err + } + moduleResolver := bufapimodule.NewModuleResolver( + container.Logger(), + bufapimodule.NewRepositoryCommitServiceClientFactory(clientConfig), + ) + moduleReader, err := bufcli.NewModuleReaderAndCreateCacheDirs(container, clientConfig) + if err != nil { + return err + } + moduleConfigReader := bufwire.NewModuleConfigReader( + container.Logger(), + storageosProvider, + bufcli.NewFetchReader(container.Logger(), storageosProvider, runner, moduleResolver, moduleReader), + bufmodulebuild.NewModuleBucketBuilder(), + ) + if err != nil { + return err + } + graphBuilder := bufgraph.NewBuilder( + container.Logger(), + moduleResolver, + moduleReader, + ) + moduleConfigSet, err := moduleConfigReader.GetModuleConfigSet( + ctx, + container, + sourceOrModuleRef, + flags.Config, + nil, + nil, + false, + ) + if err != nil { + return err + } + moduleConfigs := moduleConfigSet.ModuleConfigs() + modules := make([]bufmodule.Module, len(moduleConfigs)) + for i, moduleConfig := range moduleConfigs { + modules[i] = moduleConfig.Module() + } + graph, fileAnnotations, err := graphBuilder.Build( + ctx, + modules, + bufgraph.BuildWithWorkspace(moduleConfigSet.Workspace()), + ) + if err != nil { + return err + } + if len(fileAnnotations) > 0 { + // stderr since we do output to stdout potentially + if err := bufanalysis.PrintFileAnnotations( + container.Stderr(), + fileAnnotations, + flags.ErrorFormat, + ); err != nil { + return err + } + return bufcli.ErrFileAnnotation + } + dotString, err := graph.DOTString( + func(node bufgraph.Node) string { + return node.String() + }, + ) + if err != nil { + return err + } + _, err = fmt.Fprintln(container.Stdout(), dotString) + return err +} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/graph/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/graph/usage.gen.go new file mode 100644 index 000000000..f67490350 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/graph/usage.gen.go @@ -0,0 +1,19 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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. + +// Generated. DO NOT EDIT. + +package graph + +import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/price/price.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/price/price.go index d000a494e..3eabfa855 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/price/price.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/price/price.go @@ -33,18 +33,18 @@ import ( const ( disableSymlinksFlagName = "disable-symlinks" teamsDollarsPerType = float64(0.50) - proDollarsPerType = float64(1) + proDollarsPerType = float64(1.50) teamsDollarsPerTypeDiscounted = float64(0.40) - proDollarsPerTypeDiscounted = float64(0.80) + proDollarsPerTypeDiscounted = float64(1.20) tmplCopy = `Current BSR pricing: - Teams: $0.50 per type - - Pro: $1.00 per type + - Pro: $1.50 per type If you sign up before October 15, 2023, we will give you a 20% discount for the first year: - Teams: $0.40 per type for the first year - - Pro: $0.80 per type for the first year + - Pro: $1.20 per type for the first year Pricing data last updated on April 4, 2023. @@ -145,7 +145,7 @@ func run( if err != nil { return err } - moduleConfigs, err := moduleConfigReader.GetModuleConfigs( + moduleConfigSet, err := moduleConfigReader.GetModuleConfigSet( ctx, container, sourceOrModuleRef, @@ -157,6 +157,7 @@ func run( if err != nil { return err } + moduleConfigs := moduleConfigSet.ModuleConfigs() statsSlice := make([]*protostat.Stats, len(moduleConfigs)) for i, moduleConfig := range moduleConfigs { stats, err := protostat.GetStats(ctx, bufmodulestat.NewFileWalker(moduleConfig.Module())) diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugincreate/plugincreate.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugincreate/plugincreate.go deleted file mode 100644 index cf053a928..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugincreate/plugincreate.go +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 plugincreate - -import ( - "context" - "fmt" - - "github.com/bufbuild/buf/private/buf/bufcli" - "github.com/bufbuild/buf/private/buf/bufprint" - "github.com/bufbuild/buf/private/bufpkg/bufremoteplugin" - "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" - "github.com/bufbuild/buf/private/pkg/app/appcmd" - "github.com/bufbuild/buf/private/pkg/app/appflag" - "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/buf/private/pkg/stringutil" - "github.com/bufbuild/connect-go" - "github.com/spf13/cobra" - "github.com/spf13/pflag" -) - -const ( - visibilityFlagName = "visibility" - formatFlagName = "format" - - publicVisibility = "public" - privateVisibility = "private" -) - -var allVisibiltyStrings = []string{ - publicVisibility, - privateVisibility, -} - -// NewCommand returns a new Command -func NewCommand( - name string, - builder appflag.Builder, -) *appcmd.Command { - flags := newFlags() - return &appcmd.Command{ - Use: name + " ", - Short: "Create a Protobuf plugin", - Args: cobra.ExactArgs(1), - Run: builder.NewRunFunc( - func(ctx context.Context, container appflag.Container) error { - return run(ctx, container, flags) - }, - bufcli.NewErrorInterceptor(), - ), - BindFlags: flags.Bind, - } -} - -type flags struct { - Visibility string - Format string -} - -func newFlags() *flags { - return &flags{} -} - -func (f *flags) Bind(flagSet *pflag.FlagSet) { - flagSet.StringVar( - &f.Visibility, - visibilityFlagName, - "", - fmt.Sprintf(`The plugin's visibility setting. Must be one of %s`, stringutil.SliceToString(allVisibiltyStrings)), - ) - _ = cobra.MarkFlagRequired(flagSet, visibilityFlagName) - flagSet.StringVar( - &f.Format, - formatFlagName, - bufprint.FormatText.String(), - fmt.Sprintf(`The output format to use. Must be one of %s`, bufprint.AllFormatsString), - ) -} - -func run( - ctx context.Context, - container appflag.Container, - flags *flags, -) error { - bufcli.WarnBetaCommand(ctx, container) - pluginPath := container.Arg(0) - visibility, err := visibilityFlagToVisibility(flags.Visibility) - if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - format, err := bufprint.ParseFormat(flags.Format) - if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - clientConfig, err := bufcli.NewConnectClientConfig(container) - if err != nil { - return err - } - remote, owner, name, err := bufremoteplugin.ParsePluginPath(pluginPath) - if err != nil { - return err - } - pluginService := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewPluginServiceClient) - resp, err := pluginService.CreatePlugin( - ctx, - connect.NewRequest(®istryv1alpha1.CreatePluginRequest{ - Owner: owner, - Name: name, - Visibility: visibility, - }), - ) - if err != nil { - return err - } - return bufprint.NewPluginPrinter(container.Stdout()).PrintPlugin(ctx, format, resp.Msg.Plugin) -} - -// visibilityFlagToVisibility parses the given string as a registryv1alpha1.PluginVisibility. -func visibilityFlagToVisibility(visibility string) (registryv1alpha1.PluginVisibility, error) { - switch visibility { - case publicVisibility: - return registryv1alpha1.PluginVisibility_PLUGIN_VISIBILITY_PUBLIC, nil - case privateVisibility: - return registryv1alpha1.PluginVisibility_PLUGIN_VISIBILITY_PRIVATE, nil - default: - return 0, fmt.Errorf("invalid visibility: %s, expected one of %s", visibility, stringutil.SliceToString(allVisibiltyStrings)) - } -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugindelete/plugindelete.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugindelete/plugindelete.go index 27091d321..2dd72294e 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugindelete/plugindelete.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugindelete/plugindelete.go @@ -16,9 +16,11 @@ package plugindelete import ( "context" + "fmt" + "strings" "github.com/bufbuild/buf/private/buf/bufcli" - internal "github.com/bufbuild/buf/private/bufpkg/bufremoteplugin" + "github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref" "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" "github.com/bufbuild/buf/private/pkg/app/appcmd" @@ -29,19 +31,15 @@ import ( "github.com/spf13/pflag" ) -const ( - forceFlagName = "force" -) - -// NewCommand returns a new Command +// NewCommand returns a new Command. func NewCommand( name string, builder appflag.Builder, ) *appcmd.Command { flags := newFlags() return &appcmd.Command{ - Use: name + " ", - Short: "Delete a Protobuf plugin", + Use: name + " ", + Short: "Delete a plugin from the registry", Args: cobra.ExactArgs(1), Run: builder.NewRunFunc( func(ctx context.Context, container appflag.Container) error { @@ -53,22 +51,13 @@ func NewCommand( } } -type flags struct { - Force bool -} +type flags struct{} func newFlags() *flags { return &flags{} } -func (f *flags) Bind(flagSet *pflag.FlagSet) { - flagSet.BoolVar( - &f.Force, - forceFlagName, - false, - "Force deletion without confirming. Use with caution", - ) -} +func (f *flags) Bind(flagSet *pflag.FlagSet) {} func run( ctx context.Context, @@ -76,33 +65,35 @@ func run( flags *flags, ) error { bufcli.WarnBetaCommand(ctx, container) - pluginPath := container.Arg(0) - if pluginPath == "" { - return appcmd.NewInvalidArgumentError("you must specify a plugin path") - } - clientConfig, err := bufcli.NewConnectClientConfig(container) + identity, version, _ := strings.Cut(container.Arg(0), ":") + pluginIdentity, err := bufpluginref.PluginIdentityForString(identity) if err != nil { - return err + return appcmd.NewInvalidArgumentError(err.Error()) + } + if version != "" { + if err := bufpluginref.ValidatePluginVersion(version); err != nil { + return appcmd.NewInvalidArgumentError(err.Error()) + } } - remote, owner, name, err := internal.ParsePluginPath(pluginPath) + clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { return err } - pluginService := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewPluginServiceClient) - if !flags.Force { - if err := bufcli.PromptUserForDelete(container, "plugin", name); err != nil { - return err - } - } - if _, err := pluginService.DeletePlugin( + service := connectclient.Make( + clientConfig, + pluginIdentity.Remote(), + registryv1alpha1connect.NewPluginCurationServiceClient, + ) + if _, err := service.DeleteCuratedPlugin( ctx, - connect.NewRequest(®istryv1alpha1.DeletePluginRequest{ - Owner: owner, - Name: name, + connect.NewRequest(®istryv1alpha1.DeleteCuratedPluginRequest{ + Owner: pluginIdentity.Owner(), + Name: pluginIdentity.Plugin(), + Version: version, }), ); err != nil { if connect.CodeOf(err) == connect.CodeNotFound { - return bufcli.NewPluginNotFoundError(owner, name) + return fmt.Errorf("the plugin %s does not exist", container.Arg(0)) } return err } diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginlist/pluginlist.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginlist/pluginlist.go deleted file mode 100644 index 086da609f..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginlist/pluginlist.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 pluginlist - -import ( - "context" - "fmt" - - "github.com/bufbuild/buf/private/buf/bufcli" - "github.com/bufbuild/buf/private/buf/bufprint" - "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" - "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" - "github.com/bufbuild/buf/private/pkg/app/appcmd" - "github.com/bufbuild/buf/private/pkg/app/appflag" - "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/connect-go" - "github.com/spf13/cobra" - "github.com/spf13/pflag" -) - -const ( - pageSizeFlagName = "page-size" - pageTokenFlagName = "page-token" - reverseFlagName = "reverse" - formatFlagName = "format" -) - -// NewCommand returns a new Command -func NewCommand( - name string, - builder appflag.Builder, -) *appcmd.Command { - flags := newFlags() - return &appcmd.Command{ - Use: name + " ", - Short: "List plugins on the specified BSR", - Args: cobra.ExactArgs(1), - Run: builder.NewRunFunc( - func(ctx context.Context, container appflag.Container) error { - return run(ctx, container, flags) - }, - bufcli.NewErrorInterceptor(), - ), - BindFlags: flags.Bind, - } -} - -type flags struct { - PageSize uint32 - PageToken string - Reverse bool - Format string -} - -func newFlags() *flags { - return &flags{} -} - -func (f *flags) Bind(flagSet *pflag.FlagSet) { - flagSet.Uint32Var(&f.PageSize, - pageSizeFlagName, - 10, - `The page size`, - ) - flagSet.StringVar(&f.PageToken, - pageTokenFlagName, - "", - `The page token. If more results are available, a "next_page" key is present in the --format=json output`, - ) - flagSet.BoolVar(&f.Reverse, - reverseFlagName, - false, - `Reverse the results`, - ) - flagSet.StringVar( - &f.Format, - formatFlagName, - bufprint.FormatText.String(), - fmt.Sprintf(`The output format to use. Must be one of %s`, bufprint.AllFormatsString), - ) -} - -func run( - ctx context.Context, - container appflag.Container, - flags *flags, -) (retErr error) { - bufcli.WarnBetaCommand(ctx, container) - remote := container.Arg(0) - if err := bufmoduleref.ValidateRemoteNotEmpty(remote); err != nil { - return err - } - if err := bufmoduleref.ValidateRemoteHasNoPaths(remote); err != nil { - return err - } - format, err := bufprint.ParseFormat(flags.Format) - if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - clientConfig, err := bufcli.NewConnectClientConfig(container) - if err != nil { - return err - } - pluginService := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewPluginServiceClient) - resp, err := pluginService.ListPlugins( - ctx, - connect.NewRequest(®istryv1alpha1.ListPluginsRequest{ - PageSize: flags.PageSize, - PageToken: flags.PageToken, - Reverse: flags.Reverse, - }), - ) - if err != nil { - return err - } - return bufprint.NewPluginPrinter(container.Stdout()). - PrintPlugins(ctx, format, resp.Msg.NextPageToken, resp.Msg.Plugins...) -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/pluginpush/pluginpush.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush/pluginpush.go similarity index 97% rename from vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/pluginpush/pluginpush.go rename to vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush/pluginpush.go index 785fbb17c..20e33e074 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/pluginpush/pluginpush.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush/pluginpush.go @@ -132,9 +132,10 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) { flagSet.StringVar( &f.Visibility, visibilityFlagName, - "public", + "", fmt.Sprintf(`The plugin's visibility setting. Must be one of %s`, stringutil.SliceToString(allVisibiltyStrings)), ) + _ = cobra.MarkFlagRequired(flagSet, visibilityFlagName) } func run( @@ -142,7 +143,7 @@ func run( container appflag.Container, flags *flags, ) (retErr error) { - bufcli.WarnAlphaCommand(ctx, container) + bufcli.WarnBetaCommand(ctx, container) if err := bufcli.ValidateErrorFormatFlag(flags.ErrorFormat, errorFormatFlagName); err != nil { return err } @@ -399,11 +400,7 @@ func findExistingDigestForImageID( imageID string, currentImageDigest string, ) (string, error) { - pluginsRemote := plugin.Name.Remote() - if !strings.HasPrefix(pluginsRemote, bufplugindocker.PluginsImagePrefix) { - pluginsRemote = bufplugindocker.PluginsImagePrefix + pluginsRemote - } - repo, err := name.NewRepository(fmt.Sprintf("%s/%s/%s", pluginsRemote, plugin.Name.Owner(), plugin.Name.Plugin())) + repo, err := name.NewRepository(fmt.Sprintf("%s/%s/%s", plugin.Name.Remote(), plugin.Name.Owner(), plugin.Name.Plugin())) if err != nil { return "", err } @@ -424,6 +421,9 @@ func findExistingDigestForImageID( if err != nil { structuredErr := new(transport.Error) if errors.As(err, &structuredErr) { + if structuredErr.StatusCode == http.StatusUnauthorized { + return "", errors.New("you are not authenticated. For details, visit https://buf.build/docs/bsr/authentication") + } if structuredErr.StatusCode == http.StatusNotFound { return "", nil } diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/pluginpush/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush/usage.gen.go similarity index 100% rename from vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/pluginpush/usage.gen.go rename to vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush/usage.gen.go diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginversion/pluginversionlist/pluginversionlist.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginversion/pluginversionlist/pluginversionlist.go deleted file mode 100644 index d76bd1562..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginversion/pluginversionlist/pluginversionlist.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 pluginversionlist - -import ( - "context" - "fmt" - - "github.com/bufbuild/buf/private/buf/bufcli" - "github.com/bufbuild/buf/private/buf/bufprint" - "github.com/bufbuild/buf/private/bufpkg/bufremoteplugin" - "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" - "github.com/bufbuild/buf/private/pkg/app/appcmd" - "github.com/bufbuild/buf/private/pkg/app/appflag" - "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/connect-go" - "github.com/spf13/cobra" - "github.com/spf13/pflag" -) - -const ( - pageSizeFlagName = "page-size" - pageTokenFlagName = "page-token" - reverseFlagName = "reverse" - formatFlagName = "format" -) - -// NewCommand returns a new Command -func NewCommand( - name string, - builder appflag.Builder, -) *appcmd.Command { - flags := newFlags() - return &appcmd.Command{ - Use: name + " ", - Short: "List plugin versions", - Args: cobra.ExactArgs(1), - Run: builder.NewRunFunc( - func(ctx context.Context, container appflag.Container) error { - return run(ctx, container, flags) - }, - bufcli.NewErrorInterceptor(), - ), - BindFlags: flags.Bind, - } -} - -type flags struct { - PageSize uint32 - PageToken string - Reverse bool - Format string -} - -func newFlags() *flags { - return &flags{} -} - -func (f *flags) Bind(flagSet *pflag.FlagSet) { - flagSet.Uint32Var(&f.PageSize, - pageSizeFlagName, - 10, - `The page size`, - ) - flagSet.StringVar(&f.PageToken, - pageTokenFlagName, - "", - `The page token. If more results are available, a "next_page" key is present in the --format=json output`, - ) - flagSet.BoolVar(&f.Reverse, - reverseFlagName, - false, - `Reverse the results`, - ) - flagSet.StringVar( - &f.Format, - formatFlagName, - bufprint.FormatText.String(), - fmt.Sprintf(`The output format to use. Must be one of %s`, bufprint.AllFormatsString), - ) -} - -func run( - ctx context.Context, - container appflag.Container, - flags *flags, -) (retErr error) { - bufcli.WarnBetaCommand(ctx, container) - pluginPath := container.Arg(0) - format, err := bufprint.ParseFormat(flags.Format) - if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - clientConfig, err := bufcli.NewConnectClientConfig(container) - if err != nil { - return err - } - remote, owner, name, err := bufremoteplugin.ParsePluginPath(pluginPath) - if err != nil { - return err - } - pluginService := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewPluginServiceClient) - resp, err := pluginService.ListPluginVersions( - ctx, - connect.NewRequest(®istryv1alpha1.ListPluginVersionsRequest{ - Owner: owner, - Name: name, - PageSize: flags.PageSize, - PageToken: flags.PageToken, - Reverse: flags.Reverse, - }), - ) - if err != nil { - return err - } - return bufprint.NewPluginVersionPrinter(container.Stdout()). - PrintPluginVersions(ctx, format, resp.Msg.NextPageToken, resp.Msg.PluginVersions...) -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatecreate/templatecreate.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatecreate/templatecreate.go deleted file mode 100644 index c2c9300a5..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatecreate/templatecreate.go +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 templatecreate - -import ( - "context" - "fmt" - - "github.com/bufbuild/buf/private/buf/bufcli" - "github.com/bufbuild/buf/private/buf/bufprint" - "github.com/bufbuild/buf/private/bufpkg/bufremoteplugin" - "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" - "github.com/bufbuild/buf/private/pkg/app/appcmd" - "github.com/bufbuild/buf/private/pkg/app/appflag" - "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/buf/private/pkg/stringutil" - "github.com/bufbuild/connect-go" - "github.com/spf13/cobra" - "github.com/spf13/pflag" -) - -const ( - configFlagName = "config" - visibilityFlagName = "visibility" - formatFlagName = "format" - - publicVisibility = "public" - privateVisibility = "private" -) - -var allVisibiltyStrings = []string{ - publicVisibility, - privateVisibility, -} - -// NewCommand returns a new Command -func NewCommand( - name string, - builder appflag.Builder, -) *appcmd.Command { - flags := newFlags() - return &appcmd.Command{ - Use: name + " ", - Short: "Create a Buf template", - Args: cobra.ExactArgs(1), - Run: builder.NewRunFunc( - func(ctx context.Context, container appflag.Container) error { - return run(ctx, container, flags) - }, - bufcli.NewErrorInterceptor(), - ), - BindFlags: flags.Bind, - } -} - -type flags struct { - Config string - Visibility string - Format string -} - -func newFlags() *flags { - return &flags{} -} - -func (f *flags) Bind(flagSet *pflag.FlagSet) { - flagSet.StringVar( - &f.Config, - configFlagName, - "", - `The template file or data to use for configuration. Must be in either YAML or JSON format`, - ) - _ = cobra.MarkFlagRequired(flagSet, configFlagName) - flagSet.StringVar( - &f.Visibility, - visibilityFlagName, - "", - fmt.Sprintf(`The template's visibility setting. Must be one of %s`, stringutil.SliceToString(allVisibiltyStrings)), - ) - _ = cobra.MarkFlagRequired(flagSet, visibilityFlagName) - flagSet.StringVar( - &f.Format, - formatFlagName, - bufprint.FormatText.String(), - fmt.Sprintf(`The output format to use. Must be one of %s`, bufprint.AllFormatsString), - ) -} - -func run( - ctx context.Context, - container appflag.Container, - flags *flags, -) error { - bufcli.WarnBetaCommand(ctx, container) - templatePath := container.Arg(0) - visibility, err := visibilityFlagToVisibility(flags.Visibility) - if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - format, err := bufprint.ParseFormat(flags.Format) - if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - templateConfig, err := bufremoteplugin.ParseTemplateConfig(flags.Config) - if err != nil { - return err - } - clientConfig, err := bufcli.NewConnectClientConfig(container) - if err != nil { - return err - } - remote, owner, name, err := bufremoteplugin.ParseTemplatePath(templatePath) - if err != nil { - return err - } - pluginService := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewPluginServiceClient) - resp, err := pluginService.CreateTemplate( - ctx, - connect.NewRequest(®istryv1alpha1.CreateTemplateRequest{ - Owner: owner, - Name: name, - Visibility: visibility, - PluginConfigs: bufremoteplugin.TemplateConfigToProtoPluginConfigs(templateConfig), - }), - ) - if err != nil { - return err - } - return bufprint.NewTemplatePrinter(container.Stdout()).PrintTemplate(ctx, format, resp.Msg.Template) -} - -// visibilityFlagToVisibility parses the given string as a registryv1alpha1.PluginVisibility. -func visibilityFlagToVisibility(visibility string) (registryv1alpha1.PluginVisibility, error) { - switch visibility { - case publicVisibility: - return registryv1alpha1.PluginVisibility_PLUGIN_VISIBILITY_PUBLIC, nil - case privateVisibility: - return registryv1alpha1.PluginVisibility_PLUGIN_VISIBILITY_PRIVATE, nil - default: - return 0, fmt.Errorf("invalid visibility: %s, expected one of %s", visibility, stringutil.SliceToString(allVisibiltyStrings)) - } -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatedelete/templatedelete.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatedelete/templatedelete.go deleted file mode 100644 index dcb2a01f7..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatedelete/templatedelete.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 templatedelete - -import ( - "context" - - "github.com/bufbuild/buf/private/buf/bufcli" - "github.com/bufbuild/buf/private/bufpkg/bufremoteplugin" - "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" - "github.com/bufbuild/buf/private/pkg/app/appcmd" - "github.com/bufbuild/buf/private/pkg/app/appflag" - "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/connect-go" - "github.com/spf13/cobra" - "github.com/spf13/pflag" -) - -const ( - forceFlagName = "force" -) - -// NewCommand returns a new Command -func NewCommand( - name string, - builder appflag.Builder, -) *appcmd.Command { - flags := newFlags() - return &appcmd.Command{ - Use: name + " ", - Short: "Delete a template", - Args: cobra.ExactArgs(1), - Run: builder.NewRunFunc( - func(ctx context.Context, container appflag.Container) error { - return run(ctx, container, flags) - }, - bufcli.NewErrorInterceptor(), - ), - BindFlags: flags.Bind, - } -} - -type flags struct { - Force bool -} - -func newFlags() *flags { - return &flags{} -} - -func (f *flags) Bind(flagSet *pflag.FlagSet) { - flagSet.BoolVar( - &f.Force, - forceFlagName, - false, - "Force deletion without confirming. Use with caution", - ) -} - -func run( - ctx context.Context, - container appflag.Container, - flags *flags, -) error { - bufcli.WarnBetaCommand(ctx, container) - templatePath := container.Arg(0) - if templatePath == "" { - return appcmd.NewInvalidArgumentError("you must specify a template path") - } - clientConfig, err := bufcli.NewConnectClientConfig(container) - if err != nil { - return err - } - remote, owner, name, err := bufremoteplugin.ParseTemplatePath(templatePath) - if err != nil { - return err - } - pluginService := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewPluginServiceClient) - if !flags.Force { - if err := bufcli.PromptUserForDelete(container, "template", name); err != nil { - return err - } - } - if _, err := pluginService.DeleteTemplate( - ctx, - connect.NewRequest(®istryv1alpha1.DeleteTemplateRequest{ - Owner: owner, - Name: name, - }), - ); err != nil { - if connect.CodeOf(err) == connect.CodeNotFound { - return bufcli.NewTemplateNotFoundError(owner, name) - } - return err - } - return nil -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatedelete/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatedelete/usage.gen.go deleted file mode 100644 index 9eebe1bd3..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatedelete/usage.gen.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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. - -// Generated. DO NOT EDIT. - -package templatedelete - -import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatelist/templatelist.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatelist/templatelist.go deleted file mode 100644 index d9ae3dcdd..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatelist/templatelist.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 templatelist - -import ( - "context" - "fmt" - - "github.com/bufbuild/buf/private/buf/bufcli" - "github.com/bufbuild/buf/private/buf/bufprint" - "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" - "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" - "github.com/bufbuild/buf/private/pkg/app/appcmd" - "github.com/bufbuild/buf/private/pkg/app/appflag" - "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/connect-go" - "github.com/spf13/cobra" - "github.com/spf13/pflag" -) - -const ( - pageSizeFlagName = "page-size" - pageTokenFlagName = "page-token" - reverseFlagName = "reverse" - formatFlagName = "format" -) - -// NewCommand returns a new Command -func NewCommand( - name string, - builder appflag.Builder, -) *appcmd.Command { - flags := newFlags() - return &appcmd.Command{ - Use: name + " ", - Short: "List templates on the specified BSR", - Args: cobra.ExactArgs(1), - Run: builder.NewRunFunc( - func(ctx context.Context, container appflag.Container) error { - return run(ctx, container, flags) - }, - bufcli.NewErrorInterceptor(), - ), - BindFlags: flags.Bind, - } -} - -type flags struct { - PageSize uint32 - PageToken string - Reverse bool - Format string -} - -func newFlags() *flags { - return &flags{} -} - -func (f *flags) Bind(flagSet *pflag.FlagSet) { - flagSet.Uint32Var(&f.PageSize, - pageSizeFlagName, - 10, - `The page size.`, - ) - flagSet.StringVar(&f.PageToken, - pageTokenFlagName, - "", - `The page token. If more results are available, a "next_page" key is present in the --format=json output`, - ) - flagSet.BoolVar(&f.Reverse, - reverseFlagName, - false, - `Reverse the results.`, - ) - flagSet.StringVar( - &f.Format, - formatFlagName, - bufprint.FormatText.String(), - fmt.Sprintf(`The output format to use. Must be one of %s`, bufprint.AllFormatsString), - ) -} - -func run( - ctx context.Context, - container appflag.Container, - flags *flags, -) (retErr error) { - bufcli.WarnBetaCommand(ctx, container) - remote := container.Arg(0) - if err := bufmoduleref.ValidateRemoteNotEmpty(remote); err != nil { - return err - } - if err := bufmoduleref.ValidateRemoteHasNoPaths(remote); err != nil { - return err - } - format, err := bufprint.ParseFormat(flags.Format) - if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - clientConfig, err := bufcli.NewConnectClientConfig(container) - if err != nil { - return err - } - pluginService := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewPluginServiceClient) - resp, err := pluginService.ListTemplates( - ctx, - connect.NewRequest(®istryv1alpha1.ListTemplatesRequest{ - PageSize: flags.PageSize, - PageToken: flags.PageToken, - Reverse: flags.Reverse, - }), - ) - if err != nil { - return err - } - return bufprint.NewTemplatePrinter(container.Stdout()). - PrintTemplates(ctx, format, resp.Msg.NextPageToken, resp.Msg.Templates...) -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversioncreate/templateversioncreate.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversioncreate/templateversioncreate.go deleted file mode 100644 index d855d47ad..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversioncreate/templateversioncreate.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 templateversioncreate - -import ( - "context" - "fmt" - - "github.com/bufbuild/buf/private/buf/bufcli" - "github.com/bufbuild/buf/private/buf/bufprint" - "github.com/bufbuild/buf/private/bufpkg/bufremoteplugin" - "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" - "github.com/bufbuild/buf/private/pkg/app/appcmd" - "github.com/bufbuild/buf/private/pkg/app/appflag" - "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/connect-go" - "github.com/spf13/cobra" - "github.com/spf13/pflag" -) - -const ( - configFlagName = "config" - nameFlagName = "name" - formatFlagName = "format" -) - -// NewCommand returns a new Command -func NewCommand( - name string, - builder appflag.Builder, -) *appcmd.Command { - flags := newFlags() - return &appcmd.Command{ - Use: name + " ", - Short: "Create a new template version", - Args: cobra.ExactArgs(1), - Run: builder.NewRunFunc( - func(ctx context.Context, container appflag.Container) error { - return run(ctx, container, flags) - }, - bufcli.NewErrorInterceptor(), - ), - BindFlags: flags.Bind, - } -} - -type flags struct { - Config string - Name string - Format string -} - -func newFlags() *flags { - return &flags{} -} - -func (f *flags) Bind(flagSet *pflag.FlagSet) { - flagSet.StringVar( - &f.Config, - configFlagName, - "", - "The template file or data to use for configuration. Must be in either YAML or JSON format", - ) - _ = cobra.MarkFlagRequired(flagSet, configFlagName) - flagSet.StringVar( - &f.Name, - nameFlagName, - "", - "The name of the new template version", - ) - _ = cobra.MarkFlagRequired(flagSet, nameFlagName) - flagSet.StringVar( - &f.Format, - formatFlagName, - bufprint.FormatText.String(), - fmt.Sprintf("The output format to use. Must be one of %s", bufprint.AllFormatsString), - ) -} - -func run( - ctx context.Context, - container appflag.Container, - flags *flags, -) error { - bufcli.WarnBetaCommand(ctx, container) - templatePath := container.Arg(0) - format, err := bufprint.ParseFormat(flags.Format) - if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - templateVersionConfig, err := bufremoteplugin.ParseTemplateVersionConfig(flags.Config) - if err != nil { - return err - } - clientConfig, err := bufcli.NewConnectClientConfig(container) - if err != nil { - return err - } - remote, templateOwner, templateName, err := bufremoteplugin.ParseTemplatePath(templatePath) - if err != nil { - return err - } - pluginService := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewPluginServiceClient) - resp, err := pluginService.CreateTemplateVersion( - ctx, - connect.NewRequest(®istryv1alpha1.CreateTemplateVersionRequest{ - Name: flags.Name, - TemplateOwner: templateOwner, - TemplateName: templateName, - PluginVersions: bufremoteplugin.TemplateVersionConfigToProtoPluginVersionMappings(templateVersionConfig), - }), - ) - if err != nil { - return err - } - return bufprint.NewTemplateVersionPrinter(container.Stdout()). - PrintTemplateVersion(ctx, format, resp.Msg.TemplateVersion) -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversioncreate/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversioncreate/usage.gen.go deleted file mode 100644 index 3953efeff..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversioncreate/usage.gen.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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. - -// Generated. DO NOT EDIT. - -package templateversioncreate - -import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversionlist/templateversionlist.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversionlist/templateversionlist.go deleted file mode 100644 index 993cea13e..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversionlist/templateversionlist.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 templateversionlist - -import ( - "context" - "fmt" - - "github.com/bufbuild/buf/private/buf/bufcli" - "github.com/bufbuild/buf/private/buf/bufprint" - "github.com/bufbuild/buf/private/bufpkg/bufremoteplugin" - "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" - "github.com/bufbuild/buf/private/pkg/app/appcmd" - "github.com/bufbuild/buf/private/pkg/app/appflag" - "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/connect-go" - "github.com/spf13/cobra" - "github.com/spf13/pflag" -) - -const ( - pageSizeFlagName = "page-size" - pageTokenFlagName = "page-token" - reverseFlagName = "reverse" - formatFlagName = "format" -) - -// NewCommand returns a new Command -func NewCommand( - name string, - builder appflag.Builder, -) *appcmd.Command { - flags := newFlags() - return &appcmd.Command{ - Use: name + " ", - Short: "List versions for the specified template", - Args: cobra.ExactArgs(1), - Run: builder.NewRunFunc( - func(ctx context.Context, container appflag.Container) error { - return run(ctx, container, flags) - }, - bufcli.NewErrorInterceptor(), - ), - BindFlags: flags.Bind, - } -} - -type flags struct { - PageSize uint32 - PageToken string - Reverse bool - Format string -} - -func newFlags() *flags { - return &flags{} -} - -func (f *flags) Bind(flagSet *pflag.FlagSet) { - flagSet.Uint32Var(&f.PageSize, - pageSizeFlagName, - 10, - `The page size.`, - ) - flagSet.StringVar(&f.PageToken, - pageTokenFlagName, - "", - `The page token. If more results are available, a "next_page" key is present in the --format=json output`, - ) - flagSet.BoolVar(&f.Reverse, - reverseFlagName, - false, - `Reverse the results.`, - ) - flagSet.StringVar( - &f.Format, - formatFlagName, - bufprint.FormatText.String(), - fmt.Sprintf(`The output format to use. Must be one of %s`, bufprint.AllFormatsString), - ) -} - -func run( - ctx context.Context, - container appflag.Container, - flags *flags, -) (retErr error) { - bufcli.WarnBetaCommand(ctx, container) - templatePath := container.Arg(0) - format, err := bufprint.ParseFormat(flags.Format) - if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) - } - clientConfig, err := bufcli.NewConnectClientConfig(container) - if err != nil { - return err - } - remote, owner, name, err := bufremoteplugin.ParseTemplatePath(templatePath) - if err != nil { - return err - } - pluginService := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewPluginServiceClient) - resp, err := pluginService.ListTemplateVersions( - ctx, - connect.NewRequest(®istryv1alpha1.ListTemplateVersionsRequest{ - Owner: owner, - Name: name, - PageSize: flags.PageSize, - PageToken: flags.PageToken, - Reverse: flags.Reverse, - }), - ) - if err != nil { - return err - } - return bufprint.NewTemplateVersionPrinter(container.Stdout()). - PrintTemplateVersions(ctx, format, resp.Msg.NextPageToken, resp.Msg.TemplateVersions...) -} diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversionlist/usage.gen.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversionlist/usage.gen.go deleted file mode 100644 index f2cc6a025..000000000 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversionlist/usage.gen.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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. - -// Generated. DO NOT EDIT. - -package templateversionlist - -import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/stats/stats.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/stats/stats.go index 70852eaa9..8822c2960 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/stats/stats.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/stats/stats.go @@ -116,7 +116,7 @@ func run( if err != nil { return err } - moduleConfigs, err := moduleConfigReader.GetModuleConfigs( + moduleConfigSet, err := moduleConfigReader.GetModuleConfigSet( ctx, container, sourceOrModuleRef, @@ -128,6 +128,7 @@ func run( if err != nil { return err } + moduleConfigs := moduleConfigSet.ModuleConfigs() statsSlice := make([]*protostat.Stats, len(moduleConfigs)) for i, moduleConfig := range moduleConfigs { stats, err := protostat.GetStats(ctx, bufmodulestat.NewFileWalker(moduleConfig.Module())) diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/studioagent/studioagent.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/studioagent/studioagent.go index a10b9dd4d..62cfd9cdd 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/studioagent/studioagent.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/studioagent/studioagent.go @@ -99,7 +99,7 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) { flagSet.StringVar( &f.Origin, originFlagName, - "https://studio.buf.build", + "https://buf.build", "The allowed origin for CORS options", ) flagSet.StringSliceVar( diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/curl/curl.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/curl/curl.go index 35ce60f59..e2ecece8a 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/curl/curl.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/curl/curl.go @@ -91,8 +91,11 @@ const ( headerFlagShortName = "H" dataFlagName = "data" dataFlagShortName = "d" - outputFlagName = "output" - outputFlagShortName = "o" + + // Output flags + outputFlagName = "output" + outputFlagShortName = "o" + emitDefaultsFlagName = "emit-defaults" ) // NewCommand returns a new Command. @@ -223,7 +226,10 @@ type flags struct { NetrcFile string Headers []string Data string - Output string + + // Output options + Output string + EmitDefaults bool // so we can inquire about which flags present on command-line // TODO: ideally we'd use cobra directly instead of having the appcmd wrapper, @@ -468,6 +474,12 @@ provided via stdin as a file descriptor set or image`, "", `Path to output file to create with response data. If absent, response is printed to stdout`, ) + flagSet.BoolVar( + &f.EmitDefaults, + emitDefaultsFlagName, + false, + `Emit default values for JSON-encoded responses.`, + ) } func (f *flags) validate(isSecure bool) error { @@ -687,7 +699,7 @@ func basicAuth(username, password string) string { buf.WriteString(username) buf.WriteByte(':') buf.WriteString(password) - return base64.StdEncoding.EncodeToString(buf.Bytes()) + return "Basic " + base64.StdEncoding.EncodeToString(buf.Bytes()) } func validateHeaders(flags []string, flagName string, schemaIsStdin bool, allowAsterisk bool, headerFiles map[string]struct{}) error { @@ -735,7 +747,7 @@ func verifyEndpointURL(urlArg string) (endpointURL *url.URL, service, method, ba return nil, "", "", "", fmt.Errorf("%q is not a valid endpoint URL: %w", urlArg, err) } if endpointURL.Scheme != "http" && endpointURL.Scheme != "https" { - return nil, "", "", "", fmt.Errorf("invalid endpoint URL: sceme %q is not supported", endpointURL.Scheme) + return nil, "", "", "", fmt.Errorf("invalid endpoint URL: scheme %q is not supported", endpointURL.Scheme) } if strings.HasSuffix(endpointURL.Path, "/") { @@ -943,7 +955,7 @@ func run(ctx context.Context, container appflag.Container, f *flags) (err error) } // Now we can finally issue the RPC - invoker := bufcurl.NewInvoker(container, methodDescriptor, res, transport, clientOptions, container.Arg(0), output) + invoker := bufcurl.NewInvoker(container, methodDescriptor, res, f.EmitDefaults, transport, clientOptions, container.Arg(0), output) return invoker.Invoke(ctx, dataSource, dataReader, requestHeaders) } diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/export/export.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/export/export.go index 446538a0a..c30f8b64a 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/export/export.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/export/export.go @@ -64,7 +64,7 @@ Export proto files in to an output directory. $ buf export --output= -Export current directory to another local directory. +Export current directory to another local directory. $ buf export . --output= @@ -162,7 +162,7 @@ func run( if err != nil { return err } - moduleConfigs, err := moduleConfigReader.GetModuleConfigs( + moduleConfigSet, err := moduleConfigReader.GetModuleConfigSet( ctx, container, sourceOrModuleRef, @@ -174,16 +174,18 @@ func run( if err != nil { return err } + moduleConfigs := moduleConfigSet.ModuleConfigs() moduleFileSetBuilder := bufmodulebuild.NewModuleFileSetBuilder( container.Logger(), moduleReader, ) + // TODO: this is going to be a mess when we want to remove ModuleFileSet moduleFileSets := make([]bufmodule.ModuleFileSet, len(moduleConfigs)) for i, moduleConfig := range moduleConfigs { moduleFileSet, err := moduleFileSetBuilder.Build( ctx, moduleConfig.Module(), - bufmodulebuild.WithWorkspace(moduleConfig.Workspace()), + bufmodulebuild.WithWorkspace(moduleConfigSet.Workspace()), ) if err != nil { return err @@ -205,7 +207,7 @@ func run( // We gate on flags.ExcludeImports/buffetch.ProtoFileRef so that we don't waste time building if the // result of the build is not relevant. if !flags.ExcludeImports { - imageBuilder := bufimagebuild.NewBuilder(container.Logger()) + imageBuilder := bufimagebuild.NewBuilder(container.Logger(), moduleReader) for _, moduleFileSet := range moduleFileSets { targetFileInfos, err := moduleFileSet.TargetFileInfos(ctx) if err != nil { diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/format/format.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/format/format.go index c6ab28eda..92d0cfe65 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/format/format.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/format/format.go @@ -80,16 +80,16 @@ Most people will want to rewrite the files defined in the current directory in-p Display a diff between the original and formatted content with -d Write a diff instead of the formatted file: - + $ buf format simple/simple.proto -d - + $ diff -u simple/simple.proto.orig simple/simple.proto --- simple/simple.proto.orig 2022-03-24 09:44:10.000000000 -0700 +++ simple/simple.proto 2022-03-24 09:44:10.000000000 -0700 @@ -2,8 +2,7 @@ - + package simple; - + - message Object { - string key = 1; @@ -106,13 +106,13 @@ Use the --exit-code flag to exit with a non-zero exit code if there is a diff: Format a file, directory, or module reference by specifying a source e.g. Write the formatted file to stdout: - + $ buf format simple/simple.proto - + syntax = "proto3"; - + package simple; - + message Object { string key = 1; bytes value = 2; @@ -285,7 +285,7 @@ func run( if err != nil { return err } - moduleConfigs, err := moduleConfigReader.GetModuleConfigs( + moduleConfigSet, err := moduleConfigReader.GetModuleConfigSet( ctx, container, sourceOrModuleRef, @@ -297,6 +297,7 @@ func run( if err != nil { return err } + moduleConfigs := moduleConfigSet.ModuleConfigs() var outputDirectory string var singleFileOutputFilename string if flags.Output != "-" { diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modprune/modprune.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modprune/modprune.go index 95d91b2c0..a0c72de17 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modprune/modprune.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modprune/modprune.go @@ -81,15 +81,6 @@ func run( if err != nil { return err } - remote := bufconnect.DefaultRemote - if config.ModuleIdentity != nil && config.ModuleIdentity.Remote() != "" { - remote = config.ModuleIdentity.Remote() - } - clientConfig, err := bufcli.NewConnectClientConfig(container) - if err != nil { - return err - } - service := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewResolveServiceClient) module, err := bufmodule.NewModuleForBucket(ctx, readWriteBucket) if err != nil { @@ -102,6 +93,31 @@ func run( } var dependencyModulePins []bufmoduleref.ModulePin if len(requestReferences) > 0 { + var remote string + if config.ModuleIdentity != nil && config.ModuleIdentity.Remote() != "" { + remote = config.ModuleIdentity.Remote() + } else { + // At this point we know there's at least one dependency. If it's an unnamed module, select + // the right remote from the list of dependencies. + selectedRef := bufcli.SelectReferenceForRemote(config.Build.DependencyModuleReferences) + if selectedRef == nil { + return fmt.Errorf(`File %q has invalid "deps" references`, existingConfigFilePath) + } + remote = selectedRef.Remote() + container.Logger().Debug(fmt.Sprintf( + `File %q does not specify the "name" field. Based on the dependency %q, it appears that you are using a BSR instance at %q. Did you mean to specify "name: %s/..." within %q?`, + existingConfigFilePath, + selectedRef.IdentityString(), + remote, + remote, + existingConfigFilePath, + )) + } + clientConfig, err := bufcli.NewConnectClientConfig(container) + if err != nil { + return err + } + service := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewResolveServiceClient) resp, err := service.GetModulePins( ctx, connect.NewRequest(®istryv1alpha1.GetModulePinsRequest{ diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modupdate/modupdate.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modupdate/modupdate.go index aee6d31a2..dcee8259f 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modupdate/modupdate.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modupdate/modupdate.go @@ -111,32 +111,13 @@ func run( return err } - remote := bufconnect.DefaultRemote - if moduleConfig.ModuleIdentity != nil && moduleConfig.ModuleIdentity.Remote() != "" { - remote = moduleConfig.ModuleIdentity.Remote() - } else { - for _, moduleReference := range moduleConfig.Build.DependencyModuleReferences { - if moduleReference.Remote() != bufconnect.DefaultRemote { - warnMsg := fmt.Sprintf( - `%q does not specify a "name", so Buf is defaulting to using remote %q for dependency resolution. This remote may be unable to resolve %q if it's an enterprise BSR module. Did you mean to specify a "name: %s/..." on this module?`, - existingConfigFilePath, - bufconnect.DefaultRemote, - moduleReference.IdentityString(), - moduleReference.Remote(), - ) - container.Logger().Warn(warnMsg) - break - } - } - } - pinnedRepositories, err := getDependencies( ctx, container, flags, - remote, moduleConfig, readWriteBucket, + existingConfigFilePath, ) if err != nil { return err @@ -178,9 +159,9 @@ func getDependencies( ctx context.Context, container appflag.Container, flags *flags, - remote string, moduleConfig *bufconfig.Config, readWriteBucket storage.ReadWriteBucket, + existingConfigFilePath string, ) ([]*pinnedRepository, error) { if len(moduleConfig.Build.DependencyModuleReferences) == 0 { return nil, nil @@ -189,6 +170,26 @@ func getDependencies( if err != nil { return nil, err } + var remote string + if moduleConfig.ModuleIdentity != nil && moduleConfig.ModuleIdentity.Remote() != "" { + remote = moduleConfig.ModuleIdentity.Remote() + } else { + // At this point we know there's at least one dependency. If it's an unnamed module, select + // the right remote from the list of dependencies. + selectedRef := bufcli.SelectReferenceForRemote(moduleConfig.Build.DependencyModuleReferences) + if selectedRef == nil { + return nil, fmt.Errorf(`File %q has invalid "deps" references`, existingConfigFilePath) + } + remote = selectedRef.Remote() + container.Logger().Debug(fmt.Sprintf( + `File %q does not specify the "name" field. Based on the dependency %q, it appears that you are using a BSR instance at %q. Did you mean to specify "name: %s/..." within %q?`, + existingConfigFilePath, + selectedRef.IdentityString(), + remote, + remote, + existingConfigFilePath, + )) + } service := connectclient.Make(clientConfig, remote, registryv1alpha1connect.NewResolveServiceClient) var protoDependencyModuleReferences []*modulev1alpha1.ModuleReference var currentProtoModulePins []*modulev1alpha1.ModulePin diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/push/push.go b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/push/push.go index fd475bb22..151102d54 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/push/push.go +++ b/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/push/push.go @@ -22,7 +22,6 @@ import ( "github.com/bufbuild/buf/private/buf/bufcli" "github.com/bufbuild/buf/private/bufpkg/bufanalysis" "github.com/bufbuild/buf/private/bufpkg/bufmanifest" - "github.com/bufbuild/buf/private/bufpkg/bufmodule" "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild" "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" @@ -39,11 +38,13 @@ import ( ) const ( - tagFlagName = "tag" - tagFlagShortName = "t" - draftFlagName = "draft" - errorFormatFlagName = "error-format" - disableSymlinksFlagName = "disable-symlinks" + tagFlagName = "tag" + tagFlagShortName = "t" + draftFlagName = "draft" + errorFormatFlagName = "error-format" + disableSymlinksFlagName = "disable-symlinks" + createFlagName = "create" + createVisibilityFlagName = "create-visibility" // deprecated trackFlagName = "track" ) @@ -70,10 +71,12 @@ func NewCommand( } type flags struct { - Tags []string - Draft string - ErrorFormat string - DisableSymlinks bool + Tags []string + Draft string + ErrorFormat string + DisableSymlinks bool + Create bool + CreateVisibility string // Deprecated Tracks []string // special @@ -87,6 +90,7 @@ func newFlags() *flags { func (f *flags) Bind(flagSet *pflag.FlagSet) { bufcli.BindInputHashtag(flagSet, &f.InputHashtag) bufcli.BindDisableSymlinks(flagSet, &f.DisableSymlinks, disableSymlinksFlagName) + bufcli.BindCreateVisibility(flagSet, &f.CreateVisibility, createVisibilityFlagName, createFlagName) flagSet.StringSliceVarP( &f.Tags, tagFlagName, @@ -116,6 +120,12 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) { stringutil.SliceToString(bufanalysis.AllFormatStrings), ), ) + flagSet.BoolVar( + &f.Create, + createFlagName, + false, + fmt.Sprintf("Create the repository if it does not exist. Must set a visibility using --%s", createVisibilityFlagName), + ) flagSet.StringSliceVar( &f.Tracks, trackFlagName, @@ -139,6 +149,18 @@ func run( if len(flags.Tags) > 0 && flags.Draft != "" { return appcmd.NewInvalidArgumentErrorf("--%s (-%s) and --%s cannot be used together.", tagFlagName, tagFlagShortName, draftFlagName) } + if flags.CreateVisibility != "" { + if !flags.Create { + return appcmd.NewInvalidArgumentErrorf("Cannot set --%s without --%s.", createVisibilityFlagName, createFlagName) + } + // We re-parse below as needed, but do not return an appcmd.NewInvalidArgumentError below as + // we expect validation to be handled here. + if _, err := bufcli.VisibilityFlagToVisibility(flags.CreateVisibility); err != nil { + return appcmd.NewInvalidArgumentError(err.Error()) + } + } else if flags.Create { + return appcmd.NewInvalidArgumentErrorf("--%s is required if --%s is set.", createVisibilityFlagName, createFlagName) + } source, err := bufcli.GetInputValue(container, flags.InputHashtag, ".") if err != nil { return err @@ -159,7 +181,7 @@ func run( return err } moduleIdentity := sourceConfig.ModuleIdentity - builtModule, err := bufmodulebuild.BuildForBucket( + builtModule, err := bufmodulebuild.NewModuleBucketBuilder().BuildForBucket( ctx, sourceBucket, sourceConfig.Build, @@ -167,7 +189,7 @@ func run( if err != nil { return err } - modulePin, err := push(ctx, container, moduleIdentity, builtModule, flags) + modulePin, err := pushOrCreate(ctx, container, moduleIdentity, builtModule, flags) if err != nil { if connect.CodeOf(err) == connect.CodeAlreadyExists { if _, err := container.Stderr().Write( @@ -188,7 +210,7 @@ func run( return nil } -func push( +func pushOrCreate( ctx context.Context, container appflag.Container, moduleIdentity bufmoduleref.ModuleIdentity, @@ -199,48 +221,49 @@ func push( if err != nil { return nil, err } - service := connectclient.Make(clientConfig, moduleIdentity.Remote(), registryv1alpha1connect.NewPushServiceClient) - // Check if tamper proofing env var is enabled - tamperProofingEnabled, err := bufcli.IsBetaTamperProofingEnabled(container) + modulePin, err := push(ctx, container, clientConfig, moduleIdentity, builtModule, flags) if err != nil { + // We rely on Push* returning a NotFound error to denote the repository is not created. + // This technically could be a NotFound error for some other entity than the repository + // in question, however if it is, then this Create call will just fail as the repository + // is already created, and there is no side effect. The 99% case is that a NotFound + // error is because the repository does not exist, and we want to avoid having to do + // a GetRepository RPC call for every call to push --create. + if flags.Create && connect.CodeOf(err) == connect.CodeNotFound { + if err := create(ctx, container, clientConfig, moduleIdentity, flags); err != nil { + return nil, err + } + return push(ctx, container, clientConfig, moduleIdentity, builtModule, flags) + } return nil, err } - if tamperProofingEnabled { - m, blobSet, err := manifest.NewFromBucket(ctx, builtModule.Bucket) - if err != nil { - return nil, err - } - bucketManifest, blobs, err := bufmanifest.ToProtoManifestAndBlobs(ctx, m, blobSet) - if err != nil { - return nil, err - } - resp, err := service.PushManifestAndBlobs( - ctx, - connect.NewRequest(®istryv1alpha1.PushManifestAndBlobsRequest{ - Owner: moduleIdentity.Owner(), - Repository: moduleIdentity.Repository(), - Manifest: bucketManifest, - Blobs: blobs, - Tags: flags.Tags, - DraftName: flags.Draft, - }), - ) - if err != nil { - return nil, err - } - return resp.Msg.LocalModulePin, nil + return modulePin, nil +} + +func push( + ctx context.Context, + container appflag.Container, + clientConfig *connectclient.Config, + moduleIdentity bufmoduleref.ModuleIdentity, + builtModule *bufmodulebuild.BuiltModule, + flags *flags, +) (*registryv1alpha1.LocalModulePin, error) { + service := connectclient.Make(clientConfig, moduleIdentity.Remote(), registryv1alpha1connect.NewPushServiceClient) + m, blobSet, err := manifest.NewFromBucket(ctx, builtModule.Bucket) + if err != nil { + return nil, err } - // Fall back to previous push call - protoModule, err := bufmodule.ModuleToProtoModule(ctx, builtModule.Module) + bucketManifest, blobs, err := bufmanifest.ToProtoManifestAndBlobs(ctx, m, blobSet) if err != nil { return nil, err } - resp, err := service.Push( + resp, err := service.PushManifestAndBlobs( ctx, - connect.NewRequest(®istryv1alpha1.PushRequest{ + connect.NewRequest(®istryv1alpha1.PushManifestAndBlobsRequest{ Owner: moduleIdentity.Owner(), Repository: moduleIdentity.Repository(), - Module: protoModule, + Manifest: bucketManifest, + Blobs: blobs, Tags: flags.Tags, DraftName: flags.Draft, }), @@ -250,3 +273,29 @@ func push( } return resp.Msg.LocalModulePin, nil } + +func create( + ctx context.Context, + container appflag.Container, + clientConfig *connectclient.Config, + moduleIdentity bufmoduleref.ModuleIdentity, + flags *flags, +) error { + service := connectclient.Make(clientConfig, moduleIdentity.Remote(), registryv1alpha1connect.NewRepositoryServiceClient) + visiblity, err := bufcli.VisibilityFlagToVisibility(flags.CreateVisibility) + if err != nil { + return err + } + fullName := moduleIdentity.Owner() + "/" + moduleIdentity.Repository() + _, err = service.CreateRepositoryByFullName( + ctx, + connect.NewRequest(®istryv1alpha1.CreateRepositoryByFullNameRequest{ + FullName: fullName, + Visibility: visiblity, + }), + ) + if err != nil && connect.CodeOf(err) == connect.CodeAlreadyExists { + return connect.NewError(connect.CodeInternal, fmt.Errorf("Expected repository %s to be missing but found the repository to already exist", fullName)) + } + return err +} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufanalysis/bufanalysis.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufanalysis/bufanalysis.go index a3667ec0f..ed6bae1e6 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufanalysis/bufanalysis.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufanalysis/bufanalysis.go @@ -32,6 +32,10 @@ const ( FormatMSVS // FormatJUnit is the JUnit format for FileAnnotations. FormatJUnit + // FormatGithubActions is the Github Actions format for FileAnnotations. + // + // See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message. + FormatGithubActions ) var ( @@ -43,6 +47,7 @@ var ( "json", "msvs", "junit", + "github-actions", } // AllFormatStringsWithAliases is all format strings with aliases. // @@ -53,21 +58,24 @@ var ( "json", "msvs", "junit", + "github-actions", } stringToFormat = map[string]Format{ "text": FormatText, // alias for text - "gcc": FormatText, - "json": FormatJSON, - "msvs": FormatMSVS, - "junit": FormatJUnit, + "gcc": FormatText, + "json": FormatJSON, + "msvs": FormatMSVS, + "junit": FormatJUnit, + "github-actions": FormatGithubActions, } formatToString = map[Format]string{ - FormatText: "text", - FormatJSON: "json", - FormatMSVS: "msvs", - FormatJUnit: "junit", + FormatText: "text", + FormatJSON: "json", + FormatMSVS: "msvs", + FormatJUnit: "junit", + FormatGithubActions: "github-actions", } ) @@ -209,6 +217,8 @@ func PrintFileAnnotations(writer io.Writer, fileAnnotations []FileAnnotation, fo return printAsMSVS(writer, fileAnnotations) case FormatJUnit: return printAsJUnit(writer, fileAnnotations) + case FormatGithubActions: + return printAsGithubActions(writer, fileAnnotations) default: return fmt.Errorf("unknown FileAnnotation Format: %v", format) } diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufanalysis/print.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufanalysis/print.go index f625b9c31..3f837fd86 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufanalysis/print.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufanalysis/print.go @@ -48,6 +48,14 @@ func printAsJSON(writer io.Writer, fileAnnotations []FileAnnotation) error { ) } +func printAsGithubActions(writer io.Writer, fileAnnotations []FileAnnotation) error { + return printEachAnnotationOnNewLine( + writer, + fileAnnotations, + printFileAnnotationAsGithubActions, + ) +} + func printAsJUnit(writer io.Writer, fileAnnotations []FileAnnotation) error { encoder := xml.NewEncoder(writer) encoder.Indent("", " ") @@ -198,6 +206,49 @@ func printFileAnnotationAsJSON(buffer *bytes.Buffer, f FileAnnotation) error { return nil } +func printFileAnnotationAsGithubActions(buffer *bytes.Buffer, f FileAnnotation) error { + if f == nil { + return nil + } + _, _ = buffer.WriteString("::error ") + + // file= is required for GitHub Actions, however it is possible to not have + // a path for a FileAnnotation. We still print something, however we need + // to test what happens in GitHub Actions if no valid path is printed out. + path := "" + if f.FileInfo() != nil { + path = f.FileInfo().ExternalPath() + } + _, _ = buffer.WriteString("file=") + _, _ = buffer.WriteString(path) + + // Everything else is optional. + if startLine := f.StartLine(); startLine > 0 { + _, _ = buffer.WriteString(",line=") + _, _ = buffer.WriteString(strconv.Itoa(startLine)) + // We only print column information if we have line information. + if startColumn := f.StartColumn(); startColumn > 0 { + _, _ = buffer.WriteString(",col=") + _, _ = buffer.WriteString(strconv.Itoa(startColumn)) + } + // We only do any ending line information if we have starting line information + if endLine := f.EndLine(); endLine > 0 { + _, _ = buffer.WriteString(",endLine=") + _, _ = buffer.WriteString(strconv.Itoa(endLine)) + // We only print column information if we have line information. + if endColumn := f.EndColumn(); endColumn > 0 { + // Yes, the spec has "col" for start and "endColumn" for end. + _, _ = buffer.WriteString(",endColumn=") + _, _ = buffer.WriteString(strconv.Itoa(endColumn)) + } + } + } + + _, _ = buffer.WriteString("::") + _, _ = buffer.WriteString(f.Message()) + return nil +} + type externalFileAnnotation struct { Path string `json:"path,omitempty" yaml:"path,omitempty"` StartLine int `json:"start_line,omitempty" yaml:"start_line,omitempty"` diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/bufapimodule.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/bufapimodule.go index 0d6860559..42c2c254f 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/bufapimodule.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/bufapimodule.go @@ -51,13 +51,6 @@ func NewModuleReader( // ModuleReaderOption allows configuration of a module reader. type ModuleReaderOption func(reader *moduleReader) -// WithTamperProofing enables tamper proofing support (use of manifest/blobs). -func WithTamperProofing() ModuleReaderOption { - return func(reader *moduleReader) { - reader.tamperProofingEnabled = true - } -} - // NewModuleResolver returns a new ModuleResolver backed by the resolve service. func NewModuleResolver( logger *zap.Logger, diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/module_reader.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/module_reader.go index b9b0dac42..34cd9359b 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/module_reader.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/module_reader.go @@ -28,7 +28,6 @@ import ( type moduleReader struct { downloadClientFactory DownloadServiceClientFactory - tamperProofingEnabled bool } func newModuleReader( @@ -58,57 +57,23 @@ func (m *moduleReader) GetModule(ctx context.Context, modulePin bufmoduleref.Mod moduleIdentity, modulePin.Commit(), ) - if m.tamperProofingEnabled { - resp, err := m.downloadManifestAndBlobs(ctx, modulePin) - if err != nil { - return nil, err - } - if resp.Manifest == nil { - return nil, errors.New("expected non-nil manifest with tamper proofing enabled") - } - // use manifest and blobs - moduleManifest, err := bufmanifest.NewManifestFromProto(ctx, resp.Manifest) - if err != nil { - return nil, err - } - blobSet, err := bufmanifest.NewBlobSetFromProto(ctx, resp.Blobs) - if err != nil { - return nil, err - } - return bufmodule.NewModuleForManifestAndBlobSet(ctx, moduleManifest, blobSet) - } - resp, err := m.download(ctx, modulePin) + resp, err := m.downloadManifestAndBlobs(ctx, modulePin) if err != nil { return nil, err } - if resp.Module == nil { - // funny, success without a module to build - return nil, errors.New("no module in response") + if resp.Manifest == nil { + return nil, errors.New("expected non-nil manifest") } - return bufmodule.NewModuleForProto(ctx, resp.Module, identityAndCommitOpt) -} - -func (m *moduleReader) download( - ctx context.Context, - modulePin bufmoduleref.ModulePin, -) (*registryv1alpha1.DownloadResponse, error) { - downloadService := m.downloadClientFactory(modulePin.Remote()) - resp, err := downloadService.Download( - ctx, - connect.NewRequest(®istryv1alpha1.DownloadRequest{ - Owner: modulePin.Owner(), - Repository: modulePin.Repository(), - Reference: modulePin.Commit(), - }), - ) + // use manifest and blobs + moduleManifest, err := bufmanifest.NewManifestFromProto(ctx, resp.Manifest) if err != nil { - if connect.CodeOf(err) == connect.CodeNotFound { - // Required by ModuleReader interface spec - return nil, storage.NewErrNotExist(modulePin.String()) - } return nil, err } - return resp.Msg, err + blobSet, err := bufmanifest.NewBlobSetFromProto(ctx, resp.Blobs) + if err != nil { + return nil, err + } + return bufmodule.NewModuleForManifestAndBlobSet(ctx, moduleManifest, blobSet, identityAndCommitOpt) } func (m *moduleReader) downloadManifestAndBlobs( diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/module_resolver.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/module_resolver.go index 749780a41..311283265 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/module_resolver.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufapimodule/module_resolver.go @@ -66,7 +66,7 @@ func (m *moduleResolver) GetModulePin(ctx context.Context, moduleReference bufmo moduleReference.Repository(), "", // branch resp.Msg.RepositoryCommit.Name, - resp.Msg.RepositoryCommit.Digest, + resp.Msg.RepositoryCommit.ManifestDigest, resp.Msg.RepositoryCommit.CreateTime.AsTime(), ) } diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufconnect/bufconnect.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufconnect/bufconnect.go index f4ae8b459..3b2e994ff 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufconnect/bufconnect.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufconnect/bufconnect.go @@ -24,6 +24,9 @@ const ( AuthenticationTokenPrefix = "Bearer " // CliVersionHeaderName is the name of the header carrying the buf CLI version. CliVersionHeaderName = "buf-version" + // CLIWarningHeaderName is the name of the header carrying a base64-encoded warning message + // from the server to the CLI. + CLIWarningHeaderName = "buf-warning-bin" // DefaultRemote is the default remote if none can be inferred from a module name. DefaultRemote = "buf.build" ) diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufconnect/interceptors.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufconnect/interceptors.go index f76237cf5..505630065 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufconnect/interceptors.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufconnect/interceptors.go @@ -16,7 +16,11 @@ package bufconnect import ( "context" + "errors" + "fmt" + "net/http" + "github.com/bufbuild/buf/private/pkg/app/applog" "github.com/bufbuild/connect-go" ) @@ -28,10 +32,7 @@ const ( // NewSetCLIVersionInterceptor returns a new Connect Interceptor that sets the Buf CLI version into all request headers func NewSetCLIVersionInterceptor(version string) connect.UnaryInterceptorFunc { interceptor := func(next connect.UnaryFunc) connect.UnaryFunc { - return func( - ctx context.Context, - req connect.AnyRequest, - ) (connect.AnyResponse, error) { + return func(ctx context.Context, req connect.AnyRequest) (connect.AnyResponse, error) { req.Header().Set(CliVersionHeaderName, version) return next(ctx, req) } @@ -39,6 +40,38 @@ func NewSetCLIVersionInterceptor(version string) connect.UnaryInterceptorFunc { return interceptor } +// NewCLIWarningInterceptor returns a new Connect Interceptor that logs CLI warnings returned by server responses. +func NewCLIWarningInterceptor(container applog.Container) connect.UnaryInterceptorFunc { + interceptor := func(next connect.UnaryFunc) connect.UnaryFunc { + return func(ctx context.Context, req connect.AnyRequest) (connect.AnyResponse, error) { + resp, err := next(ctx, req) + if resp != nil { + logWarningFromHeader(container, resp.Header()) + } else if err != nil { + if connectErr := new(connect.Error); errors.As(err, &connectErr) { + logWarningFromHeader(container, connectErr.Meta()) + } + } + return resp, err + } + } + return interceptor +} + +func logWarningFromHeader(container applog.Container, header http.Header) { + encoded := header.Get(CLIWarningHeaderName) + if encoded != "" { + warning, err := connect.DecodeBinaryHeader(encoded) + if err != nil { + container.Logger().Debug(fmt.Errorf("failed to decode warning header: %w", err).Error()) + return + } + if len(warning) > 0 { + container.Logger().Warn(string(warning)) + } + } +} + // TokenProvider finds the token for NewAuthorizationInterceptorProvider. type TokenProvider interface { // RemoteToken returns the remote token from the remote address. @@ -55,10 +88,7 @@ type TokenProvider interface { func NewAuthorizationInterceptorProvider(tokenProviders ...TokenProvider) func(string) connect.UnaryInterceptorFunc { return func(address string) connect.UnaryInterceptorFunc { interceptor := func(next connect.UnaryFunc) connect.UnaryFunc { - return connect.UnaryFunc(func( - ctx context.Context, - req connect.AnyRequest, - ) (connect.AnyResponse, error) { + return connect.UnaryFunc(func(ctx context.Context, req connect.AnyRequest) (connect.AnyResponse, error) { usingTokenEnvKey := false for _, tf := range tokenProviders { if token := tf.RemoteToken(address); token != "" { diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/bufgraph.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/bufgraph.go new file mode 100644 index 000000000..851134172 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/bufgraph.go @@ -0,0 +1,88 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 bufgraph + +import ( + "context" + + "github.com/bufbuild/buf/private/bufpkg/bufanalysis" + "github.com/bufbuild/buf/private/bufpkg/bufmodule" + "github.com/bufbuild/buf/private/pkg/dag" + "go.uber.org/zap" +) + +// Node is a node in a dependency graph. +// +// This is a struct because this needs to be comparable for the *dag.Graph. +// +// TODO: Don't have the duplication across Node and ImageModuleDependency. +type Node struct { + // Required, + Remote string + // Required. + Owner string + // Required. + Repository string + // Optional. Will not bet set for modules read from workspaces. + Commit string +} + +// IdentityString prints remote/owner/repository. +func (n *Node) IdentityString() string { + return n.Remote + "/" + n.Owner + "/" + n.Repository +} + +// String prints remote/owner/repository[:commit]. +func (n *Node) String() string { + s := n.IdentityString() + if n.Commit != "" { + return s + ":" + n.Commit + } + return s +} + +// Builder builds dependency graphs. +type Builder interface { + // Build builds the dependency graph. + Build( + ctx context.Context, + modules []bufmodule.Module, + options ...BuildOption, + ) (*dag.Graph[Node], []bufanalysis.FileAnnotation, error) +} + +// NewBuilder returns a new Builder. +func NewBuilder( + logger *zap.Logger, + moduleResolver bufmodule.ModuleResolver, + moduleReader bufmodule.ModuleReader, +) Builder { + return newBuilder( + logger, + moduleResolver, + moduleReader, + ) +} + +// BuildOption is an option for Build. +type BuildOption func(*buildOptions) + +// BuildWithWorkspace returns a new BuildOption that specifies a workspace +// that is being operated on. +func BuildWithWorkspace(workspace bufmodule.Workspace) BuildOption { + return func(buildOptions *buildOptions) { + buildOptions.workspace = workspace + } +} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/builder.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/builder.go new file mode 100644 index 000000000..c5168102f --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/builder.go @@ -0,0 +1,226 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 bufgraph + +import ( + "context" + "fmt" + + "github.com/bufbuild/buf/private/bufpkg/bufanalysis" + "github.com/bufbuild/buf/private/bufpkg/bufimage" + "github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagebuild" + "github.com/bufbuild/buf/private/bufpkg/bufmodule" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/pkg/dag" + "go.uber.org/zap" +) + +type builder struct { + logger *zap.Logger + moduleResolver bufmodule.ModuleResolver + moduleReader bufmodule.ModuleReader + imageBuilder bufimagebuild.Builder +} + +func newBuilder( + logger *zap.Logger, + moduleResolver bufmodule.ModuleResolver, + moduleReader bufmodule.ModuleReader, +) *builder { + return &builder{ + logger: logger, + moduleResolver: moduleResolver, + moduleReader: moduleReader, + imageBuilder: bufimagebuild.NewBuilder( + logger, + moduleReader, + ), + } +} + +func (b *builder) Build( + ctx context.Context, + modules []bufmodule.Module, + options ...BuildOption, +) (*dag.Graph[Node], []bufanalysis.FileAnnotation, error) { + buildOptions := newBuildOptions() + for _, option := range options { + option(buildOptions) + } + return b.build( + ctx, + modules, + buildOptions.workspace, + ) +} + +func (b *builder) build( + ctx context.Context, + modules []bufmodule.Module, + workspace bufmodule.Workspace, +) (*dag.Graph[Node], []bufanalysis.FileAnnotation, error) { + graph := dag.NewGraph[Node]() + alreadyProcessedNodes := make(map[Node]struct{}) + for _, module := range modules { + fileAnnotations, err := b.buildForModule( + ctx, + module, + newNodeForModule(module), + workspace, + graph, + alreadyProcessedNodes, + ) + if err != nil { + return nil, nil, err + } + if len(fileAnnotations) > 0 { + return nil, fileAnnotations, nil + } + } + return graph, nil, nil +} + +func (b *builder) buildForModule( + ctx context.Context, + module bufmodule.Module, + node Node, + workspace bufmodule.Workspace, + graph *dag.Graph[Node], + alreadyProcessedNodes map[Node]struct{}, +) ([]bufanalysis.FileAnnotation, error) { + // We can't rely on the existence of a node in the graph for this, as when we add an edge + // to the graph, the node is added, and we still need to process the node as a potential + // source node. + if _, ok := alreadyProcessedNodes[node]; ok { + return nil, nil + } + alreadyProcessedNodes[node] = struct{}{} + graph.AddNode(node) + image, fileAnnotations, err := b.imageBuilder.Build( + ctx, + module, + bufimagebuild.WithWorkspace(workspace), + bufimagebuild.WithExpectedDirectDependencies(module.DeclaredDirectDependencies()), + ) + if err != nil { + return nil, err + } + if len(fileAnnotations) > 0 { + return fileAnnotations, nil + } + for _, imageModuleDependency := range bufimage.ImageModuleDependencies(image) { + dependencyNode := newNodeForImageModuleDependency(imageModuleDependency) + if imageModuleDependency.IsDirect() { + graph.AddEdge(node, dependencyNode) + } + dependencyModule, err := b.getModuleForImageModuleDependency( + ctx, + imageModuleDependency, + workspace, + ) + if err != nil { + return nil, err + } + // TODO: deal with the case where there are differing commits for a given ModuleIdentity. + fileAnnotations, err := b.buildForModule( + ctx, + dependencyModule, + dependencyNode, + workspace, + graph, + alreadyProcessedNodes, + ) + if err != nil { + return nil, err + } + if len(fileAnnotations) > 0 { + return fileAnnotations, nil + } + } + return nil, nil +} + +func (b *builder) getModuleForImageModuleDependency( + ctx context.Context, + imageModuleDependency bufimage.ImageModuleDependency, + workspace bufmodule.Workspace, +) (bufmodule.Module, error) { + moduleIdentity := imageModuleDependency.ModuleIdentity() + commit := imageModuleDependency.Commit() + if workspace != nil { + module, ok := workspace.GetModule(moduleIdentity) + if ok { + return module, nil + } + } + if commit == "" { + // TODO: can we error here? The only + // case we should likely not have a commit is when we are using a workspace. + // There's no enforcement of this property, so erroring here is a bit weird, + // but it might be better to check our assumptions and figure out if there + // are exceptions after the fact, as opposed to resolving a ModulePin for + // main when we don't know if main is what we want. + return nil, fmt.Errorf("had ModuleIdentity %v with no associated commit, but did not have the module in a workspace", moduleIdentity) + } + moduleReference, err := bufmoduleref.NewModuleReference( + moduleIdentity.Remote(), + moduleIdentity.Owner(), + moduleIdentity.Repository(), + commit, + ) + if err != nil { + return nil, err + } + modulePin, err := b.moduleResolver.GetModulePin( + ctx, + moduleReference, + ) + if err != nil { + return nil, err + } + return b.moduleReader.GetModule( + ctx, + modulePin, + ) +} + +func newNodeForImageModuleDependency(imageModuleDependency bufimage.ImageModuleDependency) Node { + return Node{ + Remote: imageModuleDependency.ModuleIdentity().Remote(), + Owner: imageModuleDependency.ModuleIdentity().Owner(), + Repository: imageModuleDependency.ModuleIdentity().Repository(), + Commit: imageModuleDependency.Commit(), + } +} + +func newNodeForModule(module bufmodule.Module) Node { + // TODO: deal with unnamed Modules + var node Node + if moduleIdentity := module.ModuleIdentity(); moduleIdentity != nil { + node.Remote = moduleIdentity.Remote() + node.Owner = moduleIdentity.Owner() + node.Repository = moduleIdentity.Repository() + node.Commit = module.Commit() + } + return node +} + +type buildOptions struct { + workspace bufmodule.Workspace +} + +func newBuildOptions() *buildOptions { + return &buildOptions{} +} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/usage.gen.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/usage.gen.go new file mode 100644 index 000000000..e9c1d1b31 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufgraph/usage.gen.go @@ -0,0 +1,19 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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. + +// Generated. DO NOT EDIT. + +package bufgraph + +import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimage.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimage.go index 24edb1d8d..f97085b08 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimage.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimage.go @@ -87,6 +87,9 @@ type Image interface { // // This contains all files, including imports if available. // The returned files are in correct DAG order. + // + // All files that have the same ModuleIdentity will also have the same commit, or no commit. + // This is enforced at construction time. Files() []ImageFile // GetFile gets the file for the root relative file path. // @@ -467,6 +470,98 @@ func ProtoImageToFileDescriptors(protoImage *imagev1.Image) []protodescriptor.Fi return protoImageFilesToFileDescriptors(protoImage.File) } +// ImageDependency is a dependency of an image. +// +// This could conceivably be part of ImageFile or bufmoduleref.FileInfo. +// For ImageFile, this would be a field that is ignored when translated to proto, +// and is calculated on creation from proto. IsImport would become ImportType. +// You could go a step further and make this optionally part of the proto definition. +// +// You could even go down to bufmoduleref.FileInfo if you used the AST, but this +// could be error prone. +// +// However, for simplicity now (and to not rewrite the whole codebase), we make +// this a separate type that is calculated off of an Image after the fact. +// +// If this became part of ImageFile or bufmoduleref.FileInfo, you would get +// all the ImageDependencies from the ImageFiles, and then sort | uniq them +// to get the ImageDependencies for an Image. This would remove the requirement +// of this associated type to have a ModuleIdentity and commit, so in +// the IsDirect example below, d.proto would not be "ignored" - it would +// be an ImageFile like any other, with ImportType DIRECT. +// +// Note that if we ever do this, there is validation in newImage that enforces +// that all ImageFiles with the same ModuleIdentity have the same commit. This +// validation will likely have to be moved around. +type ImageModuleDependency interface { + // String() returns remote/owner/repository[:commit]. + fmt.Stringer + + // Required. Will never be nil. + ModuleIdentity() bufmoduleref.ModuleIdentity + // Optional. May be empty. + Commit() string + + // IsDirect returns true if the dependency is a direct dependency. + // + // A dependency is direct if it is only an import of non-imports in the image. + // + // Example: + // + // a.proto, module buf.build/foo/a, is non-import, imports b.proto + // b.proto, module buf.build/foo/b, is import, imports c.proto + // c.proto, module buf.build/foo/c, is import + // + // In this case, the list would contain only buf.build/foo/b, as buf.build/foo/a + // for a.proto is a non-import, and buf.build/foo/c for c.proto is only imported + // by an import + IsDirect() bool + + isImageModuleDependency() +} + +// ImageModuleDependency returns all ImageModuleDependencies for the Image. +// +// Does not return any ImageModuleDependencies for non-imports, that is the +// ModuleIdentities and commits represented by non-imports are not represented +// in this list. +func ImageModuleDependencies(image Image) []ImageModuleDependency { + importsOfNonImports := make(map[string]struct{}) + for _, imageFile := range image.Files() { + if !imageFile.IsImport() { + for _, dependency := range imageFile.FileDescriptor().GetDependency() { + importsOfNonImports[dependency] = struct{}{} + } + } + } + // We know that all ImageFiles with the same ModuleIdentity + // have the same commit or no commit, so using String() will properly identify + // unique dependencies. + stringToImageModuleDependency := make(map[string]ImageModuleDependency) + for _, imageFile := range image.Files() { + if imageFile.IsImport() { + if moduleIdentity := imageFile.ModuleIdentity(); moduleIdentity != nil { + _, isDirect := importsOfNonImports[imageFile.Path()] + imageModuleDependency := newImageModuleDependency( + moduleIdentity, + imageFile.Commit(), + isDirect, + ) + stringToImageModuleDependency[imageModuleDependency.String()] = imageModuleDependency + } + } + } + imageModuleDependencies := make([]ImageModuleDependency, 0, len(stringToImageModuleDependency)) + for _, imageModuleDependency := range stringToImageModuleDependency { + imageModuleDependencies = append( + imageModuleDependencies, + imageModuleDependency, + ) + } + sortImageModuleDependencies(imageModuleDependencies) + return imageModuleDependencies +} + type newImageForProtoOptions struct { noReparse bool computeUnusedImports bool diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagebuild/bufimagebuild.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagebuild/bufimagebuild.go index 98e87bf8f..1d4ceb882 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagebuild/bufimagebuild.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagebuild/bufimagebuild.go @@ -20,6 +20,7 @@ import ( "github.com/bufbuild/buf/private/bufpkg/bufanalysis" "github.com/bufbuild/buf/private/bufpkg/bufimage" "github.com/bufbuild/buf/private/bufpkg/bufmodule" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" "go.uber.org/zap" ) @@ -36,14 +37,14 @@ type Builder interface { // FileAnnotations will use external file paths. Build( ctx context.Context, - moduleFileSet bufmodule.ModuleFileSet, + module bufmodule.Module, options ...BuildOption, ) (bufimage.Image, []bufanalysis.FileAnnotation, error) } // NewBuilder returns a new Builder. -func NewBuilder(logger *zap.Logger) Builder { - return newBuilder(logger) +func NewBuilder(logger *zap.Logger, moduleReader bufmodule.ModuleReader) Builder { + return newBuilder(logger, moduleReader) } // BuildOption is an option for Build. @@ -55,3 +56,25 @@ func WithExcludeSourceCodeInfo() BuildOption { buildOptions.excludeSourceCodeInfo = true } } + +// WithExpectedDirectDependencies sets the module dependencies that are expected, usually because +// they are in a configuration file (buf.yaml). If the build detects that there are direct dependencies +// outside of this list, a warning will be printed. +func WithExpectedDirectDependencies(expectedDirectDependencies []bufmoduleref.ModuleReference) BuildOption { + return func(buildOptions *buildOptions) { + buildOptions.expectedDirectDependencies = expectedDirectDependencies + } +} + +// WithWorkspace sets the workspace to be read from instead of ModuleReader, and to not warn imports for. +// +// TODO: this can probably be dealt with by finding out if an ImageFile has a commit +// or not, although that is hacky, that's an implementation detail in practice, but perhaps +// we could justify it - transitive dependencies without commits don't make sense? +// +// TODO: shouldn't buf.yamls in workspaces have deps properly declared in them anyways? Why not warn? +func WithWorkspace(workspace bufmodule.Workspace) BuildOption { + return func(buildOptions *buildOptions) { + buildOptions.workspace = workspace + } +} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagebuild/builder.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagebuild/builder.go index 35583ada5..684bf3a3b 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagebuild/builder.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagebuild/builder.go @@ -22,7 +22,10 @@ import ( "github.com/bufbuild/buf/private/bufpkg/bufanalysis" "github.com/bufbuild/buf/private/bufpkg/bufimage" "github.com/bufbuild/buf/private/bufpkg/bufmodule" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild" "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleprotocompile" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/gen/data/datawkt" "github.com/bufbuild/buf/private/pkg/thread" "github.com/bufbuild/protocompile" "github.com/bufbuild/protocompile/linker" @@ -42,20 +45,25 @@ const ( ) type builder struct { - logger *zap.Logger - tracer trace.Tracer + logger *zap.Logger + moduleFileSetBuilder bufmodulebuild.ModuleFileSetBuilder + tracer trace.Tracer } -func newBuilder(logger *zap.Logger) *builder { +func newBuilder(logger *zap.Logger, moduleReader bufmodule.ModuleReader) *builder { return &builder{ logger: logger.Named(loggerName), + moduleFileSetBuilder: bufmodulebuild.NewModuleFileSetBuilder( + logger, + moduleReader, + ), tracer: otel.GetTracerProvider().Tracer(tracerName), } } func (b *builder) Build( ctx context.Context, - moduleFileSet bufmodule.ModuleFileSet, + module bufmodule.Module, options ...BuildOption, ) (bufimage.Image, []bufanalysis.FileAnnotation, error) { buildOptions := newBuildOptions() @@ -64,15 +72,19 @@ func (b *builder) Build( } return b.build( ctx, - moduleFileSet, + module, buildOptions.excludeSourceCodeInfo, + buildOptions.expectedDirectDependencies, + buildOptions.workspace, ) } func (b *builder) build( ctx context.Context, - moduleFileSet bufmodule.ModuleFileSet, + module bufmodule.Module, excludeSourceCodeInfo bool, + expectedDirectDeps []bufmoduleref.ModuleReference, + workspace bufmodule.Workspace, ) (_ bufimage.Image, _ []bufanalysis.FileAnnotation, retErr error) { ctx, span := b.tracer.Start(ctx, "build") defer span.End() @@ -83,6 +95,23 @@ func (b *builder) build( } }() + // TODO: remove this once bufmodule.ModuleFileSet is deleted or no longer inherits from Module + // We still need to handle the ModuleFileSet case for buf export, as we actually need the + // ModuleFileSet there. + moduleFileSet, ok := module.(bufmodule.ModuleFileSet) + if !ok { + // If we just had a Module, convert it to a ModuleFileSet. + var err error + moduleFileSet, err = b.moduleFileSetBuilder.Build( + ctx, + module, + bufmodulebuild.WithWorkspace(workspace), + ) + if err != nil { + return nil, nil, err + } + } + parserAccessorHandler := bufmoduleprotocompile.NewParserAccessorHandler(ctx, moduleFileSet) targetFileInfos, err := moduleFileSet.TargetFileInfos(ctx) if err != nil { @@ -125,9 +154,154 @@ func (b *builder) build( if err != nil { return nil, nil, err } + if err := b.warnInvalidImports(ctx, image, expectedDirectDeps, workspace); err != nil { + b.logger.Error("warn_invalid_imports", zap.Error(err)) + } return image, nil, nil } +// warnInvalidImports checks that all the target image files have valid imports statements that +// point to files in the local module, in a direct dependency, or in a workspace local unnamed +// module. It outputs WARN messages otherwise, one per invalid import statement. +// +// TODO: Understand this code before doing anything +// TODO: switch to use bufimage.ImageModuleDependencies +func (b *builder) warnInvalidImports( + ctx context.Context, + builtImage bufimage.Image, + expectedDirectDeps []bufmoduleref.ModuleReference, + localWorkspace bufmodule.Workspace, +) error { + if expectedDirectDeps == nil && localWorkspace == nil { + // Bail out early in case the caller didn't send explicitly send direct module dependencies nor + // workspace. TODO: We should always send direct deps, so this imports warning can always + // happen. + return nil + } + expectedDirectDepsIdentities := make(map[string]struct{}, len(expectedDirectDeps)) + for _, expectedDirectDep := range expectedDirectDeps { + expectedDirectDepsIdentities[expectedDirectDep.IdentityString()] = struct{}{} + } + workspaceIdentities := make(map[string]struct{}) + if localWorkspace != nil { + wsModules := localWorkspace.GetModules() + for _, mod := range wsModules { + if mod == nil { + b.logger.Debug("nil_module_in_workspace") + continue + } + targetFiles, err := mod.TargetFileInfos(ctx) + if err != nil { + return fmt.Errorf("workspace module target file infos: %w", err) + } + for _, file := range targetFiles { + if file.ModuleIdentity() != nil { + workspaceIdentities[file.ModuleIdentity().IdentityString()] = struct{}{} + break + } + } + } + } + b.logger.Debug( + "module_identities", + zap.Any("from_direct_dependencies", expectedDirectDepsIdentities), + zap.Any("from_workspace", workspaceIdentities), + ) + + // categorize image files into direct vs transitive dependencies + allImgFiles := make(map[string]map[string][]string) // for logging purposes only, modIdentity:filepath:imports + targetFiles := make(map[string]struct{}) // filepath + expectedDirectDepsFilesToModule := make(map[string]string) // filepath:modIdentity + workspaceFilesToModule := make(map[string]string) // filepath:modIdentity + transitiveDepsFilesToModule := make(map[string]string) // filepath:modIdentity + for _, file := range builtImage.Files() { + { // populate allImgFiles + modIdentity := "local" + if file.ModuleIdentity() != nil { + modIdentity = file.ModuleIdentity().IdentityString() + } + if _, ok := allImgFiles[modIdentity]; !ok { + allImgFiles[modIdentity] = make(map[string][]string) + } + allImgFiles[modIdentity][file.Path()] = file.FileDescriptor().GetDependency() + } + if !file.IsImport() { + targetFiles[file.Path()] = struct{}{} + continue + } + if file.ModuleIdentity() == nil { + workspaceFilesToModule[file.Path()] = "" // local workspace unnamed module + continue + } + // file is import and comes from a named module. It's either a direct dep, a workspace module, + // or a transitive dep. + modIdentity := file.ModuleIdentity().IdentityString() + if _, ok := expectedDirectDepsIdentities[modIdentity]; ok { + expectedDirectDepsFilesToModule[file.Path()] = modIdentity + } else if _, ok := workspaceIdentities[modIdentity]; ok { + workspaceFilesToModule[file.Path()] = modIdentity + } else { + transitiveDepsFilesToModule[file.Path()] = modIdentity + } + } + b.logger.Debug( + "image_files", + zap.Any("all_with_imports", allImgFiles), + zap.Any("local_target", targetFiles), + zap.Any("from_workspace", workspaceFilesToModule), + zap.Any("from_expected_direct_dependencies", expectedDirectDepsFilesToModule), + zap.Any("from_transitive_dependencies", transitiveDepsFilesToModule), + ) + + // validate import statements of target files against dependencies categorization above + for _, file := range builtImage.Files() { + if file.IsImport() { + continue // only check import statements in local files + } + // .GetDependency() returns an array of file path imports in the file descriptor + for _, importFilePath := range file.FileDescriptor().GetDependency() { + if _, ok := targetFiles[importFilePath]; ok { + continue // import comes from local + } + if _, ok := expectedDirectDepsFilesToModule[importFilePath]; ok { + continue // import comes from direct dep + } + if datawkt.Exists(importFilePath) { + continue // wkt files are shipped with protoc, and we ship them in datawkt, so it's always safe to import them + } + warnMsg := fmt.Sprintf( + "File %q imports %q, which is not found in your local files or direct dependencies", + file.Path(), importFilePath, + ) + if workspaceModule, ok := workspaceFilesToModule[importFilePath]; ok { + if workspaceModule == "" { + // If dependency comes from an unnamed module, that is probably a local dependency, and + // that module won't be pushed to the BSR. We can skip this warning. + continue + } + // If dependency comes from a named module, we _could_ skip this warning as it _might_ + // fail when pushing trying to build, but we better keep it in case it is a transitive + // dependency too, and both direct and transitive dependencies live in the same workspace. + warnMsg += fmt.Sprintf( + ", but is found in local workspace module %q. Declare dependency %q in the deps key in buf.yaml.", + workspaceModule, + workspaceModule, + ) + } else if transitiveDepModule, ok := transitiveDepsFilesToModule[importFilePath]; ok { + warnMsg += fmt.Sprintf( + ", but is found in the transitive dependency %q. Declare dependency %q in the deps key in buf.yaml.", + transitiveDepModule, + transitiveDepModule, + ) + } else { + warnMsg += ", or any of your workspace modules or transitive dependencies. Check that external imports are declared as dependencies in the deps key in buf.yaml." + } + b.logger.Warn(warnMsg) + } + } + return nil +} + func getBuildResult( ctx context.Context, parserAccessorHandler bufmoduleprotocompile.ParserAccessorHandler, @@ -465,7 +639,9 @@ func newBuildResult( } type buildOptions struct { - excludeSourceCodeInfo bool + excludeSourceCodeInfo bool + expectedDirectDependencies []bufmoduleref.ModuleReference + workspace bufmodule.Workspace } func newBuildOptions() *buildOptions { diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/bufimageutil.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/bufimageutil.go index f6d874f61..db2d06d20 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/bufimageutil.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/bufimageutil.go @@ -258,6 +258,18 @@ func ImageFilteredByTypesWithOptions(image bufimage.Image, types []string, opts imageFileDescriptor := imageFile.Proto() importsRequired := closure.imports[imageFile.Path()] + // If the file has source code info, we need to remap paths to correctly + // update this info for the elements retained after filtering. + var sourcePathRemapper *sourcePathsRemapTrie + if len(imageFileDescriptor.SourceCodeInfo.GetLocation()) > 0 { + sourcePathRemapper = &sourcePathsRemapTrie{} + } + // We track the source path as we go through the model, so that we can + // mark paths as moved or deleted. Whenever an element is deleted, any + // subsequent elements of the same type in the same scope have are "moved", + // because their index is shifted down. + basePath := make([]int32, 1, 16) + basePath[0] = fileDependencyTag // While employing // https://github.com/golang/go/wiki/SliceTricks#filter-in-place, // also keep a record of which index moved where, so we can fixup @@ -265,12 +277,16 @@ func ImageFilteredByTypesWithOptions(image bufimage.Image, types []string, opts indexFromTo := make(map[int32]int32) indexTo := 0 for indexFrom, importPath := range imageFileDescriptor.GetDependency() { + path := append(basePath, int32(indexFrom)) if _, ok := importsRequired[importPath]; ok { + sourcePathRemapper.markMoved(path, int32(indexTo)) indexFromTo[int32(indexFrom)] = int32(indexTo) imageFileDescriptor.Dependency[indexTo] = importPath indexTo++ - // delete them as we go, so we know which ones weren't in the list + // markDeleted them as we go, so we know which ones weren't in the list delete(importsRequired, importPath) + } else { + sourcePathRemapper.markDeleted(path) } } imageFileDescriptor.Dependency = imageFileDescriptor.Dependency[:indexTo] @@ -282,39 +298,93 @@ func ImageFilteredByTypesWithOptions(image bufimage.Image, types []string, opts imageFileDescriptor.Dependency = append(imageFileDescriptor.Dependency, importPath) } imageFileDescriptor.PublicDependency = nil + sourcePathRemapper.markDeleted([]int32{filePublicDependencyTag}) + basePath = basePath[:1] + basePath[0] = fileWeakDependencyTag i := 0 for _, indexFrom := range imageFileDescriptor.WeakDependency { + path := append(basePath, indexFrom) if indexTo, ok := indexFromTo[indexFrom]; ok { + sourcePathRemapper.markMoved(path, indexTo) imageFileDescriptor.WeakDependency[i] = indexTo i++ + } else { + sourcePathRemapper.markDeleted(path) } } imageFileDescriptor.WeakDependency = imageFileDescriptor.WeakDependency[:i] if _, ok := closure.completeFiles[imageFile.Path()]; !ok { // if not keeping entire file, filter contents now - imageFileDescriptor.MessageType = trimMessageDescriptors(imageFileDescriptor.MessageType, closure.elements) - imageFileDescriptor.EnumType = trimSlice(imageFileDescriptor.EnumType, closure.elements) - imageFileDescriptor.Extension = trimSlice(imageFileDescriptor.Extension, closure.elements) - imageFileDescriptor.Service = trimSlice(imageFileDescriptor.Service, closure.elements) - for _, serviceDescriptor := range imageFileDescriptor.Service { - serviceDescriptor.Method = trimSlice(serviceDescriptor.Method, closure.elements) + basePath = basePath[:0] + imageFileDescriptor.MessageType = trimMessageDescriptors(imageFileDescriptor.MessageType, closure.elements, sourcePathRemapper, append(basePath, fileMessagesTag)) + imageFileDescriptor.EnumType = trimSlice(imageFileDescriptor.EnumType, closure.elements, sourcePathRemapper, append(basePath, fileEnumsTag)) + // TODO: We could end up removing all extensions from a particular extend block + // but we then don't mark that extend block's source code info for deletion. This + // is because extend blocks don't have distinct paths -- we have to actually look + // at the span information to determine which extensions correspond to which blocks + // to decide which blocks to remove. That is possible, but non-trivial, and it's + // unclear if the "juice is worth the squeeze", so we leave it. The best we do is + // to remove comments for extend blocks when there are NO extensions. + extsPath := append(basePath, fileExtensionsTag) + imageFileDescriptor.Extension = trimSlice(imageFileDescriptor.Extension, closure.elements, sourcePathRemapper, extsPath) + if len(imageFileDescriptor.Extension) == 0 { + sourcePathRemapper.markDeleted(extsPath) } + svcsPath := append(basePath, fileServicesTag) + // We must iterate through the services *before* we trim the slice. That way the + // index we see is for the "old path", which we need to know to mark elements as + // moved or deleted with the sourcePathRemapper. + for index, serviceDescriptor := range imageFileDescriptor.Service { + if _, ok := closure.elements[serviceDescriptor]; !ok { + continue + } + methodPath := append(svcsPath, int32(index), serviceMethodsTag) + serviceDescriptor.Method = trimSlice(serviceDescriptor.Method, closure.elements, sourcePathRemapper, methodPath) + } + imageFileDescriptor.Service = trimSlice(imageFileDescriptor.Service, closure.elements, sourcePathRemapper, svcsPath) + } + + if len(imageFileDescriptor.SourceCodeInfo.GetLocation()) > 0 { + // Now the sourcePathRemapper has been fully populated for all of the deletions + // and moves above. So we can use it to reconstruct the source code info slice + // of locations. + i := 0 + for _, location := range imageFileDescriptor.SourceCodeInfo.Location { + // This function returns newPath==nil if the element at the given path + // was marked for deletion (so this location should be omitted). + newPath, noComment := sourcePathRemapper.newPath(location.Path) + if newPath != nil { + imageFileDescriptor.SourceCodeInfo.Location[i] = location + location.Path = newPath + if noComment { + location.LeadingDetachedComments = nil + location.LeadingComments = nil + location.TrailingComments = nil + } + i++ + } + } + imageFileDescriptor.SourceCodeInfo.Location = imageFileDescriptor.SourceCodeInfo.Location[:i] } - - // TODO: With some from/to mappings, perhaps even sourcecodeinfo - // isn't too bad. - imageFileDescriptor.SourceCodeInfo = nil } return bufimage.NewImage(includedFiles) } // trimMessageDescriptors removes (nested) messages and nested enums from a slice // of message descriptors if their type names are not found in the toKeep map. -func trimMessageDescriptors(in []*descriptorpb.DescriptorProto, toKeep map[namedDescriptor]closureInclusionMode) []*descriptorpb.DescriptorProto { - in = trimSlice(in, toKeep) - for _, messageDescriptor := range in { +func trimMessageDescriptors( + in []*descriptorpb.DescriptorProto, + toKeep map[namedDescriptor]closureInclusionMode, + sourcePathRemapper *sourcePathsRemapTrie, + pathSoFar []int32, +) []*descriptorpb.DescriptorProto { + // We must iterate through the messages *before* we trim the slice. That way the + // index we see is for the "old path", which we need to know to mark elements as + // moved or deleted with the sourcePathRemapper. + for index, messageDescriptor := range in { + path := append(pathSoFar, int32(index)) mode, ok := toKeep[messageDescriptor] if !ok { continue @@ -327,22 +397,45 @@ func trimMessageDescriptors(in []*descriptorpb.DescriptorProto, toKeep map[named messageDescriptor.ExtensionRange = nil messageDescriptor.ReservedRange = nil messageDescriptor.ReservedName = nil - } - messageDescriptor.NestedType = trimMessageDescriptors(messageDescriptor.NestedType, toKeep) - messageDescriptor.EnumType = trimSlice(messageDescriptor.EnumType, toKeep) - messageDescriptor.Extension = trimSlice(messageDescriptor.Extension, toKeep) - } - return in + sourcePathRemapper.markNoComment(path) + sourcePathRemapper.markDeleted(append(path, messageFieldsTag)) + sourcePathRemapper.markDeleted(append(path, messageOneofsTag)) + sourcePathRemapper.markDeleted(append(path, messageExtensionRangesTag)) + sourcePathRemapper.markDeleted(append(path, messageReservedRangesTag)) + sourcePathRemapper.markDeleted(append(path, messageReservedNamesTag)) + } + messageDescriptor.NestedType = trimMessageDescriptors(messageDescriptor.NestedType, toKeep, sourcePathRemapper, append(path, messageNestedMessagesTag)) + messageDescriptor.EnumType = trimSlice(messageDescriptor.EnumType, toKeep, sourcePathRemapper, append(path, messageEnumsTag)) + // TODO: We could end up removing all extensions from a particular extend block + // but we then don't mark that extend block's source code info for deletion. The + // best we do is to remove comments for extend blocks when there are NO extensions. + // See comment above for file extensions for more info. + extsPath := append(path, messageExtensionsTag) + messageDescriptor.Extension = trimSlice(messageDescriptor.Extension, toKeep, sourcePathRemapper, extsPath) + if len(messageDescriptor.Extension) == 0 { + sourcePathRemapper.markDeleted(extsPath) + } + } + return trimSlice(in, toKeep, sourcePathRemapper, pathSoFar) } // trimSlice removes elements from a slice of descriptors if they are // not present in the given map. -func trimSlice[T namedDescriptor](in []T, toKeep map[namedDescriptor]closureInclusionMode) []T { +func trimSlice[T namedDescriptor]( + in []T, + toKeep map[namedDescriptor]closureInclusionMode, + sourcePathRemapper *sourcePathsRemapTrie, + pathSoFar []int32, +) []T { i := 0 - for _, descriptor := range in { + for index, descriptor := range in { + path := append(pathSoFar, int32(index)) if _, ok := toKeep[descriptor]; ok { + sourcePathRemapper.markMoved(path, int32(i)) in[i] = descriptor i++ + } else { + sourcePathRemapper.markDeleted(path) } } return in[:i] @@ -741,7 +834,7 @@ func (t *transitiveClosure) exploreOptionValueForAny( if isMessageKind(fd.MapValue().Kind()) { var err error val.Map().Range(func(_ protoreflect.MapKey, v protoreflect.Value) bool { - if err = t.exploreOptionScalarValueForAny(v.Message(), referrerFile, imageIndex, opts); err != nil { + if err = t.exploreOptionSingularValueForAny(v.Message(), referrerFile, imageIndex, opts); err != nil { return false } return true @@ -752,18 +845,18 @@ func (t *transitiveClosure) exploreOptionValueForAny( if fd.IsList() { listVal := val.List() for i := 0; i < listVal.Len(); i++ { - if err := t.exploreOptionScalarValueForAny(listVal.Get(i).Message(), referrerFile, imageIndex, opts); err != nil { + if err := t.exploreOptionSingularValueForAny(listVal.Get(i).Message(), referrerFile, imageIndex, opts); err != nil { return err } } } else { - return t.exploreOptionScalarValueForAny(val.Message(), referrerFile, imageIndex, opts) + return t.exploreOptionSingularValueForAny(val.Message(), referrerFile, imageIndex, opts) } } return nil } -func (t *transitiveClosure) exploreOptionScalarValueForAny( +func (t *transitiveClosure) exploreOptionSingularValueForAny( msg protoreflect.Message, referrerFile string, imageIndex *imageIndex, diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/source_paths_remap.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/source_paths_remap.go new file mode 100644 index 000000000..34e81fe2c --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/source_paths_remap.go @@ -0,0 +1,145 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 bufimageutil + +import "sort" + +// sourcePathsRemapTrieNode is a node in a trie. Each node represents the +// path of a source code location. +type sourcePathsRemapTrieNode struct { + oldIndex int32 + // If == -1, the item at this path is being deleted. Otherwise, + // if != oldIndex, the item at this path is being moved, as well as + // all its descendents in the trie. + newIndex int32 + // If true, the item at this point has its comments omitted. This is + // used to omit comments for messages that, after filtering, are only + // present as a namespace (so the comments likely no longer apply). + noComment bool + // This node's children. These represent paths for which the current + // node is a path prefix (aka ancestor). + children sourcePathsRemapTrie +} + +// sourcePathsRemapTrie is a trie (aka prefix tree) whose children are a +// sorted slice (more efficient than a map, mainly due to not having to +// sort it with every addition, in practice, since source code info is +// mostly sorted). +// +// Each node in the trie represents some path of a source code location. +// This is used to track renumbering and deletions of paths. +type sourcePathsRemapTrie []*sourcePathsRemapTrieNode + +// markMoved inserts the given path into the trie and marks the last element +// of oldPath to be replaced with newIndex. +func (t *sourcePathsRemapTrie) markMoved(oldPath []int32, newIndex int32) { + t.doTrieInsert(oldPath, newIndex, false) +} + +// markDeleted marks the given path for deletion. +func (t *sourcePathsRemapTrie) markDeleted(oldPath []int32) { + t.doTrieInsert(oldPath, -1, false) +} + +// markNoComment inserts the given path into the trie and marks the element so +// its comments will be dropped. +func (t *sourcePathsRemapTrie) markNoComment(oldPath []int32) { + t.doTrieInsert(oldPath, oldPath[len(oldPath)-1], true) +} + +func (t *sourcePathsRemapTrie) doTrieInsert(oldPath []int32, newIndex int32, noComment bool) { + if t == nil { + return + } + items := *t + searchIndex := oldPath[0] + idx, found := sort.Find(len(items), func(i int) int { + return int(searchIndex - items[i].oldIndex) + }) + if !found { + // shouldn't usually need to sort because incoming items are often in order + needSort := len(items) > 0 && searchIndex < items[len(items)-1].oldIndex + idx = len(items) + items = append(items, &sourcePathsRemapTrieNode{ + oldIndex: searchIndex, + newIndex: searchIndex, + }) + if needSort { + sort.Slice(items, func(i, j int) bool { + return items[i].oldIndex < items[j].oldIndex + }) + // find the index of the thing we just added + idx, _ = sort.Find(len(items), func(i int) int { + return int(searchIndex - items[i].oldIndex) + }) + } + *t = items + } + if len(oldPath) > 1 { + items[idx].children.doTrieInsert(oldPath[1:], newIndex, noComment) + return + } + if noComment { + items[idx].noComment = noComment + } else { + items[idx].newIndex = newIndex + } +} + +// newPath returns the corrected path of oldPath, given any moves and +// deletions inserted into t. If the item at the given oldPath was deleted +// then nil is returned. Otherwise, the corrected path is returned. If the +// item at oldPath was not moved or deleted, the returned path has the +// same values as oldPath. +func (t *sourcePathsRemapTrie) newPath(oldPath []int32) (path []int32, noComment bool) { + if len(oldPath) == 0 { + // make sure return value is non-nil, so response doesn't + // get confused for "delete this entry" + return []int32{}, false + } + if t == nil { + return oldPath, false + } + newPath := make([]int32, len(oldPath)) + keep, noComment := t.fix(oldPath, newPath) + if !keep { + return nil, false + } + return newPath, noComment +} + +func (t *sourcePathsRemapTrie) fix(oldPath, newPath []int32) (keep, noComment bool) { + items := *t + searchIndex := oldPath[0] + idx, found := sort.Find(len(items), func(i int) int { + return int(searchIndex - items[i].oldIndex) + }) + if !found { + copy(newPath, oldPath) + return true, false + } + item := items[idx] + if item.newIndex == -1 { + return false, false + } + newPath[0] = item.newIndex + if len(oldPath) > 1 { + if item.newIndex == -1 { + newPath[0] = item.oldIndex + } + return item.children.fix(oldPath[1:], newPath[1:]) + } + return true, item.noComment +} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/tags.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/tags.go new file mode 100644 index 000000000..79bbbb57b --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil/tags.go @@ -0,0 +1,39 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 bufimageutil + +const ( + // These constants are tag numbers for fields of messages in descriptor.proto. + // We use them to construct source code info paths, which must be re-written + // when we filter out elements of an image. + + fileDependencyTag = 3 + filePublicDependencyTag = 10 + fileWeakDependencyTag = 11 + fileMessagesTag = 4 + fileEnumsTag = 5 + fileServicesTag = 6 + fileExtensionsTag = 7 + messageFieldsTag = 2 + messageNestedMessagesTag = 3 + messageEnumsTag = 4 + messageExtensionsTag = 6 + messageOneofsTag = 8 + messageExtensionRangesTag = 5 + messageReservedRangesTag = 9 + messageReservedNamesTag = 10 + enumValuesTag = 2 + serviceMethodsTag = 2 +) diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/image.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/image.go index 6c17741e2..5ed7f0a11 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/image.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/image.go @@ -31,12 +31,24 @@ func newImage(files []ImageFile, reorder bool) (*image, error) { return nil, errors.New("image contains no files") } pathToImageFile := make(map[string]ImageFile, len(files)) + identityStringToCommit := make(map[string]string) for _, file := range files { path := file.Path() if _, ok := pathToImageFile[path]; ok { return nil, fmt.Errorf("duplicate file: %s", path) } pathToImageFile[path] = file + if moduleIdentity := file.ModuleIdentity(); moduleIdentity != nil { + identityString := moduleIdentity.IdentityString() + existingCommit, ok := identityStringToCommit[identityString] + if ok { + if existingCommit != file.Commit() { + return nil, fmt.Errorf("image had two different commits for the same module: %q and %q", existingCommit, file.Commit()) + } + } else { + identityStringToCommit[identityString] = file.Commit() + } + } } if reorder { files = orderImageFiles(files, pathToImageFile) diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/image_module_dependency.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/image_module_dependency.go new file mode 100644 index 000000000..9451e15c4 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/image_module_dependency.go @@ -0,0 +1,61 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 bufimage + +import ( + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" +) + +var _ ImageModuleDependency = &imageModuleDependency{} + +type imageModuleDependency struct { + moduleIdentity bufmoduleref.ModuleIdentity + commit string + isDirect bool +} + +func newImageModuleDependency( + moduleIdentity bufmoduleref.ModuleIdentity, + commit string, + isDirect bool, +) *imageModuleDependency { + return &imageModuleDependency{ + moduleIdentity: moduleIdentity, + commit: commit, + isDirect: isDirect, + } +} + +func (i *imageModuleDependency) ModuleIdentity() bufmoduleref.ModuleIdentity { + return i.moduleIdentity +} + +func (i *imageModuleDependency) Commit() string { + return i.commit +} + +func (i *imageModuleDependency) IsDirect() bool { + return i.isDirect +} + +func (i *imageModuleDependency) String() string { + moduleIdentityString := i.moduleIdentity.IdentityString() + if i.commit != "" { + return moduleIdentityString + ":" + i.commit + } + return moduleIdentityString +} + +func (*imageModuleDependency) isImageModuleDependency() {} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/util.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/util.go index d46ca11a4..bea4309f9 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/util.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufimage/util.go @@ -17,6 +17,7 @@ package bufimage import ( "errors" "fmt" + "sort" "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" "github.com/bufbuild/buf/private/gen/data/datawkt" @@ -499,3 +500,69 @@ func isFileToGenerate( } return true } + +func sortImageModuleDependencies(imageModuleDependencies []ImageModuleDependency) { + sort.Slice(imageModuleDependencies, func(i, j int) bool { + return imageModuleDependencyLess(imageModuleDependencies[i], imageModuleDependencies[j]) + }) +} + +func imageModuleDependencyLess(a ImageModuleDependency, b ImageModuleDependency) bool { + return imageModuleDependencyCompareTo(a, b) < 0 +} + +// return -1 if less +// return 1 if greater +// return 0 if equal +func imageModuleDependencyCompareTo(a ImageModuleDependency, b ImageModuleDependency) int { + if a == nil && b == nil { + return 0 + } + if a == nil && b != nil { + return -1 + } + if a != nil && b == nil { + return 1 + } + aModuleIdentity := a.ModuleIdentity() + bModuleIdentity := b.ModuleIdentity() + if aModuleIdentity != nil || bModuleIdentity != nil { + if aModuleIdentity == nil && bModuleIdentity != nil { + return -1 + } + if aModuleIdentity != nil && bModuleIdentity == nil { + return 1 + } + if aModuleIdentity.Remote() < bModuleIdentity.Remote() { + return -1 + } + if aModuleIdentity.Remote() > bModuleIdentity.Remote() { + return 1 + } + if aModuleIdentity.Owner() < bModuleIdentity.Owner() { + return -1 + } + if aModuleIdentity.Owner() > bModuleIdentity.Owner() { + return 1 + } + if aModuleIdentity.Repository() < bModuleIdentity.Repository() { + return -1 + } + if aModuleIdentity.Repository() > bModuleIdentity.Repository() { + return 1 + } + } + if a.Commit() < b.Commit() { + return -1 + } + if a.Commit() > b.Commit() { + return 1 + } + if a.IsDirect() && !b.IsDirect() { + return -1 + } + if !a.IsDirect() && b.IsDirect() { + return 1 + } + return 0 +} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/buflock/buflock.go b/vendor/github.com/bufbuild/buf/private/bufpkg/buflock/buflock.go index 444718fe8..36467ea36 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/buflock/buflock.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/buflock/buflock.go @@ -17,9 +17,9 @@ package buflock import ( "context" + "strings" "time" - "github.com/bufbuild/buf/private/pkg/manifest" "github.com/bufbuild/buf/private/pkg/storage" ) @@ -85,9 +85,9 @@ type ExternalConfigDependencyV1 struct { // DependencyForExternalConfigDependencyV1 returns the Dependency representation of a ExternalConfigDependencyV1. func DependencyForExternalConfigDependencyV1(dep ExternalConfigDependencyV1) Dependency { - // Don't consume old buf digests. digest := dep.Digest - if !isValidDigest(digest) { + // Don't consume old b1/b3 buf digests. + if strings.HasPrefix(digest, "b1-") || strings.HasPrefix(digest, "b3-") { digest = "" } return Dependency{ @@ -152,10 +152,3 @@ func ExternalConfigDependencyV1Beta1ForDependency(dep Dependency) ExternalConfig type ExternalConfigVersion struct { Version string `json:"version,omitempty" yaml:"version,omitempty"` } - -// isValidDigest returns true when the digest string is successfully parsed -// by the `manifest` pkg. Older buf digests are not considered valid (b1/b3). -func isValidDigest(digest string) bool { - _, err := manifest.NewDigestFromString(digest) - return err == nil -} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodule.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodule.go index 2225d3da5..c7a0b5162 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodule.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodule.go @@ -99,6 +99,16 @@ type Module interface { // // Returns storage.IsNotExist error if the file does not exist. GetModuleFile(ctx context.Context, path string) (ModuleFile, error) + // DeclaredDirectDependencies returns the direct dependencies declared in the configuration file. + // + // The returned ModuleReferences are sorted by remote, owner, repository, and reference (if + // present). The returned ModulePins are unique by remote, owner, repository. + // + // This does not include any transitive dependencies, but if the declarations are correct, + // this should be a subset of the dependencies from DependencyModulePins. + // + // TODO: validate that this is a subset? This may mess up construction. + DeclaredDirectDependencies() []bufmoduleref.ModuleReference // DependencyModulePins gets the dependency ModulePins. // // The returned ModulePins are sorted by remote, owner, repository, branch, commit, and then digest. @@ -140,19 +150,21 @@ type Module interface { BlobSet() *manifest.BlobSet getSourceReadBucket() storage.ReadBucket + // ModuleIdentity returns the ModuleIdentity for the Module, if it was + // provided at construction time via ModuleWithModuleIdentity or ModuleWithModuleIdentityAndCommit. + // // Note this *can* be nil if we did not build from a named module. // All code must assume this can be nil. // nil checking should work since the backing type is always a pointer. - // - // TODO: We can remove the getModuleReference method on the if we fetch - // FileInfos from the Module and plumb in the ModuleReference here. - // - // This approach assumes that all of the FileInfos returned - // from SourceFileInfos will have their ModuleReference - // set to the same value, which can be validated. - getModuleIdentity() bufmoduleref.ModuleIdentity + ModuleIdentity() bufmoduleref.ModuleIdentity + // Commit returns the commit for the Module, if it was + // provided at construction time via ModuleWithModuleIdentityAndCommit. + // Note this can be empty. - getCommit() string + // This will only be set if ModuleIdentity is set. but may not be set + // even if ModuleIdentity is set, that is commit is optional information + // even if we know what module this file came from. + Commit() string isModule() } @@ -167,6 +179,9 @@ func ModuleWithModuleIdentity(moduleIdentity bufmoduleref.ModuleIdentity) Module } // ModuleWithModuleIdentityAndCommit is used to construct a Module with a ModuleIdentity and commit. +// +// If the moduleIdentity is nil, the commit must be empty, that is it is not valid to have +// a non-empty commit and a nil moduleIdentity. func ModuleWithModuleIdentityAndCommit(moduleIdentity bufmoduleref.ModuleIdentity, commit string) ModuleOption { return func(module *module) { module.moduleIdentity = moduleIdentity @@ -308,20 +323,27 @@ func NewModuleFileSet( return newModuleFileSet(module, dependencies) } -// Workspace represents a module workspace. +// Workspace represents a workspace. +// +// It is guaranteed that all Modules within this workspace have no overlapping file paths. type Workspace interface { // GetModule gets the module identified by the given ModuleIdentity. + // GetModule(moduleIdentity bufmoduleref.ModuleIdentity) (Module, bool) // GetModules returns all of the modules found in the workspace. GetModules() []Module } // NewWorkspace returns a new module workspace. +// +// The Context is not retained, and is only used for validation during construction. func NewWorkspace( + ctx context.Context, namedModules map[string]Module, allModules []Module, -) Workspace { +) (Workspace, error) { return newWorkspace( + ctx, namedModules, allModules, ) @@ -417,7 +439,7 @@ func ModuleDigestB3(ctx context.Context, module Module) (string, error) { return "", err } } - if moduleIdentity := module.getModuleIdentity(); moduleIdentity != nil { + if moduleIdentity := module.ModuleIdentity(); moduleIdentity != nil { if _, err := hash.Write([]byte(moduleIdentity.IdentityString())); err != nil { return "", err } @@ -514,7 +536,7 @@ func ModuleToBucket( version = breakingConfigVersion } writeConfigOptions := []bufconfig.WriteConfigOption{ - bufconfig.WriteConfigWithModuleIdentity(module.getModuleIdentity()), + bufconfig.WriteConfigWithModuleIdentity(module.ModuleIdentity()), bufconfig.WriteConfigWithBreakingConfig(module.BreakingConfig()), bufconfig.WriteConfigWithLintConfig(module.LintConfig()), bufconfig.WriteConfigWithVersion(version), diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/bufmodulebuild.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/bufmodulebuild.go index e13de6417..88282d307 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/bufmodulebuild.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/bufmodulebuild.go @@ -18,7 +18,9 @@ import ( "context" "github.com/bufbuild/buf/private/bufpkg/bufmodule" + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleconfig" "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/pkg/storage" "github.com/bufbuild/buf/private/pkg/storage/storageos" "go.uber.org/zap" ) @@ -50,14 +52,35 @@ func WithWorkspace(workspace bufmodule.Workspace) BuildModuleFileSetOption { } } +// BuiltModule ties a bufmodule.Module with the configuration and a bucket +// containing just the files required to build it. +type BuiltModule struct { + bufmodule.Module + Bucket storage.ReadBucket +} + // ModuleBucketBuilder builds modules for buckets. -type ModuleBucketBuilder = *moduleBucketBuilder +type ModuleBucketBuilder interface { + // BuildForBucket constructs a minimal bucket from the passed readBucket and + // builds a module from it. + // + // config's value is used even if the bucket contains configuration (buf.yaml). + // This means the module is built differently than described in storage, which + // may cause building to fail or succeed when it shouldn't. For your own + // sanity, you should pass a config value read from the provided bucket. + // + // TODO: why do we pass a config here?! This parameter should be removed. + BuildForBucket( + ctx context.Context, + readBucket storage.ReadBucket, + config *bufmoduleconfig.Config, + options ...BuildOption, + ) (*BuiltModule, error) +} // NewModuleBucketBuilder returns a new BucketBuilder. -func NewModuleBucketBuilder( - options ...BuildOption, -) ModuleBucketBuilder { - return newModuleBucketBuilder(options...) +func NewModuleBucketBuilder() ModuleBucketBuilder { + return newModuleBucketBuilder() } // ModuleIncludeBuilder builds modules for includes. diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/module_bucket_builder.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/module_bucket_builder.go index ecdf07444..ee8a4812c 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/module_bucket_builder.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/module_bucket_builder.go @@ -26,58 +26,36 @@ import ( "github.com/bufbuild/buf/private/pkg/storage/storagemem" ) -// BuiltModule ties a bufmodule.Module with the configuration and a bucket -// containing just the files required to build it. -type BuiltModule struct { - bufmodule.Module - Bucket storage.ReadBucket -} - type moduleBucketBuilder struct { - opt buildOptions } -func newModuleBucketBuilder( - options ...BuildOption, -) *moduleBucketBuilder { - opt := buildOptions{} - for _, option := range options { - option(&opt) - } - return &moduleBucketBuilder{opt: opt} +func newModuleBucketBuilder() *moduleBucketBuilder { + return &moduleBucketBuilder{} } -// BuildForBucket is an alternative constructor of NewModuleBucketBuilder -// followed by calling the BuildForBucket method. -func BuildForBucket( +func (b *moduleBucketBuilder) BuildForBucket( ctx context.Context, readBucket storage.ReadBucket, config *bufmoduleconfig.Config, options ...BuildOption, ) (*BuiltModule, error) { - builder := newModuleBucketBuilder(options...) - bm, err := builder.BuildForBucket( + buildOptions := &buildOptions{} + for _, option := range options { + option(buildOptions) + } + return b.buildForBucket( ctx, readBucket, config, + buildOptions, ) - if err != nil { - return nil, err - } - return bm, nil } -// BuildForBucket constructs a minimal bucket from the passed readBucket and -// builds a module from it. -// -// config's value is used even if the bucket contains configuration (buf.yaml). -// This means the module is built differently than described in storage, which -// may cause building to fail or succeed when it shouldn't. For your own -// sanity, you should pass a config value read from the provided bucket. -func (b *moduleBucketBuilder) BuildForBucket( +func (b *moduleBucketBuilder) buildForBucket( ctx context.Context, readBucket storage.ReadBucket, config *bufmoduleconfig.Config, + buildOptions *buildOptions, ) (*BuiltModule, error) { // proxy plain files externalPaths := []string{ @@ -145,7 +123,7 @@ func (b *moduleBucketBuilder) BuildForBucket( ctx, bucket, bufmodule.ModuleWithModuleIdentity( - b.opt.moduleIdentity, // This may be nil + buildOptions.moduleIdentity, // This may be nil ), ) if err != nil { @@ -154,9 +132,9 @@ func (b *moduleBucketBuilder) BuildForBucket( appliedModule, err := applyModulePaths( module, roots, - b.opt.paths, - b.opt.excludePaths, - b.opt.pathsAllowNotExist, + buildOptions.paths, + buildOptions.excludePaths, + buildOptions.pathsAllowNotExist, normalpath.Relative, ) if err != nil { diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/module_file_set_builder.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/module_file_set_builder.go index 71622f49a..19bba2d11 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/module_file_set_builder.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild/module_file_set_builder.go @@ -16,9 +16,12 @@ package bufmodulebuild import ( "context" + "encoding/hex" + "errors" "github.com/bufbuild/buf/private/bufpkg/bufmodule" "go.uber.org/zap" + "golang.org/x/crypto/sha3" ) type moduleFileSetBuilder struct { @@ -57,17 +60,71 @@ func (m *moduleFileSetBuilder) build( workspace bufmodule.Workspace, ) (bufmodule.ModuleFileSet, error) { var dependencyModules []bufmodule.Module + hashes := make(map[string]struct{}) + moduleHash, err := protoPathsHash(ctx, module) + if err != nil { + return nil, err + } + hashes[moduleHash] = struct{}{} if workspace != nil { // From the perspective of the ModuleFileSet, we include all of the files // specified in the workspace. When we build the Image from the ModuleFileSet, // we construct it based on the TargetFileInfos, and thus only include the files // in the transitive closure. // - // We *could* determine which modules could be omitted here, but it would incur + // This is defensible as we're saying that everything in the workspace is a potential + // dependency, even if some are not actual dependencies of this specific module. In this + // case, the extra modules are no different than unused dependencies in a buf.yaml/buf.lock. + // + // By including all the Modules from the workspace, we are potentially including the input + // Module itself. This is bad, and will result in errors when using the result ModuleFileSet. + // The ModuleFileSet expects a Module, and its dependency Modules, but it is not OK for + // a Module to both be the input Module and a dependency Module. We have no concept + // of Module "ID" - a Module may have a ModuleIdentity and commit associated with it, + // but there is no guarantee of this. To get around this, we do a hash of the .proto file + // paths within a Module, and say that Modules are equivalent if they contain the exact + // same .proto file paths. If they have the same .proto file paths, then we do not + // add the Module as a dependency. + // + // We know from bufmodule.Workspace that no two Modules in a Workspace will have overlapping + // file paths, therefore if the Module is in the Workspace and has equivalent file paths, + // we know that it must be the same module. If the Module is not in the workspace...why + // did we provide a workspace? + // + // We could use other methods for equivalence or to say "do not add": + // + // - If there are any overlapping files: for example, one module has a.proto, one module + // has b.proto, and both have c.proto. We don't use this heuristic as what we are looking + // for here is a situation where based on our Module construction, we have two actually-equivalent + // Modules. The existence of any overlapping files will result in an error during build, which + // is what we want. This would also indicate this Module did not come from the Workspace, given + // the property of file uniqueness in Workspaces. + // - Golang object equivalence: for example, doing "module != potentialDependencyModule". This + // happens to work since we only construct Modules once, but it's error-prone: it's totally + // possible to create two Module objects from the same source, and if they represent the + // same Module on disk/in the BSR, we don't want to include these as duplicates. + // - Full module digest and/or proto file content: We could include buf.yaml, buf.lock, + // README.md, etc, and also hash the actual content of the .proto files, but we're saying + // that this doesn't help us any more than just comparing .proto files, and may lead to + // false negatives. However, this is the most likely candidate as an alternative, as you + // could argue that at the ModuleFileSetBuilder level, we should say "assume any difference + // is a real difference". + // + // We could also determine which modules could be omitted here, but it would incur // the cost of parsing the target files and detecting exactly which imports are // used. We already get this for free in Image construction, so it's simplest and // most efficient to bundle all of the modules together like so. - dependencyModules = workspace.GetModules() + for _, potentialDependencyModule := range workspace.GetModules() { + potentialDependencyModuleHash, err := protoPathsHash(ctx, potentialDependencyModule) + if err != nil { + return nil, err + } + if _, ok := hashes[potentialDependencyModuleHash]; !ok { + dependencyModules = append(dependencyModules, potentialDependencyModule) + } else { + hashes[potentialDependencyModuleHash] = struct{}{} + } + } } // We know these are unique by remote, owner, repository and // contain all transitive dependencies. @@ -83,7 +140,36 @@ func (m *moduleFileSetBuilder) build( if err != nil { return nil, err } + dependencyModuleHash, err := protoPathsHash(ctx, dependencyModule) + if err != nil { + return nil, err + } + // At this point, this is really just a safety check. + if _, ok := hashes[dependencyModuleHash]; ok { + return nil, errors.New("module declared in DependencyModulePins but not in workspace was already added to the dependency Module set, this is a system error") + } dependencyModules = append(dependencyModules, dependencyModule) + hashes[dependencyModuleHash] = struct{}{} } return bufmodule.NewModuleFileSet(module, dependencyModules), nil } + +// protoPathsHash returns a hash representing the paths of the .proto files within the Module. +func protoPathsHash(ctx context.Context, module bufmodule.Module) (string, error) { + fileInfos, err := module.SourceFileInfos(ctx) + if err != nil { + return "", err + } + shakeHash := sha3.NewShake256() + for _, fileInfo := range fileInfos { + _, err := shakeHash.Write([]byte(fileInfo.Path())) + if err != nil { + return "", err + } + } + data := make([]byte, 64) + if _, err := shakeHash.Read(data); err != nil { + return "", err + } + return hex.EncodeToString(data), nil +} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/bufmodulecache.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/bufmodulecache.go index a212b9d2b..1acc6cc56 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/bufmodulecache.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/bufmodulecache.go @@ -18,15 +18,11 @@ import ( "github.com/bufbuild/buf/private/bufpkg/bufmodule" "github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect" "github.com/bufbuild/buf/private/pkg/connectclient" - "github.com/bufbuild/buf/private/pkg/filelock" "github.com/bufbuild/buf/private/pkg/storage" "github.com/bufbuild/buf/private/pkg/verbose" "go.uber.org/zap" ) -// ModuleReaderOption is an option for creating a ModuleReader. -type ModuleReaderOption func(*moduleReaderOptions) - type RepositoryServiceClientFactory func(address string) registryv1alpha1connect.RepositoryServiceClient func NewRepositoryServiceClientFactory(clientConfig *connectclient.Config) RepositoryServiceClientFactory { @@ -35,41 +31,8 @@ func NewRepositoryServiceClientFactory(clientConfig *connectclient.Config) Repos } } -// NewModuleReader returns a new ModuleReader that uses cache as a caching layer, and -// delegate as the source of truth. +// NewModuleReader creates a new module reader using content addressable storage. func NewModuleReader( - logger *zap.Logger, - verbosePrinter verbose.Printer, - fileLocker filelock.Locker, - dataReadWriteBucket storage.ReadWriteBucket, - sumReadWriteBucket storage.ReadWriteBucket, - delegate bufmodule.ModuleReader, - repositoryClientFactory RepositoryServiceClientFactory, - options ...ModuleReaderOption, -) bufmodule.ModuleReader { - return newModuleReader( - logger, - verbosePrinter, - fileLocker, - dataReadWriteBucket, - sumReadWriteBucket, - delegate, - repositoryClientFactory, - options..., - ) -} - -// ModuleReaderWithExternalPaths is used to preserve the external paths -// to the files resolved from the module cache. -func ModuleReaderWithExternalPaths() ModuleReaderOption { - return func(moduleReaderOptions *moduleReaderOptions) { - moduleReaderOptions.allowCacheExternalPaths = true - } -} - -// NewCASModuleReader creates a new module reader using content addressable storage. -// This doesn't require file locking and enables support for tamper proofing. -func NewCASModuleReader( logger *zap.Logger, verbosePrinter verbose.Printer, bucket storage.ReadWriteBucket, @@ -84,7 +47,3 @@ func NewCASModuleReader( verbosePrinter, ) } - -type moduleReaderOptions struct { - allowCacheExternalPaths bool -} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/cas_module_cacher.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/cas_module_cacher.go index c752de128..2051d9886 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/cas_module_cacher.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/cas_module_cacher.go @@ -41,8 +41,6 @@ type casModuleCacher struct { bucket storage.ReadWriteBucket } -var _ moduleCache = (*casModuleCacher)(nil) - func (c *casModuleCacher) GetModule( ctx context.Context, modulePin bufmoduleref.ModulePin, @@ -79,7 +77,15 @@ func (c *casModuleCacher) GetModule( if err != nil { return nil, err } - return bufmodule.NewModuleForManifestAndBlobSet(ctx, manifestFromCache, blobSet) + return bufmodule.NewModuleForManifestAndBlobSet( + ctx, + manifestFromCache, + blobSet, + bufmodule.ModuleWithModuleIdentityAndCommit( + modulePin, + modulePin.Commit(), + ), + ) } func (c *casModuleCacher) PutModule( diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/cas_module_reader.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/cas_module_reader.go index 87fdc8c5d..e9ad49f1b 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/cas_module_reader.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/cas_module_reader.go @@ -83,8 +83,7 @@ func (c *casModuleReader) GetModule( if err != nil { return nil, err } - // Manifest and BlobSet should always be set if tamper proofing is enabled. - // If not, the BSR doesn't support tamper proofing while the CLI feature is enabled. + // Manifest and BlobSet should always be set. if remoteModule.Manifest() == nil || remoteModule.BlobSet() == nil { return nil, fmt.Errorf("required manifest/blobSet not set on module") } diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/module_cacher.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/module_cacher.go deleted file mode 100644 index 59b841423..000000000 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/module_cacher.go +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 bufmodulecache - -import ( - "context" - - "github.com/bufbuild/buf/private/bufpkg/buflock" - "github.com/bufbuild/buf/private/bufpkg/bufmodule" - "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" - "github.com/bufbuild/buf/private/pkg/storage" - "go.uber.org/multierr" - "go.uber.org/zap" -) - -type moduleCache interface { - bufmodule.ModuleReader - // PutModule stores the module in the cache. - PutModule( - ctx context.Context, - modulePin bufmoduleref.ModulePin, - module bufmodule.Module, - ) error -} - -type moduleCacher struct { - logger *zap.Logger - dataReadWriteBucket storage.ReadWriteBucket - sumReadWriteBucket storage.ReadWriteBucket - allowCacheExternalPaths bool -} - -var _ moduleCache = (*moduleCacher)(nil) - -func newModuleCacher( - logger *zap.Logger, - dataReadWriteBucket storage.ReadWriteBucket, - sumReadWriteBucket storage.ReadWriteBucket, - allowCacheExternalPaths bool, -) *moduleCacher { - return &moduleCacher{ - logger: logger, - dataReadWriteBucket: dataReadWriteBucket, - sumReadWriteBucket: sumReadWriteBucket, - allowCacheExternalPaths: allowCacheExternalPaths, - } -} - -func (m *moduleCacher) GetModule( - ctx context.Context, - modulePin bufmoduleref.ModulePin, -) (bufmodule.Module, error) { - modulePath := newCacheKey(modulePin) - // Explicitly assign the variable as a storage.ReadBucket so - // that we can easily transform it with storage.NoExternalPathReadBucket - // below. - var dataReadWriteBucket storage.ReadBucket = storage.MapReadWriteBucket( - m.dataReadWriteBucket, - storage.MapOnPrefix(modulePath), - ) - if !m.allowCacheExternalPaths { - // In general, we do not want the external path of the cache to be propagated to the user. - dataReadWriteBucket = storage.NoExternalPathReadBucket(dataReadWriteBucket) - } - exists, err := storage.Exists(ctx, dataReadWriteBucket, buflock.ExternalConfigFilePath) - if err != nil { - return nil, err - } - if !exists { - return nil, storage.NewErrNotExist(modulePath) - } - module, err := bufmodule.NewModuleForBucket( - ctx, - dataReadWriteBucket, - bufmodule.ModuleWithModuleIdentityAndCommit(modulePin, modulePin.Commit()), - ) - if err != nil { - return nil, err - } - storedDigestData, err := storage.ReadPath(ctx, m.sumReadWriteBucket, modulePath) - if err != nil { - // This can happen if we couldn't find the sum file, which means - // we are in an invalid state - if storage.IsNotExist(err) { - m.logger.Sugar().Warnf( - "Module %q has invalid cache state: no stored digest could be found. The cache will attempt to self-correct.", - modulePin.String(), - ) - // We want to return ErrNotExist so that the ModuleReader can re-download - return nil, storage.NewErrNotExist(modulePath) - } - return nil, err - } - storedDigest := string(storedDigestData) - // This can happen if we couldn't find the sum file, which means - // we are in an invalid state - if storedDigest == "" { - m.logger.Sugar().Warnf( - "Module %q has invalid cache state: no stored digest could be found. The cache will attempt to self-correct.", - modulePin.String(), - ) - // We want to return ErrNotExist so that the ModuleReader can re-download - // Note that we deal with invalid data in the cache at the ModuleReader level by overwriting via PutModule - return nil, storage.NewErrNotExist(modulePath) - } - digest, err := bufmodule.ModuleDigestB3(ctx, module) - if err != nil { - return nil, err - } - if digest != storedDigest { - m.logger.Sugar().Warnf( - "Module %q has invalid cache state: calculated digest %q does not match stored digest %q. The cache will attempt to self-correct.", - modulePin.String(), - digest, - storedDigest, - ) - // We want to return ErrNotExist so that the ModuleReader can re-download - // Note that we deal with invalid data in the cache at the ModuleReader level by overwriting via PutModule - return nil, storage.NewErrNotExist(modulePath) - } - return module, nil -} - -func (m *moduleCacher) PutModule( - ctx context.Context, - modulePin bufmoduleref.ModulePin, - module bufmodule.Module, -) error { - modulePath := newCacheKey(modulePin) - digest, err := bufmodule.ModuleDigestB3(ctx, module) - if err != nil { - return err - } - dataReadWriteBucket := storage.MapReadWriteBucket( - m.dataReadWriteBucket, - storage.MapOnPrefix(modulePath), - ) - exists, err := storage.Exists(ctx, dataReadWriteBucket, buflock.ExternalConfigFilePath) - if err != nil { - return err - } - if exists { - // If the module already exists in the cache, we want to make sure we delete it - // before putting new data - if err := dataReadWriteBucket.DeleteAll(ctx, ""); err != nil { - return err - } - } - if err := bufmodule.ModuleToBucket(ctx, module, dataReadWriteBucket); err != nil { - return err - } - // This will overwrite if necessary - if err := storage.PutPath(ctx, m.sumReadWriteBucket, modulePath, []byte(digest)); err != nil { - return multierr.Append( - err, - // Try to clean up after ourselves. - dataReadWriteBucket.DeleteAll(ctx, ""), - ) - } - return nil -} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/module_reader.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/module_reader.go deleted file mode 100644 index ac0bbdce1..000000000 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/module_reader.go +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 bufmodulecache - -import ( - "context" - - "github.com/bufbuild/buf/private/bufpkg/bufmodule" - "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" - "github.com/bufbuild/buf/private/pkg/filelock" - "github.com/bufbuild/buf/private/pkg/storage" - "github.com/bufbuild/buf/private/pkg/verbose" - "go.uber.org/multierr" - "go.uber.org/zap" -) - -type moduleReader struct { - logger *zap.Logger - verbosePrinter verbose.Printer - fileLocker filelock.Locker - cache *moduleCacher - delegate bufmodule.ModuleReader - repositoryClientFactory RepositoryServiceClientFactory - - stats *cacheStats -} - -func newModuleReader( - logger *zap.Logger, - verbosePrinter verbose.Printer, - fileLocker filelock.Locker, - dataReadWriteBucket storage.ReadWriteBucket, - sumReadWriteBucket storage.ReadWriteBucket, - delegate bufmodule.ModuleReader, - repositoryClientFactory RepositoryServiceClientFactory, - options ...ModuleReaderOption, -) *moduleReader { - moduleReaderOptions := &moduleReaderOptions{} - for _, option := range options { - option(moduleReaderOptions) - } - return &moduleReader{ - logger: logger, - verbosePrinter: verbosePrinter, - fileLocker: fileLocker, - cache: newModuleCacher( - logger, - dataReadWriteBucket, - sumReadWriteBucket, - moduleReaderOptions.allowCacheExternalPaths, - ), - delegate: delegate, - repositoryClientFactory: repositoryClientFactory, - stats: &cacheStats{}, - } -} - -func (m *moduleReader) GetModule( - ctx context.Context, - modulePin bufmoduleref.ModulePin, -) (_ bufmodule.Module, retErr error) { - cacheKey := newCacheKey(modulePin) - - // First, do a GetModule with a read lock to see if we have a valid module. - readUnlocker, err := m.fileLocker.RLock(ctx, cacheKey) - if err != nil { - return nil, err - } - module, err := m.cache.GetModule(ctx, modulePin) - err = multierr.Append(err, readUnlocker.Unlock()) - if err == nil { - m.logger.Debug( - "cache_hit", - zap.String("module_pin", modulePin.String()), - ) - m.stats.MarkHit() - return module, nil - } - if !storage.IsNotExist(err) { - return nil, err - } - - // We now had a IsNotExist error, so we do a write lock and check again (double locking). - // If we still have an error, we do a GetModule from the delegate, and put the result. - // - // Note that IsNotExist will happen if there was a checksum mismatch as well, in which case - // we want to overwrite whatever is actually in the cache and self-correct the issue - unlocker, err := m.fileLocker.Lock(ctx, cacheKey) - if err != nil { - return nil, err - } - defer func() { - retErr = multierr.Append(retErr, unlocker.Unlock()) - }() - module, err = m.cache.GetModule(ctx, modulePin) - if err == nil { - m.logger.Debug( - "cache_hit", - zap.String("module_pin", modulePin.String()), - ) - m.stats.MarkHit() - return module, nil - } - if !storage.IsNotExist(err) { - return nil, err - } - m.stats.MarkMiss() - - // We now had a IsNotExist error within a write lock, so go to the delegate and then put. - m.logger.Debug( - "cache_miss", - zap.String("module_pin", modulePin.String()), - ) - m.verbosePrinter.Printf("downloading " + modulePin.String()) - module, err = m.delegate.GetModule(ctx, modulePin) - if err != nil { - return nil, err - } - if err := m.cache.PutModule( - ctx, - modulePin, - module, - ); err != nil { - return nil, err - } - if err := warnIfDeprecated(ctx, m.repositoryClientFactory, modulePin, m.logger); err != nil { - return nil, err - } - return module, nil -} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/util.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/util.go index 585b27140..9dc361fc4 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/util.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache/util.go @@ -20,17 +20,10 @@ import ( "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" - "github.com/bufbuild/buf/private/pkg/normalpath" "github.com/bufbuild/connect-go" "go.uber.org/zap" ) -// newCacheKey returns the key associated with the given module pin. -// The cache key is of the form: remote/owner/repository/commit. -func newCacheKey(modulePin bufmoduleref.ModulePin) string { - return normalpath.Join(modulePin.Remote(), modulePin.Owner(), modulePin.Repository(), modulePin.Commit()) -} - // warnIfDeprecated emits a warning message to logger if the repository // is deprecated on the BSR. func warnIfDeprecated( diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleprotocompile/bufmoduleprotocompile.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleprotocompile/bufmoduleprotocompile.go index c59ae51df..dd77a6a9c 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleprotocompile/bufmoduleprotocompile.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleprotocompile/bufmoduleprotocompile.go @@ -45,12 +45,9 @@ type ParserAccessorHandler interface { // NewParserAccessorHandler returns a new ParserAccessorHandler. // -// The given module should be a bufmodule.ModuleFileSet for image builds, as it needs -// access to not just the target files, but all dependency files as well. -// -// For AST building, this can just be a bufmodule.Module. -func NewParserAccessorHandler(ctx context.Context, module bufmodule.Module) ParserAccessorHandler { - return newParserAccessorHandler(ctx, module) +// TODO: make this dependent on whatever derivative getter type we create to replace ModuleFileSet. +func NewParserAccessorHandler(ctx context.Context, moduleFileSet bufmodule.ModuleFileSet) ParserAccessorHandler { + return newParserAccessorHandler(ctx, moduleFileSet) } // GetFileAnnotations gets the FileAnnotations for the ErrorWithPos errors. diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleprotocompile/path_resolver.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleprotocompile/path_resolver.go index f489eac40..1a5b28e13 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleprotocompile/path_resolver.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleprotocompile/path_resolver.go @@ -27,9 +27,14 @@ import ( "go.uber.org/multierr" ) +// TODO: remove when we remove ModuleFileSet +type moduleFileReader interface { + GetModuleFile(context.Context, string) (bufmodule.ModuleFile, error) +} + type parserAccessorHandler struct { ctx context.Context - module bufmodule.Module + moduleFileReader moduleFileReader pathToExternalPath map[string]string nonImportPaths map[string]struct{} pathToModuleIdentity map[string]bufmoduleref.ModuleIdentity @@ -39,11 +44,11 @@ type parserAccessorHandler struct { func newParserAccessorHandler( ctx context.Context, - module bufmodule.Module, + moduleFileReader moduleFileReader, ) *parserAccessorHandler { return &parserAccessorHandler{ ctx: ctx, - module: module, + moduleFileReader: moduleFileReader, pathToExternalPath: make(map[string]string), nonImportPaths: make(map[string]struct{}), pathToModuleIdentity: make(map[string]bufmoduleref.ModuleIdentity), @@ -52,7 +57,7 @@ func newParserAccessorHandler( } func (p *parserAccessorHandler) Open(path string) (_ io.ReadCloser, retErr error) { - moduleFile, moduleErr := p.module.GetModuleFile(p.ctx, path) + moduleFile, moduleErr := p.moduleFileReader.GetModuleFile(p.ctx, path) if moduleErr != nil { if !storage.IsNotExist(moduleErr) { return nil, moduleErr diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref/bufmoduleref.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref/bufmoduleref.go index 2f58ee4d0..297a05c5c 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref/bufmoduleref.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref/bufmoduleref.go @@ -62,7 +62,7 @@ type FileInfo interface { ModuleIdentity() ModuleIdentity // Commit is the commit for the module that this file came from. // - // This will only be set if ModuleIdentity is set. but may not be set + // This will only be set if ModuleIdentity is set, but may not be set // even if ModuleIdentity is set, that is commit is optional information // even if we know what module this file came from. Commit() string @@ -536,6 +536,13 @@ func SortFileInfosByExternalPath(fileInfos []FileInfo) { ) } +// SortModuleReferences sorts the ModuleReferences lexicographically by their identity. +func SortModuleReferences(references []ModuleReference) { + sort.Slice(references, func(i, j int) bool { + return references[i].IdentityString() < references[j].IdentityString() + }) +} + // SortModulePins sorts the ModulePins. func SortModulePins(modulePins []ModulePin) { sort.Slice(modulePins, func(i, j int) bool { diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/module.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/module.go index 38dded18d..f44b9e821 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/module.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/module.go @@ -32,17 +32,18 @@ import ( ) type module struct { - sourceReadBucket storage.ReadBucket - dependencyModulePins []bufmoduleref.ModulePin - moduleIdentity bufmoduleref.ModuleIdentity - commit string - documentation string - documentationPath string - license string - breakingConfig *bufbreakingconfig.Config - lintConfig *buflintconfig.Config - manifest *manifest.Manifest - blobSet *manifest.BlobSet + sourceReadBucket storage.ReadBucket + declaredDirectDependencies []bufmoduleref.ModuleReference + dependencyModulePins []bufmoduleref.ModulePin + moduleIdentity bufmoduleref.ModuleIdentity + commit string + documentation string + documentationPath string + license string + breakingConfig *bufbreakingconfig.Config + lintConfig *buflintconfig.Config + manifest *manifest.Manifest + blobSet *manifest.BlobSet } func newModuleForProto( @@ -72,9 +73,19 @@ func newModuleForProto( if err != nil { return nil, err } + allDependenciesRefs := make([]bufmoduleref.ModuleReference, len(dependencyModulePins)) + for i, dep := range dependencyModulePins { + allDependenciesRefs[i], err = bufmoduleref.NewModuleReference( + dep.Remote(), dep.Owner(), dep.Repository(), dep.Commit(), + ) + if err != nil { + return nil, fmt.Errorf("cannot build module reference from dependency pin %s: %w", dep.String(), err) + } + } return newModule( ctx, readWriteBucket, + allDependenciesRefs, // Since proto has no distinction between direct/transitive dependencies, we'll need to set them all as direct, otherwise the build will fail. dependencyModulePins, nil, // The module identity is not stored on the proto. We rely on the layer above, (e.g. `ModuleReader`) to set this as needed. protoModule.GetDocumentation(), @@ -174,6 +185,7 @@ func newModuleForBucket( return newModule( ctx, storage.MapReadBucket(sourceReadBucket, storage.MatchPathExt(".proto")), + moduleConfig.Build.DependencyModuleReferences, // straight copy from the buf.yaml file dependencyModulePins, moduleIdentity, documentation, @@ -214,6 +226,7 @@ func newModule( ctx context.Context, // must only contain .proto files sourceReadBucket storage.ReadBucket, + declaredDirectDependencies []bufmoduleref.ModuleReference, dependencyModulePins []bufmoduleref.ModulePin, moduleIdentity bufmoduleref.ModuleIdentity, documentation string, @@ -223,24 +236,32 @@ func newModule( lintConfig *buflintconfig.Config, options ...ModuleOption, ) (_ *module, retErr error) { + if err := bufmoduleref.ValidateModuleReferencesUniqueByIdentity(declaredDirectDependencies); err != nil { + return nil, err + } if err := bufmoduleref.ValidateModulePinsUniqueByIdentity(dependencyModulePins); err != nil { return nil, err } // we rely on this being sorted here + bufmoduleref.SortModuleReferences(declaredDirectDependencies) bufmoduleref.SortModulePins(dependencyModulePins) module := &module{ - sourceReadBucket: sourceReadBucket, - dependencyModulePins: dependencyModulePins, - moduleIdentity: moduleIdentity, - documentation: documentation, - documentationPath: documentationPath, - license: license, - breakingConfig: breakingConfig, - lintConfig: lintConfig, + sourceReadBucket: sourceReadBucket, + declaredDirectDependencies: declaredDirectDependencies, + dependencyModulePins: dependencyModulePins, + moduleIdentity: moduleIdentity, + documentation: documentation, + documentationPath: documentationPath, + license: license, + breakingConfig: breakingConfig, + lintConfig: lintConfig, } for _, option := range options { option(module) } + if module.moduleIdentity == nil && module.commit != "" { + return nil, fmt.Errorf("module was constructed with commit %q but no associated ModuleIdentity", module.commit) + } return module, nil } @@ -296,6 +317,11 @@ func (m *module) GetModuleFile(ctx context.Context, path string) (ModuleFile, er return newModuleFile(fileInfo, readObjectCloser), nil } +func (m *module) DeclaredDirectDependencies() []bufmoduleref.ModuleReference { + // already sorted in constructor + return m.declaredDirectDependencies +} + func (m *module) DependencyModulePins() []bufmoduleref.ModulePin { // already sorted in constructor return m.dependencyModulePins @@ -329,16 +355,16 @@ func (m *module) BlobSet() *manifest.BlobSet { return m.blobSet } -func (m *module) getModuleIdentity() bufmoduleref.ModuleIdentity { +func (m *module) ModuleIdentity() bufmoduleref.ModuleIdentity { return m.moduleIdentity } -func (m *module) getSourceReadBucket() storage.ReadBucket { - return m.sourceReadBucket +func (m *module) Commit() string { + return m.commit } -func (m *module) getCommit() string { - return m.commit +func (m *module) getSourceReadBucket() storage.ReadBucket { + return m.sourceReadBucket } func (m *module) isModule() {} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/module_file_set.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/module_file_set.go index a5b7a6e79..22a571864 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/module_file_set.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/module_file_set.go @@ -43,8 +43,8 @@ func newModuleFileSet( moduleReadBuckets := []moduleReadBucket{ newSingleModuleReadBucket( module.getSourceReadBucket(), - module.getModuleIdentity(), - module.getCommit(), + module.ModuleIdentity(), + module.Commit(), ), } for _, dependency := range dependencies { @@ -52,8 +52,8 @@ func newModuleFileSet( moduleReadBuckets, newSingleModuleReadBucket( dependency.getSourceReadBucket(), - dependency.getModuleIdentity(), - dependency.getCommit(), + dependency.ModuleIdentity(), + dependency.Commit(), ), ) } diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/targeting_module.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/targeting_module.go index 96192060c..701518b85 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/targeting_module.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/targeting_module.go @@ -104,8 +104,8 @@ func (m *targetingModule) TargetFileInfos(ctx context.Context) (fileInfos []bufm objectInfo.Path(), objectInfo.ExternalPath(), false, - m.Module.getModuleIdentity(), - m.Module.getCommit(), + m.Module.ModuleIdentity(), + m.Module.Commit(), ) if err != nil { return nil, err @@ -196,8 +196,8 @@ func (m *targetingModule) TargetFileInfos(ctx context.Context) (fileInfos []bufm objectInfo.Path(), objectInfo.ExternalPath(), false, - m.Module.getModuleIdentity(), - m.Module.getCommit(), + m.Module.ModuleIdentity(), + m.Module.Commit(), ) if err != nil { return err diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/workspace.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/workspace.go index 5aafa45b8..e62d5722a 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/workspace.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufmodule/workspace.go @@ -14,7 +14,12 @@ package bufmodule -import "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" +import ( + "context" + + "github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref" + "github.com/bufbuild/buf/private/pkg/storage" +) type workspace struct { // bufmoduleref.ModuleIdentity -> bufmodule.Module @@ -23,13 +28,30 @@ type workspace struct { } func newWorkspace( + ctx context.Context, namedModules map[string]Module, allModules []Module, -) *workspace { +) (*workspace, error) { + pathToExternalPaths := make(map[string][]string) + for _, module := range allModules { + fileInfos, err := module.SourceFileInfos(ctx) + if err != nil { + return nil, err + } + for _, fileInfo := range fileInfos { + pathToExternalPaths[fileInfo.Path()] = append(pathToExternalPaths[fileInfo.Path()], fileInfo.ExternalPath()) + } + } + for path, externalPaths := range pathToExternalPaths { + // Will be >1 even if the externalPaths are equal, we mostly care ab0out the count + if len(externalPaths) > 1 { + return nil, storage.NewErrExistsMultipleLocations(path, externalPaths...) + } + } return &workspace{ namedModules: namedModules, allModules: allModules, - } + }, nil } func (w *workspace) GetModule(moduleIdentity bufmoduleref.ModuleIdentity) (Module, bool) { diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufplugin.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufplugin.go index bef1f6d51..e741c89b2 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufplugin.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufplugin.go @@ -261,10 +261,11 @@ func ProtoSwiftConfigToSwiftRegistryConfig(protoSwiftConfig *registryv1alpha1.Sw swiftConfig.Dependencies = make([]bufpluginconfig.SwiftRegistryDependencyConfig, 0, len(runtimeLibs)) for _, runtimeLib := range runtimeLibs { dependencyConfig := bufpluginconfig.SwiftRegistryDependencyConfig{ - Source: runtimeLib.GetSource(), - Package: runtimeLib.GetPackage(), - Version: runtimeLib.GetVersion(), - Products: runtimeLib.GetProducts(), + Source: runtimeLib.GetSource(), + Package: runtimeLib.GetPackage(), + Version: runtimeLib.GetVersion(), + Products: runtimeLib.GetProducts(), + SwiftVersions: runtimeLib.GetSwiftVersions(), } platforms := runtimeLib.GetPlatforms() for _, platform := range platforms { @@ -293,10 +294,11 @@ func SwiftRegistryConfigToProtoSwiftConfig(swiftConfig *bufpluginconfig.SwiftReg protoSwiftConfig.RuntimeLibraries = make([]*registryv1alpha1.SwiftConfig_RuntimeLibrary, 0, len(swiftConfig.Dependencies)) for _, dependency := range swiftConfig.Dependencies { depConfig := ®istryv1alpha1.SwiftConfig_RuntimeLibrary{ - Source: dependency.Source, - Package: dependency.Package, - Version: dependency.Version, - Products: dependency.Products, + Source: dependency.Source, + Package: dependency.Package, + Version: dependency.Version, + Products: dependency.Products, + SwiftVersions: dependency.SwiftVersions, } if dependency.Platforms.MacOS != "" { depConfig.Platforms = append(depConfig.Platforms, ®istryv1alpha1.SwiftConfig_RuntimeLibrary_Platform{ diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginconfig/bufpluginconfig.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginconfig/bufpluginconfig.go index 26b07a297..217e3e610 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginconfig/bufpluginconfig.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginconfig/bufpluginconfig.go @@ -211,6 +211,8 @@ type SwiftRegistryDependencyConfig struct { Products []string // Platforms are the minimum versions for platforms the package supports. Platforms SwiftRegistryDependencyPlatformConfig + // SwiftVersions are the versions of Swift the package supports. + SwiftVersions []string } // SwiftRegistryDependencyPlatformConfig is the swift registry dependency platform configuration. @@ -445,6 +447,8 @@ type ExternalSwiftRegistryDependencyConfig struct { Products []string `json:"products,omitempty" yaml:"products,omitempty"` // Platforms are the minimum versions for platforms the package supports. Platforms ExternalSwiftRegistryDependencyPlatformConfig `json:"platforms,omitempty" yaml:"platforms,omitempty"` + // SwiftVersions are the versions of Swift the package supports. + SwiftVersions []string `json:"swift_versions,omitempty" yaml:"swift_versions,omitempty"` } // ExternalSwiftRegistryDependencyPlatformConfig is the swift registry dependency platform configuration. diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginconfig/config.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginconfig/config.go index f8e3fa911..3a237c309 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginconfig/config.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginconfig/config.go @@ -308,10 +308,11 @@ func swiftExternalDependencyToDependencyConfig(externalDep ExternalSwiftRegistry return SwiftRegistryDependencyConfig{}, fmt.Errorf("swift runtime dependency %s:%s does not have a valid semantic version", externalDep.Package, externalDep.Version) } return SwiftRegistryDependencyConfig{ - Source: externalDep.Source, - Package: externalDep.Package, - Version: externalDep.Version, - Products: externalDep.Products, + Source: externalDep.Source, + Package: externalDep.Package, + Version: externalDep.Version, + Products: externalDep.Products, + SwiftVersions: externalDep.SwiftVersions, Platforms: SwiftRegistryDependencyPlatformConfig{ MacOS: externalDep.Platforms.MacOS, IOS: externalDep.Platforms.IOS, diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufplugindocker/docker.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufplugindocker/docker.go index 438cd265c..9568c6a04 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufplugindocker/docker.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufplugindocker/docker.go @@ -35,9 +35,6 @@ import ( ) const ( - // PluginsImagePrefix is used to prefix all image names with the correct path for pushing to the OCI registry. - PluginsImagePrefix = "plugins." - // Setting this value on the buf docker client allows us to propagate a custom // value to the OCI registry. This is a useful property that enables registries // to differentiate between the buf cli vs other tools like docker cli. @@ -152,9 +149,6 @@ func (d *dockerAPIClient) Tag(ctx context.Context, image string, config *bufplug } buildID := stringid.GenerateRandomID() imageName := config.Name.IdentityString() + ":" + buildID - if !strings.HasPrefix(imageName, PluginsImagePrefix) { - imageName = PluginsImagePrefix + imageName - } if err := d.cli.ImageTag(ctx, image, imageName); err != nil { return nil, err } diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref/bufpluginref.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref/bufpluginref.go index c4b647c61..7f6a044b1 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref/bufpluginref.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref/bufpluginref.go @@ -93,6 +93,21 @@ func PluginReferenceForString(reference string, revision int) (PluginReference, return parsePluginReference(reference, revision) } +// ParsePluginIdentityOptionalVersion returns the PluginIdentity and version for the given string. +// If the string does not contain a version, the version is assumed to be an empty string. +// This parses the path in the form remote/owner/plugin:version. +func ParsePluginIdentityOptionalVersion(rawReference string) (PluginIdentity, string, error) { + if reference, err := PluginReferenceForString(rawReference, 0); err == nil { + return reference, reference.Version(), nil + } + // Try parsing as a plugin identity (no version information) + identity, err := PluginIdentityForString(rawReference) + if err != nil { + return nil, "", fmt.Errorf("invalid remote plugin %s", rawReference) + } + return identity, "", nil +} + // IsPluginReferenceOrIdentity returns true if the argument matches a plugin // reference (with version) or a plugin identity (without version). func IsPluginReferenceOrIdentity(plugin string) bool { diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/bufremoteplugin/bufremoteplugin.go b/vendor/github.com/bufbuild/buf/private/bufpkg/bufremoteplugin/bufremoteplugin.go index f83aea9d5..a8f347be9 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/bufremoteplugin/bufremoteplugin.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/bufremoteplugin/bufremoteplugin.go @@ -15,27 +15,16 @@ package bufremoteplugin import ( - "errors" "fmt" - "os" - "path/filepath" "strings" - registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" "github.com/bufbuild/buf/private/pkg/app/appcmd" - "github.com/bufbuild/buf/private/pkg/encoding" ) const ( // PluginsPathName is the path prefix used to signify that // a name belongs to a plugin. PluginsPathName = "plugins" - - // TemplatesPathName is the path prefix used to signify that - // a name belongs to a template. - TemplatesPathName = "templates" - - v1Version = "v1" ) // ParsePluginPath parses a string in the format @@ -68,201 +57,3 @@ func ParsePluginVersionPath(pluginVersionPath string) (remote string, owner stri return "", "", "", "", fmt.Errorf("invalid version: %q", name) } } - -// ParseTemplatePath parses a string in the format -// into remote, owner and name. -func ParseTemplatePath(templatePath string) (remote string, owner string, name string, _ error) { - if templatePath == "" { - return "", "", "", appcmd.NewInvalidArgumentError("you must specify a template path") - } - components := strings.Split(templatePath, "/") - if len(components) != 4 || components[2] != TemplatesPathName { - return "", "", "", appcmd.NewInvalidArgumentErrorf("%s is not a valid template path", templatePath) - } - return components[0], components[1], components[3], nil -} - -// ValidateTemplateName validates the format of the template name. -// This is only used for client side validation and attempts to avoid -// validation constraints that we may want to change. -func ValidateTemplateName(templateName string) error { - if templateName == "" { - return errors.New("template name is required") - } - return nil -} - -// TemplateConfig is the config used to describe the plugins -// of a new template. -type TemplateConfig struct { - Plugins []PluginConfig -} - -// TemplateConfigToProtoPluginConfigs converts the template config to a slice of proto plugin configs, -// suitable for use with the Plugin Service CreateTemplate RPC. -func TemplateConfigToProtoPluginConfigs(templateConfig *TemplateConfig) []*registryv1alpha1.PluginConfig { - pluginConfigs := make([]*registryv1alpha1.PluginConfig, 0, len(templateConfig.Plugins)) - for _, plugin := range templateConfig.Plugins { - pluginConfigs = append( - pluginConfigs, - ®istryv1alpha1.PluginConfig{ - PluginOwner: plugin.Owner, - PluginName: plugin.Name, - Parameters: plugin.Parameters, - }, - ) - } - return pluginConfigs -} - -// PluginConfig is the config used to describe a plugin in -// a new template. -type PluginConfig struct { - Owner string - Name string - Parameters []string -} - -// ParseTemplateConfig parses the input template config as a path or JSON/YAML literal. -func ParseTemplateConfig(config string) (*TemplateConfig, error) { - var data []byte - var err error - switch filepath.Ext(config) { - case ".json", ".yaml", ".yml": - data, err = os.ReadFile(config) - if err != nil { - return nil, fmt.Errorf("could not read file: %v", err) - } - default: - data = []byte(config) - } - var version externalTemplateConfigVersion - if err := encoding.UnmarshalJSONOrYAMLNonStrict(data, &version); err != nil { - return nil, fmt.Errorf("failed to determine version of template config: %w", err) - } - switch version.Version { - case "": - return nil, errors.New("template config version is required") - case v1Version: - default: - return nil, fmt.Errorf("unknown template config version: %q", version.Version) - } - var externalConfig externalTemplateConfig - if err := encoding.UnmarshalJSONOrYAMLStrict(data, &externalConfig); err != nil { - return nil, fmt.Errorf("failed to unmarshal template config: %w", err) - } - templateConfig := &TemplateConfig{ - Plugins: make([]PluginConfig, 0, len(externalConfig.Plugins)), - } - for _, plugin := range externalConfig.Plugins { - templatePlugin := PluginConfig{ - Owner: plugin.Owner, - Name: plugin.Name, - } - parameterString, err := encoding.InterfaceSliceOrStringToCommaSepString(plugin.Options) - if err != nil { - return nil, fmt.Errorf("failed to parse options: %w", err) - } - if parameterString != "" { - templatePlugin.Parameters = strings.Split(parameterString, ",") - } - templateConfig.Plugins = append(templateConfig.Plugins, templatePlugin) - } - return templateConfig, nil -} - -// TemplateVersionConfig is the config used to describe the plugin -// version of a new template version. -type TemplateVersionConfig struct { - PluginVersions []PluginVersion -} - -// TemplateVersionConfigToProtoPluginVersionMappings converts the template version config to a -// slice of Plugin version mappings, suitable for use with the Plugin Service CreateTemplateVersion RPC. -func TemplateVersionConfigToProtoPluginVersionMappings( - templateVersionConfig *TemplateVersionConfig, -) []*registryv1alpha1.PluginVersionMapping { - pluginVersions := make([]*registryv1alpha1.PluginVersionMapping, 0, len(templateVersionConfig.PluginVersions)) - for _, pluginVersion := range templateVersionConfig.PluginVersions { - pluginVersions = append( - pluginVersions, - ®istryv1alpha1.PluginVersionMapping{ - PluginOwner: pluginVersion.Owner, - PluginName: pluginVersion.Name, - Version: pluginVersion.Version, - }, - ) - } - return pluginVersions -} - -// PluginVersion describes a version of a plugin for -// use in a template version. -type PluginVersion struct { - Owner string - Name string - Version string -} - -// ParseTemplateVersionConfig parses the input template version config as a path or JSON/YAML literal. -func ParseTemplateVersionConfig(config string) (*TemplateVersionConfig, error) { - var data []byte - var err error - switch filepath.Ext(config) { - case ".json", ".yaml", ".yml": - data, err = os.ReadFile(config) - if err != nil { - return nil, fmt.Errorf("could not read file: %v", err) - } - default: - data = []byte(config) - } - var version externalTemplateConfigVersion - if err := encoding.UnmarshalJSONOrYAMLNonStrict(data, &version); err != nil { - return nil, fmt.Errorf("failed to determine version of template version config: %w", err) - } - switch version.Version { - case "": - return nil, errors.New("template version config version is required") - case v1Version: - default: - return nil, fmt.Errorf("unknown template version config version: %q", version.Version) - } - var externalConfig externalTemplateVersionConfig - if err := encoding.UnmarshalJSONOrYAMLStrict(data, &externalConfig); err != nil { - return nil, fmt.Errorf("failed to unmarshal template version config: %w", err) - } - templateVersionConfig := &TemplateVersionConfig{ - PluginVersions: make([]PluginVersion, 0, len(externalConfig.PluginVersions)), - } - for _, pluginVersion := range externalConfig.PluginVersions { - templateVersionConfig.PluginVersions = append(templateVersionConfig.PluginVersions, PluginVersion(pluginVersion)) - } - return templateVersionConfig, nil -} - -type externalTemplateConfig struct { - Version string `json:"version,omitempty" yaml:"version,omitempty"` - Plugins []externalPluginConfig `json:"plugins,omitempty" yaml:"plugins,omitempty"` -} - -type externalPluginConfig struct { - Owner string `json:"owner,omitempty" yaml:"owner,omitempty"` - Name string `json:"name,omitempty" yaml:"name,omitempty"` - Options interface{} `json:"opt,omitempty" yaml:"opt,omitempty"` -} - -type externalTemplateVersionConfig struct { - Version string `json:"version,omitempty" yaml:"version,omitempty"` - PluginVersions []externalPluginVersion `json:"plugin_versions,omitempty" yaml:"plugin_versions,omitempty"` -} - -type externalPluginVersion struct { - Owner string `json:"owner,omitempty" yaml:"owner,omitempty"` - Name string `json:"name,omitempty" yaml:"name,omitempty"` - Version string `json:"version,omitempty" yaml:"version,omitempty"` -} - -type externalTemplateConfigVersion struct { - Version string `json:"version,omitempty" yaml:"version,omitempty"` -} diff --git a/vendor/github.com/bufbuild/buf/private/bufpkg/buftransport/buftransport.go b/vendor/github.com/bufbuild/buf/private/bufpkg/buftransport/buftransport.go index b0b5ab158..9c9978d9f 100644 --- a/vendor/github.com/bufbuild/buf/private/bufpkg/buftransport/buftransport.go +++ b/vendor/github.com/bufbuild/buf/private/bufpkg/buftransport/buftransport.go @@ -14,38 +14,11 @@ package buftransport -import ( - "strings" - - "github.com/bufbuild/buf/private/pkg/app" -) - const ( - // APISubdomain is the subdomain used for calls to the BSR API - APISubdomain = "api" - schemeHTTP = "http" schemeHTTPS = "https" - - // TODO: change to based on "use" - disableAPISubdomainEnvKey = "BUF_DISABLE_API_SUBDOMAIN" ) -// IsAPISubdomainEnabled returns true if the container says to use the API subdomain. -func IsAPISubdomainEnabled(container app.EnvContainer) bool { - return strings.TrimSpace(strings.ToLower(container.Env(disableAPISubdomainEnvKey))) == "" -} - -// SetDisableAPISubdomain sets the environment map to disable the API subdomain. -func SetDisableAPISubdomain(env map[string]string) { - env[disableAPISubdomainEnvKey] = "disable" -} - -// PrependAPISubdomain prepends the API subdomain to the given address. -func PrependAPISubdomain(address string) string { - return APISubdomain + "." + address -} - // PrependHTTP prepends an http scheme to the given address func PrependHTTP(address string) string { return schemeHTTP + "://" + address diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/admin.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/admin.connect.go index cf831a30a..94e5e6651 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/admin.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/admin.connect.go @@ -32,7 +32,7 @@ import ( // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. -const _ = connect_go.IsAtLeastVersion0_1_0 +const _ = connect_go.IsAtLeastVersion1_7_0 const ( // AdminServiceName is the fully-qualified name of the AdminService service. @@ -59,6 +59,12 @@ const ( // AdminServiceCreateMachineUserProcedure is the fully-qualified name of the AdminService's // CreateMachineUser RPC. AdminServiceCreateMachineUserProcedure = "/buf.alpha.registry.v1alpha1.AdminService/CreateMachineUser" + // AdminServiceGetBreakingChangePolicyProcedure is the fully-qualified name of the AdminService's + // GetBreakingChangePolicy RPC. + AdminServiceGetBreakingChangePolicyProcedure = "/buf.alpha.registry.v1alpha1.AdminService/GetBreakingChangePolicy" + // AdminServiceUpdateBreakingChangePolicyProcedure is the fully-qualified name of the AdminService's + // UpdateBreakingChangePolicy RPC. + AdminServiceUpdateBreakingChangePolicyProcedure = "/buf.alpha.registry.v1alpha1.AdminService/UpdateBreakingChangePolicy" ) // AdminServiceClient is a client for the buf.alpha.registry.v1alpha1.AdminService service. @@ -72,6 +78,10 @@ type AdminServiceClient interface { UpdateOrganizationVerificationStatus(context.Context, *connect_go.Request[v1alpha1.UpdateOrganizationVerificationStatusRequest]) (*connect_go.Response[v1alpha1.UpdateOrganizationVerificationStatusResponse], error) // Create a new machine user on the server. CreateMachineUser(context.Context, *connect_go.Request[v1alpha1.CreateMachineUserRequest]) (*connect_go.Response[v1alpha1.CreateMachineUserResponse], error) + // Get breaking change policy for the server. + GetBreakingChangePolicy(context.Context, *connect_go.Request[v1alpha1.GetBreakingChangePolicyRequest]) (*connect_go.Response[v1alpha1.GetBreakingChangePolicyResponse], error) + // Update breaking change policy for the server. + UpdateBreakingChangePolicy(context.Context, *connect_go.Request[v1alpha1.UpdateBreakingChangePolicyRequest]) (*connect_go.Response[v1alpha1.UpdateBreakingChangePolicyResponse], error) } // NewAdminServiceClient constructs a client for the buf.alpha.registry.v1alpha1.AdminService @@ -87,7 +97,8 @@ func NewAdminServiceClient(httpClient connect_go.HTTPClient, baseURL string, opt forceDeleteUser: connect_go.NewClient[v1alpha1.ForceDeleteUserRequest, v1alpha1.ForceDeleteUserResponse]( httpClient, baseURL+AdminServiceForceDeleteUserProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), updateUserVerificationStatus: connect_go.NewClient[v1alpha1.UpdateUserVerificationStatusRequest, v1alpha1.UpdateUserVerificationStatusResponse]( httpClient, @@ -102,6 +113,18 @@ func NewAdminServiceClient(httpClient connect_go.HTTPClient, baseURL string, opt createMachineUser: connect_go.NewClient[v1alpha1.CreateMachineUserRequest, v1alpha1.CreateMachineUserResponse]( httpClient, baseURL+AdminServiceCreateMachineUserProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), + ), + getBreakingChangePolicy: connect_go.NewClient[v1alpha1.GetBreakingChangePolicyRequest, v1alpha1.GetBreakingChangePolicyResponse]( + httpClient, + baseURL+AdminServiceGetBreakingChangePolicyProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithClientOptions(opts...), + ), + updateBreakingChangePolicy: connect_go.NewClient[v1alpha1.UpdateBreakingChangePolicyRequest, v1alpha1.UpdateBreakingChangePolicyResponse]( + httpClient, + baseURL+AdminServiceUpdateBreakingChangePolicyProcedure, opts..., ), } @@ -113,6 +136,8 @@ type adminServiceClient struct { updateUserVerificationStatus *connect_go.Client[v1alpha1.UpdateUserVerificationStatusRequest, v1alpha1.UpdateUserVerificationStatusResponse] updateOrganizationVerificationStatus *connect_go.Client[v1alpha1.UpdateOrganizationVerificationStatusRequest, v1alpha1.UpdateOrganizationVerificationStatusResponse] createMachineUser *connect_go.Client[v1alpha1.CreateMachineUserRequest, v1alpha1.CreateMachineUserResponse] + getBreakingChangePolicy *connect_go.Client[v1alpha1.GetBreakingChangePolicyRequest, v1alpha1.GetBreakingChangePolicyResponse] + updateBreakingChangePolicy *connect_go.Client[v1alpha1.UpdateBreakingChangePolicyRequest, v1alpha1.UpdateBreakingChangePolicyResponse] } // ForceDeleteUser calls buf.alpha.registry.v1alpha1.AdminService.ForceDeleteUser. @@ -137,6 +162,17 @@ func (c *adminServiceClient) CreateMachineUser(ctx context.Context, req *connect return c.createMachineUser.CallUnary(ctx, req) } +// GetBreakingChangePolicy calls buf.alpha.registry.v1alpha1.AdminService.GetBreakingChangePolicy. +func (c *adminServiceClient) GetBreakingChangePolicy(ctx context.Context, req *connect_go.Request[v1alpha1.GetBreakingChangePolicyRequest]) (*connect_go.Response[v1alpha1.GetBreakingChangePolicyResponse], error) { + return c.getBreakingChangePolicy.CallUnary(ctx, req) +} + +// UpdateBreakingChangePolicy calls +// buf.alpha.registry.v1alpha1.AdminService.UpdateBreakingChangePolicy. +func (c *adminServiceClient) UpdateBreakingChangePolicy(ctx context.Context, req *connect_go.Request[v1alpha1.UpdateBreakingChangePolicyRequest]) (*connect_go.Response[v1alpha1.UpdateBreakingChangePolicyResponse], error) { + return c.updateBreakingChangePolicy.CallUnary(ctx, req) +} + // AdminServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.AdminService service. type AdminServiceHandler interface { // ForceDeleteUser forces to delete a user. Resources and organizations that are @@ -148,6 +184,10 @@ type AdminServiceHandler interface { UpdateOrganizationVerificationStatus(context.Context, *connect_go.Request[v1alpha1.UpdateOrganizationVerificationStatusRequest]) (*connect_go.Response[v1alpha1.UpdateOrganizationVerificationStatusResponse], error) // Create a new machine user on the server. CreateMachineUser(context.Context, *connect_go.Request[v1alpha1.CreateMachineUserRequest]) (*connect_go.Response[v1alpha1.CreateMachineUserResponse], error) + // Get breaking change policy for the server. + GetBreakingChangePolicy(context.Context, *connect_go.Request[v1alpha1.GetBreakingChangePolicyRequest]) (*connect_go.Response[v1alpha1.GetBreakingChangePolicyResponse], error) + // Update breaking change policy for the server. + UpdateBreakingChangePolicy(context.Context, *connect_go.Request[v1alpha1.UpdateBreakingChangePolicyRequest]) (*connect_go.Response[v1alpha1.UpdateBreakingChangePolicyResponse], error) } // NewAdminServiceHandler builds an HTTP handler from the service implementation. It returns the @@ -160,7 +200,8 @@ func NewAdminServiceHandler(svc AdminServiceHandler, opts ...connect_go.HandlerO mux.Handle(AdminServiceForceDeleteUserProcedure, connect_go.NewUnaryHandler( AdminServiceForceDeleteUserProcedure, svc.ForceDeleteUser, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(AdminServiceUpdateUserVerificationStatusProcedure, connect_go.NewUnaryHandler( AdminServiceUpdateUserVerificationStatusProcedure, @@ -175,6 +216,18 @@ func NewAdminServiceHandler(svc AdminServiceHandler, opts ...connect_go.HandlerO mux.Handle(AdminServiceCreateMachineUserProcedure, connect_go.NewUnaryHandler( AdminServiceCreateMachineUserProcedure, svc.CreateMachineUser, + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), + )) + mux.Handle(AdminServiceGetBreakingChangePolicyProcedure, connect_go.NewUnaryHandler( + AdminServiceGetBreakingChangePolicyProcedure, + svc.GetBreakingChangePolicy, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithHandlerOptions(opts...), + )) + mux.Handle(AdminServiceUpdateBreakingChangePolicyProcedure, connect_go.NewUnaryHandler( + AdminServiceUpdateBreakingChangePolicyProcedure, + svc.UpdateBreakingChangePolicy, opts..., )) return "/buf.alpha.registry.v1alpha1.AdminService/", mux @@ -198,3 +251,11 @@ func (UnimplementedAdminServiceHandler) UpdateOrganizationVerificationStatus(con func (UnimplementedAdminServiceHandler) CreateMachineUser(context.Context, *connect_go.Request[v1alpha1.CreateMachineUserRequest]) (*connect_go.Response[v1alpha1.CreateMachineUserResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.AdminService.CreateMachineUser is not implemented")) } + +func (UnimplementedAdminServiceHandler) GetBreakingChangePolicy(context.Context, *connect_go.Request[v1alpha1.GetBreakingChangePolicyRequest]) (*connect_go.Response[v1alpha1.GetBreakingChangePolicyResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.AdminService.GetBreakingChangePolicy is not implemented")) +} + +func (UnimplementedAdminServiceHandler) UpdateBreakingChangePolicy(context.Context, *connect_go.Request[v1alpha1.UpdateBreakingChangePolicyRequest]) (*connect_go.Response[v1alpha1.UpdateBreakingChangePolicyResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.AdminService.UpdateBreakingChangePolicy is not implemented")) +} diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/authz.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/authz.connect.go index a48edcf20..d54bc456e 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/authz.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/authz.connect.go @@ -107,12 +107,6 @@ const ( // AuthzServiceUserCanManageRepositoryContributorsProcedure is the fully-qualified name of the // AuthzService's UserCanManageRepositoryContributors RPC. AuthzServiceUserCanManageRepositoryContributorsProcedure = "/buf.alpha.registry.v1alpha1.AuthzService/UserCanManageRepositoryContributors" - // AuthzServiceUserCanManagePluginContributorsProcedure is the fully-qualified name of the - // AuthzService's UserCanManagePluginContributors RPC. - AuthzServiceUserCanManagePluginContributorsProcedure = "/buf.alpha.registry.v1alpha1.AuthzService/UserCanManagePluginContributors" - // AuthzServiceUserCanManageTemplateContributorsProcedure is the fully-qualified name of the - // AuthzService's UserCanManageTemplateContributors RPC. - AuthzServiceUserCanManageTemplateContributorsProcedure = "/buf.alpha.registry.v1alpha1.AuthzService/UserCanManageTemplateContributors" ) // AuthzServiceClient is a client for the buf.alpha.registry.v1alpha1.AuthzService service. @@ -194,16 +188,6 @@ type AuthzServiceClient interface { // UserCanManageRepositoryContributors returns whether the user is authorized to manage // any contributors to the repository and the list of roles they can manage. UserCanManageRepositoryContributors(context.Context, *connect_go.Request[v1alpha1.UserCanManageRepositoryContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManageRepositoryContributorsResponse], error) - // UserCanManagePluginContributors returns whether the user is authorized to manage - // any contributors to the plugin and the list of roles they can manage. - // - // Deprecated: do not use. - UserCanManagePluginContributors(context.Context, *connect_go.Request[v1alpha1.UserCanManagePluginContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManagePluginContributorsResponse], error) - // UserCanManageTemplateContributors returns whether the user is authorized to manage - // any contributors to the template and the list of roles they can manage. - // - // Deprecated: do not use. - UserCanManageTemplateContributors(context.Context, *connect_go.Request[v1alpha1.UserCanManageTemplateContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManageTemplateContributorsResponse], error) } // NewAuthzServiceClient constructs a client for the buf.alpha.registry.v1alpha1.AuthzService @@ -336,18 +320,6 @@ func NewAuthzServiceClient(httpClient connect_go.HTTPClient, baseURL string, opt connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithClientOptions(opts...), ), - userCanManagePluginContributors: connect_go.NewClient[v1alpha1.UserCanManagePluginContributorsRequest, v1alpha1.UserCanManagePluginContributorsResponse]( - httpClient, - baseURL+AuthzServiceUserCanManagePluginContributorsProcedure, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithClientOptions(opts...), - ), - userCanManageTemplateContributors: connect_go.NewClient[v1alpha1.UserCanManageTemplateContributorsRequest, v1alpha1.UserCanManageTemplateContributorsResponse]( - httpClient, - baseURL+AuthzServiceUserCanManageTemplateContributorsProcedure, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithClientOptions(opts...), - ), } } @@ -373,8 +345,6 @@ type authzServiceClient struct { userCanDeleteUser *connect_go.Client[v1alpha1.UserCanDeleteUserRequest, v1alpha1.UserCanDeleteUserResponse] userCanSeeServerAdminPanel *connect_go.Client[v1alpha1.UserCanSeeServerAdminPanelRequest, v1alpha1.UserCanSeeServerAdminPanelResponse] userCanManageRepositoryContributors *connect_go.Client[v1alpha1.UserCanManageRepositoryContributorsRequest, v1alpha1.UserCanManageRepositoryContributorsResponse] - userCanManagePluginContributors *connect_go.Client[v1alpha1.UserCanManagePluginContributorsRequest, v1alpha1.UserCanManagePluginContributorsResponse] - userCanManageTemplateContributors *connect_go.Client[v1alpha1.UserCanManageTemplateContributorsRequest, v1alpha1.UserCanManageTemplateContributorsResponse] } // UserCanCreateOrganizationRepository calls @@ -509,22 +479,6 @@ func (c *authzServiceClient) UserCanManageRepositoryContributors(ctx context.Con return c.userCanManageRepositoryContributors.CallUnary(ctx, req) } -// UserCanManagePluginContributors calls -// buf.alpha.registry.v1alpha1.AuthzService.UserCanManagePluginContributors. -// -// Deprecated: do not use. -func (c *authzServiceClient) UserCanManagePluginContributors(ctx context.Context, req *connect_go.Request[v1alpha1.UserCanManagePluginContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManagePluginContributorsResponse], error) { - return c.userCanManagePluginContributors.CallUnary(ctx, req) -} - -// UserCanManageTemplateContributors calls -// buf.alpha.registry.v1alpha1.AuthzService.UserCanManageTemplateContributors. -// -// Deprecated: do not use. -func (c *authzServiceClient) UserCanManageTemplateContributors(ctx context.Context, req *connect_go.Request[v1alpha1.UserCanManageTemplateContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManageTemplateContributorsResponse], error) { - return c.userCanManageTemplateContributors.CallUnary(ctx, req) -} - // AuthzServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.AuthzService service. type AuthzServiceHandler interface { // UserCanCreateOrganizationRepository returns whether the user is authorized @@ -604,16 +558,6 @@ type AuthzServiceHandler interface { // UserCanManageRepositoryContributors returns whether the user is authorized to manage // any contributors to the repository and the list of roles they can manage. UserCanManageRepositoryContributors(context.Context, *connect_go.Request[v1alpha1.UserCanManageRepositoryContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManageRepositoryContributorsResponse], error) - // UserCanManagePluginContributors returns whether the user is authorized to manage - // any contributors to the plugin and the list of roles they can manage. - // - // Deprecated: do not use. - UserCanManagePluginContributors(context.Context, *connect_go.Request[v1alpha1.UserCanManagePluginContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManagePluginContributorsResponse], error) - // UserCanManageTemplateContributors returns whether the user is authorized to manage - // any contributors to the template and the list of roles they can manage. - // - // Deprecated: do not use. - UserCanManageTemplateContributors(context.Context, *connect_go.Request[v1alpha1.UserCanManageTemplateContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManageTemplateContributorsResponse], error) } // NewAuthzServiceHandler builds an HTTP handler from the service implementation. It returns the @@ -743,18 +687,6 @@ func NewAuthzServiceHandler(svc AuthzServiceHandler, opts ...connect_go.HandlerO connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithHandlerOptions(opts...), )) - mux.Handle(AuthzServiceUserCanManagePluginContributorsProcedure, connect_go.NewUnaryHandler( - AuthzServiceUserCanManagePluginContributorsProcedure, - svc.UserCanManagePluginContributors, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithHandlerOptions(opts...), - )) - mux.Handle(AuthzServiceUserCanManageTemplateContributorsProcedure, connect_go.NewUnaryHandler( - AuthzServiceUserCanManageTemplateContributorsProcedure, - svc.UserCanManageTemplateContributors, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithHandlerOptions(opts...), - )) return "/buf.alpha.registry.v1alpha1.AuthzService/", mux } @@ -840,11 +772,3 @@ func (UnimplementedAuthzServiceHandler) UserCanSeeServerAdminPanel(context.Conte func (UnimplementedAuthzServiceHandler) UserCanManageRepositoryContributors(context.Context, *connect_go.Request[v1alpha1.UserCanManageRepositoryContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManageRepositoryContributorsResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.AuthzService.UserCanManageRepositoryContributors is not implemented")) } - -func (UnimplementedAuthzServiceHandler) UserCanManagePluginContributors(context.Context, *connect_go.Request[v1alpha1.UserCanManagePluginContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManagePluginContributorsResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.AuthzService.UserCanManagePluginContributors is not implemented")) -} - -func (UnimplementedAuthzServiceHandler) UserCanManageTemplateContributors(context.Context, *connect_go.Request[v1alpha1.UserCanManageTemplateContributorsRequest]) (*connect_go.Response[v1alpha1.UserCanManageTemplateContributorsResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.AuthzService.UserCanManageTemplateContributors is not implemented")) -} diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/display.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/display.connect.go index 108055bef..85a048808 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/display.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/display.connect.go @@ -53,12 +53,6 @@ const ( // DisplayServiceDisplayRepositoryElementsProcedure is the fully-qualified name of the // DisplayService's DisplayRepositoryElements RPC. DisplayServiceDisplayRepositoryElementsProcedure = "/buf.alpha.registry.v1alpha1.DisplayService/DisplayRepositoryElements" - // DisplayServiceDisplayPluginElementsProcedure is the fully-qualified name of the DisplayService's - // DisplayPluginElements RPC. - DisplayServiceDisplayPluginElementsProcedure = "/buf.alpha.registry.v1alpha1.DisplayService/DisplayPluginElements" - // DisplayServiceDisplayTemplateElementsProcedure is the fully-qualified name of the - // DisplayService's DisplayTemplateElements RPC. - DisplayServiceDisplayTemplateElementsProcedure = "/buf.alpha.registry.v1alpha1.DisplayService/DisplayTemplateElements" // DisplayServiceDisplayUserElementsProcedure is the fully-qualified name of the DisplayService's // DisplayUserElements RPC. DisplayServiceDisplayUserElementsProcedure = "/buf.alpha.registry.v1alpha1.DisplayService/DisplayUserElements" @@ -77,18 +71,6 @@ const ( // DisplayServiceListManageableUserRepositoryRolesProcedure is the fully-qualified name of the // DisplayService's ListManageableUserRepositoryRoles RPC. DisplayServiceListManageableUserRepositoryRolesProcedure = "/buf.alpha.registry.v1alpha1.DisplayService/ListManageableUserRepositoryRoles" - // DisplayServiceListManageablePluginRolesProcedure is the fully-qualified name of the - // DisplayService's ListManageablePluginRoles RPC. - DisplayServiceListManageablePluginRolesProcedure = "/buf.alpha.registry.v1alpha1.DisplayService/ListManageablePluginRoles" - // DisplayServiceListManageableUserPluginRolesProcedure is the fully-qualified name of the - // DisplayService's ListManageableUserPluginRoles RPC. - DisplayServiceListManageableUserPluginRolesProcedure = "/buf.alpha.registry.v1alpha1.DisplayService/ListManageableUserPluginRoles" - // DisplayServiceListManageableTemplateRolesProcedure is the fully-qualified name of the - // DisplayService's ListManageableTemplateRoles RPC. - DisplayServiceListManageableTemplateRolesProcedure = "/buf.alpha.registry.v1alpha1.DisplayService/ListManageableTemplateRoles" - // DisplayServiceListManageableUserTemplateRolesProcedure is the fully-qualified name of the - // DisplayService's ListManageableUserTemplateRoles RPC. - DisplayServiceListManageableUserTemplateRolesProcedure = "/buf.alpha.registry.v1alpha1.DisplayService/ListManageableUserTemplateRoles" ) // DisplayServiceClient is a client for the buf.alpha.registry.v1alpha1.DisplayService service. @@ -97,14 +79,6 @@ type DisplayServiceClient interface { DisplayOrganizationElements(context.Context, *connect_go.Request[v1alpha1.DisplayOrganizationElementsRequest]) (*connect_go.Response[v1alpha1.DisplayOrganizationElementsResponse], error) // DisplayRepositoryElements returns which repository elements should be displayed to the user. DisplayRepositoryElements(context.Context, *connect_go.Request[v1alpha1.DisplayRepositoryElementsRequest]) (*connect_go.Response[v1alpha1.DisplayRepositoryElementsResponse], error) - // DisplayPluginElements returns which plugin elements should be displayed to the user. - // - // Deprecated: do not use. - DisplayPluginElements(context.Context, *connect_go.Request[v1alpha1.DisplayPluginElementsRequest]) (*connect_go.Response[v1alpha1.DisplayPluginElementsResponse], error) - // DisplayTemplateElements returns which template elements should be displayed to the user. - // - // Deprecated: do not use. - DisplayTemplateElements(context.Context, *connect_go.Request[v1alpha1.DisplayTemplateElementsRequest]) (*connect_go.Response[v1alpha1.DisplayTemplateElementsResponse], error) // DisplayUserElements returns which user elements should be displayed to the user. DisplayUserElements(context.Context, *connect_go.Request[v1alpha1.DisplayUserElementsRequest]) (*connect_go.Response[v1alpha1.DisplayUserElementsResponse], error) // DisplayServerElements returns which server elements should be displayed to the user. @@ -119,26 +93,6 @@ type DisplayServiceClient interface { // ListManageableUserRepositoryRoles returns which roles should be displayed // to the user when they are managing a specific contributor on the repository. ListManageableUserRepositoryRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableUserRepositoryRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserRepositoryRolesResponse], error) - // ListManageablePluginRoles returns which roles should be displayed - // to the user when they are managing contributors on the plugin. - // - // Deprecated: do not use. - ListManageablePluginRoles(context.Context, *connect_go.Request[v1alpha1.ListManageablePluginRolesRequest]) (*connect_go.Response[v1alpha1.ListManageablePluginRolesResponse], error) - // ListManageableUserPluginRoles returns which roles should be displayed - // to the user when they are managing a specific contributor on the plugin. - // - // Deprecated: do not use. - ListManageableUserPluginRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableUserPluginRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserPluginRolesResponse], error) - // ListManageableTemplateRoles returns which roles should be displayed - // to the user when they are managing contributors on the template. - // - // Deprecated: do not use. - ListManageableTemplateRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableTemplateRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableTemplateRolesResponse], error) - // ListManageableUserTemplateRoles returns which roles should be displayed - // to the user when they are managing a specific contributor on the template. - // - // Deprecated: do not use. - ListManageableUserTemplateRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableUserTemplateRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserTemplateRolesResponse], error) } // NewDisplayServiceClient constructs a client for the buf.alpha.registry.v1alpha1.DisplayService @@ -163,18 +117,6 @@ func NewDisplayServiceClient(httpClient connect_go.HTTPClient, baseURL string, o connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithClientOptions(opts...), ), - displayPluginElements: connect_go.NewClient[v1alpha1.DisplayPluginElementsRequest, v1alpha1.DisplayPluginElementsResponse]( - httpClient, - baseURL+DisplayServiceDisplayPluginElementsProcedure, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithClientOptions(opts...), - ), - displayTemplateElements: connect_go.NewClient[v1alpha1.DisplayTemplateElementsRequest, v1alpha1.DisplayTemplateElementsResponse]( - httpClient, - baseURL+DisplayServiceDisplayTemplateElementsProcedure, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithClientOptions(opts...), - ), displayUserElements: connect_go.NewClient[v1alpha1.DisplayUserElementsRequest, v1alpha1.DisplayUserElementsResponse]( httpClient, baseURL+DisplayServiceDisplayUserElementsProcedure, @@ -211,30 +153,6 @@ func NewDisplayServiceClient(httpClient connect_go.HTTPClient, baseURL string, o connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithClientOptions(opts...), ), - listManageablePluginRoles: connect_go.NewClient[v1alpha1.ListManageablePluginRolesRequest, v1alpha1.ListManageablePluginRolesResponse]( - httpClient, - baseURL+DisplayServiceListManageablePluginRolesProcedure, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithClientOptions(opts...), - ), - listManageableUserPluginRoles: connect_go.NewClient[v1alpha1.ListManageableUserPluginRolesRequest, v1alpha1.ListManageableUserPluginRolesResponse]( - httpClient, - baseURL+DisplayServiceListManageableUserPluginRolesProcedure, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithClientOptions(opts...), - ), - listManageableTemplateRoles: connect_go.NewClient[v1alpha1.ListManageableTemplateRolesRequest, v1alpha1.ListManageableTemplateRolesResponse]( - httpClient, - baseURL+DisplayServiceListManageableTemplateRolesProcedure, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithClientOptions(opts...), - ), - listManageableUserTemplateRoles: connect_go.NewClient[v1alpha1.ListManageableUserTemplateRolesRequest, v1alpha1.ListManageableUserTemplateRolesResponse]( - httpClient, - baseURL+DisplayServiceListManageableUserTemplateRolesProcedure, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithClientOptions(opts...), - ), } } @@ -242,18 +160,12 @@ func NewDisplayServiceClient(httpClient connect_go.HTTPClient, baseURL string, o type displayServiceClient struct { displayOrganizationElements *connect_go.Client[v1alpha1.DisplayOrganizationElementsRequest, v1alpha1.DisplayOrganizationElementsResponse] displayRepositoryElements *connect_go.Client[v1alpha1.DisplayRepositoryElementsRequest, v1alpha1.DisplayRepositoryElementsResponse] - displayPluginElements *connect_go.Client[v1alpha1.DisplayPluginElementsRequest, v1alpha1.DisplayPluginElementsResponse] - displayTemplateElements *connect_go.Client[v1alpha1.DisplayTemplateElementsRequest, v1alpha1.DisplayTemplateElementsResponse] displayUserElements *connect_go.Client[v1alpha1.DisplayUserElementsRequest, v1alpha1.DisplayUserElementsResponse] displayServerElements *connect_go.Client[v1alpha1.DisplayServerElementsRequest, v1alpha1.DisplayServerElementsResponse] displayOwnerEntitledElements *connect_go.Client[v1alpha1.DisplayOwnerEntitledElementsRequest, v1alpha1.DisplayOwnerEntitledElementsResponse] displayRepositoryEntitledElements *connect_go.Client[v1alpha1.DisplayRepositoryEntitledElementsRequest, v1alpha1.DisplayRepositoryEntitledElementsResponse] listManageableRepositoryRoles *connect_go.Client[v1alpha1.ListManageableRepositoryRolesRequest, v1alpha1.ListManageableRepositoryRolesResponse] listManageableUserRepositoryRoles *connect_go.Client[v1alpha1.ListManageableUserRepositoryRolesRequest, v1alpha1.ListManageableUserRepositoryRolesResponse] - listManageablePluginRoles *connect_go.Client[v1alpha1.ListManageablePluginRolesRequest, v1alpha1.ListManageablePluginRolesResponse] - listManageableUserPluginRoles *connect_go.Client[v1alpha1.ListManageableUserPluginRolesRequest, v1alpha1.ListManageableUserPluginRolesResponse] - listManageableTemplateRoles *connect_go.Client[v1alpha1.ListManageableTemplateRolesRequest, v1alpha1.ListManageableTemplateRolesResponse] - listManageableUserTemplateRoles *connect_go.Client[v1alpha1.ListManageableUserTemplateRolesRequest, v1alpha1.ListManageableUserTemplateRolesResponse] } // DisplayOrganizationElements calls @@ -268,20 +180,6 @@ func (c *displayServiceClient) DisplayRepositoryElements(ctx context.Context, re return c.displayRepositoryElements.CallUnary(ctx, req) } -// DisplayPluginElements calls buf.alpha.registry.v1alpha1.DisplayService.DisplayPluginElements. -// -// Deprecated: do not use. -func (c *displayServiceClient) DisplayPluginElements(ctx context.Context, req *connect_go.Request[v1alpha1.DisplayPluginElementsRequest]) (*connect_go.Response[v1alpha1.DisplayPluginElementsResponse], error) { - return c.displayPluginElements.CallUnary(ctx, req) -} - -// DisplayTemplateElements calls buf.alpha.registry.v1alpha1.DisplayService.DisplayTemplateElements. -// -// Deprecated: do not use. -func (c *displayServiceClient) DisplayTemplateElements(ctx context.Context, req *connect_go.Request[v1alpha1.DisplayTemplateElementsRequest]) (*connect_go.Response[v1alpha1.DisplayTemplateElementsResponse], error) { - return c.displayTemplateElements.CallUnary(ctx, req) -} - // DisplayUserElements calls buf.alpha.registry.v1alpha1.DisplayService.DisplayUserElements. func (c *displayServiceClient) DisplayUserElements(ctx context.Context, req *connect_go.Request[v1alpha1.DisplayUserElementsRequest]) (*connect_go.Response[v1alpha1.DisplayUserElementsResponse], error) { return c.displayUserElements.CallUnary(ctx, req) @@ -316,38 +214,6 @@ func (c *displayServiceClient) ListManageableUserRepositoryRoles(ctx context.Con return c.listManageableUserRepositoryRoles.CallUnary(ctx, req) } -// ListManageablePluginRoles calls -// buf.alpha.registry.v1alpha1.DisplayService.ListManageablePluginRoles. -// -// Deprecated: do not use. -func (c *displayServiceClient) ListManageablePluginRoles(ctx context.Context, req *connect_go.Request[v1alpha1.ListManageablePluginRolesRequest]) (*connect_go.Response[v1alpha1.ListManageablePluginRolesResponse], error) { - return c.listManageablePluginRoles.CallUnary(ctx, req) -} - -// ListManageableUserPluginRoles calls -// buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserPluginRoles. -// -// Deprecated: do not use. -func (c *displayServiceClient) ListManageableUserPluginRoles(ctx context.Context, req *connect_go.Request[v1alpha1.ListManageableUserPluginRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserPluginRolesResponse], error) { - return c.listManageableUserPluginRoles.CallUnary(ctx, req) -} - -// ListManageableTemplateRoles calls -// buf.alpha.registry.v1alpha1.DisplayService.ListManageableTemplateRoles. -// -// Deprecated: do not use. -func (c *displayServiceClient) ListManageableTemplateRoles(ctx context.Context, req *connect_go.Request[v1alpha1.ListManageableTemplateRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableTemplateRolesResponse], error) { - return c.listManageableTemplateRoles.CallUnary(ctx, req) -} - -// ListManageableUserTemplateRoles calls -// buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserTemplateRoles. -// -// Deprecated: do not use. -func (c *displayServiceClient) ListManageableUserTemplateRoles(ctx context.Context, req *connect_go.Request[v1alpha1.ListManageableUserTemplateRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserTemplateRolesResponse], error) { - return c.listManageableUserTemplateRoles.CallUnary(ctx, req) -} - // DisplayServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.DisplayService // service. type DisplayServiceHandler interface { @@ -355,14 +221,6 @@ type DisplayServiceHandler interface { DisplayOrganizationElements(context.Context, *connect_go.Request[v1alpha1.DisplayOrganizationElementsRequest]) (*connect_go.Response[v1alpha1.DisplayOrganizationElementsResponse], error) // DisplayRepositoryElements returns which repository elements should be displayed to the user. DisplayRepositoryElements(context.Context, *connect_go.Request[v1alpha1.DisplayRepositoryElementsRequest]) (*connect_go.Response[v1alpha1.DisplayRepositoryElementsResponse], error) - // DisplayPluginElements returns which plugin elements should be displayed to the user. - // - // Deprecated: do not use. - DisplayPluginElements(context.Context, *connect_go.Request[v1alpha1.DisplayPluginElementsRequest]) (*connect_go.Response[v1alpha1.DisplayPluginElementsResponse], error) - // DisplayTemplateElements returns which template elements should be displayed to the user. - // - // Deprecated: do not use. - DisplayTemplateElements(context.Context, *connect_go.Request[v1alpha1.DisplayTemplateElementsRequest]) (*connect_go.Response[v1alpha1.DisplayTemplateElementsResponse], error) // DisplayUserElements returns which user elements should be displayed to the user. DisplayUserElements(context.Context, *connect_go.Request[v1alpha1.DisplayUserElementsRequest]) (*connect_go.Response[v1alpha1.DisplayUserElementsResponse], error) // DisplayServerElements returns which server elements should be displayed to the user. @@ -377,26 +235,6 @@ type DisplayServiceHandler interface { // ListManageableUserRepositoryRoles returns which roles should be displayed // to the user when they are managing a specific contributor on the repository. ListManageableUserRepositoryRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableUserRepositoryRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserRepositoryRolesResponse], error) - // ListManageablePluginRoles returns which roles should be displayed - // to the user when they are managing contributors on the plugin. - // - // Deprecated: do not use. - ListManageablePluginRoles(context.Context, *connect_go.Request[v1alpha1.ListManageablePluginRolesRequest]) (*connect_go.Response[v1alpha1.ListManageablePluginRolesResponse], error) - // ListManageableUserPluginRoles returns which roles should be displayed - // to the user when they are managing a specific contributor on the plugin. - // - // Deprecated: do not use. - ListManageableUserPluginRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableUserPluginRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserPluginRolesResponse], error) - // ListManageableTemplateRoles returns which roles should be displayed - // to the user when they are managing contributors on the template. - // - // Deprecated: do not use. - ListManageableTemplateRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableTemplateRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableTemplateRolesResponse], error) - // ListManageableUserTemplateRoles returns which roles should be displayed - // to the user when they are managing a specific contributor on the template. - // - // Deprecated: do not use. - ListManageableUserTemplateRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableUserTemplateRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserTemplateRolesResponse], error) } // NewDisplayServiceHandler builds an HTTP handler from the service implementation. It returns the @@ -418,18 +256,6 @@ func NewDisplayServiceHandler(svc DisplayServiceHandler, opts ...connect_go.Hand connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithHandlerOptions(opts...), )) - mux.Handle(DisplayServiceDisplayPluginElementsProcedure, connect_go.NewUnaryHandler( - DisplayServiceDisplayPluginElementsProcedure, - svc.DisplayPluginElements, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithHandlerOptions(opts...), - )) - mux.Handle(DisplayServiceDisplayTemplateElementsProcedure, connect_go.NewUnaryHandler( - DisplayServiceDisplayTemplateElementsProcedure, - svc.DisplayTemplateElements, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithHandlerOptions(opts...), - )) mux.Handle(DisplayServiceDisplayUserElementsProcedure, connect_go.NewUnaryHandler( DisplayServiceDisplayUserElementsProcedure, svc.DisplayUserElements, @@ -466,30 +292,6 @@ func NewDisplayServiceHandler(svc DisplayServiceHandler, opts ...connect_go.Hand connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithHandlerOptions(opts...), )) - mux.Handle(DisplayServiceListManageablePluginRolesProcedure, connect_go.NewUnaryHandler( - DisplayServiceListManageablePluginRolesProcedure, - svc.ListManageablePluginRoles, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithHandlerOptions(opts...), - )) - mux.Handle(DisplayServiceListManageableUserPluginRolesProcedure, connect_go.NewUnaryHandler( - DisplayServiceListManageableUserPluginRolesProcedure, - svc.ListManageableUserPluginRoles, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithHandlerOptions(opts...), - )) - mux.Handle(DisplayServiceListManageableTemplateRolesProcedure, connect_go.NewUnaryHandler( - DisplayServiceListManageableTemplateRolesProcedure, - svc.ListManageableTemplateRoles, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithHandlerOptions(opts...), - )) - mux.Handle(DisplayServiceListManageableUserTemplateRolesProcedure, connect_go.NewUnaryHandler( - DisplayServiceListManageableUserTemplateRolesProcedure, - svc.ListManageableUserTemplateRoles, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), - connect_go.WithHandlerOptions(opts...), - )) return "/buf.alpha.registry.v1alpha1.DisplayService/", mux } @@ -504,14 +306,6 @@ func (UnimplementedDisplayServiceHandler) DisplayRepositoryElements(context.Cont return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.DisplayService.DisplayRepositoryElements is not implemented")) } -func (UnimplementedDisplayServiceHandler) DisplayPluginElements(context.Context, *connect_go.Request[v1alpha1.DisplayPluginElementsRequest]) (*connect_go.Response[v1alpha1.DisplayPluginElementsResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.DisplayService.DisplayPluginElements is not implemented")) -} - -func (UnimplementedDisplayServiceHandler) DisplayTemplateElements(context.Context, *connect_go.Request[v1alpha1.DisplayTemplateElementsRequest]) (*connect_go.Response[v1alpha1.DisplayTemplateElementsResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.DisplayService.DisplayTemplateElements is not implemented")) -} - func (UnimplementedDisplayServiceHandler) DisplayUserElements(context.Context, *connect_go.Request[v1alpha1.DisplayUserElementsRequest]) (*connect_go.Response[v1alpha1.DisplayUserElementsResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.DisplayService.DisplayUserElements is not implemented")) } @@ -535,19 +329,3 @@ func (UnimplementedDisplayServiceHandler) ListManageableRepositoryRoles(context. func (UnimplementedDisplayServiceHandler) ListManageableUserRepositoryRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableUserRepositoryRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserRepositoryRolesResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserRepositoryRoles is not implemented")) } - -func (UnimplementedDisplayServiceHandler) ListManageablePluginRoles(context.Context, *connect_go.Request[v1alpha1.ListManageablePluginRolesRequest]) (*connect_go.Response[v1alpha1.ListManageablePluginRolesResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.DisplayService.ListManageablePluginRoles is not implemented")) -} - -func (UnimplementedDisplayServiceHandler) ListManageableUserPluginRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableUserPluginRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserPluginRolesResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserPluginRoles is not implemented")) -} - -func (UnimplementedDisplayServiceHandler) ListManageableTemplateRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableTemplateRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableTemplateRolesResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.DisplayService.ListManageableTemplateRoles is not implemented")) -} - -func (UnimplementedDisplayServiceHandler) ListManageableUserTemplateRoles(context.Context, *connect_go.Request[v1alpha1.ListManageableUserTemplateRolesRequest]) (*connect_go.Response[v1alpha1.ListManageableUserTemplateRolesResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserTemplateRoles is not implemented")) -} diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/labels.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/labels.connect.go index a6baf63d7..b39376b26 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/labels.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/labels.connect.go @@ -76,7 +76,8 @@ func NewLabelServiceClient(httpClient connect_go.HTTPClient, baseURL string, opt createLabel: connect_go.NewClient[v1alpha1.CreateLabelRequest, v1alpha1.CreateLabelResponse]( httpClient, baseURL+LabelServiceCreateLabelProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), moveLabel: connect_go.NewClient[v1alpha1.MoveLabelRequest, v1alpha1.MoveLabelResponse]( httpClient, @@ -131,7 +132,8 @@ func NewLabelServiceHandler(svc LabelServiceHandler, opts ...connect_go.HandlerO mux.Handle(LabelServiceCreateLabelProcedure, connect_go.NewUnaryHandler( LabelServiceCreateLabelProcedure, svc.CreateLabel, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(LabelServiceMoveLabelProcedure, connect_go.NewUnaryHandler( LabelServiceMoveLabelProcedure, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/organization.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/organization.connect.go index c2ed3be3c..25371f79e 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/organization.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/organization.connect.go @@ -59,6 +59,9 @@ const ( // OrganizationServiceListUserOrganizationsProcedure is the fully-qualified name of the // OrganizationService's ListUserOrganizations RPC. OrganizationServiceListUserOrganizationsProcedure = "/buf.alpha.registry.v1alpha1.OrganizationService/ListUserOrganizations" + // OrganizationServiceGetUserOrganizationProcedure is the fully-qualified name of the + // OrganizationService's GetUserOrganization RPC. + OrganizationServiceGetUserOrganizationProcedure = "/buf.alpha.registry.v1alpha1.OrganizationService/GetUserOrganization" // OrganizationServiceCreateOrganizationProcedure is the fully-qualified name of the // OrganizationService's CreateOrganization RPC. OrganizationServiceCreateOrganizationProcedure = "/buf.alpha.registry.v1alpha1.OrganizationService/CreateOrganization" @@ -105,6 +108,7 @@ type OrganizationServiceClient interface { ListOrganizations(context.Context, *connect_go.Request[v1alpha1.ListOrganizationsRequest]) (*connect_go.Response[v1alpha1.ListOrganizationsResponse], error) // ListUserOrganizations lists all organizations a user is member of. ListUserOrganizations(context.Context, *connect_go.Request[v1alpha1.ListUserOrganizationsRequest]) (*connect_go.Response[v1alpha1.ListUserOrganizationsResponse], error) + GetUserOrganization(context.Context, *connect_go.Request[v1alpha1.GetUserOrganizationRequest]) (*connect_go.Response[v1alpha1.GetUserOrganizationResponse], error) // CreateOrganization creates a new organization. CreateOrganization(context.Context, *connect_go.Request[v1alpha1.CreateOrganizationRequest]) (*connect_go.Response[v1alpha1.CreateOrganizationResponse], error) // DeleteOrganization deletes a organization. @@ -164,25 +168,35 @@ func NewOrganizationServiceClient(httpClient connect_go.HTTPClient, baseURL stri connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithClientOptions(opts...), ), + getUserOrganization: connect_go.NewClient[v1alpha1.GetUserOrganizationRequest, v1alpha1.GetUserOrganizationResponse]( + httpClient, + baseURL+OrganizationServiceGetUserOrganizationProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithClientOptions(opts...), + ), createOrganization: connect_go.NewClient[v1alpha1.CreateOrganizationRequest, v1alpha1.CreateOrganizationResponse]( httpClient, baseURL+OrganizationServiceCreateOrganizationProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), deleteOrganization: connect_go.NewClient[v1alpha1.DeleteOrganizationRequest, v1alpha1.DeleteOrganizationResponse]( httpClient, baseURL+OrganizationServiceDeleteOrganizationProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), deleteOrganizationByName: connect_go.NewClient[v1alpha1.DeleteOrganizationByNameRequest, v1alpha1.DeleteOrganizationByNameResponse]( httpClient, baseURL+OrganizationServiceDeleteOrganizationByNameProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), addOrganizationMember: connect_go.NewClient[v1alpha1.AddOrganizationMemberRequest, v1alpha1.AddOrganizationMemberResponse]( httpClient, baseURL+OrganizationServiceAddOrganizationMemberProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), updateOrganizationMember: connect_go.NewClient[v1alpha1.UpdateOrganizationMemberRequest, v1alpha1.UpdateOrganizationMemberResponse]( httpClient, @@ -192,7 +206,8 @@ func NewOrganizationServiceClient(httpClient connect_go.HTTPClient, baseURL stri removeOrganizationMember: connect_go.NewClient[v1alpha1.RemoveOrganizationMemberRequest, v1alpha1.RemoveOrganizationMemberResponse]( httpClient, baseURL+OrganizationServiceRemoveOrganizationMemberProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), setOrganizationMember: connect_go.NewClient[v1alpha1.SetOrganizationMemberRequest, v1alpha1.SetOrganizationMemberResponse]( httpClient, @@ -213,12 +228,14 @@ func NewOrganizationServiceClient(httpClient connect_go.HTTPClient, baseURL stri addOrganizationGroup: connect_go.NewClient[v1alpha1.AddOrganizationGroupRequest, v1alpha1.AddOrganizationGroupResponse]( httpClient, baseURL+OrganizationServiceAddOrganizationGroupProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), removeOrganizationGroup: connect_go.NewClient[v1alpha1.RemoveOrganizationGroupRequest, v1alpha1.RemoveOrganizationGroupResponse]( httpClient, baseURL+OrganizationServiceRemoveOrganizationGroupProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), } } @@ -229,6 +246,7 @@ type organizationServiceClient struct { getOrganizationByName *connect_go.Client[v1alpha1.GetOrganizationByNameRequest, v1alpha1.GetOrganizationByNameResponse] listOrganizations *connect_go.Client[v1alpha1.ListOrganizationsRequest, v1alpha1.ListOrganizationsResponse] listUserOrganizations *connect_go.Client[v1alpha1.ListUserOrganizationsRequest, v1alpha1.ListUserOrganizationsResponse] + getUserOrganization *connect_go.Client[v1alpha1.GetUserOrganizationRequest, v1alpha1.GetUserOrganizationResponse] createOrganization *connect_go.Client[v1alpha1.CreateOrganizationRequest, v1alpha1.CreateOrganizationResponse] deleteOrganization *connect_go.Client[v1alpha1.DeleteOrganizationRequest, v1alpha1.DeleteOrganizationResponse] deleteOrganizationByName *connect_go.Client[v1alpha1.DeleteOrganizationByNameRequest, v1alpha1.DeleteOrganizationByNameResponse] @@ -264,6 +282,11 @@ func (c *organizationServiceClient) ListUserOrganizations(ctx context.Context, r return c.listUserOrganizations.CallUnary(ctx, req) } +// GetUserOrganization calls buf.alpha.registry.v1alpha1.OrganizationService.GetUserOrganization. +func (c *organizationServiceClient) GetUserOrganization(ctx context.Context, req *connect_go.Request[v1alpha1.GetUserOrganizationRequest]) (*connect_go.Response[v1alpha1.GetUserOrganizationResponse], error) { + return c.getUserOrganization.CallUnary(ctx, req) +} + // CreateOrganization calls buf.alpha.registry.v1alpha1.OrganizationService.CreateOrganization. func (c *organizationServiceClient) CreateOrganization(ctx context.Context, req *connect_go.Request[v1alpha1.CreateOrganizationRequest]) (*connect_go.Response[v1alpha1.CreateOrganizationResponse], error) { return c.createOrganization.CallUnary(ctx, req) @@ -338,6 +361,7 @@ type OrganizationServiceHandler interface { ListOrganizations(context.Context, *connect_go.Request[v1alpha1.ListOrganizationsRequest]) (*connect_go.Response[v1alpha1.ListOrganizationsResponse], error) // ListUserOrganizations lists all organizations a user is member of. ListUserOrganizations(context.Context, *connect_go.Request[v1alpha1.ListUserOrganizationsRequest]) (*connect_go.Response[v1alpha1.ListUserOrganizationsResponse], error) + GetUserOrganization(context.Context, *connect_go.Request[v1alpha1.GetUserOrganizationRequest]) (*connect_go.Response[v1alpha1.GetUserOrganizationResponse], error) // CreateOrganization creates a new organization. CreateOrganization(context.Context, *connect_go.Request[v1alpha1.CreateOrganizationRequest]) (*connect_go.Response[v1alpha1.CreateOrganizationResponse], error) // DeleteOrganization deletes a organization. @@ -393,25 +417,35 @@ func NewOrganizationServiceHandler(svc OrganizationServiceHandler, opts ...conne connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithHandlerOptions(opts...), )) + mux.Handle(OrganizationServiceGetUserOrganizationProcedure, connect_go.NewUnaryHandler( + OrganizationServiceGetUserOrganizationProcedure, + svc.GetUserOrganization, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithHandlerOptions(opts...), + )) mux.Handle(OrganizationServiceCreateOrganizationProcedure, connect_go.NewUnaryHandler( OrganizationServiceCreateOrganizationProcedure, svc.CreateOrganization, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(OrganizationServiceDeleteOrganizationProcedure, connect_go.NewUnaryHandler( OrganizationServiceDeleteOrganizationProcedure, svc.DeleteOrganization, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(OrganizationServiceDeleteOrganizationByNameProcedure, connect_go.NewUnaryHandler( OrganizationServiceDeleteOrganizationByNameProcedure, svc.DeleteOrganizationByName, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(OrganizationServiceAddOrganizationMemberProcedure, connect_go.NewUnaryHandler( OrganizationServiceAddOrganizationMemberProcedure, svc.AddOrganizationMember, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(OrganizationServiceUpdateOrganizationMemberProcedure, connect_go.NewUnaryHandler( OrganizationServiceUpdateOrganizationMemberProcedure, @@ -421,7 +455,8 @@ func NewOrganizationServiceHandler(svc OrganizationServiceHandler, opts ...conne mux.Handle(OrganizationServiceRemoveOrganizationMemberProcedure, connect_go.NewUnaryHandler( OrganizationServiceRemoveOrganizationMemberProcedure, svc.RemoveOrganizationMember, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(OrganizationServiceSetOrganizationMemberProcedure, connect_go.NewUnaryHandler( OrganizationServiceSetOrganizationMemberProcedure, @@ -442,12 +477,14 @@ func NewOrganizationServiceHandler(svc OrganizationServiceHandler, opts ...conne mux.Handle(OrganizationServiceAddOrganizationGroupProcedure, connect_go.NewUnaryHandler( OrganizationServiceAddOrganizationGroupProcedure, svc.AddOrganizationGroup, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(OrganizationServiceRemoveOrganizationGroupProcedure, connect_go.NewUnaryHandler( OrganizationServiceRemoveOrganizationGroupProcedure, svc.RemoveOrganizationGroup, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) return "/buf.alpha.registry.v1alpha1.OrganizationService/", mux } @@ -471,6 +508,10 @@ func (UnimplementedOrganizationServiceHandler) ListUserOrganizations(context.Con return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.OrganizationService.ListUserOrganizations is not implemented")) } +func (UnimplementedOrganizationServiceHandler) GetUserOrganization(context.Context, *connect_go.Request[v1alpha1.GetUserOrganizationRequest]) (*connect_go.Response[v1alpha1.GetUserOrganizationResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.OrganizationService.GetUserOrganization is not implemented")) +} + func (UnimplementedOrganizationServiceHandler) CreateOrganization(context.Context, *connect_go.Request[v1alpha1.CreateOrganizationRequest]) (*connect_go.Response[v1alpha1.CreateOrganizationResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.OrganizationService.CreateOrganization is not implemented")) } diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/plugin.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/plugin.connect.go index edda1f620..1d236d7af 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/plugin.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/plugin.connect.go @@ -62,20 +62,11 @@ const ( // PluginServiceListPluginVersionsProcedure is the fully-qualified name of the PluginService's // ListPluginVersions RPC. PluginServiceListPluginVersionsProcedure = "/buf.alpha.registry.v1alpha1.PluginService/ListPluginVersions" - // PluginServiceCreatePluginProcedure is the fully-qualified name of the PluginService's - // CreatePlugin RPC. - PluginServiceCreatePluginProcedure = "/buf.alpha.registry.v1alpha1.PluginService/CreatePlugin" // PluginServiceGetPluginProcedure is the fully-qualified name of the PluginService's GetPlugin RPC. PluginServiceGetPluginProcedure = "/buf.alpha.registry.v1alpha1.PluginService/GetPlugin" // PluginServiceDeletePluginProcedure is the fully-qualified name of the PluginService's // DeletePlugin RPC. PluginServiceDeletePluginProcedure = "/buf.alpha.registry.v1alpha1.PluginService/DeletePlugin" - // PluginServiceSetPluginContributorProcedure is the fully-qualified name of the PluginService's - // SetPluginContributor RPC. - PluginServiceSetPluginContributorProcedure = "/buf.alpha.registry.v1alpha1.PluginService/SetPluginContributor" - // PluginServiceListPluginContributorsProcedure is the fully-qualified name of the PluginService's - // ListPluginContributors RPC. - PluginServiceListPluginContributorsProcedure = "/buf.alpha.registry.v1alpha1.PluginService/ListPluginContributors" // PluginServiceGetTemplateProcedure is the fully-qualified name of the PluginService's GetTemplate // RPC. PluginServiceGetTemplateProcedure = "/buf.alpha.registry.v1alpha1.PluginService/GetTemplate" @@ -97,21 +88,9 @@ const ( // PluginServiceListTemplateVersionsProcedure is the fully-qualified name of the PluginService's // ListTemplateVersions RPC. PluginServiceListTemplateVersionsProcedure = "/buf.alpha.registry.v1alpha1.PluginService/ListTemplateVersions" - // PluginServiceCreateTemplateProcedure is the fully-qualified name of the PluginService's - // CreateTemplate RPC. - PluginServiceCreateTemplateProcedure = "/buf.alpha.registry.v1alpha1.PluginService/CreateTemplate" // PluginServiceDeleteTemplateProcedure is the fully-qualified name of the PluginService's // DeleteTemplate RPC. PluginServiceDeleteTemplateProcedure = "/buf.alpha.registry.v1alpha1.PluginService/DeleteTemplate" - // PluginServiceCreateTemplateVersionProcedure is the fully-qualified name of the PluginService's - // CreateTemplateVersion RPC. - PluginServiceCreateTemplateVersionProcedure = "/buf.alpha.registry.v1alpha1.PluginService/CreateTemplateVersion" - // PluginServiceSetTemplateContributorProcedure is the fully-qualified name of the PluginService's - // SetTemplateContributor RPC. - PluginServiceSetTemplateContributorProcedure = "/buf.alpha.registry.v1alpha1.PluginService/SetTemplateContributor" - // PluginServiceListTemplateContributorsProcedure is the fully-qualified name of the PluginService's - // ListTemplateContributors RPC. - PluginServiceListTemplateContributorsProcedure = "/buf.alpha.registry.v1alpha1.PluginService/ListTemplateContributors" ) // PluginServiceClient is a client for the buf.alpha.registry.v1alpha1.PluginService service. @@ -128,20 +107,12 @@ type PluginServiceClient interface { GetPluginVersion(context.Context, *connect_go.Request[v1alpha1.GetPluginVersionRequest]) (*connect_go.Response[v1alpha1.GetPluginVersionResponse], error) // ListPluginVersions lists all the versions available for the specified plugin. ListPluginVersions(context.Context, *connect_go.Request[v1alpha1.ListPluginVersionsRequest]) (*connect_go.Response[v1alpha1.ListPluginVersionsResponse], error) - // CreatePlugin creates a new plugin. - CreatePlugin(context.Context, *connect_go.Request[v1alpha1.CreatePluginRequest]) (*connect_go.Response[v1alpha1.CreatePluginResponse], error) // GetPlugin returns the plugin, if found. GetPlugin(context.Context, *connect_go.Request[v1alpha1.GetPluginRequest]) (*connect_go.Response[v1alpha1.GetPluginResponse], error) // DeletePlugin deletes the plugin, if it exists. Note that deleting // a plugin may cause breaking changes for templates using that plugin, // and should be done with extreme care. DeletePlugin(context.Context, *connect_go.Request[v1alpha1.DeletePluginRequest]) (*connect_go.Response[v1alpha1.DeletePluginResponse], error) - // SetPluginContributor sets the role of a user in the plugin. - SetPluginContributor(context.Context, *connect_go.Request[v1alpha1.SetPluginContributorRequest]) (*connect_go.Response[v1alpha1.SetPluginContributorResponse], error) - // ListPluginContributors returns the list of contributors that has an explicit role against the plugin. - // This does not include users who have implicit roles against the plugin, unless they have also been - // assigned a role explicitly. - ListPluginContributors(context.Context, *connect_go.Request[v1alpha1.ListPluginContributorsRequest]) (*connect_go.Response[v1alpha1.ListPluginContributorsResponse], error) // GetTemplate returns the template, if found. GetTemplate(context.Context, *connect_go.Request[v1alpha1.GetTemplateRequest]) (*connect_go.Response[v1alpha1.GetTemplateResponse], error) // ListTemplates returns all the templates available to the user. This includes @@ -159,18 +130,8 @@ type PluginServiceClient interface { GetTemplateVersion(context.Context, *connect_go.Request[v1alpha1.GetTemplateVersionRequest]) (*connect_go.Response[v1alpha1.GetTemplateVersionResponse], error) // ListTemplateVersions lists all the template versions available for the specified template. ListTemplateVersions(context.Context, *connect_go.Request[v1alpha1.ListTemplateVersionsRequest]) (*connect_go.Response[v1alpha1.ListTemplateVersionsResponse], error) - // CreateTemplate creates a new template. - CreateTemplate(context.Context, *connect_go.Request[v1alpha1.CreateTemplateRequest]) (*connect_go.Response[v1alpha1.CreateTemplateResponse], error) // DeleteTemplate deletes the template, if it exists. DeleteTemplate(context.Context, *connect_go.Request[v1alpha1.DeleteTemplateRequest]) (*connect_go.Response[v1alpha1.DeleteTemplateResponse], error) - // CreateTemplateVersion creates a new template version. - CreateTemplateVersion(context.Context, *connect_go.Request[v1alpha1.CreateTemplateVersionRequest]) (*connect_go.Response[v1alpha1.CreateTemplateVersionResponse], error) - // SetTemplateContributor sets the role of a user in the template. - SetTemplateContributor(context.Context, *connect_go.Request[v1alpha1.SetTemplateContributorRequest]) (*connect_go.Response[v1alpha1.SetTemplateContributorResponse], error) - // ListTemplateContributors returns the list of contributors that has an explicit role against the template. - // This does not include users who have implicit roles against the template, unless they have also been - // assigned a role explicitly. - ListTemplateContributors(context.Context, *connect_go.Request[v1alpha1.ListTemplateContributorsRequest]) (*connect_go.Response[v1alpha1.ListTemplateContributorsResponse], error) } // NewPluginServiceClient constructs a client for the buf.alpha.registry.v1alpha1.PluginService @@ -213,11 +174,6 @@ func NewPluginServiceClient(httpClient connect_go.HTTPClient, baseURL string, op connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithClientOptions(opts...), ), - createPlugin: connect_go.NewClient[v1alpha1.CreatePluginRequest, v1alpha1.CreatePluginResponse]( - httpClient, - baseURL+PluginServiceCreatePluginProcedure, - opts..., - ), getPlugin: connect_go.NewClient[v1alpha1.GetPluginRequest, v1alpha1.GetPluginResponse]( httpClient, baseURL+PluginServiceGetPluginProcedure, @@ -227,17 +183,7 @@ func NewPluginServiceClient(httpClient connect_go.HTTPClient, baseURL string, op deletePlugin: connect_go.NewClient[v1alpha1.DeletePluginRequest, v1alpha1.DeletePluginResponse]( httpClient, baseURL+PluginServiceDeletePluginProcedure, - opts..., - ), - setPluginContributor: connect_go.NewClient[v1alpha1.SetPluginContributorRequest, v1alpha1.SetPluginContributorResponse]( - httpClient, - baseURL+PluginServiceSetPluginContributorProcedure, - opts..., - ), - listPluginContributors: connect_go.NewClient[v1alpha1.ListPluginContributorsRequest, v1alpha1.ListPluginContributorsResponse]( - httpClient, - baseURL+PluginServiceListPluginContributorsProcedure, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), connect_go.WithClientOptions(opts...), ), getTemplate: connect_go.NewClient[v1alpha1.GetTemplateRequest, v1alpha1.GetTemplateResponse]( @@ -282,30 +228,10 @@ func NewPluginServiceClient(httpClient connect_go.HTTPClient, baseURL string, op connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithClientOptions(opts...), ), - createTemplate: connect_go.NewClient[v1alpha1.CreateTemplateRequest, v1alpha1.CreateTemplateResponse]( - httpClient, - baseURL+PluginServiceCreateTemplateProcedure, - opts..., - ), deleteTemplate: connect_go.NewClient[v1alpha1.DeleteTemplateRequest, v1alpha1.DeleteTemplateResponse]( httpClient, baseURL+PluginServiceDeleteTemplateProcedure, - opts..., - ), - createTemplateVersion: connect_go.NewClient[v1alpha1.CreateTemplateVersionRequest, v1alpha1.CreateTemplateVersionResponse]( - httpClient, - baseURL+PluginServiceCreateTemplateVersionProcedure, - opts..., - ), - setTemplateContributor: connect_go.NewClient[v1alpha1.SetTemplateContributorRequest, v1alpha1.SetTemplateContributorResponse]( - httpClient, - baseURL+PluginServiceSetTemplateContributorProcedure, - opts..., - ), - listTemplateContributors: connect_go.NewClient[v1alpha1.ListTemplateContributorsRequest, v1alpha1.ListTemplateContributorsResponse]( - httpClient, - baseURL+PluginServiceListTemplateContributorsProcedure, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), connect_go.WithClientOptions(opts...), ), } @@ -318,11 +244,8 @@ type pluginServiceClient struct { listOrganizationPlugins *connect_go.Client[v1alpha1.ListOrganizationPluginsRequest, v1alpha1.ListOrganizationPluginsResponse] getPluginVersion *connect_go.Client[v1alpha1.GetPluginVersionRequest, v1alpha1.GetPluginVersionResponse] listPluginVersions *connect_go.Client[v1alpha1.ListPluginVersionsRequest, v1alpha1.ListPluginVersionsResponse] - createPlugin *connect_go.Client[v1alpha1.CreatePluginRequest, v1alpha1.CreatePluginResponse] getPlugin *connect_go.Client[v1alpha1.GetPluginRequest, v1alpha1.GetPluginResponse] deletePlugin *connect_go.Client[v1alpha1.DeletePluginRequest, v1alpha1.DeletePluginResponse] - setPluginContributor *connect_go.Client[v1alpha1.SetPluginContributorRequest, v1alpha1.SetPluginContributorResponse] - listPluginContributors *connect_go.Client[v1alpha1.ListPluginContributorsRequest, v1alpha1.ListPluginContributorsResponse] getTemplate *connect_go.Client[v1alpha1.GetTemplateRequest, v1alpha1.GetTemplateResponse] listTemplates *connect_go.Client[v1alpha1.ListTemplatesRequest, v1alpha1.ListTemplatesResponse] listTemplatesUserCanAccess *connect_go.Client[v1alpha1.ListTemplatesUserCanAccessRequest, v1alpha1.ListTemplatesUserCanAccessResponse] @@ -330,11 +253,7 @@ type pluginServiceClient struct { listOrganizationTemplates *connect_go.Client[v1alpha1.ListOrganizationTemplatesRequest, v1alpha1.ListOrganizationTemplatesResponse] getTemplateVersion *connect_go.Client[v1alpha1.GetTemplateVersionRequest, v1alpha1.GetTemplateVersionResponse] listTemplateVersions *connect_go.Client[v1alpha1.ListTemplateVersionsRequest, v1alpha1.ListTemplateVersionsResponse] - createTemplate *connect_go.Client[v1alpha1.CreateTemplateRequest, v1alpha1.CreateTemplateResponse] deleteTemplate *connect_go.Client[v1alpha1.DeleteTemplateRequest, v1alpha1.DeleteTemplateResponse] - createTemplateVersion *connect_go.Client[v1alpha1.CreateTemplateVersionRequest, v1alpha1.CreateTemplateVersionResponse] - setTemplateContributor *connect_go.Client[v1alpha1.SetTemplateContributorRequest, v1alpha1.SetTemplateContributorResponse] - listTemplateContributors *connect_go.Client[v1alpha1.ListTemplateContributorsRequest, v1alpha1.ListTemplateContributorsResponse] } // ListPlugins calls buf.alpha.registry.v1alpha1.PluginService.ListPlugins. @@ -362,11 +281,6 @@ func (c *pluginServiceClient) ListPluginVersions(ctx context.Context, req *conne return c.listPluginVersions.CallUnary(ctx, req) } -// CreatePlugin calls buf.alpha.registry.v1alpha1.PluginService.CreatePlugin. -func (c *pluginServiceClient) CreatePlugin(ctx context.Context, req *connect_go.Request[v1alpha1.CreatePluginRequest]) (*connect_go.Response[v1alpha1.CreatePluginResponse], error) { - return c.createPlugin.CallUnary(ctx, req) -} - // GetPlugin calls buf.alpha.registry.v1alpha1.PluginService.GetPlugin. func (c *pluginServiceClient) GetPlugin(ctx context.Context, req *connect_go.Request[v1alpha1.GetPluginRequest]) (*connect_go.Response[v1alpha1.GetPluginResponse], error) { return c.getPlugin.CallUnary(ctx, req) @@ -377,16 +291,6 @@ func (c *pluginServiceClient) DeletePlugin(ctx context.Context, req *connect_go. return c.deletePlugin.CallUnary(ctx, req) } -// SetPluginContributor calls buf.alpha.registry.v1alpha1.PluginService.SetPluginContributor. -func (c *pluginServiceClient) SetPluginContributor(ctx context.Context, req *connect_go.Request[v1alpha1.SetPluginContributorRequest]) (*connect_go.Response[v1alpha1.SetPluginContributorResponse], error) { - return c.setPluginContributor.CallUnary(ctx, req) -} - -// ListPluginContributors calls buf.alpha.registry.v1alpha1.PluginService.ListPluginContributors. -func (c *pluginServiceClient) ListPluginContributors(ctx context.Context, req *connect_go.Request[v1alpha1.ListPluginContributorsRequest]) (*connect_go.Response[v1alpha1.ListPluginContributorsResponse], error) { - return c.listPluginContributors.CallUnary(ctx, req) -} - // GetTemplate calls buf.alpha.registry.v1alpha1.PluginService.GetTemplate. func (c *pluginServiceClient) GetTemplate(ctx context.Context, req *connect_go.Request[v1alpha1.GetTemplateRequest]) (*connect_go.Response[v1alpha1.GetTemplateResponse], error) { return c.getTemplate.CallUnary(ctx, req) @@ -424,32 +328,11 @@ func (c *pluginServiceClient) ListTemplateVersions(ctx context.Context, req *con return c.listTemplateVersions.CallUnary(ctx, req) } -// CreateTemplate calls buf.alpha.registry.v1alpha1.PluginService.CreateTemplate. -func (c *pluginServiceClient) CreateTemplate(ctx context.Context, req *connect_go.Request[v1alpha1.CreateTemplateRequest]) (*connect_go.Response[v1alpha1.CreateTemplateResponse], error) { - return c.createTemplate.CallUnary(ctx, req) -} - // DeleteTemplate calls buf.alpha.registry.v1alpha1.PluginService.DeleteTemplate. func (c *pluginServiceClient) DeleteTemplate(ctx context.Context, req *connect_go.Request[v1alpha1.DeleteTemplateRequest]) (*connect_go.Response[v1alpha1.DeleteTemplateResponse], error) { return c.deleteTemplate.CallUnary(ctx, req) } -// CreateTemplateVersion calls buf.alpha.registry.v1alpha1.PluginService.CreateTemplateVersion. -func (c *pluginServiceClient) CreateTemplateVersion(ctx context.Context, req *connect_go.Request[v1alpha1.CreateTemplateVersionRequest]) (*connect_go.Response[v1alpha1.CreateTemplateVersionResponse], error) { - return c.createTemplateVersion.CallUnary(ctx, req) -} - -// SetTemplateContributor calls buf.alpha.registry.v1alpha1.PluginService.SetTemplateContributor. -func (c *pluginServiceClient) SetTemplateContributor(ctx context.Context, req *connect_go.Request[v1alpha1.SetTemplateContributorRequest]) (*connect_go.Response[v1alpha1.SetTemplateContributorResponse], error) { - return c.setTemplateContributor.CallUnary(ctx, req) -} - -// ListTemplateContributors calls -// buf.alpha.registry.v1alpha1.PluginService.ListTemplateContributors. -func (c *pluginServiceClient) ListTemplateContributors(ctx context.Context, req *connect_go.Request[v1alpha1.ListTemplateContributorsRequest]) (*connect_go.Response[v1alpha1.ListTemplateContributorsResponse], error) { - return c.listTemplateContributors.CallUnary(ctx, req) -} - // PluginServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.PluginService // service. type PluginServiceHandler interface { @@ -465,20 +348,12 @@ type PluginServiceHandler interface { GetPluginVersion(context.Context, *connect_go.Request[v1alpha1.GetPluginVersionRequest]) (*connect_go.Response[v1alpha1.GetPluginVersionResponse], error) // ListPluginVersions lists all the versions available for the specified plugin. ListPluginVersions(context.Context, *connect_go.Request[v1alpha1.ListPluginVersionsRequest]) (*connect_go.Response[v1alpha1.ListPluginVersionsResponse], error) - // CreatePlugin creates a new plugin. - CreatePlugin(context.Context, *connect_go.Request[v1alpha1.CreatePluginRequest]) (*connect_go.Response[v1alpha1.CreatePluginResponse], error) // GetPlugin returns the plugin, if found. GetPlugin(context.Context, *connect_go.Request[v1alpha1.GetPluginRequest]) (*connect_go.Response[v1alpha1.GetPluginResponse], error) // DeletePlugin deletes the plugin, if it exists. Note that deleting // a plugin may cause breaking changes for templates using that plugin, // and should be done with extreme care. DeletePlugin(context.Context, *connect_go.Request[v1alpha1.DeletePluginRequest]) (*connect_go.Response[v1alpha1.DeletePluginResponse], error) - // SetPluginContributor sets the role of a user in the plugin. - SetPluginContributor(context.Context, *connect_go.Request[v1alpha1.SetPluginContributorRequest]) (*connect_go.Response[v1alpha1.SetPluginContributorResponse], error) - // ListPluginContributors returns the list of contributors that has an explicit role against the plugin. - // This does not include users who have implicit roles against the plugin, unless they have also been - // assigned a role explicitly. - ListPluginContributors(context.Context, *connect_go.Request[v1alpha1.ListPluginContributorsRequest]) (*connect_go.Response[v1alpha1.ListPluginContributorsResponse], error) // GetTemplate returns the template, if found. GetTemplate(context.Context, *connect_go.Request[v1alpha1.GetTemplateRequest]) (*connect_go.Response[v1alpha1.GetTemplateResponse], error) // ListTemplates returns all the templates available to the user. This includes @@ -496,18 +371,8 @@ type PluginServiceHandler interface { GetTemplateVersion(context.Context, *connect_go.Request[v1alpha1.GetTemplateVersionRequest]) (*connect_go.Response[v1alpha1.GetTemplateVersionResponse], error) // ListTemplateVersions lists all the template versions available for the specified template. ListTemplateVersions(context.Context, *connect_go.Request[v1alpha1.ListTemplateVersionsRequest]) (*connect_go.Response[v1alpha1.ListTemplateVersionsResponse], error) - // CreateTemplate creates a new template. - CreateTemplate(context.Context, *connect_go.Request[v1alpha1.CreateTemplateRequest]) (*connect_go.Response[v1alpha1.CreateTemplateResponse], error) // DeleteTemplate deletes the template, if it exists. DeleteTemplate(context.Context, *connect_go.Request[v1alpha1.DeleteTemplateRequest]) (*connect_go.Response[v1alpha1.DeleteTemplateResponse], error) - // CreateTemplateVersion creates a new template version. - CreateTemplateVersion(context.Context, *connect_go.Request[v1alpha1.CreateTemplateVersionRequest]) (*connect_go.Response[v1alpha1.CreateTemplateVersionResponse], error) - // SetTemplateContributor sets the role of a user in the template. - SetTemplateContributor(context.Context, *connect_go.Request[v1alpha1.SetTemplateContributorRequest]) (*connect_go.Response[v1alpha1.SetTemplateContributorResponse], error) - // ListTemplateContributors returns the list of contributors that has an explicit role against the template. - // This does not include users who have implicit roles against the template, unless they have also been - // assigned a role explicitly. - ListTemplateContributors(context.Context, *connect_go.Request[v1alpha1.ListTemplateContributorsRequest]) (*connect_go.Response[v1alpha1.ListTemplateContributorsResponse], error) } // NewPluginServiceHandler builds an HTTP handler from the service implementation. It returns the @@ -547,11 +412,6 @@ func NewPluginServiceHandler(svc PluginServiceHandler, opts ...connect_go.Handle connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithHandlerOptions(opts...), )) - mux.Handle(PluginServiceCreatePluginProcedure, connect_go.NewUnaryHandler( - PluginServiceCreatePluginProcedure, - svc.CreatePlugin, - opts..., - )) mux.Handle(PluginServiceGetPluginProcedure, connect_go.NewUnaryHandler( PluginServiceGetPluginProcedure, svc.GetPlugin, @@ -561,17 +421,7 @@ func NewPluginServiceHandler(svc PluginServiceHandler, opts ...connect_go.Handle mux.Handle(PluginServiceDeletePluginProcedure, connect_go.NewUnaryHandler( PluginServiceDeletePluginProcedure, svc.DeletePlugin, - opts..., - )) - mux.Handle(PluginServiceSetPluginContributorProcedure, connect_go.NewUnaryHandler( - PluginServiceSetPluginContributorProcedure, - svc.SetPluginContributor, - opts..., - )) - mux.Handle(PluginServiceListPluginContributorsProcedure, connect_go.NewUnaryHandler( - PluginServiceListPluginContributorsProcedure, - svc.ListPluginContributors, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), connect_go.WithHandlerOptions(opts...), )) mux.Handle(PluginServiceGetTemplateProcedure, connect_go.NewUnaryHandler( @@ -616,30 +466,10 @@ func NewPluginServiceHandler(svc PluginServiceHandler, opts ...connect_go.Handle connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithHandlerOptions(opts...), )) - mux.Handle(PluginServiceCreateTemplateProcedure, connect_go.NewUnaryHandler( - PluginServiceCreateTemplateProcedure, - svc.CreateTemplate, - opts..., - )) mux.Handle(PluginServiceDeleteTemplateProcedure, connect_go.NewUnaryHandler( PluginServiceDeleteTemplateProcedure, svc.DeleteTemplate, - opts..., - )) - mux.Handle(PluginServiceCreateTemplateVersionProcedure, connect_go.NewUnaryHandler( - PluginServiceCreateTemplateVersionProcedure, - svc.CreateTemplateVersion, - opts..., - )) - mux.Handle(PluginServiceSetTemplateContributorProcedure, connect_go.NewUnaryHandler( - PluginServiceSetTemplateContributorProcedure, - svc.SetTemplateContributor, - opts..., - )) - mux.Handle(PluginServiceListTemplateContributorsProcedure, connect_go.NewUnaryHandler( - PluginServiceListTemplateContributorsProcedure, - svc.ListTemplateContributors, - connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), connect_go.WithHandlerOptions(opts...), )) return "/buf.alpha.registry.v1alpha1.PluginService/", mux @@ -668,10 +498,6 @@ func (UnimplementedPluginServiceHandler) ListPluginVersions(context.Context, *co return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.ListPluginVersions is not implemented")) } -func (UnimplementedPluginServiceHandler) CreatePlugin(context.Context, *connect_go.Request[v1alpha1.CreatePluginRequest]) (*connect_go.Response[v1alpha1.CreatePluginResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.CreatePlugin is not implemented")) -} - func (UnimplementedPluginServiceHandler) GetPlugin(context.Context, *connect_go.Request[v1alpha1.GetPluginRequest]) (*connect_go.Response[v1alpha1.GetPluginResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.GetPlugin is not implemented")) } @@ -680,14 +506,6 @@ func (UnimplementedPluginServiceHandler) DeletePlugin(context.Context, *connect_ return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.DeletePlugin is not implemented")) } -func (UnimplementedPluginServiceHandler) SetPluginContributor(context.Context, *connect_go.Request[v1alpha1.SetPluginContributorRequest]) (*connect_go.Response[v1alpha1.SetPluginContributorResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.SetPluginContributor is not implemented")) -} - -func (UnimplementedPluginServiceHandler) ListPluginContributors(context.Context, *connect_go.Request[v1alpha1.ListPluginContributorsRequest]) (*connect_go.Response[v1alpha1.ListPluginContributorsResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.ListPluginContributors is not implemented")) -} - func (UnimplementedPluginServiceHandler) GetTemplate(context.Context, *connect_go.Request[v1alpha1.GetTemplateRequest]) (*connect_go.Response[v1alpha1.GetTemplateResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.GetTemplate is not implemented")) } @@ -716,22 +534,6 @@ func (UnimplementedPluginServiceHandler) ListTemplateVersions(context.Context, * return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.ListTemplateVersions is not implemented")) } -func (UnimplementedPluginServiceHandler) CreateTemplate(context.Context, *connect_go.Request[v1alpha1.CreateTemplateRequest]) (*connect_go.Response[v1alpha1.CreateTemplateResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.CreateTemplate is not implemented")) -} - func (UnimplementedPluginServiceHandler) DeleteTemplate(context.Context, *connect_go.Request[v1alpha1.DeleteTemplateRequest]) (*connect_go.Response[v1alpha1.DeleteTemplateResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.DeleteTemplate is not implemented")) } - -func (UnimplementedPluginServiceHandler) CreateTemplateVersion(context.Context, *connect_go.Request[v1alpha1.CreateTemplateVersionRequest]) (*connect_go.Response[v1alpha1.CreateTemplateVersionResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.CreateTemplateVersion is not implemented")) -} - -func (UnimplementedPluginServiceHandler) SetTemplateContributor(context.Context, *connect_go.Request[v1alpha1.SetTemplateContributorRequest]) (*connect_go.Response[v1alpha1.SetTemplateContributorResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.SetTemplateContributor is not implemented")) -} - -func (UnimplementedPluginServiceHandler) ListTemplateContributors(context.Context, *connect_go.Request[v1alpha1.ListTemplateContributorsRequest]) (*connect_go.Response[v1alpha1.ListTemplateContributorsResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.PluginService.ListTemplateContributors is not implemented")) -} diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/plugin_curation.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/plugin_curation.connect.go index 863756891..e042ac665 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/plugin_curation.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/plugin_curation.connect.go @@ -99,7 +99,8 @@ func NewPluginCurationServiceClient(httpClient connect_go.HTTPClient, baseURL st createCuratedPlugin: connect_go.NewClient[v1alpha1.CreateCuratedPluginRequest, v1alpha1.CreateCuratedPluginResponse]( httpClient, baseURL+PluginCurationServiceCreateCuratedPluginProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), getLatestCuratedPlugin: connect_go.NewClient[v1alpha1.GetLatestCuratedPluginRequest, v1alpha1.GetLatestCuratedPluginResponse]( httpClient, @@ -110,7 +111,8 @@ func NewPluginCurationServiceClient(httpClient connect_go.HTTPClient, baseURL st deleteCuratedPlugin: connect_go.NewClient[v1alpha1.DeleteCuratedPluginRequest, v1alpha1.DeleteCuratedPluginResponse]( httpClient, baseURL+PluginCurationServiceDeleteCuratedPluginProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), } } @@ -173,7 +175,8 @@ func NewPluginCurationServiceHandler(svc PluginCurationServiceHandler, opts ...c mux.Handle(PluginCurationServiceCreateCuratedPluginProcedure, connect_go.NewUnaryHandler( PluginCurationServiceCreateCuratedPluginProcedure, svc.CreateCuratedPlugin, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(PluginCurationServiceGetLatestCuratedPluginProcedure, connect_go.NewUnaryHandler( PluginCurationServiceGetLatestCuratedPluginProcedure, @@ -184,7 +187,8 @@ func NewPluginCurationServiceHandler(svc PluginCurationServiceHandler, opts ...c mux.Handle(PluginCurationServiceDeleteCuratedPluginProcedure, connect_go.NewUnaryHandler( PluginCurationServiceDeleteCuratedPluginProcedure, svc.DeleteCuratedPlugin, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) return "/buf.alpha.registry.v1alpha1.PluginCurationService/", mux } diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/push.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/push.connect.go index ae0b2e2e9..b2aa21a2b 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/push.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/push.connect.go @@ -32,7 +32,7 @@ import ( // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. -const _ = connect_go.IsAtLeastVersion0_1_0 +const _ = connect_go.IsAtLeastVersion1_7_0 const ( // PushServiceName is the fully-qualified name of the PushService service. @@ -76,12 +76,14 @@ func NewPushServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts push: connect_go.NewClient[v1alpha1.PushRequest, v1alpha1.PushResponse]( httpClient, baseURL+PushServicePushProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), pushManifestAndBlobs: connect_go.NewClient[v1alpha1.PushManifestAndBlobsRequest, v1alpha1.PushManifestAndBlobsResponse]( httpClient, baseURL+PushServicePushManifestAndBlobsProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), } } @@ -121,12 +123,14 @@ func NewPushServiceHandler(svc PushServiceHandler, opts ...connect_go.HandlerOpt mux.Handle(PushServicePushProcedure, connect_go.NewUnaryHandler( PushServicePushProcedure, svc.Push, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(PushServicePushManifestAndBlobsProcedure, connect_go.NewUnaryHandler( PushServicePushManifestAndBlobsProcedure, svc.PushManifestAndBlobs, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) return "/buf.alpha.registry.v1alpha1.PushService/", mux } diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/recommendation.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/recommendation.connect.go index a7243132a..6869d446a 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/recommendation.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/recommendation.connect.go @@ -108,7 +108,8 @@ func NewRecommendationServiceClient(httpClient connect_go.HTTPClient, baseURL st setRecommendedResources: connect_go.NewClient[v1alpha1.SetRecommendedResourcesRequest, v1alpha1.SetRecommendedResourcesResponse]( httpClient, baseURL+RecommendationServiceSetRecommendedResourcesProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), } } @@ -190,7 +191,8 @@ func NewRecommendationServiceHandler(svc RecommendationServiceHandler, opts ...c mux.Handle(RecommendationServiceSetRecommendedResourcesProcedure, connect_go.NewUnaryHandler( RecommendationServiceSetRecommendedResourcesProcedure, svc.SetRecommendedResources, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) return "/buf.alpha.registry.v1alpha1.RecommendationService/", mux } diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/reference.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/reference.connect.go index 9c851de8b..d4440c788 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/reference.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/reference.connect.go @@ -50,6 +50,9 @@ const ( // ReferenceServiceGetReferenceByNameProcedure is the fully-qualified name of the ReferenceService's // GetReferenceByName RPC. ReferenceServiceGetReferenceByNameProcedure = "/buf.alpha.registry.v1alpha1.ReferenceService/GetReferenceByName" + // ReferenceServiceListGitCommitMetadataForReferenceProcedure is the fully-qualified name of the + // ReferenceService's ListGitCommitMetadataForReference RPC. + ReferenceServiceListGitCommitMetadataForReferenceProcedure = "/buf.alpha.registry.v1alpha1.ReferenceService/ListGitCommitMetadataForReference" ) // ReferenceServiceClient is a client for the buf.alpha.registry.v1alpha1.ReferenceService service. @@ -57,6 +60,9 @@ type ReferenceServiceClient interface { // GetReferenceByName takes a reference name and returns the // reference either as 'main', a tag, or commit. GetReferenceByName(context.Context, *connect_go.Request[v1alpha1.GetReferenceByNameRequest]) (*connect_go.Response[v1alpha1.GetReferenceByNameResponse], error) + // ListGitCommitMetadataForReference takes a string reference and returns all the git commit + // metadata associated with the resolved reference commit. + ListGitCommitMetadataForReference(context.Context, *connect_go.Request[v1alpha1.ListGitCommitMetadataForReferenceRequest]) (*connect_go.Response[v1alpha1.ListGitCommitMetadataForReferenceResponse], error) } // NewReferenceServiceClient constructs a client for the @@ -76,12 +82,19 @@ func NewReferenceServiceClient(httpClient connect_go.HTTPClient, baseURL string, connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithClientOptions(opts...), ), + listGitCommitMetadataForReference: connect_go.NewClient[v1alpha1.ListGitCommitMetadataForReferenceRequest, v1alpha1.ListGitCommitMetadataForReferenceResponse]( + httpClient, + baseURL+ReferenceServiceListGitCommitMetadataForReferenceProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithClientOptions(opts...), + ), } } // referenceServiceClient implements ReferenceServiceClient. type referenceServiceClient struct { - getReferenceByName *connect_go.Client[v1alpha1.GetReferenceByNameRequest, v1alpha1.GetReferenceByNameResponse] + getReferenceByName *connect_go.Client[v1alpha1.GetReferenceByNameRequest, v1alpha1.GetReferenceByNameResponse] + listGitCommitMetadataForReference *connect_go.Client[v1alpha1.ListGitCommitMetadataForReferenceRequest, v1alpha1.ListGitCommitMetadataForReferenceResponse] } // GetReferenceByName calls buf.alpha.registry.v1alpha1.ReferenceService.GetReferenceByName. @@ -89,12 +102,21 @@ func (c *referenceServiceClient) GetReferenceByName(ctx context.Context, req *co return c.getReferenceByName.CallUnary(ctx, req) } +// ListGitCommitMetadataForReference calls +// buf.alpha.registry.v1alpha1.ReferenceService.ListGitCommitMetadataForReference. +func (c *referenceServiceClient) ListGitCommitMetadataForReference(ctx context.Context, req *connect_go.Request[v1alpha1.ListGitCommitMetadataForReferenceRequest]) (*connect_go.Response[v1alpha1.ListGitCommitMetadataForReferenceResponse], error) { + return c.listGitCommitMetadataForReference.CallUnary(ctx, req) +} + // ReferenceServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.ReferenceService // service. type ReferenceServiceHandler interface { // GetReferenceByName takes a reference name and returns the // reference either as 'main', a tag, or commit. GetReferenceByName(context.Context, *connect_go.Request[v1alpha1.GetReferenceByNameRequest]) (*connect_go.Response[v1alpha1.GetReferenceByNameResponse], error) + // ListGitCommitMetadataForReference takes a string reference and returns all the git commit + // metadata associated with the resolved reference commit. + ListGitCommitMetadataForReference(context.Context, *connect_go.Request[v1alpha1.ListGitCommitMetadataForReferenceRequest]) (*connect_go.Response[v1alpha1.ListGitCommitMetadataForReferenceResponse], error) } // NewReferenceServiceHandler builds an HTTP handler from the service implementation. It returns the @@ -110,6 +132,12 @@ func NewReferenceServiceHandler(svc ReferenceServiceHandler, opts ...connect_go. connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithHandlerOptions(opts...), )) + mux.Handle(ReferenceServiceListGitCommitMetadataForReferenceProcedure, connect_go.NewUnaryHandler( + ReferenceServiceListGitCommitMetadataForReferenceProcedure, + svc.ListGitCommitMetadataForReference, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithHandlerOptions(opts...), + )) return "/buf.alpha.registry.v1alpha1.ReferenceService/", mux } @@ -119,3 +147,7 @@ type UnimplementedReferenceServiceHandler struct{} func (UnimplementedReferenceServiceHandler) GetReferenceByName(context.Context, *connect_go.Request[v1alpha1.GetReferenceByNameRequest]) (*connect_go.Response[v1alpha1.GetReferenceByNameResponse], error) { return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.ReferenceService.GetReferenceByName is not implemented")) } + +func (UnimplementedReferenceServiceHandler) ListGitCommitMetadataForReference(context.Context, *connect_go.Request[v1alpha1.ListGitCommitMetadataForReferenceRequest]) (*connect_go.Response[v1alpha1.ListGitCommitMetadataForReferenceResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.ReferenceService.ListGitCommitMetadataForReference is not implemented")) +} diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository.connect.go index 265bbdd3f..2d1d9f450 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository.connect.go @@ -199,17 +199,20 @@ func NewRepositoryServiceClient(httpClient connect_go.HTTPClient, baseURL string createRepositoryByFullName: connect_go.NewClient[v1alpha1.CreateRepositoryByFullNameRequest, v1alpha1.CreateRepositoryByFullNameResponse]( httpClient, baseURL+RepositoryServiceCreateRepositoryByFullNameProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), deleteRepository: connect_go.NewClient[v1alpha1.DeleteRepositoryRequest, v1alpha1.DeleteRepositoryResponse]( httpClient, baseURL+RepositoryServiceDeleteRepositoryProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), deleteRepositoryByFullName: connect_go.NewClient[v1alpha1.DeleteRepositoryByFullNameRequest, v1alpha1.DeleteRepositoryByFullNameResponse]( httpClient, baseURL+RepositoryServiceDeleteRepositoryByFullNameProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), deprecateRepositoryByName: connect_go.NewClient[v1alpha1.DeprecateRepositoryByNameRequest, v1alpha1.DeprecateRepositoryByNameResponse]( httpClient, @@ -481,17 +484,20 @@ func NewRepositoryServiceHandler(svc RepositoryServiceHandler, opts ...connect_g mux.Handle(RepositoryServiceCreateRepositoryByFullNameProcedure, connect_go.NewUnaryHandler( RepositoryServiceCreateRepositoryByFullNameProcedure, svc.CreateRepositoryByFullName, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(RepositoryServiceDeleteRepositoryProcedure, connect_go.NewUnaryHandler( RepositoryServiceDeleteRepositoryProcedure, svc.DeleteRepository, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(RepositoryServiceDeleteRepositoryByFullNameProcedure, connect_go.NewUnaryHandler( RepositoryServiceDeleteRepositoryByFullNameProcedure, svc.DeleteRepositoryByFullName, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(RepositoryServiceDeprecateRepositoryByNameProcedure, connect_go.NewUnaryHandler( RepositoryServiceDeprecateRepositoryByNameProcedure, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_branch.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_branch.connect.go new file mode 100644 index 000000000..708264030 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_branch.connect.go @@ -0,0 +1,121 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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. + +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: buf/alpha/registry/v1alpha1/repository_branch.proto + +package registryv1alpha1connect + +import ( + context "context" + errors "errors" + v1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" + connect_go "github.com/bufbuild/connect-go" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect_go.IsAtLeastVersion1_7_0 + +const ( + // RepositoryBranchServiceName is the fully-qualified name of the RepositoryBranchService service. + RepositoryBranchServiceName = "buf.alpha.registry.v1alpha1.RepositoryBranchService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // RepositoryBranchServiceListRepositoryBranchesProcedure is the fully-qualified name of the + // RepositoryBranchService's ListRepositoryBranches RPC. + RepositoryBranchServiceListRepositoryBranchesProcedure = "/buf.alpha.registry.v1alpha1.RepositoryBranchService/ListRepositoryBranches" +) + +// RepositoryBranchServiceClient is a client for the +// buf.alpha.registry.v1alpha1.RepositoryBranchService service. +type RepositoryBranchServiceClient interface { + // ListRepositoryBranchs lists the repository branches associated with a Repository. + ListRepositoryBranches(context.Context, *connect_go.Request[v1alpha1.ListRepositoryBranchesRequest]) (*connect_go.Response[v1alpha1.ListRepositoryBranchesResponse], error) +} + +// NewRepositoryBranchServiceClient constructs a client for the +// buf.alpha.registry.v1alpha1.RepositoryBranchService service. By default, it uses the Connect +// protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed +// requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or +// connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewRepositoryBranchServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) RepositoryBranchServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &repositoryBranchServiceClient{ + listRepositoryBranches: connect_go.NewClient[v1alpha1.ListRepositoryBranchesRequest, v1alpha1.ListRepositoryBranchesResponse]( + httpClient, + baseURL+RepositoryBranchServiceListRepositoryBranchesProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithClientOptions(opts...), + ), + } +} + +// repositoryBranchServiceClient implements RepositoryBranchServiceClient. +type repositoryBranchServiceClient struct { + listRepositoryBranches *connect_go.Client[v1alpha1.ListRepositoryBranchesRequest, v1alpha1.ListRepositoryBranchesResponse] +} + +// ListRepositoryBranches calls +// buf.alpha.registry.v1alpha1.RepositoryBranchService.ListRepositoryBranches. +func (c *repositoryBranchServiceClient) ListRepositoryBranches(ctx context.Context, req *connect_go.Request[v1alpha1.ListRepositoryBranchesRequest]) (*connect_go.Response[v1alpha1.ListRepositoryBranchesResponse], error) { + return c.listRepositoryBranches.CallUnary(ctx, req) +} + +// RepositoryBranchServiceHandler is an implementation of the +// buf.alpha.registry.v1alpha1.RepositoryBranchService service. +type RepositoryBranchServiceHandler interface { + // ListRepositoryBranchs lists the repository branches associated with a Repository. + ListRepositoryBranches(context.Context, *connect_go.Request[v1alpha1.ListRepositoryBranchesRequest]) (*connect_go.Response[v1alpha1.ListRepositoryBranchesResponse], error) +} + +// NewRepositoryBranchServiceHandler builds an HTTP handler from the service implementation. It +// returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewRepositoryBranchServiceHandler(svc RepositoryBranchServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) { + mux := http.NewServeMux() + mux.Handle(RepositoryBranchServiceListRepositoryBranchesProcedure, connect_go.NewUnaryHandler( + RepositoryBranchServiceListRepositoryBranchesProcedure, + svc.ListRepositoryBranches, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithHandlerOptions(opts...), + )) + return "/buf.alpha.registry.v1alpha1.RepositoryBranchService/", mux +} + +// UnimplementedRepositoryBranchServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedRepositoryBranchServiceHandler struct{} + +func (UnimplementedRepositoryBranchServiceHandler) ListRepositoryBranches(context.Context, *connect_go.Request[v1alpha1.ListRepositoryBranchesRequest]) (*connect_go.Response[v1alpha1.ListRepositoryBranchesResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.RepositoryBranchService.ListRepositoryBranches is not implemented")) +} diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_commit.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_commit.connect.go index 8649454bc..97f09c60a 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_commit.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_commit.connect.go @@ -134,7 +134,8 @@ func NewRepositoryCommitServiceClient(httpClient connect_go.HTTPClient, baseURL deleteRepositoryDraftCommit: connect_go.NewClient[v1alpha1.DeleteRepositoryDraftCommitRequest, v1alpha1.DeleteRepositoryDraftCommitResponse]( httpClient, baseURL+RepositoryCommitServiceDeleteRepositoryDraftCommitProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), } } @@ -250,7 +251,8 @@ func NewRepositoryCommitServiceHandler(svc RepositoryCommitServiceHandler, opts mux.Handle(RepositoryCommitServiceDeleteRepositoryDraftCommitProcedure, connect_go.NewUnaryHandler( RepositoryCommitServiceDeleteRepositoryDraftCommitProcedure, svc.DeleteRepositoryDraftCommit, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) return "/buf.alpha.registry.v1alpha1.RepositoryCommitService/", mux } diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_tag.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_tag.connect.go index 9a0a00951..6c1b52d20 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_tag.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/repository_tag.connect.go @@ -78,7 +78,8 @@ func NewRepositoryTagServiceClient(httpClient connect_go.HTTPClient, baseURL str createRepositoryTag: connect_go.NewClient[v1alpha1.CreateRepositoryTagRequest, v1alpha1.CreateRepositoryTagResponse]( httpClient, baseURL+RepositoryTagServiceCreateRepositoryTagProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), listRepositoryTags: connect_go.NewClient[v1alpha1.ListRepositoryTagsRequest, v1alpha1.ListRepositoryTagsResponse]( httpClient, @@ -124,7 +125,8 @@ func NewRepositoryTagServiceHandler(svc RepositoryTagServiceHandler, opts ...con mux.Handle(RepositoryTagServiceCreateRepositoryTagProcedure, connect_go.NewUnaryHandler( RepositoryTagServiceCreateRepositoryTagProcedure, svc.CreateRepositoryTag, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(RepositoryTagServiceListRepositoryTagsProcedure, connect_go.NewUnaryHandler( RepositoryTagServiceListRepositoryTagsProcedure, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/resolve.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/resolve.connect.go index 81ea18ca5..be69d5ce4 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/resolve.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/resolve.connect.go @@ -52,6 +52,18 @@ const ( // ResolveServiceGetModulePinsProcedure is the fully-qualified name of the ResolveService's // GetModulePins RPC. ResolveServiceGetModulePinsProcedure = "/buf.alpha.registry.v1alpha1.ResolveService/GetModulePins" + // ResolveServiceGetGoVersionProcedure is the fully-qualified name of the ResolveService's + // GetGoVersion RPC. + ResolveServiceGetGoVersionProcedure = "/buf.alpha.registry.v1alpha1.ResolveService/GetGoVersion" + // ResolveServiceGetSwiftVersionProcedure is the fully-qualified name of the ResolveService's + // GetSwiftVersion RPC. + ResolveServiceGetSwiftVersionProcedure = "/buf.alpha.registry.v1alpha1.ResolveService/GetSwiftVersion" + // ResolveServiceGetMavenVersionProcedure is the fully-qualified name of the ResolveService's + // GetMavenVersion RPC. + ResolveServiceGetMavenVersionProcedure = "/buf.alpha.registry.v1alpha1.ResolveService/GetMavenVersion" + // ResolveServiceGetNPMVersionProcedure is the fully-qualified name of the ResolveService's + // GetNPMVersion RPC. + ResolveServiceGetNPMVersionProcedure = "/buf.alpha.registry.v1alpha1.ResolveService/GetNPMVersion" // LocalResolveServiceGetLocalModulePinsProcedure is the fully-qualified name of the // LocalResolveService's GetLocalModulePins RPC. LocalResolveServiceGetLocalModulePinsProcedure = "/buf.alpha.registry.v1alpha1.LocalResolveService/GetLocalModulePins" @@ -67,6 +79,14 @@ type ResolveServiceClient interface { // // This function also deals with tiebreaking what ModulePin wins for the same repository. GetModulePins(context.Context, *connect_go.Request[v1alpha1.GetModulePinsRequest]) (*connect_go.Response[v1alpha1.GetModulePinsResponse], error) + // GetGoVersion resolves the given plugin and module references to a version. + GetGoVersion(context.Context, *connect_go.Request[v1alpha1.GetGoVersionRequest]) (*connect_go.Response[v1alpha1.GetGoVersionResponse], error) + // GetSwiftVersion resolves the given plugin and module references to a version. + GetSwiftVersion(context.Context, *connect_go.Request[v1alpha1.GetSwiftVersionRequest]) (*connect_go.Response[v1alpha1.GetSwiftVersionResponse], error) + // GetMavenVersion resolves the given plugin and module references to a version. + GetMavenVersion(context.Context, *connect_go.Request[v1alpha1.GetMavenVersionRequest]) (*connect_go.Response[v1alpha1.GetMavenVersionResponse], error) + // GetNPMVersion resolves the given plugin and module references to a version. + GetNPMVersion(context.Context, *connect_go.Request[v1alpha1.GetNPMVersionRequest]) (*connect_go.Response[v1alpha1.GetNPMVersionResponse], error) } // NewResolveServiceClient constructs a client for the buf.alpha.registry.v1alpha1.ResolveService @@ -85,12 +105,40 @@ func NewResolveServiceClient(httpClient connect_go.HTTPClient, baseURL string, o connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithClientOptions(opts...), ), + getGoVersion: connect_go.NewClient[v1alpha1.GetGoVersionRequest, v1alpha1.GetGoVersionResponse]( + httpClient, + baseURL+ResolveServiceGetGoVersionProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithClientOptions(opts...), + ), + getSwiftVersion: connect_go.NewClient[v1alpha1.GetSwiftVersionRequest, v1alpha1.GetSwiftVersionResponse]( + httpClient, + baseURL+ResolveServiceGetSwiftVersionProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithClientOptions(opts...), + ), + getMavenVersion: connect_go.NewClient[v1alpha1.GetMavenVersionRequest, v1alpha1.GetMavenVersionResponse]( + httpClient, + baseURL+ResolveServiceGetMavenVersionProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithClientOptions(opts...), + ), + getNPMVersion: connect_go.NewClient[v1alpha1.GetNPMVersionRequest, v1alpha1.GetNPMVersionResponse]( + httpClient, + baseURL+ResolveServiceGetNPMVersionProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithClientOptions(opts...), + ), } } // resolveServiceClient implements ResolveServiceClient. type resolveServiceClient struct { - getModulePins *connect_go.Client[v1alpha1.GetModulePinsRequest, v1alpha1.GetModulePinsResponse] + getModulePins *connect_go.Client[v1alpha1.GetModulePinsRequest, v1alpha1.GetModulePinsResponse] + getGoVersion *connect_go.Client[v1alpha1.GetGoVersionRequest, v1alpha1.GetGoVersionResponse] + getSwiftVersion *connect_go.Client[v1alpha1.GetSwiftVersionRequest, v1alpha1.GetSwiftVersionResponse] + getMavenVersion *connect_go.Client[v1alpha1.GetMavenVersionRequest, v1alpha1.GetMavenVersionResponse] + getNPMVersion *connect_go.Client[v1alpha1.GetNPMVersionRequest, v1alpha1.GetNPMVersionResponse] } // GetModulePins calls buf.alpha.registry.v1alpha1.ResolveService.GetModulePins. @@ -98,6 +146,26 @@ func (c *resolveServiceClient) GetModulePins(ctx context.Context, req *connect_g return c.getModulePins.CallUnary(ctx, req) } +// GetGoVersion calls buf.alpha.registry.v1alpha1.ResolveService.GetGoVersion. +func (c *resolveServiceClient) GetGoVersion(ctx context.Context, req *connect_go.Request[v1alpha1.GetGoVersionRequest]) (*connect_go.Response[v1alpha1.GetGoVersionResponse], error) { + return c.getGoVersion.CallUnary(ctx, req) +} + +// GetSwiftVersion calls buf.alpha.registry.v1alpha1.ResolveService.GetSwiftVersion. +func (c *resolveServiceClient) GetSwiftVersion(ctx context.Context, req *connect_go.Request[v1alpha1.GetSwiftVersionRequest]) (*connect_go.Response[v1alpha1.GetSwiftVersionResponse], error) { + return c.getSwiftVersion.CallUnary(ctx, req) +} + +// GetMavenVersion calls buf.alpha.registry.v1alpha1.ResolveService.GetMavenVersion. +func (c *resolveServiceClient) GetMavenVersion(ctx context.Context, req *connect_go.Request[v1alpha1.GetMavenVersionRequest]) (*connect_go.Response[v1alpha1.GetMavenVersionResponse], error) { + return c.getMavenVersion.CallUnary(ctx, req) +} + +// GetNPMVersion calls buf.alpha.registry.v1alpha1.ResolveService.GetNPMVersion. +func (c *resolveServiceClient) GetNPMVersion(ctx context.Context, req *connect_go.Request[v1alpha1.GetNPMVersionRequest]) (*connect_go.Response[v1alpha1.GetNPMVersionResponse], error) { + return c.getNPMVersion.CallUnary(ctx, req) +} + // ResolveServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.ResolveService // service. type ResolveServiceHandler interface { @@ -109,6 +177,14 @@ type ResolveServiceHandler interface { // // This function also deals with tiebreaking what ModulePin wins for the same repository. GetModulePins(context.Context, *connect_go.Request[v1alpha1.GetModulePinsRequest]) (*connect_go.Response[v1alpha1.GetModulePinsResponse], error) + // GetGoVersion resolves the given plugin and module references to a version. + GetGoVersion(context.Context, *connect_go.Request[v1alpha1.GetGoVersionRequest]) (*connect_go.Response[v1alpha1.GetGoVersionResponse], error) + // GetSwiftVersion resolves the given plugin and module references to a version. + GetSwiftVersion(context.Context, *connect_go.Request[v1alpha1.GetSwiftVersionRequest]) (*connect_go.Response[v1alpha1.GetSwiftVersionResponse], error) + // GetMavenVersion resolves the given plugin and module references to a version. + GetMavenVersion(context.Context, *connect_go.Request[v1alpha1.GetMavenVersionRequest]) (*connect_go.Response[v1alpha1.GetMavenVersionResponse], error) + // GetNPMVersion resolves the given plugin and module references to a version. + GetNPMVersion(context.Context, *connect_go.Request[v1alpha1.GetNPMVersionRequest]) (*connect_go.Response[v1alpha1.GetNPMVersionResponse], error) } // NewResolveServiceHandler builds an HTTP handler from the service implementation. It returns the @@ -124,6 +200,30 @@ func NewResolveServiceHandler(svc ResolveServiceHandler, opts ...connect_go.Hand connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), connect_go.WithHandlerOptions(opts...), )) + mux.Handle(ResolveServiceGetGoVersionProcedure, connect_go.NewUnaryHandler( + ResolveServiceGetGoVersionProcedure, + svc.GetGoVersion, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithHandlerOptions(opts...), + )) + mux.Handle(ResolveServiceGetSwiftVersionProcedure, connect_go.NewUnaryHandler( + ResolveServiceGetSwiftVersionProcedure, + svc.GetSwiftVersion, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithHandlerOptions(opts...), + )) + mux.Handle(ResolveServiceGetMavenVersionProcedure, connect_go.NewUnaryHandler( + ResolveServiceGetMavenVersionProcedure, + svc.GetMavenVersion, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithHandlerOptions(opts...), + )) + mux.Handle(ResolveServiceGetNPMVersionProcedure, connect_go.NewUnaryHandler( + ResolveServiceGetNPMVersionProcedure, + svc.GetNPMVersion, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithHandlerOptions(opts...), + )) return "/buf.alpha.registry.v1alpha1.ResolveService/", mux } @@ -134,6 +234,22 @@ func (UnimplementedResolveServiceHandler) GetModulePins(context.Context, *connec return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.ResolveService.GetModulePins is not implemented")) } +func (UnimplementedResolveServiceHandler) GetGoVersion(context.Context, *connect_go.Request[v1alpha1.GetGoVersionRequest]) (*connect_go.Response[v1alpha1.GetGoVersionResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.ResolveService.GetGoVersion is not implemented")) +} + +func (UnimplementedResolveServiceHandler) GetSwiftVersion(context.Context, *connect_go.Request[v1alpha1.GetSwiftVersionRequest]) (*connect_go.Response[v1alpha1.GetSwiftVersionResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.ResolveService.GetSwiftVersion is not implemented")) +} + +func (UnimplementedResolveServiceHandler) GetMavenVersion(context.Context, *connect_go.Request[v1alpha1.GetMavenVersionRequest]) (*connect_go.Response[v1alpha1.GetMavenVersionResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.ResolveService.GetMavenVersion is not implemented")) +} + +func (UnimplementedResolveServiceHandler) GetNPMVersion(context.Context, *connect_go.Request[v1alpha1.GetNPMVersionRequest]) (*connect_go.Response[v1alpha1.GetNPMVersionResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.ResolveService.GetNPMVersion is not implemented")) +} + // LocalResolveServiceClient is a client for the buf.alpha.registry.v1alpha1.LocalResolveService // service. type LocalResolveServiceClient interface { diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/scim_token.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/scim_token.connect.go index 197fce343..5ae9d50bd 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/scim_token.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/scim_token.connect.go @@ -99,7 +99,8 @@ func NewSCIMTokenServiceClient(httpClient connect_go.HTTPClient, baseURL string, deleteSCIMToken: connect_go.NewClient[v1alpha1.DeleteSCIMTokenRequest, v1alpha1.DeleteSCIMTokenResponse]( httpClient, baseURL+SCIMTokenServiceDeleteSCIMTokenProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), } } @@ -164,7 +165,8 @@ func NewSCIMTokenServiceHandler(svc SCIMTokenServiceHandler, opts ...connect_go. mux.Handle(SCIMTokenServiceDeleteSCIMTokenProcedure, connect_go.NewUnaryHandler( SCIMTokenServiceDeleteSCIMTokenProcedure, svc.DeleteSCIMToken, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) return "/buf.alpha.registry.v1alpha1.SCIMTokenService/", mux } diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/studio_request.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/studio_request.connect.go index cb3f5efea..4a2d54757 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/studio_request.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/studio_request.connect.go @@ -100,7 +100,8 @@ func NewStudioRequestServiceClient(httpClient connect_go.HTTPClient, baseURL str deleteStudioRequest: connect_go.NewClient[v1alpha1.DeleteStudioRequestRequest, v1alpha1.DeleteStudioRequestResponse]( httpClient, baseURL+StudioRequestServiceDeleteStudioRequestProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), listStudioRequests: connect_go.NewClient[v1alpha1.ListStudioRequestsRequest, v1alpha1.ListStudioRequestsResponse]( httpClient, @@ -174,7 +175,8 @@ func NewStudioRequestServiceHandler(svc StudioRequestServiceHandler, opts ...con mux.Handle(StudioRequestServiceDeleteStudioRequestProcedure, connect_go.NewUnaryHandler( StudioRequestServiceDeleteStudioRequestProcedure, svc.DeleteStudioRequest, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(StudioRequestServiceListStudioRequestsProcedure, connect_go.NewUnaryHandler( StudioRequestServiceListStudioRequestsProcedure, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/sync.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/sync.connect.go new file mode 100644 index 000000000..19eac3171 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/sync.connect.go @@ -0,0 +1,148 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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. + +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: buf/alpha/registry/v1alpha1/sync.proto + +package registryv1alpha1connect + +import ( + context "context" + errors "errors" + v1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1" + connect_go "github.com/bufbuild/connect-go" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect_go.IsAtLeastVersion1_7_0 + +const ( + // SyncServiceName is the fully-qualified name of the SyncService service. + SyncServiceName = "buf.alpha.registry.v1alpha1.SyncService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // SyncServiceGetGitSyncPointProcedure is the fully-qualified name of the SyncService's + // GetGitSyncPoint RPC. + SyncServiceGetGitSyncPointProcedure = "/buf.alpha.registry.v1alpha1.SyncService/GetGitSyncPoint" + // SyncServiceSyncGitCommitProcedure is the fully-qualified name of the SyncService's SyncGitCommit + // RPC. + SyncServiceSyncGitCommitProcedure = "/buf.alpha.registry.v1alpha1.SyncService/SyncGitCommit" +) + +// SyncServiceClient is a client for the buf.alpha.registry.v1alpha1.SyncService service. +type SyncServiceClient interface { + // GetGitSyncPoint retrieves the Git sync point for the named repository + // on the specified branch. + GetGitSyncPoint(context.Context, *connect_go.Request[v1alpha1.GetGitSyncPointRequest]) (*connect_go.Response[v1alpha1.GetGitSyncPointResponse], error) + // SyncGitCommit syncs a Git commit containing a module to a named repository. + SyncGitCommit(context.Context, *connect_go.Request[v1alpha1.SyncGitCommitRequest]) (*connect_go.Response[v1alpha1.SyncGitCommitResponse], error) +} + +// NewSyncServiceClient constructs a client for the buf.alpha.registry.v1alpha1.SyncService service. +// By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped +// responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the +// connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewSyncServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) SyncServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &syncServiceClient{ + getGitSyncPoint: connect_go.NewClient[v1alpha1.GetGitSyncPointRequest, v1alpha1.GetGitSyncPointResponse]( + httpClient, + baseURL+SyncServiceGetGitSyncPointProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithClientOptions(opts...), + ), + syncGitCommit: connect_go.NewClient[v1alpha1.SyncGitCommitRequest, v1alpha1.SyncGitCommitResponse]( + httpClient, + baseURL+SyncServiceSyncGitCommitProcedure, + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), + ), + } +} + +// syncServiceClient implements SyncServiceClient. +type syncServiceClient struct { + getGitSyncPoint *connect_go.Client[v1alpha1.GetGitSyncPointRequest, v1alpha1.GetGitSyncPointResponse] + syncGitCommit *connect_go.Client[v1alpha1.SyncGitCommitRequest, v1alpha1.SyncGitCommitResponse] +} + +// GetGitSyncPoint calls buf.alpha.registry.v1alpha1.SyncService.GetGitSyncPoint. +func (c *syncServiceClient) GetGitSyncPoint(ctx context.Context, req *connect_go.Request[v1alpha1.GetGitSyncPointRequest]) (*connect_go.Response[v1alpha1.GetGitSyncPointResponse], error) { + return c.getGitSyncPoint.CallUnary(ctx, req) +} + +// SyncGitCommit calls buf.alpha.registry.v1alpha1.SyncService.SyncGitCommit. +func (c *syncServiceClient) SyncGitCommit(ctx context.Context, req *connect_go.Request[v1alpha1.SyncGitCommitRequest]) (*connect_go.Response[v1alpha1.SyncGitCommitResponse], error) { + return c.syncGitCommit.CallUnary(ctx, req) +} + +// SyncServiceHandler is an implementation of the buf.alpha.registry.v1alpha1.SyncService service. +type SyncServiceHandler interface { + // GetGitSyncPoint retrieves the Git sync point for the named repository + // on the specified branch. + GetGitSyncPoint(context.Context, *connect_go.Request[v1alpha1.GetGitSyncPointRequest]) (*connect_go.Response[v1alpha1.GetGitSyncPointResponse], error) + // SyncGitCommit syncs a Git commit containing a module to a named repository. + SyncGitCommit(context.Context, *connect_go.Request[v1alpha1.SyncGitCommitRequest]) (*connect_go.Response[v1alpha1.SyncGitCommitResponse], error) +} + +// NewSyncServiceHandler builds an HTTP handler from the service implementation. It returns the path +// on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewSyncServiceHandler(svc SyncServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) { + mux := http.NewServeMux() + mux.Handle(SyncServiceGetGitSyncPointProcedure, connect_go.NewUnaryHandler( + SyncServiceGetGitSyncPointProcedure, + svc.GetGitSyncPoint, + connect_go.WithIdempotency(connect_go.IdempotencyNoSideEffects), + connect_go.WithHandlerOptions(opts...), + )) + mux.Handle(SyncServiceSyncGitCommitProcedure, connect_go.NewUnaryHandler( + SyncServiceSyncGitCommitProcedure, + svc.SyncGitCommit, + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), + )) + return "/buf.alpha.registry.v1alpha1.SyncService/", mux +} + +// UnimplementedSyncServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedSyncServiceHandler struct{} + +func (UnimplementedSyncServiceHandler) GetGitSyncPoint(context.Context, *connect_go.Request[v1alpha1.GetGitSyncPointRequest]) (*connect_go.Response[v1alpha1.GetGitSyncPointResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.SyncService.GetGitSyncPoint is not implemented")) +} + +func (UnimplementedSyncServiceHandler) SyncGitCommit(context.Context, *connect_go.Request[v1alpha1.SyncGitCommitRequest]) (*connect_go.Response[v1alpha1.SyncGitCommitResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("buf.alpha.registry.v1alpha1.SyncService.SyncGitCommit is not implemented")) +} diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/token.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/token.connect.go index 497d949ea..6c6e87d5a 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/token.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/token.connect.go @@ -107,7 +107,8 @@ func NewTokenServiceClient(httpClient connect_go.HTTPClient, baseURL string, opt deleteToken: connect_go.NewClient[v1alpha1.DeleteTokenRequest, v1alpha1.DeleteTokenResponse]( httpClient, baseURL+TokenServiceDeleteTokenProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), } } @@ -185,7 +186,8 @@ func NewTokenServiceHandler(svc TokenServiceHandler, opts ...connect_go.HandlerO mux.Handle(TokenServiceDeleteTokenProcedure, connect_go.NewUnaryHandler( TokenServiceDeleteTokenProcedure, svc.DeleteToken, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) return "/buf.alpha.registry.v1alpha1.TokenService/", mux } diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/user.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/user.connect.go index 637c57158..8b90093df 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/user.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/user.connect.go @@ -112,7 +112,8 @@ func NewUserServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts createUser: connect_go.NewClient[v1alpha1.CreateUserRequest, v1alpha1.CreateUserResponse]( httpClient, baseURL+UserServiceCreateUserProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), getUser: connect_go.NewClient[v1alpha1.GetUserRequest, v1alpha1.GetUserResponse]( httpClient, @@ -141,12 +142,14 @@ func NewUserServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts deleteUser: connect_go.NewClient[v1alpha1.DeleteUserRequest, v1alpha1.DeleteUserResponse]( httpClient, baseURL+UserServiceDeleteUserProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), deactivateUser: connect_go.NewClient[v1alpha1.DeactivateUserRequest, v1alpha1.DeactivateUserResponse]( httpClient, baseURL+UserServiceDeactivateUserProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), updateUserServerRole: connect_go.NewClient[v1alpha1.UpdateUserServerRoleRequest, v1alpha1.UpdateUserServerRoleResponse]( httpClient, @@ -266,7 +269,8 @@ func NewUserServiceHandler(svc UserServiceHandler, opts ...connect_go.HandlerOpt mux.Handle(UserServiceCreateUserProcedure, connect_go.NewUnaryHandler( UserServiceCreateUserProcedure, svc.CreateUser, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(UserServiceGetUserProcedure, connect_go.NewUnaryHandler( UserServiceGetUserProcedure, @@ -295,12 +299,14 @@ func NewUserServiceHandler(svc UserServiceHandler, opts ...connect_go.HandlerOpt mux.Handle(UserServiceDeleteUserProcedure, connect_go.NewUnaryHandler( UserServiceDeleteUserProcedure, svc.DeleteUser, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(UserServiceDeactivateUserProcedure, connect_go.NewUnaryHandler( UserServiceDeactivateUserProcedure, svc.DeactivateUser, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(UserServiceUpdateUserServerRoleProcedure, connect_go.NewUnaryHandler( UserServiceUpdateUserServerRoleProcedure, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/webhook.connect.go b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/webhook.connect.go index 57257898a..586e0b560 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/webhook.connect.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect/webhook.connect.go @@ -82,12 +82,14 @@ func NewWebhookServiceClient(httpClient connect_go.HTTPClient, baseURL string, o createWebhook: connect_go.NewClient[v1alpha1.CreateWebhookRequest, v1alpha1.CreateWebhookResponse]( httpClient, baseURL+WebhookServiceCreateWebhookProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), deleteWebhook: connect_go.NewClient[v1alpha1.DeleteWebhookRequest, v1alpha1.DeleteWebhookResponse]( httpClient, baseURL+WebhookServiceDeleteWebhookProcedure, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithClientOptions(opts...), ), listWebhooks: connect_go.NewClient[v1alpha1.ListWebhooksRequest, v1alpha1.ListWebhooksResponse]( httpClient, @@ -142,12 +144,14 @@ func NewWebhookServiceHandler(svc WebhookServiceHandler, opts ...connect_go.Hand mux.Handle(WebhookServiceCreateWebhookProcedure, connect_go.NewUnaryHandler( WebhookServiceCreateWebhookProcedure, svc.CreateWebhook, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(WebhookServiceDeleteWebhookProcedure, connect_go.NewUnaryHandler( WebhookServiceDeleteWebhookProcedure, svc.DeleteWebhook, - opts..., + connect_go.WithIdempotency(connect_go.IdempotencyIdempotent), + connect_go.WithHandlerOptions(opts...), )) mux.Handle(WebhookServiceListWebhooksProcedure, connect_go.NewUnaryHandler( WebhookServiceListWebhooksProcedure, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/admin.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/admin.pb.go index 3958a9b0f..1f6b71e90 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/admin.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/admin.pb.go @@ -34,6 +34,119 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// BreakingChangeCategory is the allowed list of categories for breaking rule settings. +type BreakingChangeCategory int32 + +const ( + BreakingChangeCategory_BREAKING_CHANGE_CATEGORY_UNSPECIFIED BreakingChangeCategory = 0 + BreakingChangeCategory_BREAKING_CHANGE_CATEGORY_FILE BreakingChangeCategory = 1 + BreakingChangeCategory_BREAKING_CHANGE_CATEGORY_WIRE_JSON BreakingChangeCategory = 2 +) + +// Enum value maps for BreakingChangeCategory. +var ( + BreakingChangeCategory_name = map[int32]string{ + 0: "BREAKING_CHANGE_CATEGORY_UNSPECIFIED", + 1: "BREAKING_CHANGE_CATEGORY_FILE", + 2: "BREAKING_CHANGE_CATEGORY_WIRE_JSON", + } + BreakingChangeCategory_value = map[string]int32{ + "BREAKING_CHANGE_CATEGORY_UNSPECIFIED": 0, + "BREAKING_CHANGE_CATEGORY_FILE": 1, + "BREAKING_CHANGE_CATEGORY_WIRE_JSON": 2, + } +) + +func (x BreakingChangeCategory) Enum() *BreakingChangeCategory { + p := new(BreakingChangeCategory) + *p = x + return p +} + +func (x BreakingChangeCategory) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (BreakingChangeCategory) Descriptor() protoreflect.EnumDescriptor { + return file_buf_alpha_registry_v1alpha1_admin_proto_enumTypes[0].Descriptor() +} + +func (BreakingChangeCategory) Type() protoreflect.EnumType { + return &file_buf_alpha_registry_v1alpha1_admin_proto_enumTypes[0] +} + +func (x BreakingChangeCategory) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use BreakingChangeCategory.Descriptor instead. +func (BreakingChangeCategory) EnumDescriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{0} +} + +type BreakingChangePolicy struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Enabled *bool `protobuf:"varint,1,opt,name=enabled,proto3,oneof" json:"enabled,omitempty"` + IgnoreUnstablePackages *bool `protobuf:"varint,2,opt,name=ignore_unstable_packages,json=ignoreUnstablePackages,proto3,oneof" json:"ignore_unstable_packages,omitempty"` + Category BreakingChangeCategory `protobuf:"varint,3,opt,name=category,proto3,enum=buf.alpha.registry.v1alpha1.BreakingChangeCategory" json:"category,omitempty"` +} + +func (x *BreakingChangePolicy) Reset() { + *x = BreakingChangePolicy{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BreakingChangePolicy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BreakingChangePolicy) ProtoMessage() {} + +func (x *BreakingChangePolicy) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BreakingChangePolicy.ProtoReflect.Descriptor instead. +func (*BreakingChangePolicy) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{0} +} + +func (x *BreakingChangePolicy) GetEnabled() bool { + if x != nil && x.Enabled != nil { + return *x.Enabled + } + return false +} + +func (x *BreakingChangePolicy) GetIgnoreUnstablePackages() bool { + if x != nil && x.IgnoreUnstablePackages != nil { + return *x.IgnoreUnstablePackages + } + return false +} + +func (x *BreakingChangePolicy) GetCategory() BreakingChangeCategory { + if x != nil { + return x.Category + } + return BreakingChangeCategory_BREAKING_CHANGE_CATEGORY_UNSPECIFIED +} + type ForceDeleteUserRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -45,7 +158,7 @@ type ForceDeleteUserRequest struct { func (x *ForceDeleteUserRequest) Reset() { *x = ForceDeleteUserRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[0] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -58,7 +171,7 @@ func (x *ForceDeleteUserRequest) String() string { func (*ForceDeleteUserRequest) ProtoMessage() {} func (x *ForceDeleteUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[0] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -71,7 +184,7 @@ func (x *ForceDeleteUserRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ForceDeleteUserRequest.ProtoReflect.Descriptor instead. func (*ForceDeleteUserRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{0} + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{1} } func (x *ForceDeleteUserRequest) GetUserId() string { @@ -105,7 +218,7 @@ type ForceDeleteUserResponse struct { func (x *ForceDeleteUserResponse) Reset() { *x = ForceDeleteUserResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[1] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -118,7 +231,7 @@ func (x *ForceDeleteUserResponse) String() string { func (*ForceDeleteUserResponse) ProtoMessage() {} func (x *ForceDeleteUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[1] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -131,7 +244,7 @@ func (x *ForceDeleteUserResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ForceDeleteUserResponse.ProtoReflect.Descriptor instead. func (*ForceDeleteUserResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{1} + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{2} } func (x *ForceDeleteUserResponse) GetUser() *User { @@ -183,7 +296,7 @@ type UpdateUserVerificationStatusRequest struct { func (x *UpdateUserVerificationStatusRequest) Reset() { *x = UpdateUserVerificationStatusRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[2] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -196,7 +309,7 @@ func (x *UpdateUserVerificationStatusRequest) String() string { func (*UpdateUserVerificationStatusRequest) ProtoMessage() {} func (x *UpdateUserVerificationStatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[2] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -209,7 +322,7 @@ func (x *UpdateUserVerificationStatusRequest) ProtoReflect() protoreflect.Messag // Deprecated: Use UpdateUserVerificationStatusRequest.ProtoReflect.Descriptor instead. func (*UpdateUserVerificationStatusRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{2} + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{3} } func (x *UpdateUserVerificationStatusRequest) GetUserId() string { @@ -235,7 +348,7 @@ type UpdateUserVerificationStatusResponse struct { func (x *UpdateUserVerificationStatusResponse) Reset() { *x = UpdateUserVerificationStatusResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[3] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -248,7 +361,7 @@ func (x *UpdateUserVerificationStatusResponse) String() string { func (*UpdateUserVerificationStatusResponse) ProtoMessage() {} func (x *UpdateUserVerificationStatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[3] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -261,7 +374,7 @@ func (x *UpdateUserVerificationStatusResponse) ProtoReflect() protoreflect.Messa // Deprecated: Use UpdateUserVerificationStatusResponse.ProtoReflect.Descriptor instead. func (*UpdateUserVerificationStatusResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{3} + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{4} } type UpdateOrganizationVerificationStatusRequest struct { @@ -276,7 +389,7 @@ type UpdateOrganizationVerificationStatusRequest struct { func (x *UpdateOrganizationVerificationStatusRequest) Reset() { *x = UpdateOrganizationVerificationStatusRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[4] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -289,7 +402,7 @@ func (x *UpdateOrganizationVerificationStatusRequest) String() string { func (*UpdateOrganizationVerificationStatusRequest) ProtoMessage() {} func (x *UpdateOrganizationVerificationStatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[4] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -302,7 +415,7 @@ func (x *UpdateOrganizationVerificationStatusRequest) ProtoReflect() protoreflec // Deprecated: Use UpdateOrganizationVerificationStatusRequest.ProtoReflect.Descriptor instead. func (*UpdateOrganizationVerificationStatusRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{4} + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{5} } func (x *UpdateOrganizationVerificationStatusRequest) GetOrganizationId() string { @@ -328,7 +441,7 @@ type UpdateOrganizationVerificationStatusResponse struct { func (x *UpdateOrganizationVerificationStatusResponse) Reset() { *x = UpdateOrganizationVerificationStatusResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[5] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -341,7 +454,7 @@ func (x *UpdateOrganizationVerificationStatusResponse) String() string { func (*UpdateOrganizationVerificationStatusResponse) ProtoMessage() {} func (x *UpdateOrganizationVerificationStatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[5] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -354,7 +467,7 @@ func (x *UpdateOrganizationVerificationStatusResponse) ProtoReflect() protorefle // Deprecated: Use UpdateOrganizationVerificationStatusResponse.ProtoReflect.Descriptor instead. func (*UpdateOrganizationVerificationStatusResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{5} + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{6} } type CreateMachineUserRequest struct { @@ -368,7 +481,7 @@ type CreateMachineUserRequest struct { func (x *CreateMachineUserRequest) Reset() { *x = CreateMachineUserRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[6] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -381,7 +494,7 @@ func (x *CreateMachineUserRequest) String() string { func (*CreateMachineUserRequest) ProtoMessage() {} func (x *CreateMachineUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[6] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -394,7 +507,7 @@ func (x *CreateMachineUserRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateMachineUserRequest.ProtoReflect.Descriptor instead. func (*CreateMachineUserRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{6} + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{7} } func (x *CreateMachineUserRequest) GetUsername() string { @@ -415,7 +528,7 @@ type CreateMachineUserResponse struct { func (x *CreateMachineUserResponse) Reset() { *x = CreateMachineUserResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[7] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -428,7 +541,7 @@ func (x *CreateMachineUserResponse) String() string { func (*CreateMachineUserResponse) ProtoMessage() {} func (x *CreateMachineUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[7] + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -441,7 +554,7 @@ func (x *CreateMachineUserResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateMachineUserResponse.ProtoReflect.Descriptor instead. func (*CreateMachineUserResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{7} + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{8} } func (x *CreateMachineUserResponse) GetUser() *User { @@ -451,6 +564,176 @@ func (x *CreateMachineUserResponse) GetUser() *User { return nil } +type GetBreakingChangePolicyRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GetBreakingChangePolicyRequest) Reset() { + *x = GetBreakingChangePolicyRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBreakingChangePolicyRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBreakingChangePolicyRequest) ProtoMessage() {} + +func (x *GetBreakingChangePolicyRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBreakingChangePolicyRequest.ProtoReflect.Descriptor instead. +func (*GetBreakingChangePolicyRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{9} +} + +type GetBreakingChangePolicyResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Policy *BreakingChangePolicy `protobuf:"bytes,1,opt,name=policy,proto3" json:"policy,omitempty"` +} + +func (x *GetBreakingChangePolicyResponse) Reset() { + *x = GetBreakingChangePolicyResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBreakingChangePolicyResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBreakingChangePolicyResponse) ProtoMessage() {} + +func (x *GetBreakingChangePolicyResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBreakingChangePolicyResponse.ProtoReflect.Descriptor instead. +func (*GetBreakingChangePolicyResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{10} +} + +func (x *GetBreakingChangePolicyResponse) GetPolicy() *BreakingChangePolicy { + if x != nil { + return x.Policy + } + return nil +} + +type UpdateBreakingChangePolicyRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Policy *BreakingChangePolicy `protobuf:"bytes,1,opt,name=policy,proto3" json:"policy,omitempty"` +} + +func (x *UpdateBreakingChangePolicyRequest) Reset() { + *x = UpdateBreakingChangePolicyRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateBreakingChangePolicyRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateBreakingChangePolicyRequest) ProtoMessage() {} + +func (x *UpdateBreakingChangePolicyRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateBreakingChangePolicyRequest.ProtoReflect.Descriptor instead. +func (*UpdateBreakingChangePolicyRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{11} +} + +func (x *UpdateBreakingChangePolicyRequest) GetPolicy() *BreakingChangePolicy { + if x != nil { + return x.Policy + } + return nil +} + +type UpdateBreakingChangePolicyResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *UpdateBreakingChangePolicyResponse) Reset() { + *x = UpdateBreakingChangePolicyResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateBreakingChangePolicyResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateBreakingChangePolicyResponse) ProtoMessage() {} + +func (x *UpdateBreakingChangePolicyResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateBreakingChangePolicyResponse.ProtoReflect.Descriptor instead. +func (*UpdateBreakingChangePolicyResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP(), []int{12} +} + var File_buf_alpha_registry_v1alpha1_admin_proto protoreflect.FileDescriptor var file_buf_alpha_registry_v1alpha1_admin_proto_rawDesc = []byte{ @@ -472,128 +755,191 @@ var file_buf_alpha_registry_v1alpha1_admin_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x35, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x31, 0x0a, - 0x16, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, - 0x22, 0xfa, 0x02, 0x0a, 0x17, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x04, - 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, - 0x73, 0x65, 0x72, 0x12, 0x4f, 0x0a, 0x0d, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x4b, 0x0a, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, - 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x65, - 0x73, 0x12, 0x41, 0x0a, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07, 0x70, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x73, 0x12, 0x47, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x42, 0x02, - 0x18, 0x01, 0x52, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x22, 0xa0, 0x01, - 0x0a, 0x23, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, 0x69, - 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x60, - 0x0a, 0x13, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x12, 0x76, 0x65, - 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x22, 0x26, 0x0a, 0x24, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, - 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xb8, 0x01, 0x0a, 0x2b, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, - 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, - 0x64, 0x12, 0x60, 0x0a, 0x13, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x65, 0x72, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x12, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x22, 0x2e, 0x0a, 0x2c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, - 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x36, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, - 0x68, 0x69, 0x6e, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x52, 0x0a, 0x19, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x55, 0x73, 0x65, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xee, 0x01, + 0x0a, 0x14, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1d, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x64, 0x88, 0x01, 0x01, 0x12, 0x3d, 0x0a, 0x18, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, + 0x75, 0x6e, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x01, 0x52, 0x16, 0x69, 0x67, 0x6e, 0x6f, 0x72, + 0x65, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, + 0x73, 0x88, 0x01, 0x01, 0x12, 0x4f, 0x0a, 0x08, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x32, - 0xf5, 0x04, 0x0a, 0x0c, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x7c, 0x0a, 0x0f, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, - 0x73, 0x65, 0x72, 0x12, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x08, 0x63, 0x61, 0x74, + 0x65, 0x67, 0x6f, 0x72, 0x79, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x42, 0x1b, 0x0a, 0x19, 0x5f, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x75, 0x6e, 0x73, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x22, 0x31, + 0x0a, 0x16, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, + 0x64, 0x22, 0xfa, 0x02, 0x0a, 0x17, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, + 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, + 0x75, 0x73, 0x65, 0x72, 0x12, 0x4f, 0x0a, 0x0d, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x4b, 0x0a, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x6f, 0x72, 0x79, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x69, + 0x65, 0x73, 0x12, 0x41, 0x0a, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07, 0x70, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x47, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, + 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0xa3, - 0x01, 0x0a, 0x1c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x40, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x41, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0xbb, 0x01, 0x0a, 0x24, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, - 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x48, 0x2e, - 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x42, + 0x02, 0x18, 0x01, 0x52, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x22, 0xa0, + 0x01, 0x0a, 0x23, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, + 0x60, 0x0a, 0x13, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x12, 0x76, + 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x22, 0x26, 0x0a, 0x24, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x56, + 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xb8, 0x01, 0x0a, 0x2b, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x49, 0x64, 0x12, 0x60, 0x0a, 0x13, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x49, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x52, 0x12, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x22, 0x2e, 0x0a, 0x2c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, + 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x36, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, + 0x63, 0x68, 0x69, 0x6e, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x52, 0x0a, 0x19, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x55, 0x73, 0x65, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x04, 0x75, 0x73, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, + 0x22, 0x20, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x22, 0x6c, 0x0a, 0x1f, 0x47, 0x65, 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, + 0x67, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0x22, 0x6e, 0x0a, 0x21, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, + 0x6e, 0x67, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x49, 0x0a, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0x22, 0x24, 0x0a, 0x22, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, + 0x6e, 0x67, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x8d, 0x01, 0x0a, 0x16, 0x42, 0x72, 0x65, 0x61, 0x6b, + 0x69, 0x6e, 0x67, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, + 0x79, 0x12, 0x28, 0x0a, 0x24, 0x42, 0x52, 0x45, 0x41, 0x4b, 0x49, 0x4e, 0x47, 0x5f, 0x43, 0x48, + 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x43, 0x41, 0x54, 0x45, 0x47, 0x4f, 0x52, 0x59, 0x5f, 0x55, 0x4e, + 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x21, 0x0a, 0x1d, 0x42, + 0x52, 0x45, 0x41, 0x4b, 0x49, 0x4e, 0x47, 0x5f, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x43, + 0x41, 0x54, 0x45, 0x47, 0x4f, 0x52, 0x59, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x10, 0x01, 0x12, 0x26, + 0x0a, 0x22, 0x42, 0x52, 0x45, 0x41, 0x4b, 0x49, 0x4e, 0x47, 0x5f, 0x43, 0x48, 0x41, 0x4e, 0x47, + 0x45, 0x5f, 0x43, 0x41, 0x54, 0x45, 0x47, 0x4f, 0x52, 0x59, 0x5f, 0x57, 0x49, 0x52, 0x45, 0x5f, + 0x4a, 0x53, 0x4f, 0x4e, 0x10, 0x02, 0x32, 0xbc, 0x07, 0x0a, 0x0c, 0x41, 0x64, 0x6d, 0x69, 0x6e, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x81, 0x01, 0x0a, 0x0f, 0x46, 0x6f, 0x72, 0x63, + 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x33, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x46, + 0x6f, 0x72, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0xa3, 0x01, 0x0a, 0x1c, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x40, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0xbb, 0x01, 0x0a, 0x24, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x82, 0x01, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, - 0x68, 0x69, 0x6e, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, - 0x68, 0x69, 0x6e, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x97, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, - 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0a, 0x41, 0x64, 0x6d, - 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, - 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, - 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, - 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x48, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x49, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x87, 0x01, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, + 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, + 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x99, 0x01, 0x0a, 0x17, 0x47, 0x65, + 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x47, 0x65, 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x9d, 0x01, 0x0a, 0x1a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x6f, + 0x6c, 0x69, 0x63, 0x79, 0x12, 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, + 0x67, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, + 0x67, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x97, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0a, 0x41, 0x64, 0x6d, 0x69, 0x6e, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, + 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, + 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -608,45 +954,59 @@ func file_buf_alpha_registry_v1alpha1_admin_proto_rawDescGZIP() []byte { return file_buf_alpha_registry_v1alpha1_admin_proto_rawDescData } -var file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_buf_alpha_registry_v1alpha1_admin_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_buf_alpha_registry_v1alpha1_admin_proto_goTypes = []interface{}{ - (*ForceDeleteUserRequest)(nil), // 0: buf.alpha.registry.v1alpha1.ForceDeleteUserRequest - (*ForceDeleteUserResponse)(nil), // 1: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse - (*UpdateUserVerificationStatusRequest)(nil), // 2: buf.alpha.registry.v1alpha1.UpdateUserVerificationStatusRequest - (*UpdateUserVerificationStatusResponse)(nil), // 3: buf.alpha.registry.v1alpha1.UpdateUserVerificationStatusResponse - (*UpdateOrganizationVerificationStatusRequest)(nil), // 4: buf.alpha.registry.v1alpha1.UpdateOrganizationVerificationStatusRequest - (*UpdateOrganizationVerificationStatusResponse)(nil), // 5: buf.alpha.registry.v1alpha1.UpdateOrganizationVerificationStatusResponse - (*CreateMachineUserRequest)(nil), // 6: buf.alpha.registry.v1alpha1.CreateMachineUserRequest - (*CreateMachineUserResponse)(nil), // 7: buf.alpha.registry.v1alpha1.CreateMachineUserResponse - (*User)(nil), // 8: buf.alpha.registry.v1alpha1.User - (*Organization)(nil), // 9: buf.alpha.registry.v1alpha1.Organization - (*Repository)(nil), // 10: buf.alpha.registry.v1alpha1.Repository - (*Plugin)(nil), // 11: buf.alpha.registry.v1alpha1.Plugin - (*Template)(nil), // 12: buf.alpha.registry.v1alpha1.Template - (VerificationStatus)(0), // 13: buf.alpha.registry.v1alpha1.VerificationStatus + (BreakingChangeCategory)(0), // 0: buf.alpha.registry.v1alpha1.BreakingChangeCategory + (*BreakingChangePolicy)(nil), // 1: buf.alpha.registry.v1alpha1.BreakingChangePolicy + (*ForceDeleteUserRequest)(nil), // 2: buf.alpha.registry.v1alpha1.ForceDeleteUserRequest + (*ForceDeleteUserResponse)(nil), // 3: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse + (*UpdateUserVerificationStatusRequest)(nil), // 4: buf.alpha.registry.v1alpha1.UpdateUserVerificationStatusRequest + (*UpdateUserVerificationStatusResponse)(nil), // 5: buf.alpha.registry.v1alpha1.UpdateUserVerificationStatusResponse + (*UpdateOrganizationVerificationStatusRequest)(nil), // 6: buf.alpha.registry.v1alpha1.UpdateOrganizationVerificationStatusRequest + (*UpdateOrganizationVerificationStatusResponse)(nil), // 7: buf.alpha.registry.v1alpha1.UpdateOrganizationVerificationStatusResponse + (*CreateMachineUserRequest)(nil), // 8: buf.alpha.registry.v1alpha1.CreateMachineUserRequest + (*CreateMachineUserResponse)(nil), // 9: buf.alpha.registry.v1alpha1.CreateMachineUserResponse + (*GetBreakingChangePolicyRequest)(nil), // 10: buf.alpha.registry.v1alpha1.GetBreakingChangePolicyRequest + (*GetBreakingChangePolicyResponse)(nil), // 11: buf.alpha.registry.v1alpha1.GetBreakingChangePolicyResponse + (*UpdateBreakingChangePolicyRequest)(nil), // 12: buf.alpha.registry.v1alpha1.UpdateBreakingChangePolicyRequest + (*UpdateBreakingChangePolicyResponse)(nil), // 13: buf.alpha.registry.v1alpha1.UpdateBreakingChangePolicyResponse + (*User)(nil), // 14: buf.alpha.registry.v1alpha1.User + (*Organization)(nil), // 15: buf.alpha.registry.v1alpha1.Organization + (*Repository)(nil), // 16: buf.alpha.registry.v1alpha1.Repository + (*Plugin)(nil), // 17: buf.alpha.registry.v1alpha1.Plugin + (*Template)(nil), // 18: buf.alpha.registry.v1alpha1.Template + (VerificationStatus)(0), // 19: buf.alpha.registry.v1alpha1.VerificationStatus } var file_buf_alpha_registry_v1alpha1_admin_proto_depIdxs = []int32{ - 8, // 0: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse.user:type_name -> buf.alpha.registry.v1alpha1.User - 9, // 1: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse.organizations:type_name -> buf.alpha.registry.v1alpha1.Organization - 10, // 2: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse.repositories:type_name -> buf.alpha.registry.v1alpha1.Repository - 11, // 3: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse.plugins:type_name -> buf.alpha.registry.v1alpha1.Plugin - 12, // 4: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse.templates:type_name -> buf.alpha.registry.v1alpha1.Template - 13, // 5: buf.alpha.registry.v1alpha1.UpdateUserVerificationStatusRequest.verification_status:type_name -> buf.alpha.registry.v1alpha1.VerificationStatus - 13, // 6: buf.alpha.registry.v1alpha1.UpdateOrganizationVerificationStatusRequest.verification_status:type_name -> buf.alpha.registry.v1alpha1.VerificationStatus - 8, // 7: buf.alpha.registry.v1alpha1.CreateMachineUserResponse.user:type_name -> buf.alpha.registry.v1alpha1.User - 0, // 8: buf.alpha.registry.v1alpha1.AdminService.ForceDeleteUser:input_type -> buf.alpha.registry.v1alpha1.ForceDeleteUserRequest - 2, // 9: buf.alpha.registry.v1alpha1.AdminService.UpdateUserVerificationStatus:input_type -> buf.alpha.registry.v1alpha1.UpdateUserVerificationStatusRequest - 4, // 10: buf.alpha.registry.v1alpha1.AdminService.UpdateOrganizationVerificationStatus:input_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationVerificationStatusRequest - 6, // 11: buf.alpha.registry.v1alpha1.AdminService.CreateMachineUser:input_type -> buf.alpha.registry.v1alpha1.CreateMachineUserRequest - 1, // 12: buf.alpha.registry.v1alpha1.AdminService.ForceDeleteUser:output_type -> buf.alpha.registry.v1alpha1.ForceDeleteUserResponse - 3, // 13: buf.alpha.registry.v1alpha1.AdminService.UpdateUserVerificationStatus:output_type -> buf.alpha.registry.v1alpha1.UpdateUserVerificationStatusResponse - 5, // 14: buf.alpha.registry.v1alpha1.AdminService.UpdateOrganizationVerificationStatus:output_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationVerificationStatusResponse - 7, // 15: buf.alpha.registry.v1alpha1.AdminService.CreateMachineUser:output_type -> buf.alpha.registry.v1alpha1.CreateMachineUserResponse - 12, // [12:16] is the sub-list for method output_type - 8, // [8:12] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 0, // 0: buf.alpha.registry.v1alpha1.BreakingChangePolicy.category:type_name -> buf.alpha.registry.v1alpha1.BreakingChangeCategory + 14, // 1: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse.user:type_name -> buf.alpha.registry.v1alpha1.User + 15, // 2: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse.organizations:type_name -> buf.alpha.registry.v1alpha1.Organization + 16, // 3: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse.repositories:type_name -> buf.alpha.registry.v1alpha1.Repository + 17, // 4: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse.plugins:type_name -> buf.alpha.registry.v1alpha1.Plugin + 18, // 5: buf.alpha.registry.v1alpha1.ForceDeleteUserResponse.templates:type_name -> buf.alpha.registry.v1alpha1.Template + 19, // 6: buf.alpha.registry.v1alpha1.UpdateUserVerificationStatusRequest.verification_status:type_name -> buf.alpha.registry.v1alpha1.VerificationStatus + 19, // 7: buf.alpha.registry.v1alpha1.UpdateOrganizationVerificationStatusRequest.verification_status:type_name -> buf.alpha.registry.v1alpha1.VerificationStatus + 14, // 8: buf.alpha.registry.v1alpha1.CreateMachineUserResponse.user:type_name -> buf.alpha.registry.v1alpha1.User + 1, // 9: buf.alpha.registry.v1alpha1.GetBreakingChangePolicyResponse.policy:type_name -> buf.alpha.registry.v1alpha1.BreakingChangePolicy + 1, // 10: buf.alpha.registry.v1alpha1.UpdateBreakingChangePolicyRequest.policy:type_name -> buf.alpha.registry.v1alpha1.BreakingChangePolicy + 2, // 11: buf.alpha.registry.v1alpha1.AdminService.ForceDeleteUser:input_type -> buf.alpha.registry.v1alpha1.ForceDeleteUserRequest + 4, // 12: buf.alpha.registry.v1alpha1.AdminService.UpdateUserVerificationStatus:input_type -> buf.alpha.registry.v1alpha1.UpdateUserVerificationStatusRequest + 6, // 13: buf.alpha.registry.v1alpha1.AdminService.UpdateOrganizationVerificationStatus:input_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationVerificationStatusRequest + 8, // 14: buf.alpha.registry.v1alpha1.AdminService.CreateMachineUser:input_type -> buf.alpha.registry.v1alpha1.CreateMachineUserRequest + 10, // 15: buf.alpha.registry.v1alpha1.AdminService.GetBreakingChangePolicy:input_type -> buf.alpha.registry.v1alpha1.GetBreakingChangePolicyRequest + 12, // 16: buf.alpha.registry.v1alpha1.AdminService.UpdateBreakingChangePolicy:input_type -> buf.alpha.registry.v1alpha1.UpdateBreakingChangePolicyRequest + 3, // 17: buf.alpha.registry.v1alpha1.AdminService.ForceDeleteUser:output_type -> buf.alpha.registry.v1alpha1.ForceDeleteUserResponse + 5, // 18: buf.alpha.registry.v1alpha1.AdminService.UpdateUserVerificationStatus:output_type -> buf.alpha.registry.v1alpha1.UpdateUserVerificationStatusResponse + 7, // 19: buf.alpha.registry.v1alpha1.AdminService.UpdateOrganizationVerificationStatus:output_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationVerificationStatusResponse + 9, // 20: buf.alpha.registry.v1alpha1.AdminService.CreateMachineUser:output_type -> buf.alpha.registry.v1alpha1.CreateMachineUserResponse + 11, // 21: buf.alpha.registry.v1alpha1.AdminService.GetBreakingChangePolicy:output_type -> buf.alpha.registry.v1alpha1.GetBreakingChangePolicyResponse + 13, // 22: buf.alpha.registry.v1alpha1.AdminService.UpdateBreakingChangePolicy:output_type -> buf.alpha.registry.v1alpha1.UpdateBreakingChangePolicyResponse + 17, // [17:23] is the sub-list for method output_type + 11, // [11:17] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_buf_alpha_registry_v1alpha1_admin_proto_init() } @@ -661,7 +1021,7 @@ func file_buf_alpha_registry_v1alpha1_admin_proto_init() { file_buf_alpha_registry_v1alpha1_verification_status_proto_init() if !protoimpl.UnsafeEnabled { file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ForceDeleteUserRequest); i { + switch v := v.(*BreakingChangePolicy); i { case 0: return &v.state case 1: @@ -673,7 +1033,7 @@ func file_buf_alpha_registry_v1alpha1_admin_proto_init() { } } file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ForceDeleteUserResponse); i { + switch v := v.(*ForceDeleteUserRequest); i { case 0: return &v.state case 1: @@ -685,7 +1045,7 @@ func file_buf_alpha_registry_v1alpha1_admin_proto_init() { } } file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateUserVerificationStatusRequest); i { + switch v := v.(*ForceDeleteUserResponse); i { case 0: return &v.state case 1: @@ -697,7 +1057,7 @@ func file_buf_alpha_registry_v1alpha1_admin_proto_init() { } } file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateUserVerificationStatusResponse); i { + switch v := v.(*UpdateUserVerificationStatusRequest); i { case 0: return &v.state case 1: @@ -709,7 +1069,7 @@ func file_buf_alpha_registry_v1alpha1_admin_proto_init() { } } file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateOrganizationVerificationStatusRequest); i { + switch v := v.(*UpdateUserVerificationStatusResponse); i { case 0: return &v.state case 1: @@ -721,7 +1081,7 @@ func file_buf_alpha_registry_v1alpha1_admin_proto_init() { } } file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateOrganizationVerificationStatusResponse); i { + switch v := v.(*UpdateOrganizationVerificationStatusRequest); i { case 0: return &v.state case 1: @@ -733,7 +1093,7 @@ func file_buf_alpha_registry_v1alpha1_admin_proto_init() { } } file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateMachineUserRequest); i { + switch v := v.(*UpdateOrganizationVerificationStatusResponse); i { case 0: return &v.state case 1: @@ -745,6 +1105,18 @@ func file_buf_alpha_registry_v1alpha1_admin_proto_init() { } } file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateMachineUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CreateMachineUserResponse); i { case 0: return &v.state @@ -756,19 +1128,69 @@ func file_buf_alpha_registry_v1alpha1_admin_proto_init() { return nil } } + file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBreakingChangePolicyRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBreakingChangePolicyResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateBreakingChangePolicyRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateBreakingChangePolicyResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } + file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes[0].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_alpha_registry_v1alpha1_admin_proto_rawDesc, - NumEnums: 0, - NumMessages: 8, + NumEnums: 1, + NumMessages: 13, NumExtensions: 0, NumServices: 1, }, GoTypes: file_buf_alpha_registry_v1alpha1_admin_proto_goTypes, DependencyIndexes: file_buf_alpha_registry_v1alpha1_admin_proto_depIdxs, + EnumInfos: file_buf_alpha_registry_v1alpha1_admin_proto_enumTypes, MessageInfos: file_buf_alpha_registry_v1alpha1_admin_proto_msgTypes, }.Build() File_buf_alpha_registry_v1alpha1_admin_proto = out.File diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/authz.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/authz.pb.go index 297998536..c72e2eb93 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/authz.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/authz.pb.go @@ -1998,206 +1998,6 @@ func (x *UserCanManageRepositoryContributorsResponse) GetAuthorizedRoles() []Rep return nil } -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/authz.proto. -type UserCanManagePluginContributorsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ID of the plugin for which to check - // whether the user is authorized. - PluginId string `protobuf:"bytes,1,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` -} - -func (x *UserCanManagePluginContributorsRequest) Reset() { - *x = UserCanManagePluginContributorsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[40] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UserCanManagePluginContributorsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserCanManagePluginContributorsRequest) ProtoMessage() {} - -func (x *UserCanManagePluginContributorsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[40] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserCanManagePluginContributorsRequest.ProtoReflect.Descriptor instead. -func (*UserCanManagePluginContributorsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_authz_proto_rawDescGZIP(), []int{40} -} - -func (x *UserCanManagePluginContributorsRequest) GetPluginId() string { - if x != nil { - return x.PluginId - } - return "" -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/authz.proto. -type UserCanManagePluginContributorsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The list of roles that the user is authorized to manage, empty list means the user is - // not authorized to manage any contributors. - AuthorizedRoles []PluginRole `protobuf:"varint,1,rep,packed,name=authorized_roles,json=authorizedRoles,proto3,enum=buf.alpha.registry.v1alpha1.PluginRole" json:"authorized_roles,omitempty"` -} - -func (x *UserCanManagePluginContributorsResponse) Reset() { - *x = UserCanManagePluginContributorsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[41] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UserCanManagePluginContributorsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserCanManagePluginContributorsResponse) ProtoMessage() {} - -func (x *UserCanManagePluginContributorsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[41] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserCanManagePluginContributorsResponse.ProtoReflect.Descriptor instead. -func (*UserCanManagePluginContributorsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_authz_proto_rawDescGZIP(), []int{41} -} - -func (x *UserCanManagePluginContributorsResponse) GetAuthorizedRoles() []PluginRole { - if x != nil { - return x.AuthorizedRoles - } - return nil -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/authz.proto. -type UserCanManageTemplateContributorsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ID of the template for which to check - // whether the user is authorized. - TemplateId string `protobuf:"bytes,1,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` -} - -func (x *UserCanManageTemplateContributorsRequest) Reset() { - *x = UserCanManageTemplateContributorsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[42] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UserCanManageTemplateContributorsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserCanManageTemplateContributorsRequest) ProtoMessage() {} - -func (x *UserCanManageTemplateContributorsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[42] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserCanManageTemplateContributorsRequest.ProtoReflect.Descriptor instead. -func (*UserCanManageTemplateContributorsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_authz_proto_rawDescGZIP(), []int{42} -} - -func (x *UserCanManageTemplateContributorsRequest) GetTemplateId() string { - if x != nil { - return x.TemplateId - } - return "" -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/authz.proto. -type UserCanManageTemplateContributorsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The list of roles that the user is authorized to manage, empty list means the user is - // not authorized to manage any contributors. - AuthorizedRoles []TemplateRole `protobuf:"varint,1,rep,packed,name=authorized_roles,json=authorizedRoles,proto3,enum=buf.alpha.registry.v1alpha1.TemplateRole" json:"authorized_roles,omitempty"` -} - -func (x *UserCanManageTemplateContributorsResponse) Reset() { - *x = UserCanManageTemplateContributorsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[43] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UserCanManageTemplateContributorsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserCanManageTemplateContributorsResponse) ProtoMessage() {} - -func (x *UserCanManageTemplateContributorsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[43] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserCanManageTemplateContributorsResponse.ProtoReflect.Descriptor instead. -func (*UserCanManageTemplateContributorsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_authz_proto_rawDescGZIP(), []int{43} -} - -func (x *UserCanManageTemplateContributorsResponse) GetAuthorizedRoles() []TemplateRole { - if x != nil { - return x.AuthorizedRoles - } - return nil -} - var File_buf_alpha_registry_v1alpha1_authz_proto protoreflect.FileDescriptor var file_buf_alpha_registry_v1alpha1_authz_proto_rawDesc = []byte{ @@ -2406,287 +2206,237 @@ var file_buf_alpha_registry_v1alpha1_authz_proto_rawDesc = []byte{ 0x0e, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0f, - 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x22, - 0x49, 0x0a, 0x26, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, - 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x3a, 0x02, 0x18, 0x01, 0x22, 0x81, 0x01, 0x0a, 0x27, 0x55, - 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x10, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, - 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, - 0x32, 0x27, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0f, 0x61, 0x75, 0x74, 0x68, 0x6f, - 0x72, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x3a, 0x02, 0x18, 0x01, 0x22, 0x4f, - 0x0a, 0x28, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x54, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x64, 0x3a, 0x02, 0x18, 0x01, 0x22, - 0x85, 0x01, 0x0a, 0x29, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, - 0x10, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x72, 0x6f, 0x6c, 0x65, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, - 0x6c, 0x65, 0x52, 0x0f, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x6f, - 0x6c, 0x65, 0x73, 0x3a, 0x02, 0x18, 0x01, 0x32, 0xab, 0x1d, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, - 0x7a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xbd, 0x01, 0x0a, 0x23, 0x55, 0x73, 0x65, - 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, - 0x12, 0x47, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, - 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x48, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xa8, 0x01, 0x0a, 0x1c, 0x55, 0x73, 0x65, - 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, - 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x40, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, - 0x65, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, - 0x6e, 0x53, 0x65, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, - 0x90, 0x02, 0x01, 0x12, 0xae, 0x01, 0x0a, 0x1e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, - 0x65, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x42, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x4f, - 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, - 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x43, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, - 0x53, 0x65, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, - 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x03, 0x90, 0x02, 0x01, 0x12, 0x8a, 0x01, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, - 0x52, 0x65, 0x61, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x35, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, - 0x52, 0x65, 0x61, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x32, + 0xb7, 0x1a, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0xbd, 0x01, 0x0a, 0x23, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x47, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x48, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, + 0x12, 0xa8, 0x01, 0x0a, 0x1c, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x52, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x12, 0x40, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x52, 0x65, 0x61, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x52, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xae, 0x01, 0x0a, 0x1e, + 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x42, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, + 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x43, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, + 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x8a, 0x01, 0x0a, + 0x11, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x52, 0x65, 0x61, 0x64, 0x50, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x12, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x52, 0x65, 0x61, 0x64, 0x50, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x52, + 0x65, 0x61, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xa5, 0x01, 0x0a, 0x1a, 0x55, 0x73, + 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, - 0x01, 0x12, 0xa5, 0x01, 0x0a, 0x1a, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x3f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xab, 0x01, 0x0a, 0x1c, 0x55, 0x73, - 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x62, - 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, - 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xb4, 0x01, 0x0a, 0x1f, 0x55, 0x73, 0x65, 0x72, - 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x43, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, - 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x44, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xba, - 0x01, 0x0a, 0x21, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x12, 0x45, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x01, 0x12, 0xab, 0x01, 0x0a, 0x1c, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x40, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, + 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x46, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, - 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0x9f, 0x01, 0x0a, 0x18, - 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, + 0xb4, 0x01, 0x0a, 0x1f, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x12, 0x43, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x44, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, - 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xa5, 0x01, - 0x0a, 0x1a, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x54, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x3e, 0x2e, 0x62, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, + 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xba, 0x01, 0x0a, 0x21, 0x55, 0x73, 0x65, 0x72, 0x43, + 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x45, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, - 0x61, 0x6e, 0x53, 0x65, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x62, + 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x46, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6c, + 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, + 0x90, 0x02, 0x01, 0x12, 0x9f, 0x01, 0x0a, 0x18, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, + 0x65, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, + 0x12, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, + 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3d, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, + 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, + 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xa5, 0x01, 0x0a, 0x1a, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, + 0x6e, 0x53, 0x65, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x12, 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x54, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x54, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xa8, 0x01, + 0x0a, 0x1c, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x40, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, + 0x72, 0x43, 0x61, 0x6e, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x41, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, + 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xb1, 0x01, 0x0a, 0x1f, 0x55, 0x73, 0x65, + 0x72, 0x43, 0x61, 0x6e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x43, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, - 0x61, 0x6e, 0x53, 0x65, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, - 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xa8, 0x01, 0x0a, 0x1c, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, - 0x6e, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x40, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x41, 0x64, 0x64, 0x4f, - 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x41, 0x64, - 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, + 0x61, 0x6e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x44, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xb1, 0x01, 0x0a, + 0x1f, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, + 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x43, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, + 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x44, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x52, 0x65, 0x6d, 0x6f, 0x76, + 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, - 0x12, 0xb1, 0x01, 0x0a, 0x1f, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, - 0x6d, 0x62, 0x65, 0x72, 0x12, 0x43, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x44, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x03, 0x90, 0x02, 0x01, 0x12, 0xb1, 0x01, 0x0a, 0x1f, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, - 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x43, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x52, 0x65, - 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x44, 0x2e, + 0x12, 0x9f, 0x01, 0x0a, 0x19, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3d, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, + 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, - 0x43, 0x61, 0x6e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x9f, 0x01, 0x0a, 0x19, 0x55, 0x73, 0x65, - 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x99, 0x01, 0x0a, 0x17, 0x55, - 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, - 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x96, 0x01, 0x0a, 0x15, 0x55, 0x73, 0x65, 0x72, 0x43, - 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x12, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, + 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, + 0x02, 0x01, 0x12, 0x99, 0x01, 0x0a, 0x17, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x3b, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, + 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, - 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, - 0x90, 0x01, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, - 0x02, 0x01, 0x12, 0x87, 0x01, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, + 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x96, + 0x01, 0x0a, 0x15, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0x90, 0x01, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, + 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, + 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, - 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xa2, 0x01, 0x0a, - 0x1a, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x12, 0x3e, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, - 0x6e, 0x53, 0x65, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x50, - 0x61, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, - 0x6e, 0x53, 0x65, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x50, - 0x61, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, - 0x01, 0x12, 0xbd, 0x01, 0x0a, 0x23, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6e, - 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x47, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x43, - 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x48, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x52, 0x65, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, - 0x01, 0x12, 0xb4, 0x01, 0x0a, 0x1f, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x43, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x44, 0x2e, 0x62, 0x75, 0x66, + 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0x87, 0x01, 0x0a, 0x11, 0x55, + 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, + 0x12, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, + 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x03, 0x90, 0x02, 0x01, 0x12, 0xa2, 0x01, 0x0a, 0x1a, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, + 0x53, 0x65, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x50, 0x61, + 0x6e, 0x65, 0x6c, 0x12, 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x53, 0x65, 0x65, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xbd, 0x01, 0x0a, 0x23, 0x55, 0x73, + 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, + 0x73, 0x12, 0x47, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, + 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x48, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, - 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xba, 0x01, 0x0a, 0x21, 0x55, 0x73, 0x65, - 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x45, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, - 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x46, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, - 0x02, 0x01, 0x90, 0x02, 0x01, 0x42, 0x97, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x7a, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, - 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, - 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, - 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, 0x97, 0x02, 0x0a, 0x1f, 0x63, 0x6f, + 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0a, 0x41, + 0x75, 0x74, 0x68, 0x7a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, + 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, + 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, + 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, + 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, + 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2701,7 +2451,7 @@ func file_buf_alpha_registry_v1alpha1_authz_proto_rawDescGZIP() []byte { return file_buf_alpha_registry_v1alpha1_authz_proto_rawDescData } -var file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes = make([]protoimpl.MessageInfo, 44) +var file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes = make([]protoimpl.MessageInfo, 40) var file_buf_alpha_registry_v1alpha1_authz_proto_goTypes = []interface{}{ (*UserCanCreateOrganizationRepositoryRequest)(nil), // 0: buf.alpha.registry.v1alpha1.UserCanCreateOrganizationRepositoryRequest (*UserCanCreateOrganizationRepositoryResponse)(nil), // 1: buf.alpha.registry.v1alpha1.UserCanCreateOrganizationRepositoryResponse @@ -2743,71 +2493,59 @@ var file_buf_alpha_registry_v1alpha1_authz_proto_goTypes = []interface{}{ (*UserCanSeeServerAdminPanelResponse)(nil), // 37: buf.alpha.registry.v1alpha1.UserCanSeeServerAdminPanelResponse (*UserCanManageRepositoryContributorsRequest)(nil), // 38: buf.alpha.registry.v1alpha1.UserCanManageRepositoryContributorsRequest (*UserCanManageRepositoryContributorsResponse)(nil), // 39: buf.alpha.registry.v1alpha1.UserCanManageRepositoryContributorsResponse - (*UserCanManagePluginContributorsRequest)(nil), // 40: buf.alpha.registry.v1alpha1.UserCanManagePluginContributorsRequest - (*UserCanManagePluginContributorsResponse)(nil), // 41: buf.alpha.registry.v1alpha1.UserCanManagePluginContributorsResponse - (*UserCanManageTemplateContributorsRequest)(nil), // 42: buf.alpha.registry.v1alpha1.UserCanManageTemplateContributorsRequest - (*UserCanManageTemplateContributorsResponse)(nil), // 43: buf.alpha.registry.v1alpha1.UserCanManageTemplateContributorsResponse - (OrganizationRole)(0), // 44: buf.alpha.registry.v1alpha1.OrganizationRole - (RepositoryRole)(0), // 45: buf.alpha.registry.v1alpha1.RepositoryRole - (PluginRole)(0), // 46: buf.alpha.registry.v1alpha1.PluginRole - (TemplateRole)(0), // 47: buf.alpha.registry.v1alpha1.TemplateRole + (OrganizationRole)(0), // 40: buf.alpha.registry.v1alpha1.OrganizationRole + (RepositoryRole)(0), // 41: buf.alpha.registry.v1alpha1.RepositoryRole } var file_buf_alpha_registry_v1alpha1_authz_proto_depIdxs = []int32{ - 44, // 0: buf.alpha.registry.v1alpha1.UserCanAddOrganizationMemberResponse.authorized_roles:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole - 44, // 1: buf.alpha.registry.v1alpha1.UserCanUpdateOrganizationMemberResponse.authorized_roles:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole - 44, // 2: buf.alpha.registry.v1alpha1.UserCanRemoveOrganizationMemberResponse.authorized_roles:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole - 45, // 3: buf.alpha.registry.v1alpha1.UserCanManageRepositoryContributorsResponse.authorized_roles:type_name -> buf.alpha.registry.v1alpha1.RepositoryRole - 46, // 4: buf.alpha.registry.v1alpha1.UserCanManagePluginContributorsResponse.authorized_roles:type_name -> buf.alpha.registry.v1alpha1.PluginRole - 47, // 5: buf.alpha.registry.v1alpha1.UserCanManageTemplateContributorsResponse.authorized_roles:type_name -> buf.alpha.registry.v1alpha1.TemplateRole - 0, // 6: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationRepository:input_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationRepositoryRequest - 2, // 7: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeRepositorySettings:input_type -> buf.alpha.registry.v1alpha1.UserCanSeeRepositorySettingsRequest - 4, // 8: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeOrganizationSettings:input_type -> buf.alpha.registry.v1alpha1.UserCanSeeOrganizationSettingsRequest - 6, // 9: buf.alpha.registry.v1alpha1.AuthzService.UserCanReadPlugin:input_type -> buf.alpha.registry.v1alpha1.UserCanReadPluginRequest - 8, // 10: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreatePluginVersion:input_type -> buf.alpha.registry.v1alpha1.UserCanCreatePluginVersionRequest - 10, // 11: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateTemplateVersion:input_type -> buf.alpha.registry.v1alpha1.UserCanCreateTemplateVersionRequest - 12, // 12: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationPlugin:input_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationPluginRequest - 14, // 13: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationTemplate:input_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationTemplateRequest - 16, // 14: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeePluginSettings:input_type -> buf.alpha.registry.v1alpha1.UserCanSeePluginSettingsRequest - 18, // 15: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeTemplateSettings:input_type -> buf.alpha.registry.v1alpha1.UserCanSeeTemplateSettingsRequest - 20, // 16: buf.alpha.registry.v1alpha1.AuthzService.UserCanAddOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.UserCanAddOrganizationMemberRequest - 22, // 17: buf.alpha.registry.v1alpha1.AuthzService.UserCanUpdateOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.UserCanUpdateOrganizationMemberRequest - 24, // 18: buf.alpha.registry.v1alpha1.AuthzService.UserCanRemoveOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.UserCanRemoveOrganizationMemberRequest - 26, // 19: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteOrganization:input_type -> buf.alpha.registry.v1alpha1.UserCanDeleteOrganizationRequest - 28, // 20: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteRepository:input_type -> buf.alpha.registry.v1alpha1.UserCanDeleteRepositoryRequest - 30, // 21: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteTemplate:input_type -> buf.alpha.registry.v1alpha1.UserCanDeleteTemplateRequest - 32, // 22: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeletePlugin:input_type -> buf.alpha.registry.v1alpha1.UserCanDeletePluginRequest - 34, // 23: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteUser:input_type -> buf.alpha.registry.v1alpha1.UserCanDeleteUserRequest - 36, // 24: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeServerAdminPanel:input_type -> buf.alpha.registry.v1alpha1.UserCanSeeServerAdminPanelRequest - 38, // 25: buf.alpha.registry.v1alpha1.AuthzService.UserCanManageRepositoryContributors:input_type -> buf.alpha.registry.v1alpha1.UserCanManageRepositoryContributorsRequest - 40, // 26: buf.alpha.registry.v1alpha1.AuthzService.UserCanManagePluginContributors:input_type -> buf.alpha.registry.v1alpha1.UserCanManagePluginContributorsRequest - 42, // 27: buf.alpha.registry.v1alpha1.AuthzService.UserCanManageTemplateContributors:input_type -> buf.alpha.registry.v1alpha1.UserCanManageTemplateContributorsRequest - 1, // 28: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationRepository:output_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationRepositoryResponse - 3, // 29: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeRepositorySettings:output_type -> buf.alpha.registry.v1alpha1.UserCanSeeRepositorySettingsResponse - 5, // 30: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeOrganizationSettings:output_type -> buf.alpha.registry.v1alpha1.UserCanSeeOrganizationSettingsResponse - 7, // 31: buf.alpha.registry.v1alpha1.AuthzService.UserCanReadPlugin:output_type -> buf.alpha.registry.v1alpha1.UserCanReadPluginResponse - 9, // 32: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreatePluginVersion:output_type -> buf.alpha.registry.v1alpha1.UserCanCreatePluginVersionResponse - 11, // 33: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateTemplateVersion:output_type -> buf.alpha.registry.v1alpha1.UserCanCreateTemplateVersionResponse - 13, // 34: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationPlugin:output_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationPluginResponse - 15, // 35: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationTemplate:output_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationTemplateResponse - 17, // 36: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeePluginSettings:output_type -> buf.alpha.registry.v1alpha1.UserCanSeePluginSettingsResponse - 19, // 37: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeTemplateSettings:output_type -> buf.alpha.registry.v1alpha1.UserCanSeeTemplateSettingsResponse - 21, // 38: buf.alpha.registry.v1alpha1.AuthzService.UserCanAddOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.UserCanAddOrganizationMemberResponse - 23, // 39: buf.alpha.registry.v1alpha1.AuthzService.UserCanUpdateOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.UserCanUpdateOrganizationMemberResponse - 25, // 40: buf.alpha.registry.v1alpha1.AuthzService.UserCanRemoveOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.UserCanRemoveOrganizationMemberResponse - 27, // 41: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteOrganization:output_type -> buf.alpha.registry.v1alpha1.UserCanDeleteOrganizationResponse - 29, // 42: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteRepository:output_type -> buf.alpha.registry.v1alpha1.UserCanDeleteRepositoryResponse - 31, // 43: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteTemplate:output_type -> buf.alpha.registry.v1alpha1.UserCanDeleteTemplateResponse - 33, // 44: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeletePlugin:output_type -> buf.alpha.registry.v1alpha1.UserCanDeletePluginResponse - 35, // 45: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteUser:output_type -> buf.alpha.registry.v1alpha1.UserCanDeleteUserResponse - 37, // 46: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeServerAdminPanel:output_type -> buf.alpha.registry.v1alpha1.UserCanSeeServerAdminPanelResponse - 39, // 47: buf.alpha.registry.v1alpha1.AuthzService.UserCanManageRepositoryContributors:output_type -> buf.alpha.registry.v1alpha1.UserCanManageRepositoryContributorsResponse - 41, // 48: buf.alpha.registry.v1alpha1.AuthzService.UserCanManagePluginContributors:output_type -> buf.alpha.registry.v1alpha1.UserCanManagePluginContributorsResponse - 43, // 49: buf.alpha.registry.v1alpha1.AuthzService.UserCanManageTemplateContributors:output_type -> buf.alpha.registry.v1alpha1.UserCanManageTemplateContributorsResponse - 28, // [28:50] is the sub-list for method output_type - 6, // [6:28] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 40, // 0: buf.alpha.registry.v1alpha1.UserCanAddOrganizationMemberResponse.authorized_roles:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole + 40, // 1: buf.alpha.registry.v1alpha1.UserCanUpdateOrganizationMemberResponse.authorized_roles:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole + 40, // 2: buf.alpha.registry.v1alpha1.UserCanRemoveOrganizationMemberResponse.authorized_roles:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole + 41, // 3: buf.alpha.registry.v1alpha1.UserCanManageRepositoryContributorsResponse.authorized_roles:type_name -> buf.alpha.registry.v1alpha1.RepositoryRole + 0, // 4: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationRepository:input_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationRepositoryRequest + 2, // 5: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeRepositorySettings:input_type -> buf.alpha.registry.v1alpha1.UserCanSeeRepositorySettingsRequest + 4, // 6: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeOrganizationSettings:input_type -> buf.alpha.registry.v1alpha1.UserCanSeeOrganizationSettingsRequest + 6, // 7: buf.alpha.registry.v1alpha1.AuthzService.UserCanReadPlugin:input_type -> buf.alpha.registry.v1alpha1.UserCanReadPluginRequest + 8, // 8: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreatePluginVersion:input_type -> buf.alpha.registry.v1alpha1.UserCanCreatePluginVersionRequest + 10, // 9: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateTemplateVersion:input_type -> buf.alpha.registry.v1alpha1.UserCanCreateTemplateVersionRequest + 12, // 10: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationPlugin:input_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationPluginRequest + 14, // 11: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationTemplate:input_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationTemplateRequest + 16, // 12: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeePluginSettings:input_type -> buf.alpha.registry.v1alpha1.UserCanSeePluginSettingsRequest + 18, // 13: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeTemplateSettings:input_type -> buf.alpha.registry.v1alpha1.UserCanSeeTemplateSettingsRequest + 20, // 14: buf.alpha.registry.v1alpha1.AuthzService.UserCanAddOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.UserCanAddOrganizationMemberRequest + 22, // 15: buf.alpha.registry.v1alpha1.AuthzService.UserCanUpdateOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.UserCanUpdateOrganizationMemberRequest + 24, // 16: buf.alpha.registry.v1alpha1.AuthzService.UserCanRemoveOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.UserCanRemoveOrganizationMemberRequest + 26, // 17: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteOrganization:input_type -> buf.alpha.registry.v1alpha1.UserCanDeleteOrganizationRequest + 28, // 18: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteRepository:input_type -> buf.alpha.registry.v1alpha1.UserCanDeleteRepositoryRequest + 30, // 19: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteTemplate:input_type -> buf.alpha.registry.v1alpha1.UserCanDeleteTemplateRequest + 32, // 20: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeletePlugin:input_type -> buf.alpha.registry.v1alpha1.UserCanDeletePluginRequest + 34, // 21: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteUser:input_type -> buf.alpha.registry.v1alpha1.UserCanDeleteUserRequest + 36, // 22: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeServerAdminPanel:input_type -> buf.alpha.registry.v1alpha1.UserCanSeeServerAdminPanelRequest + 38, // 23: buf.alpha.registry.v1alpha1.AuthzService.UserCanManageRepositoryContributors:input_type -> buf.alpha.registry.v1alpha1.UserCanManageRepositoryContributorsRequest + 1, // 24: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationRepository:output_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationRepositoryResponse + 3, // 25: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeRepositorySettings:output_type -> buf.alpha.registry.v1alpha1.UserCanSeeRepositorySettingsResponse + 5, // 26: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeOrganizationSettings:output_type -> buf.alpha.registry.v1alpha1.UserCanSeeOrganizationSettingsResponse + 7, // 27: buf.alpha.registry.v1alpha1.AuthzService.UserCanReadPlugin:output_type -> buf.alpha.registry.v1alpha1.UserCanReadPluginResponse + 9, // 28: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreatePluginVersion:output_type -> buf.alpha.registry.v1alpha1.UserCanCreatePluginVersionResponse + 11, // 29: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateTemplateVersion:output_type -> buf.alpha.registry.v1alpha1.UserCanCreateTemplateVersionResponse + 13, // 30: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationPlugin:output_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationPluginResponse + 15, // 31: buf.alpha.registry.v1alpha1.AuthzService.UserCanCreateOrganizationTemplate:output_type -> buf.alpha.registry.v1alpha1.UserCanCreateOrganizationTemplateResponse + 17, // 32: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeePluginSettings:output_type -> buf.alpha.registry.v1alpha1.UserCanSeePluginSettingsResponse + 19, // 33: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeTemplateSettings:output_type -> buf.alpha.registry.v1alpha1.UserCanSeeTemplateSettingsResponse + 21, // 34: buf.alpha.registry.v1alpha1.AuthzService.UserCanAddOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.UserCanAddOrganizationMemberResponse + 23, // 35: buf.alpha.registry.v1alpha1.AuthzService.UserCanUpdateOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.UserCanUpdateOrganizationMemberResponse + 25, // 36: buf.alpha.registry.v1alpha1.AuthzService.UserCanRemoveOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.UserCanRemoveOrganizationMemberResponse + 27, // 37: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteOrganization:output_type -> buf.alpha.registry.v1alpha1.UserCanDeleteOrganizationResponse + 29, // 38: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteRepository:output_type -> buf.alpha.registry.v1alpha1.UserCanDeleteRepositoryResponse + 31, // 39: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteTemplate:output_type -> buf.alpha.registry.v1alpha1.UserCanDeleteTemplateResponse + 33, // 40: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeletePlugin:output_type -> buf.alpha.registry.v1alpha1.UserCanDeletePluginResponse + 35, // 41: buf.alpha.registry.v1alpha1.AuthzService.UserCanDeleteUser:output_type -> buf.alpha.registry.v1alpha1.UserCanDeleteUserResponse + 37, // 42: buf.alpha.registry.v1alpha1.AuthzService.UserCanSeeServerAdminPanel:output_type -> buf.alpha.registry.v1alpha1.UserCanSeeServerAdminPanelResponse + 39, // 43: buf.alpha.registry.v1alpha1.AuthzService.UserCanManageRepositoryContributors:output_type -> buf.alpha.registry.v1alpha1.UserCanManageRepositoryContributorsResponse + 24, // [24:44] is the sub-list for method output_type + 4, // [4:24] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_buf_alpha_registry_v1alpha1_authz_proto_init() } @@ -3297,54 +3035,6 @@ func file_buf_alpha_registry_v1alpha1_authz_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UserCanManagePluginContributorsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UserCanManagePluginContributorsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UserCanManageTemplateContributorsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_authz_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UserCanManageTemplateContributorsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -3352,7 +3042,7 @@ func file_buf_alpha_registry_v1alpha1_authz_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_alpha_registry_v1alpha1_authz_proto_rawDesc, NumEnums: 0, - NumMessages: 44, + NumMessages: 40, NumExtensions: 0, NumServices: 1, }, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/display.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/display.pb.go index 7b7a11c04..c9293d0cb 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/display.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/display.pb.go @@ -297,240 +297,6 @@ func (x *DisplayRepositoryElementsResponse) GetWrite() bool { return false } -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type DisplayPluginElementsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ID of the plugin for which to check - // which elements should be displayed. - PluginId string `protobuf:"bytes,1,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` -} - -func (x *DisplayPluginElementsRequest) Reset() { - *x = DisplayPluginElementsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DisplayPluginElementsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DisplayPluginElementsRequest) ProtoMessage() {} - -func (x *DisplayPluginElementsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DisplayPluginElementsRequest.ProtoReflect.Descriptor instead. -func (*DisplayPluginElementsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{4} -} - -func (x *DisplayPluginElementsRequest) GetPluginId() string { - if x != nil { - return x.PluginId - } - return "" -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type DisplayPluginElementsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Display create plugin version element if true. - CreateVersion bool `protobuf:"varint,1,opt,name=create_version,json=createVersion,proto3" json:"create_version,omitempty"` - // Display plugin settings element if true. - Settings bool `protobuf:"varint,2,opt,name=settings,proto3" json:"settings,omitempty"` - // Display delete plugin element if true. - Delete bool `protobuf:"varint,3,opt,name=delete,proto3" json:"delete,omitempty"` -} - -func (x *DisplayPluginElementsResponse) Reset() { - *x = DisplayPluginElementsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DisplayPluginElementsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DisplayPluginElementsResponse) ProtoMessage() {} - -func (x *DisplayPluginElementsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DisplayPluginElementsResponse.ProtoReflect.Descriptor instead. -func (*DisplayPluginElementsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{5} -} - -func (x *DisplayPluginElementsResponse) GetCreateVersion() bool { - if x != nil { - return x.CreateVersion - } - return false -} - -func (x *DisplayPluginElementsResponse) GetSettings() bool { - if x != nil { - return x.Settings - } - return false -} - -func (x *DisplayPluginElementsResponse) GetDelete() bool { - if x != nil { - return x.Delete - } - return false -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type DisplayTemplateElementsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ID of the template for which to check - // which elements should be displayed. - TemplateId string `protobuf:"bytes,1,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` -} - -func (x *DisplayTemplateElementsRequest) Reset() { - *x = DisplayTemplateElementsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DisplayTemplateElementsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DisplayTemplateElementsRequest) ProtoMessage() {} - -func (x *DisplayTemplateElementsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DisplayTemplateElementsRequest.ProtoReflect.Descriptor instead. -func (*DisplayTemplateElementsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{6} -} - -func (x *DisplayTemplateElementsRequest) GetTemplateId() string { - if x != nil { - return x.TemplateId - } - return "" -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type DisplayTemplateElementsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Display create template version element if true. - CreateVersion bool `protobuf:"varint,1,opt,name=create_version,json=createVersion,proto3" json:"create_version,omitempty"` - // Display template settings element if true. - Settings bool `protobuf:"varint,2,opt,name=settings,proto3" json:"settings,omitempty"` - // Display delete template element if true. - Delete bool `protobuf:"varint,3,opt,name=delete,proto3" json:"delete,omitempty"` -} - -func (x *DisplayTemplateElementsResponse) Reset() { - *x = DisplayTemplateElementsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DisplayTemplateElementsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DisplayTemplateElementsResponse) ProtoMessage() {} - -func (x *DisplayTemplateElementsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DisplayTemplateElementsResponse.ProtoReflect.Descriptor instead. -func (*DisplayTemplateElementsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{7} -} - -func (x *DisplayTemplateElementsResponse) GetCreateVersion() bool { - if x != nil { - return x.CreateVersion - } - return false -} - -func (x *DisplayTemplateElementsResponse) GetSettings() bool { - if x != nil { - return x.Settings - } - return false -} - -func (x *DisplayTemplateElementsResponse) GetDelete() bool { - if x != nil { - return x.Delete - } - return false -} - type DisplayUserElementsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -540,7 +306,7 @@ type DisplayUserElementsRequest struct { func (x *DisplayUserElementsRequest) Reset() { *x = DisplayUserElementsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[8] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -553,7 +319,7 @@ func (x *DisplayUserElementsRequest) String() string { func (*DisplayUserElementsRequest) ProtoMessage() {} func (x *DisplayUserElementsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[8] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -566,7 +332,7 @@ func (x *DisplayUserElementsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DisplayUserElementsRequest.ProtoReflect.Descriptor instead. func (*DisplayUserElementsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{8} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{4} } type DisplayUserElementsResponse struct { @@ -581,7 +347,7 @@ type DisplayUserElementsResponse struct { func (x *DisplayUserElementsResponse) Reset() { *x = DisplayUserElementsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[9] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -594,7 +360,7 @@ func (x *DisplayUserElementsResponse) String() string { func (*DisplayUserElementsResponse) ProtoMessage() {} func (x *DisplayUserElementsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[9] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -607,7 +373,7 @@ func (x *DisplayUserElementsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DisplayUserElementsResponse.ProtoReflect.Descriptor instead. func (*DisplayUserElementsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{9} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{5} } func (x *DisplayUserElementsResponse) GetDelete() bool { @@ -626,7 +392,7 @@ type DisplayServerElementsRequest struct { func (x *DisplayServerElementsRequest) Reset() { *x = DisplayServerElementsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[10] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -639,7 +405,7 @@ func (x *DisplayServerElementsRequest) String() string { func (*DisplayServerElementsRequest) ProtoMessage() {} func (x *DisplayServerElementsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[10] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -652,7 +418,7 @@ func (x *DisplayServerElementsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DisplayServerElementsRequest.ProtoReflect.Descriptor instead. func (*DisplayServerElementsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{10} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{6} } type DisplayServerElementsResponse struct { @@ -667,7 +433,7 @@ type DisplayServerElementsResponse struct { func (x *DisplayServerElementsResponse) Reset() { *x = DisplayServerElementsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[11] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -680,7 +446,7 @@ func (x *DisplayServerElementsResponse) String() string { func (*DisplayServerElementsResponse) ProtoMessage() {} func (x *DisplayServerElementsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[11] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -693,7 +459,7 @@ func (x *DisplayServerElementsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DisplayServerElementsResponse.ProtoReflect.Descriptor instead. func (*DisplayServerElementsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{11} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{7} } func (x *DisplayServerElementsResponse) GetAdminPanel() bool { @@ -716,7 +482,7 @@ type DisplayOwnerEntitledElementsRequest struct { func (x *DisplayOwnerEntitledElementsRequest) Reset() { *x = DisplayOwnerEntitledElementsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[12] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -729,7 +495,7 @@ func (x *DisplayOwnerEntitledElementsRequest) String() string { func (*DisplayOwnerEntitledElementsRequest) ProtoMessage() {} func (x *DisplayOwnerEntitledElementsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[12] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -742,7 +508,7 @@ func (x *DisplayOwnerEntitledElementsRequest) ProtoReflect() protoreflect.Messag // Deprecated: Use DisplayOwnerEntitledElementsRequest.ProtoReflect.Descriptor instead. func (*DisplayOwnerEntitledElementsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{12} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{8} } func (x *DisplayOwnerEntitledElementsRequest) GetOwnerName() string { @@ -764,7 +530,7 @@ type DisplayOwnerEntitledElementsResponse struct { func (x *DisplayOwnerEntitledElementsResponse) Reset() { *x = DisplayOwnerEntitledElementsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[13] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -777,7 +543,7 @@ func (x *DisplayOwnerEntitledElementsResponse) String() string { func (*DisplayOwnerEntitledElementsResponse) ProtoMessage() {} func (x *DisplayOwnerEntitledElementsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[13] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -790,7 +556,7 @@ func (x *DisplayOwnerEntitledElementsResponse) ProtoReflect() protoreflect.Messa // Deprecated: Use DisplayOwnerEntitledElementsResponse.ProtoReflect.Descriptor instead. func (*DisplayOwnerEntitledElementsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{13} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{9} } func (x *DisplayOwnerEntitledElementsResponse) GetCreatePrivateRepository() bool { @@ -813,7 +579,7 @@ type DisplayRepositoryEntitledElementsRequest struct { func (x *DisplayRepositoryEntitledElementsRequest) Reset() { *x = DisplayRepositoryEntitledElementsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[14] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -826,7 +592,7 @@ func (x *DisplayRepositoryEntitledElementsRequest) String() string { func (*DisplayRepositoryEntitledElementsRequest) ProtoMessage() {} func (x *DisplayRepositoryEntitledElementsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[14] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -839,7 +605,7 @@ func (x *DisplayRepositoryEntitledElementsRequest) ProtoReflect() protoreflect.M // Deprecated: Use DisplayRepositoryEntitledElementsRequest.ProtoReflect.Descriptor instead. func (*DisplayRepositoryEntitledElementsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{14} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{10} } func (x *DisplayRepositoryEntitledElementsRequest) GetRepositoryId() string { @@ -861,7 +627,7 @@ type DisplayRepositoryEntitledElementsResponse struct { func (x *DisplayRepositoryEntitledElementsResponse) Reset() { *x = DisplayRepositoryEntitledElementsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[15] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -874,7 +640,7 @@ func (x *DisplayRepositoryEntitledElementsResponse) String() string { func (*DisplayRepositoryEntitledElementsResponse) ProtoMessage() {} func (x *DisplayRepositoryEntitledElementsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[15] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -887,7 +653,7 @@ func (x *DisplayRepositoryEntitledElementsResponse) ProtoReflect() protoreflect. // Deprecated: Use DisplayRepositoryEntitledElementsResponse.ProtoReflect.Descriptor instead. func (*DisplayRepositoryEntitledElementsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{15} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{11} } func (x *DisplayRepositoryEntitledElementsResponse) GetSetPrivate() bool { @@ -910,7 +676,7 @@ type ListManageableRepositoryRolesRequest struct { func (x *ListManageableRepositoryRolesRequest) Reset() { *x = ListManageableRepositoryRolesRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[16] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -923,7 +689,7 @@ func (x *ListManageableRepositoryRolesRequest) String() string { func (*ListManageableRepositoryRolesRequest) ProtoMessage() {} func (x *ListManageableRepositoryRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[16] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -936,7 +702,7 @@ func (x *ListManageableRepositoryRolesRequest) ProtoReflect() protoreflect.Messa // Deprecated: Use ListManageableRepositoryRolesRequest.ProtoReflect.Descriptor instead. func (*ListManageableRepositoryRolesRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{16} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{12} } func (x *ListManageableRepositoryRolesRequest) GetRepositoryId() string { @@ -959,7 +725,7 @@ type ListManageableRepositoryRolesResponse struct { func (x *ListManageableRepositoryRolesResponse) Reset() { *x = ListManageableRepositoryRolesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[17] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -972,7 +738,7 @@ func (x *ListManageableRepositoryRolesResponse) String() string { func (*ListManageableRepositoryRolesResponse) ProtoMessage() {} func (x *ListManageableRepositoryRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[17] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -985,7 +751,7 @@ func (x *ListManageableRepositoryRolesResponse) ProtoReflect() protoreflect.Mess // Deprecated: Use ListManageableRepositoryRolesResponse.ProtoReflect.Descriptor instead. func (*ListManageableRepositoryRolesResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{17} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{13} } func (x *ListManageableRepositoryRolesResponse) GetRoles() []RepositoryRole { @@ -1011,7 +777,7 @@ type ListManageableUserRepositoryRolesRequest struct { func (x *ListManageableUserRepositoryRolesRequest) Reset() { *x = ListManageableUserRepositoryRolesRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[18] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1024,7 +790,7 @@ func (x *ListManageableUserRepositoryRolesRequest) String() string { func (*ListManageableUserRepositoryRolesRequest) ProtoMessage() {} func (x *ListManageableUserRepositoryRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[18] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1037,7 +803,7 @@ func (x *ListManageableUserRepositoryRolesRequest) ProtoReflect() protoreflect.M // Deprecated: Use ListManageableUserRepositoryRolesRequest.ProtoReflect.Descriptor instead. func (*ListManageableUserRepositoryRolesRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{18} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{14} } func (x *ListManageableUserRepositoryRolesRequest) GetRepositoryId() string { @@ -1067,7 +833,7 @@ type ListManageableUserRepositoryRolesResponse struct { func (x *ListManageableUserRepositoryRolesResponse) Reset() { *x = ListManageableUserRepositoryRolesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[19] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1080,7 +846,7 @@ func (x *ListManageableUserRepositoryRolesResponse) String() string { func (*ListManageableUserRepositoryRolesResponse) ProtoMessage() {} func (x *ListManageableUserRepositoryRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[19] + mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1093,7 +859,7 @@ func (x *ListManageableUserRepositoryRolesResponse) ProtoReflect() protoreflect. // Deprecated: Use ListManageableUserRepositoryRolesResponse.ProtoReflect.Descriptor instead. func (*ListManageableUserRepositoryRolesResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{19} + return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{15} } func (x *ListManageableUserRepositoryRolesResponse) GetRoles() []RepositoryRole { @@ -1103,427 +869,7 @@ func (x *ListManageableUserRepositoryRolesResponse) GetRoles() []RepositoryRole return nil } -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type ListManageablePluginRolesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ID of the plugin for which to check - // which roles should be displayed as manageable. - PluginId string `protobuf:"bytes,1,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` -} - -func (x *ListManageablePluginRolesRequest) Reset() { - *x = ListManageablePluginRolesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListManageablePluginRolesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListManageablePluginRolesRequest) ProtoMessage() {} - -func (x *ListManageablePluginRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[20] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListManageablePluginRolesRequest.ProtoReflect.Descriptor instead. -func (*ListManageablePluginRolesRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{20} -} - -func (x *ListManageablePluginRolesRequest) GetPluginId() string { - if x != nil { - return x.PluginId - } - return "" -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type ListManageablePluginRolesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The list of roles that should be displayed - // to the user as manageable. - Roles []PluginRole `protobuf:"varint,1,rep,packed,name=roles,proto3,enum=buf.alpha.registry.v1alpha1.PluginRole" json:"roles,omitempty"` -} - -func (x *ListManageablePluginRolesResponse) Reset() { - *x = ListManageablePluginRolesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListManageablePluginRolesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListManageablePluginRolesResponse) ProtoMessage() {} - -func (x *ListManageablePluginRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[21] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListManageablePluginRolesResponse.ProtoReflect.Descriptor instead. -func (*ListManageablePluginRolesResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{21} -} - -func (x *ListManageablePluginRolesResponse) GetRoles() []PluginRole { - if x != nil { - return x.Roles - } - return nil -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type ListManageableUserPluginRolesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ID of the plugin for which to check - // which roles should be displayed as manageable. - PluginId string `protobuf:"bytes,1,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` - // The ID of the target user for which to check - // which roles are manageable. - UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` -} - -func (x *ListManageableUserPluginRolesRequest) Reset() { - *x = ListManageableUserPluginRolesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListManageableUserPluginRolesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListManageableUserPluginRolesRequest) ProtoMessage() {} - -func (x *ListManageableUserPluginRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[22] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListManageableUserPluginRolesRequest.ProtoReflect.Descriptor instead. -func (*ListManageableUserPluginRolesRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{22} -} - -func (x *ListManageableUserPluginRolesRequest) GetPluginId() string { - if x != nil { - return x.PluginId - } - return "" -} - -func (x *ListManageableUserPluginRolesRequest) GetUserId() string { - if x != nil { - return x.UserId - } - return "" -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type ListManageableUserPluginRolesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The list of roles that should be displayed - // to the user as manageable. - Roles []PluginRole `protobuf:"varint,1,rep,packed,name=roles,proto3,enum=buf.alpha.registry.v1alpha1.PluginRole" json:"roles,omitempty"` -} - -func (x *ListManageableUserPluginRolesResponse) Reset() { - *x = ListManageableUserPluginRolesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListManageableUserPluginRolesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListManageableUserPluginRolesResponse) ProtoMessage() {} - -func (x *ListManageableUserPluginRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[23] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListManageableUserPluginRolesResponse.ProtoReflect.Descriptor instead. -func (*ListManageableUserPluginRolesResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{23} -} - -func (x *ListManageableUserPluginRolesResponse) GetRoles() []PluginRole { - if x != nil { - return x.Roles - } - return nil -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type ListManageableTemplateRolesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ID of the template for which to check - // which roles should be displayed as manageable. - TemplateId string `protobuf:"bytes,1,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` -} - -func (x *ListManageableTemplateRolesRequest) Reset() { - *x = ListManageableTemplateRolesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListManageableTemplateRolesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListManageableTemplateRolesRequest) ProtoMessage() {} - -func (x *ListManageableTemplateRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[24] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListManageableTemplateRolesRequest.ProtoReflect.Descriptor instead. -func (*ListManageableTemplateRolesRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{24} -} - -func (x *ListManageableTemplateRolesRequest) GetTemplateId() string { - if x != nil { - return x.TemplateId - } - return "" -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type ListManageableTemplateRolesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The list of roles that should be displayed - // to the user as manageable. - Roles []TemplateRole `protobuf:"varint,1,rep,packed,name=roles,proto3,enum=buf.alpha.registry.v1alpha1.TemplateRole" json:"roles,omitempty"` -} - -func (x *ListManageableTemplateRolesResponse) Reset() { - *x = ListManageableTemplateRolesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListManageableTemplateRolesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListManageableTemplateRolesResponse) ProtoMessage() {} - -func (x *ListManageableTemplateRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[25] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListManageableTemplateRolesResponse.ProtoReflect.Descriptor instead. -func (*ListManageableTemplateRolesResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{25} -} - -func (x *ListManageableTemplateRolesResponse) GetRoles() []TemplateRole { - if x != nil { - return x.Roles - } - return nil -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type ListManageableUserTemplateRolesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ID of the template for which to check - // which roles should be displayed as manageable. - TemplateId string `protobuf:"bytes,1,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` - // The ID of the target user for which to check - // which roles are manageable. - UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` -} - -func (x *ListManageableUserTemplateRolesRequest) Reset() { - *x = ListManageableUserTemplateRolesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[26] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListManageableUserTemplateRolesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListManageableUserTemplateRolesRequest) ProtoMessage() {} - -func (x *ListManageableUserTemplateRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[26] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListManageableUserTemplateRolesRequest.ProtoReflect.Descriptor instead. -func (*ListManageableUserTemplateRolesRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{26} -} - -func (x *ListManageableUserTemplateRolesRequest) GetTemplateId() string { - if x != nil { - return x.TemplateId - } - return "" -} - -func (x *ListManageableUserTemplateRolesRequest) GetUserId() string { - if x != nil { - return x.UserId - } - return "" -} - -// Deprecated: Marked as deprecated in buf/alpha/registry/v1alpha1/display.proto. -type ListManageableUserTemplateRolesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The list of roles that should be displayed - // to the user as manageable. - Roles []TemplateRole `protobuf:"varint,1,rep,packed,name=roles,proto3,enum=buf.alpha.registry.v1alpha1.TemplateRole" json:"roles,omitempty"` -} - -func (x *ListManageableUserTemplateRolesResponse) Reset() { - *x = ListManageableUserTemplateRolesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[27] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListManageableUserTemplateRolesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListManageableUserTemplateRolesResponse) ProtoMessage() {} - -func (x *ListManageableUserTemplateRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[27] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListManageableUserTemplateRolesResponse.ProtoReflect.Descriptor instead. -func (*ListManageableUserTemplateRolesResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP(), []int{27} -} - -func (x *ListManageableUserTemplateRolesResponse) GetRoles() []TemplateRole { - if x != nil { - return x.Roles - } - return nil -} - -var File_buf_alpha_registry_v1alpha1_display_proto protoreflect.FileDescriptor +var File_buf_alpha_registry_v1alpha1_display_proto protoreflect.FileDescriptor var file_buf_alpha_registry_v1alpha1_display_proto_rawDesc = []byte{ 0x0a, 0x29, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, @@ -1566,303 +912,167 @@ var file_buf_alpha_registry_v1alpha1_display_proto_rawDesc = []byte{ 0x73, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x72, 0x69, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x77, 0x72, 0x69, 0x74, 0x65, 0x22, - 0x3f, 0x0a, 0x1c, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1b, 0x0a, 0x09, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x3a, 0x02, 0x18, 0x01, - 0x22, 0x7e, 0x0a, 0x1d, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x3a, 0x02, 0x18, 0x01, - 0x22, 0x45, 0x0a, 0x1e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x54, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, - 0x65, 0x49, 0x64, 0x3a, 0x02, 0x18, 0x01, 0x22, 0x80, 0x01, 0x0a, 0x1f, 0x44, 0x69, 0x73, 0x70, - 0x6c, 0x61, 0x79, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x45, 0x6c, 0x65, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x0d, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16, - 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, - 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x3a, 0x02, 0x18, 0x01, 0x22, 0x1c, 0x0a, 0x1a, 0x44, 0x69, - 0x73, 0x70, 0x6c, 0x61, 0x79, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x35, 0x0a, 0x1b, 0x44, 0x69, 0x73, 0x70, - 0x6c, 0x61, 0x79, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x22, - 0x1e, 0x0a, 0x1c, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, - 0x40, 0x0a, 0x1d, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x5f, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x50, 0x61, 0x6e, 0x65, - 0x6c, 0x22, 0x44, 0x0a, 0x23, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4f, 0x77, 0x6e, 0x65, - 0x72, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6f, 0x77, 0x6e, 0x65, - 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x77, - 0x6e, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x62, 0x0a, 0x24, 0x44, 0x69, 0x73, 0x70, 0x6c, - 0x61, 0x79, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, - 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x3a, 0x0a, 0x19, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, - 0x65, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x17, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, - 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x4f, 0x0a, 0x28, 0x44, - 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, - 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x1c, 0x0a, 0x1a, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6c, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x35, 0x0a, + 0x1b, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x64, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x22, 0x1e, 0x0a, 0x1c, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x40, 0x0a, 0x1d, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x5f, 0x70, + 0x61, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x61, 0x64, 0x6d, 0x69, + 0x6e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x22, 0x44, 0x0a, 0x23, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, + 0x79, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, + 0x0a, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x62, 0x0a, 0x24, + 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x69, + 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x19, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x70, + 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x17, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, + 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x22, 0x4f, 0x0a, 0x28, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, + 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x49, + 0x64, 0x22, 0x4c, 0x0a, 0x29, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, + 0x0a, 0x0b, 0x73, 0x65, 0x74, 0x5f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x65, 0x74, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x22, + 0x4b, 0x0a, 0x24, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, + 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x22, 0x4c, 0x0a, 0x29, - 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, - 0x79, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x74, - 0x5f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, - 0x73, 0x65, 0x74, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x22, 0x4b, 0x0a, 0x24, 0x4c, 0x69, - 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x22, 0x6a, 0x0a, 0x25, 0x4c, 0x69, 0x73, 0x74, 0x4d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x41, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, - 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, - 0x6c, 0x65, 0x73, 0x22, 0x68, 0x0a, 0x28, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, - 0x72, 0x79, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x6e, 0x0a, - 0x29, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, - 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x05, 0x72, 0x6f, - 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, - 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, 0x43, 0x0a, - 0x20, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x3a, 0x02, - 0x18, 0x01, 0x22, 0x66, 0x0a, 0x21, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x52, - 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x3a, 0x02, 0x18, 0x01, 0x22, 0x60, 0x0a, 0x24, 0x4c, 0x69, - 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x12, - 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x3a, 0x02, 0x18, 0x01, 0x22, 0x6a, 0x0a, 0x25, - 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, - 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x22, 0x6a, 0x0a, 0x25, + 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, - 0x6f, 0x6c, 0x65, 0x73, 0x3a, 0x02, 0x18, 0x01, 0x22, 0x49, 0x0a, 0x22, 0x4c, 0x69, 0x73, 0x74, - 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, - 0x0a, 0x0b, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x64, 0x3a, - 0x02, 0x18, 0x01, 0x22, 0x6a, 0x0a, 0x23, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, - 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x05, 0x72, 0x6f, - 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x3a, 0x02, 0x18, 0x01, 0x22, - 0x66, 0x0a, 0x26, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, - 0x65, 0x55, 0x73, 0x65, 0x72, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, - 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, - 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x3a, 0x02, 0x18, 0x01, 0x22, 0x6e, 0x0a, 0x27, 0x4c, 0x69, 0x73, 0x74, 0x4d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x54, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0e, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, - 0x6c, 0x65, 0x73, 0x3a, 0x02, 0x18, 0x01, 0x32, 0xbd, 0x12, 0x0a, 0x0e, 0x44, 0x69, 0x73, 0x70, - 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa5, 0x01, 0x0a, 0x1b, 0x44, - 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3f, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, - 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6c, 0x65, 0x6d, - 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x40, 0x2e, 0x62, 0x75, + 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, + 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, 0x68, 0x0a, 0x28, 0x4c, 0x69, 0x73, 0x74, + 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, + 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, + 0x49, 0x64, 0x22, 0x6e, 0x0a, 0x29, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, + 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x41, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x2b, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, + 0x65, 0x73, 0x32, 0xcd, 0x0a, 0x0a, 0x0e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa5, 0x01, 0x0a, 0x1b, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, + 0x79, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6c, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4f, 0x72, 0x67, 0x61, 0x6e, + 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x40, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x9f, 0x01, + 0x0a, 0x19, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, - 0x79, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6c, 0x65, - 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, - 0x02, 0x01, 0x12, 0x9f, 0x01, 0x0a, 0x19, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, - 0x12, 0x3d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x79, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x45, 0x6c, 0x65, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3e, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, + 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, + 0x8d, 0x01, 0x0a, 0x13, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x55, 0x73, 0x65, 0x72, 0x45, + 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x55, 0x73, 0x65, + 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, - 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, - 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, - 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x45, - 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x03, 0x90, 0x02, 0x01, 0x12, 0x96, 0x01, 0x0a, 0x15, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x39, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, - 0x70, 0x6c, 0x61, 0x79, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, + 0x93, 0x01, 0x0a, 0x15, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0x9c, 0x01, - 0x0a, 0x17, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, - 0x65, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x54, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x54, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0x8d, 0x01, 0x0a, - 0x13, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, - 0x65, 0x6e, 0x74, 0x73, 0x12, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6c, - 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, - 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, - 0x6c, 0x61, 0x79, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x93, 0x01, 0x0a, - 0x15, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x45, 0x6c, - 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xa8, 0x01, 0x0a, 0x1c, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, + 0x79, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x40, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x45, 0x6c, 0x65, - 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, - 0x02, 0x01, 0x12, 0xa8, 0x01, 0x0a, 0x1c, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4f, 0x77, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4f, 0x77, 0x6e, 0x65, + 0x72, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x12, 0x40, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x45, 0x6e, - 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4f, 0x77, 0x6e, 0x65, 0x72, - 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xb7, 0x01, - 0x0a, 0x21, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x12, 0x45, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x46, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, - 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, - 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xab, 0x01, 0x0a, 0x1d, 0x4c, 0x69, 0x73, 0x74, - 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x41, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, - 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x42, 0x2e, 0x62, - 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xb7, 0x01, 0x0a, 0x21, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x45, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x46, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, - 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, - 0xa2, 0x01, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, - 0x6c, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x3d, 0x2e, + 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, + 0x12, 0xb7, 0x01, 0x0a, 0x21, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x45, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x46, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3e, 0x2e, 0x62, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, + 0x6c, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x45, 0x6e, 0x74, + 0x69, 0x74, 0x6c, 0x65, 0x64, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xab, 0x01, 0x0a, 0x1d, 0x4c, + 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x41, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, - 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, - 0x01, 0x90, 0x02, 0x01, 0x12, 0xae, 0x01, 0x0a, 0x1d, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x41, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, - 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, - 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x42, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, - 0x02, 0x01, 0x90, 0x02, 0x01, 0x12, 0xa8, 0x01, 0x0a, 0x1b, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x3f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x42, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xb7, 0x01, 0x0a, 0x21, 0x4c, 0x69, 0x73, + 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x45, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x46, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, - 0x6c, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x40, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, - 0x62, 0x6c, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, - 0x12, 0xb4, 0x01, 0x0a, 0x1f, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, - 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, - 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x43, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x61, 0x62, 0x6c, - 0x65, 0x55, 0x73, 0x65, 0x72, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, - 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x44, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x06, 0x88, 0x02, 0x01, 0x90, 0x02, 0x01, 0x42, 0x99, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, - 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0c, 0x44, 0x69, 0x73, - 0x70, 0x6c, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, - 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, - 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, - 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, - 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, - 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, - 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, + 0x02, 0x01, 0x42, 0x99, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0c, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, + 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, + 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, + 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1877,80 +1087,50 @@ func file_buf_alpha_registry_v1alpha1_display_proto_rawDescGZIP() []byte { return file_buf_alpha_registry_v1alpha1_display_proto_rawDescData } -var file_buf_alpha_registry_v1alpha1_display_proto_msgTypes = make([]protoimpl.MessageInfo, 28) +var file_buf_alpha_registry_v1alpha1_display_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_buf_alpha_registry_v1alpha1_display_proto_goTypes = []interface{}{ (*DisplayOrganizationElementsRequest)(nil), // 0: buf.alpha.registry.v1alpha1.DisplayOrganizationElementsRequest (*DisplayOrganizationElementsResponse)(nil), // 1: buf.alpha.registry.v1alpha1.DisplayOrganizationElementsResponse (*DisplayRepositoryElementsRequest)(nil), // 2: buf.alpha.registry.v1alpha1.DisplayRepositoryElementsRequest (*DisplayRepositoryElementsResponse)(nil), // 3: buf.alpha.registry.v1alpha1.DisplayRepositoryElementsResponse - (*DisplayPluginElementsRequest)(nil), // 4: buf.alpha.registry.v1alpha1.DisplayPluginElementsRequest - (*DisplayPluginElementsResponse)(nil), // 5: buf.alpha.registry.v1alpha1.DisplayPluginElementsResponse - (*DisplayTemplateElementsRequest)(nil), // 6: buf.alpha.registry.v1alpha1.DisplayTemplateElementsRequest - (*DisplayTemplateElementsResponse)(nil), // 7: buf.alpha.registry.v1alpha1.DisplayTemplateElementsResponse - (*DisplayUserElementsRequest)(nil), // 8: buf.alpha.registry.v1alpha1.DisplayUserElementsRequest - (*DisplayUserElementsResponse)(nil), // 9: buf.alpha.registry.v1alpha1.DisplayUserElementsResponse - (*DisplayServerElementsRequest)(nil), // 10: buf.alpha.registry.v1alpha1.DisplayServerElementsRequest - (*DisplayServerElementsResponse)(nil), // 11: buf.alpha.registry.v1alpha1.DisplayServerElementsResponse - (*DisplayOwnerEntitledElementsRequest)(nil), // 12: buf.alpha.registry.v1alpha1.DisplayOwnerEntitledElementsRequest - (*DisplayOwnerEntitledElementsResponse)(nil), // 13: buf.alpha.registry.v1alpha1.DisplayOwnerEntitledElementsResponse - (*DisplayRepositoryEntitledElementsRequest)(nil), // 14: buf.alpha.registry.v1alpha1.DisplayRepositoryEntitledElementsRequest - (*DisplayRepositoryEntitledElementsResponse)(nil), // 15: buf.alpha.registry.v1alpha1.DisplayRepositoryEntitledElementsResponse - (*ListManageableRepositoryRolesRequest)(nil), // 16: buf.alpha.registry.v1alpha1.ListManageableRepositoryRolesRequest - (*ListManageableRepositoryRolesResponse)(nil), // 17: buf.alpha.registry.v1alpha1.ListManageableRepositoryRolesResponse - (*ListManageableUserRepositoryRolesRequest)(nil), // 18: buf.alpha.registry.v1alpha1.ListManageableUserRepositoryRolesRequest - (*ListManageableUserRepositoryRolesResponse)(nil), // 19: buf.alpha.registry.v1alpha1.ListManageableUserRepositoryRolesResponse - (*ListManageablePluginRolesRequest)(nil), // 20: buf.alpha.registry.v1alpha1.ListManageablePluginRolesRequest - (*ListManageablePluginRolesResponse)(nil), // 21: buf.alpha.registry.v1alpha1.ListManageablePluginRolesResponse - (*ListManageableUserPluginRolesRequest)(nil), // 22: buf.alpha.registry.v1alpha1.ListManageableUserPluginRolesRequest - (*ListManageableUserPluginRolesResponse)(nil), // 23: buf.alpha.registry.v1alpha1.ListManageableUserPluginRolesResponse - (*ListManageableTemplateRolesRequest)(nil), // 24: buf.alpha.registry.v1alpha1.ListManageableTemplateRolesRequest - (*ListManageableTemplateRolesResponse)(nil), // 25: buf.alpha.registry.v1alpha1.ListManageableTemplateRolesResponse - (*ListManageableUserTemplateRolesRequest)(nil), // 26: buf.alpha.registry.v1alpha1.ListManageableUserTemplateRolesRequest - (*ListManageableUserTemplateRolesResponse)(nil), // 27: buf.alpha.registry.v1alpha1.ListManageableUserTemplateRolesResponse - (RepositoryRole)(0), // 28: buf.alpha.registry.v1alpha1.RepositoryRole - (PluginRole)(0), // 29: buf.alpha.registry.v1alpha1.PluginRole - (TemplateRole)(0), // 30: buf.alpha.registry.v1alpha1.TemplateRole + (*DisplayUserElementsRequest)(nil), // 4: buf.alpha.registry.v1alpha1.DisplayUserElementsRequest + (*DisplayUserElementsResponse)(nil), // 5: buf.alpha.registry.v1alpha1.DisplayUserElementsResponse + (*DisplayServerElementsRequest)(nil), // 6: buf.alpha.registry.v1alpha1.DisplayServerElementsRequest + (*DisplayServerElementsResponse)(nil), // 7: buf.alpha.registry.v1alpha1.DisplayServerElementsResponse + (*DisplayOwnerEntitledElementsRequest)(nil), // 8: buf.alpha.registry.v1alpha1.DisplayOwnerEntitledElementsRequest + (*DisplayOwnerEntitledElementsResponse)(nil), // 9: buf.alpha.registry.v1alpha1.DisplayOwnerEntitledElementsResponse + (*DisplayRepositoryEntitledElementsRequest)(nil), // 10: buf.alpha.registry.v1alpha1.DisplayRepositoryEntitledElementsRequest + (*DisplayRepositoryEntitledElementsResponse)(nil), // 11: buf.alpha.registry.v1alpha1.DisplayRepositoryEntitledElementsResponse + (*ListManageableRepositoryRolesRequest)(nil), // 12: buf.alpha.registry.v1alpha1.ListManageableRepositoryRolesRequest + (*ListManageableRepositoryRolesResponse)(nil), // 13: buf.alpha.registry.v1alpha1.ListManageableRepositoryRolesResponse + (*ListManageableUserRepositoryRolesRequest)(nil), // 14: buf.alpha.registry.v1alpha1.ListManageableUserRepositoryRolesRequest + (*ListManageableUserRepositoryRolesResponse)(nil), // 15: buf.alpha.registry.v1alpha1.ListManageableUserRepositoryRolesResponse + (RepositoryRole)(0), // 16: buf.alpha.registry.v1alpha1.RepositoryRole } var file_buf_alpha_registry_v1alpha1_display_proto_depIdxs = []int32{ - 28, // 0: buf.alpha.registry.v1alpha1.ListManageableRepositoryRolesResponse.roles:type_name -> buf.alpha.registry.v1alpha1.RepositoryRole - 28, // 1: buf.alpha.registry.v1alpha1.ListManageableUserRepositoryRolesResponse.roles:type_name -> buf.alpha.registry.v1alpha1.RepositoryRole - 29, // 2: buf.alpha.registry.v1alpha1.ListManageablePluginRolesResponse.roles:type_name -> buf.alpha.registry.v1alpha1.PluginRole - 29, // 3: buf.alpha.registry.v1alpha1.ListManageableUserPluginRolesResponse.roles:type_name -> buf.alpha.registry.v1alpha1.PluginRole - 30, // 4: buf.alpha.registry.v1alpha1.ListManageableTemplateRolesResponse.roles:type_name -> buf.alpha.registry.v1alpha1.TemplateRole - 30, // 5: buf.alpha.registry.v1alpha1.ListManageableUserTemplateRolesResponse.roles:type_name -> buf.alpha.registry.v1alpha1.TemplateRole - 0, // 6: buf.alpha.registry.v1alpha1.DisplayService.DisplayOrganizationElements:input_type -> buf.alpha.registry.v1alpha1.DisplayOrganizationElementsRequest - 2, // 7: buf.alpha.registry.v1alpha1.DisplayService.DisplayRepositoryElements:input_type -> buf.alpha.registry.v1alpha1.DisplayRepositoryElementsRequest - 4, // 8: buf.alpha.registry.v1alpha1.DisplayService.DisplayPluginElements:input_type -> buf.alpha.registry.v1alpha1.DisplayPluginElementsRequest - 6, // 9: buf.alpha.registry.v1alpha1.DisplayService.DisplayTemplateElements:input_type -> buf.alpha.registry.v1alpha1.DisplayTemplateElementsRequest - 8, // 10: buf.alpha.registry.v1alpha1.DisplayService.DisplayUserElements:input_type -> buf.alpha.registry.v1alpha1.DisplayUserElementsRequest - 10, // 11: buf.alpha.registry.v1alpha1.DisplayService.DisplayServerElements:input_type -> buf.alpha.registry.v1alpha1.DisplayServerElementsRequest - 12, // 12: buf.alpha.registry.v1alpha1.DisplayService.DisplayOwnerEntitledElements:input_type -> buf.alpha.registry.v1alpha1.DisplayOwnerEntitledElementsRequest - 14, // 13: buf.alpha.registry.v1alpha1.DisplayService.DisplayRepositoryEntitledElements:input_type -> buf.alpha.registry.v1alpha1.DisplayRepositoryEntitledElementsRequest - 16, // 14: buf.alpha.registry.v1alpha1.DisplayService.ListManageableRepositoryRoles:input_type -> buf.alpha.registry.v1alpha1.ListManageableRepositoryRolesRequest - 18, // 15: buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserRepositoryRoles:input_type -> buf.alpha.registry.v1alpha1.ListManageableUserRepositoryRolesRequest - 20, // 16: buf.alpha.registry.v1alpha1.DisplayService.ListManageablePluginRoles:input_type -> buf.alpha.registry.v1alpha1.ListManageablePluginRolesRequest - 22, // 17: buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserPluginRoles:input_type -> buf.alpha.registry.v1alpha1.ListManageableUserPluginRolesRequest - 24, // 18: buf.alpha.registry.v1alpha1.DisplayService.ListManageableTemplateRoles:input_type -> buf.alpha.registry.v1alpha1.ListManageableTemplateRolesRequest - 26, // 19: buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserTemplateRoles:input_type -> buf.alpha.registry.v1alpha1.ListManageableUserTemplateRolesRequest - 1, // 20: buf.alpha.registry.v1alpha1.DisplayService.DisplayOrganizationElements:output_type -> buf.alpha.registry.v1alpha1.DisplayOrganizationElementsResponse - 3, // 21: buf.alpha.registry.v1alpha1.DisplayService.DisplayRepositoryElements:output_type -> buf.alpha.registry.v1alpha1.DisplayRepositoryElementsResponse - 5, // 22: buf.alpha.registry.v1alpha1.DisplayService.DisplayPluginElements:output_type -> buf.alpha.registry.v1alpha1.DisplayPluginElementsResponse - 7, // 23: buf.alpha.registry.v1alpha1.DisplayService.DisplayTemplateElements:output_type -> buf.alpha.registry.v1alpha1.DisplayTemplateElementsResponse - 9, // 24: buf.alpha.registry.v1alpha1.DisplayService.DisplayUserElements:output_type -> buf.alpha.registry.v1alpha1.DisplayUserElementsResponse - 11, // 25: buf.alpha.registry.v1alpha1.DisplayService.DisplayServerElements:output_type -> buf.alpha.registry.v1alpha1.DisplayServerElementsResponse - 13, // 26: buf.alpha.registry.v1alpha1.DisplayService.DisplayOwnerEntitledElements:output_type -> buf.alpha.registry.v1alpha1.DisplayOwnerEntitledElementsResponse - 15, // 27: buf.alpha.registry.v1alpha1.DisplayService.DisplayRepositoryEntitledElements:output_type -> buf.alpha.registry.v1alpha1.DisplayRepositoryEntitledElementsResponse - 17, // 28: buf.alpha.registry.v1alpha1.DisplayService.ListManageableRepositoryRoles:output_type -> buf.alpha.registry.v1alpha1.ListManageableRepositoryRolesResponse - 19, // 29: buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserRepositoryRoles:output_type -> buf.alpha.registry.v1alpha1.ListManageableUserRepositoryRolesResponse - 21, // 30: buf.alpha.registry.v1alpha1.DisplayService.ListManageablePluginRoles:output_type -> buf.alpha.registry.v1alpha1.ListManageablePluginRolesResponse - 23, // 31: buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserPluginRoles:output_type -> buf.alpha.registry.v1alpha1.ListManageableUserPluginRolesResponse - 25, // 32: buf.alpha.registry.v1alpha1.DisplayService.ListManageableTemplateRoles:output_type -> buf.alpha.registry.v1alpha1.ListManageableTemplateRolesResponse - 27, // 33: buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserTemplateRoles:output_type -> buf.alpha.registry.v1alpha1.ListManageableUserTemplateRolesResponse - 20, // [20:34] is the sub-list for method output_type - 6, // [6:20] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 16, // 0: buf.alpha.registry.v1alpha1.ListManageableRepositoryRolesResponse.roles:type_name -> buf.alpha.registry.v1alpha1.RepositoryRole + 16, // 1: buf.alpha.registry.v1alpha1.ListManageableUserRepositoryRolesResponse.roles:type_name -> buf.alpha.registry.v1alpha1.RepositoryRole + 0, // 2: buf.alpha.registry.v1alpha1.DisplayService.DisplayOrganizationElements:input_type -> buf.alpha.registry.v1alpha1.DisplayOrganizationElementsRequest + 2, // 3: buf.alpha.registry.v1alpha1.DisplayService.DisplayRepositoryElements:input_type -> buf.alpha.registry.v1alpha1.DisplayRepositoryElementsRequest + 4, // 4: buf.alpha.registry.v1alpha1.DisplayService.DisplayUserElements:input_type -> buf.alpha.registry.v1alpha1.DisplayUserElementsRequest + 6, // 5: buf.alpha.registry.v1alpha1.DisplayService.DisplayServerElements:input_type -> buf.alpha.registry.v1alpha1.DisplayServerElementsRequest + 8, // 6: buf.alpha.registry.v1alpha1.DisplayService.DisplayOwnerEntitledElements:input_type -> buf.alpha.registry.v1alpha1.DisplayOwnerEntitledElementsRequest + 10, // 7: buf.alpha.registry.v1alpha1.DisplayService.DisplayRepositoryEntitledElements:input_type -> buf.alpha.registry.v1alpha1.DisplayRepositoryEntitledElementsRequest + 12, // 8: buf.alpha.registry.v1alpha1.DisplayService.ListManageableRepositoryRoles:input_type -> buf.alpha.registry.v1alpha1.ListManageableRepositoryRolesRequest + 14, // 9: buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserRepositoryRoles:input_type -> buf.alpha.registry.v1alpha1.ListManageableUserRepositoryRolesRequest + 1, // 10: buf.alpha.registry.v1alpha1.DisplayService.DisplayOrganizationElements:output_type -> buf.alpha.registry.v1alpha1.DisplayOrganizationElementsResponse + 3, // 11: buf.alpha.registry.v1alpha1.DisplayService.DisplayRepositoryElements:output_type -> buf.alpha.registry.v1alpha1.DisplayRepositoryElementsResponse + 5, // 12: buf.alpha.registry.v1alpha1.DisplayService.DisplayUserElements:output_type -> buf.alpha.registry.v1alpha1.DisplayUserElementsResponse + 7, // 13: buf.alpha.registry.v1alpha1.DisplayService.DisplayServerElements:output_type -> buf.alpha.registry.v1alpha1.DisplayServerElementsResponse + 9, // 14: buf.alpha.registry.v1alpha1.DisplayService.DisplayOwnerEntitledElements:output_type -> buf.alpha.registry.v1alpha1.DisplayOwnerEntitledElementsResponse + 11, // 15: buf.alpha.registry.v1alpha1.DisplayService.DisplayRepositoryEntitledElements:output_type -> buf.alpha.registry.v1alpha1.DisplayRepositoryEntitledElementsResponse + 13, // 16: buf.alpha.registry.v1alpha1.DisplayService.ListManageableRepositoryRoles:output_type -> buf.alpha.registry.v1alpha1.ListManageableRepositoryRolesResponse + 15, // 17: buf.alpha.registry.v1alpha1.DisplayService.ListManageableUserRepositoryRoles:output_type -> buf.alpha.registry.v1alpha1.ListManageableUserRepositoryRolesResponse + 10, // [10:18] is the sub-list for method output_type + 2, // [2:10] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_buf_alpha_registry_v1alpha1_display_proto_init() } @@ -2009,54 +1189,6 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { } } file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DisplayPluginElementsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DisplayPluginElementsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DisplayTemplateElementsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DisplayTemplateElementsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DisplayUserElementsRequest); i { case 0: return &v.state @@ -2068,7 +1200,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DisplayUserElementsResponse); i { case 0: return &v.state @@ -2080,7 +1212,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DisplayServerElementsRequest); i { case 0: return &v.state @@ -2092,7 +1224,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DisplayServerElementsResponse); i { case 0: return &v.state @@ -2104,7 +1236,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DisplayOwnerEntitledElementsRequest); i { case 0: return &v.state @@ -2116,7 +1248,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DisplayOwnerEntitledElementsResponse); i { case 0: return &v.state @@ -2128,7 +1260,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DisplayRepositoryEntitledElementsRequest); i { case 0: return &v.state @@ -2140,7 +1272,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DisplayRepositoryEntitledElementsResponse); i { case 0: return &v.state @@ -2152,7 +1284,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListManageableRepositoryRolesRequest); i { case 0: return &v.state @@ -2164,7 +1296,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListManageableRepositoryRolesResponse); i { case 0: return &v.state @@ -2176,7 +1308,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListManageableUserRepositoryRolesRequest); i { case 0: return &v.state @@ -2188,7 +1320,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListManageableUserRepositoryRolesResponse); i { case 0: return &v.state @@ -2200,102 +1332,6 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListManageablePluginRolesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListManageablePluginRolesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListManageableUserPluginRolesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListManageableUserPluginRolesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListManageableTemplateRolesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListManageableTemplateRolesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListManageableUserTemplateRolesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_display_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListManageableUserTemplateRolesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -2303,7 +1339,7 @@ func file_buf_alpha_registry_v1alpha1_display_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_alpha_registry_v1alpha1_display_proto_rawDesc, NumEnums: 0, - NumMessages: 28, + NumMessages: 16, NumExtensions: 0, NumServices: 1, }, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/doc.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/doc.pb.go index 64a090891..cc224a611 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/doc.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/doc.pb.go @@ -639,6 +639,11 @@ type ModuleDocumentation struct { // The LICENSE file is a part of the module. // string is used to enforce UTF-8 encoding or 7-bit ASCII text. License string `protobuf:"bytes,4,opt,name=license,proto3" json:"license,omitempty"` + // documentation_path is the path of the file which contains the module documentation. + // + // either `buf.md`, `README.md` or `README.markdown`. + // if empty, assumes buf.md. + DocumentationPath string `protobuf:"bytes,5,opt,name=documentation_path,json=documentationPath,proto3" json:"documentation_path,omitempty"` } func (x *ModuleDocumentation) Reset() { @@ -694,6 +699,13 @@ func (x *ModuleDocumentation) GetLicense() string { return "" } +func (x *ModuleDocumentation) GetDocumentationPath() string { + if x != nil { + return x.DocumentationPath + } + return "" +} + // GetPackageDocumentationRequest takes an owner, repository, reference, and package name. type GetPackageDocumentationRequest struct { state protoimpl.MessageState @@ -2549,14 +2561,17 @@ var file_buf_alpha_registry_v1alpha1_doc_proto_rawDesc = []byte{ 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x6d, 0x6f, 0x64, 0x75, 0x6c, - 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x69, - 0x0a, 0x13, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0d, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x18, 0x0a, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x22, 0x97, 0x01, 0x0a, 0x1e, 0x47, 0x65, + 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x98, + 0x01, 0x0a, 0x13, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x64, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x74, 0x68, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x74, 0x68, 0x22, 0x97, 0x01, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/git_metadata.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/git_metadata.pb.go new file mode 100644 index 000000000..7ad8ba153 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/git_metadata.pb.go @@ -0,0 +1,319 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc (unknown) +// source: buf/alpha/registry/v1alpha1/git_metadata.proto + +package registryv1alpha1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// GitIdentity is a Git user identity, typically either an author or a commiter. +type GitIdentity struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Name is the name of the Git identity. This is not the BSR user's username. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Email is the email of the Git identity. This is not the BSR user's email. + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` + // Time is the time at which this identity was captured. + Time *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=time,proto3" json:"time,omitempty"` +} + +func (x *GitIdentity) Reset() { + *x = GitIdentity{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_git_metadata_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GitIdentity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GitIdentity) ProtoMessage() {} + +func (x *GitIdentity) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_git_metadata_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GitIdentity.ProtoReflect.Descriptor instead. +func (*GitIdentity) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDescGZIP(), []int{0} +} + +func (x *GitIdentity) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *GitIdentity) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *GitIdentity) GetTime() *timestamppb.Timestamp { + if x != nil { + return x.Time + } + return nil +} + +// GitCommitMetadata is Git metadata associated with a BSR commit. +type GitCommitMetadata struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Hash is the SHA1 has of the Git commit. + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + // Author is the author of the Git commit. This is typically an end-user. + Author *GitIdentity `protobuf:"bytes,2,opt,name=author,proto3" json:"author,omitempty"` + // Commiter is the commiter of the Git commit. This typically a CI system. + Commiter *GitIdentity `protobuf:"bytes,3,opt,name=commiter,proto3" json:"commiter,omitempty"` + // Branch is the Git branch to which this Git commit belongs. + Branch string `protobuf:"bytes,4,opt,name=branch,proto3" json:"branch,omitempty"` + // Tags are the Git tags which point to this commit. + Tags []string `protobuf:"bytes,5,rep,name=tags,proto3" json:"tags,omitempty"` +} + +func (x *GitCommitMetadata) Reset() { + *x = GitCommitMetadata{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_git_metadata_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GitCommitMetadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GitCommitMetadata) ProtoMessage() {} + +func (x *GitCommitMetadata) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_git_metadata_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GitCommitMetadata.ProtoReflect.Descriptor instead. +func (*GitCommitMetadata) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDescGZIP(), []int{1} +} + +func (x *GitCommitMetadata) GetHash() string { + if x != nil { + return x.Hash + } + return "" +} + +func (x *GitCommitMetadata) GetAuthor() *GitIdentity { + if x != nil { + return x.Author + } + return nil +} + +func (x *GitCommitMetadata) GetCommiter() *GitIdentity { + if x != nil { + return x.Commiter + } + return nil +} + +func (x *GitCommitMetadata) GetBranch() string { + if x != nil { + return x.Branch + } + return "" +} + +func (x *GitCommitMetadata) GetTags() []string { + if x != nil { + return x.Tags + } + return nil +} + +var File_buf_alpha_registry_v1alpha1_git_metadata_proto protoreflect.FileDescriptor + +var file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDesc = []byte{ + 0x0a, 0x2e, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x67, 0x69, + 0x74, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x1b, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x1f, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x67, + 0x0a, 0x0b, 0x47, 0x69, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x22, 0xdb, 0x01, 0x0a, 0x11, 0x47, 0x69, 0x74, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, + 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, + 0x68, 0x12, 0x40, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x28, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x47, 0x69, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x06, 0x61, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x12, 0x44, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x65, 0x72, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x47, 0x69, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, + 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x72, 0x61, + 0x6e, 0x63, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, + 0x68, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x04, 0x74, 0x61, 0x67, 0x73, 0x42, 0x9d, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x10, 0x47, 0x69, 0x74, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, + 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, + 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, + 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, + 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, + 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDescOnce sync.Once + file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDescData = file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDesc +) + +func file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDescGZIP() []byte { + file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDescOnce.Do(func() { + file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDescData = protoimpl.X.CompressGZIP(file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDescData) + }) + return file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDescData +} + +var file_buf_alpha_registry_v1alpha1_git_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_buf_alpha_registry_v1alpha1_git_metadata_proto_goTypes = []interface{}{ + (*GitIdentity)(nil), // 0: buf.alpha.registry.v1alpha1.GitIdentity + (*GitCommitMetadata)(nil), // 1: buf.alpha.registry.v1alpha1.GitCommitMetadata + (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp +} +var file_buf_alpha_registry_v1alpha1_git_metadata_proto_depIdxs = []int32{ + 2, // 0: buf.alpha.registry.v1alpha1.GitIdentity.time:type_name -> google.protobuf.Timestamp + 0, // 1: buf.alpha.registry.v1alpha1.GitCommitMetadata.author:type_name -> buf.alpha.registry.v1alpha1.GitIdentity + 0, // 2: buf.alpha.registry.v1alpha1.GitCommitMetadata.commiter:type_name -> buf.alpha.registry.v1alpha1.GitIdentity + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_buf_alpha_registry_v1alpha1_git_metadata_proto_init() } +func file_buf_alpha_registry_v1alpha1_git_metadata_proto_init() { + if File_buf_alpha_registry_v1alpha1_git_metadata_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_buf_alpha_registry_v1alpha1_git_metadata_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GitIdentity); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_git_metadata_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GitCommitMetadata); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_buf_alpha_registry_v1alpha1_git_metadata_proto_goTypes, + DependencyIndexes: file_buf_alpha_registry_v1alpha1_git_metadata_proto_depIdxs, + MessageInfos: file_buf_alpha_registry_v1alpha1_git_metadata_proto_msgTypes, + }.Build() + File_buf_alpha_registry_v1alpha1_git_metadata_proto = out.File + file_buf_alpha_registry_v1alpha1_git_metadata_proto_rawDesc = nil + file_buf_alpha_registry_v1alpha1_git_metadata_proto_goTypes = nil + file_buf_alpha_registry_v1alpha1_git_metadata_proto_depIdxs = nil +} diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/labels.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/labels.pb.go index 2352a7c1e..6ec993893 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/labels.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/labels.pb.go @@ -42,6 +42,8 @@ const ( LabelNamespace_LABEL_NAMESPACE_TAG LabelNamespace = 1 LabelNamespace_LABEL_NAMESPACE_BRANCH LabelNamespace = 2 LabelNamespace_LABEL_NAMESPACE_GIT_COMMIT LabelNamespace = 3 + LabelNamespace_LABEL_NAMESPACE_REVIEW LabelNamespace = 4 + LabelNamespace_LABEL_NAMESPACE_BSR_HEAD LabelNamespace = 5 ) // Enum value maps for LabelNamespace. @@ -51,12 +53,16 @@ var ( 1: "LABEL_NAMESPACE_TAG", 2: "LABEL_NAMESPACE_BRANCH", 3: "LABEL_NAMESPACE_GIT_COMMIT", + 4: "LABEL_NAMESPACE_REVIEW", + 5: "LABEL_NAMESPACE_BSR_HEAD", } LabelNamespace_value = map[string]int32{ "LABEL_NAMESPACE_UNSPECIFIED": 0, "LABEL_NAMESPACE_TAG": 1, "LABEL_NAMESPACE_BRANCH": 2, "LABEL_NAMESPACE_GIT_COMMIT": 3, + "LABEL_NAMESPACE_REVIEW": 4, + "LABEL_NAMESPACE_BSR_HEAD": 5, } ) @@ -672,7 +678,7 @@ var file_buf_alpha_registry_v1alpha1_labels_proto_rawDesc = []byte{ 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, - 0x6c, 0x73, 0x2a, 0x86, 0x01, 0x0a, 0x0e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, + 0x6c, 0x73, 0x2a, 0xc0, 0x01, 0x0a, 0x0e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x1b, 0x4c, 0x41, 0x42, 0x45, 0x4c, 0x5f, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x41, 0x42, 0x45, 0x4c, 0x5f, @@ -680,47 +686,51 @@ var file_buf_alpha_registry_v1alpha1_labels_proto_rawDesc = []byte{ 0x1a, 0x0a, 0x16, 0x4c, 0x41, 0x42, 0x45, 0x4c, 0x5f, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x42, 0x52, 0x41, 0x4e, 0x43, 0x48, 0x10, 0x02, 0x12, 0x1e, 0x0a, 0x1a, 0x4c, 0x41, 0x42, 0x45, 0x4c, 0x5f, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x47, - 0x49, 0x54, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x03, 0x32, 0xdd, 0x02, 0x0a, 0x0c, - 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x70, 0x0a, 0x0b, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x2f, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x62, - 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6a, - 0x0a, 0x09, 0x4d, 0x6f, 0x76, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x2d, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x76, 0x65, 0x4c, 0x61, - 0x62, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x62, 0x75, 0x66, + 0x49, 0x54, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x03, 0x12, 0x1a, 0x0a, 0x16, 0x4c, + 0x41, 0x42, 0x45, 0x4c, 0x5f, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x52, + 0x45, 0x56, 0x49, 0x45, 0x57, 0x10, 0x04, 0x12, 0x1c, 0x0a, 0x18, 0x4c, 0x41, 0x42, 0x45, 0x4c, + 0x5f, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x42, 0x53, 0x52, 0x5f, 0x48, + 0x45, 0x41, 0x44, 0x10, 0x05, 0x32, 0xe2, 0x02, 0x0a, 0x0c, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x75, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x6a, 0x0a, + 0x09, 0x4d, 0x6f, 0x76, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x76, 0x65, 0x4c, 0x61, 0x62, - 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6f, 0x0a, 0x09, 0x47, 0x65, - 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x76, 0x65, 0x4c, 0x61, 0x62, 0x65, + 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6f, 0x0a, 0x09, 0x47, 0x65, 0x74, + 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, 0x98, 0x02, 0x0a, 0x1f, - 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, - 0x0b, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, - 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, - 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, - 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, - 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, - 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, - 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, - 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, 0x98, 0x02, 0x0a, 0x1f, 0x63, + 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0b, + 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, + 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, + 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, + 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, + 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, + 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/organization.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/organization.pb.go index 18d469e3b..e02a8ea11 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/organization.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/organization.pb.go @@ -632,6 +632,110 @@ func (x *ListUserOrganizationsResponse) GetNextPageToken() string { return "" } +type GetUserOrganizationRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The ID of the user whose membership should be retrieved. + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + // The ID of the organization. + OrganizationId string `protobuf:"bytes,2,opt,name=organization_id,json=organizationId,proto3" json:"organization_id,omitempty"` +} + +func (x *GetUserOrganizationRequest) Reset() { + *x = GetUserOrganizationRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUserOrganizationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserOrganizationRequest) ProtoMessage() {} + +func (x *GetUserOrganizationRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetUserOrganizationRequest.ProtoReflect.Descriptor instead. +func (*GetUserOrganizationRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{10} +} + +func (x *GetUserOrganizationRequest) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *GetUserOrganizationRequest) GetOrganizationId() string { + if x != nil { + return x.OrganizationId + } + return "" +} + +type GetUserOrganizationResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + OrganizationMembership *OrganizationMembership `protobuf:"bytes,1,opt,name=organization_membership,json=organizationMembership,proto3" json:"organization_membership,omitempty"` +} + +func (x *GetUserOrganizationResponse) Reset() { + *x = GetUserOrganizationResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUserOrganizationResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserOrganizationResponse) ProtoMessage() {} + +func (x *GetUserOrganizationResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetUserOrganizationResponse.ProtoReflect.Descriptor instead. +func (*GetUserOrganizationResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{11} +} + +func (x *GetUserOrganizationResponse) GetOrganizationMembership() *OrganizationMembership { + if x != nil { + return x.OrganizationMembership + } + return nil +} + type CreateOrganizationRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -644,7 +748,7 @@ type CreateOrganizationRequest struct { func (x *CreateOrganizationRequest) Reset() { *x = CreateOrganizationRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[10] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -657,7 +761,7 @@ func (x *CreateOrganizationRequest) String() string { func (*CreateOrganizationRequest) ProtoMessage() {} func (x *CreateOrganizationRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[10] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -670,7 +774,7 @@ func (x *CreateOrganizationRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateOrganizationRequest.ProtoReflect.Descriptor instead. func (*CreateOrganizationRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{10} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{12} } func (x *CreateOrganizationRequest) GetName() string { @@ -691,7 +795,7 @@ type CreateOrganizationResponse struct { func (x *CreateOrganizationResponse) Reset() { *x = CreateOrganizationResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[11] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -704,7 +808,7 @@ func (x *CreateOrganizationResponse) String() string { func (*CreateOrganizationResponse) ProtoMessage() {} func (x *CreateOrganizationResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[11] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -717,7 +821,7 @@ func (x *CreateOrganizationResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateOrganizationResponse.ProtoReflect.Descriptor instead. func (*CreateOrganizationResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{11} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{13} } func (x *CreateOrganizationResponse) GetOrganization() *Organization { @@ -738,7 +842,7 @@ type DeleteOrganizationRequest struct { func (x *DeleteOrganizationRequest) Reset() { *x = DeleteOrganizationRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[12] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -751,7 +855,7 @@ func (x *DeleteOrganizationRequest) String() string { func (*DeleteOrganizationRequest) ProtoMessage() {} func (x *DeleteOrganizationRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[12] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -764,7 +868,7 @@ func (x *DeleteOrganizationRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteOrganizationRequest.ProtoReflect.Descriptor instead. func (*DeleteOrganizationRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{12} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{14} } func (x *DeleteOrganizationRequest) GetId() string { @@ -783,7 +887,7 @@ type DeleteOrganizationResponse struct { func (x *DeleteOrganizationResponse) Reset() { *x = DeleteOrganizationResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[13] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -796,7 +900,7 @@ func (x *DeleteOrganizationResponse) String() string { func (*DeleteOrganizationResponse) ProtoMessage() {} func (x *DeleteOrganizationResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[13] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -809,7 +913,7 @@ func (x *DeleteOrganizationResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteOrganizationResponse.ProtoReflect.Descriptor instead. func (*DeleteOrganizationResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{13} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{15} } type DeleteOrganizationByNameRequest struct { @@ -823,7 +927,7 @@ type DeleteOrganizationByNameRequest struct { func (x *DeleteOrganizationByNameRequest) Reset() { *x = DeleteOrganizationByNameRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[14] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -836,7 +940,7 @@ func (x *DeleteOrganizationByNameRequest) String() string { func (*DeleteOrganizationByNameRequest) ProtoMessage() {} func (x *DeleteOrganizationByNameRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[14] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -849,7 +953,7 @@ func (x *DeleteOrganizationByNameRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteOrganizationByNameRequest.ProtoReflect.Descriptor instead. func (*DeleteOrganizationByNameRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{14} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{16} } func (x *DeleteOrganizationByNameRequest) GetName() string { @@ -868,7 +972,7 @@ type DeleteOrganizationByNameResponse struct { func (x *DeleteOrganizationByNameResponse) Reset() { *x = DeleteOrganizationByNameResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[15] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -881,7 +985,7 @@ func (x *DeleteOrganizationByNameResponse) String() string { func (*DeleteOrganizationByNameResponse) ProtoMessage() {} func (x *DeleteOrganizationByNameResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[15] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[17] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -894,7 +998,7 @@ func (x *DeleteOrganizationByNameResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteOrganizationByNameResponse.ProtoReflect.Descriptor instead. func (*DeleteOrganizationByNameResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{15} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{17} } type AddOrganizationMemberRequest struct { @@ -913,7 +1017,7 @@ type AddOrganizationMemberRequest struct { func (x *AddOrganizationMemberRequest) Reset() { *x = AddOrganizationMemberRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[16] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -926,7 +1030,7 @@ func (x *AddOrganizationMemberRequest) String() string { func (*AddOrganizationMemberRequest) ProtoMessage() {} func (x *AddOrganizationMemberRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[16] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -939,7 +1043,7 @@ func (x *AddOrganizationMemberRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AddOrganizationMemberRequest.ProtoReflect.Descriptor instead. func (*AddOrganizationMemberRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{16} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{18} } func (x *AddOrganizationMemberRequest) GetOrganizationId() string { @@ -972,7 +1076,7 @@ type AddOrganizationMemberResponse struct { func (x *AddOrganizationMemberResponse) Reset() { *x = AddOrganizationMemberResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[17] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -985,7 +1089,7 @@ func (x *AddOrganizationMemberResponse) String() string { func (*AddOrganizationMemberResponse) ProtoMessage() {} func (x *AddOrganizationMemberResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[17] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -998,7 +1102,7 @@ func (x *AddOrganizationMemberResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AddOrganizationMemberResponse.ProtoReflect.Descriptor instead. func (*AddOrganizationMemberResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{17} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{19} } type UpdateOrganizationMemberRequest struct { @@ -1017,7 +1121,7 @@ type UpdateOrganizationMemberRequest struct { func (x *UpdateOrganizationMemberRequest) Reset() { *x = UpdateOrganizationMemberRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[18] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1030,7 +1134,7 @@ func (x *UpdateOrganizationMemberRequest) String() string { func (*UpdateOrganizationMemberRequest) ProtoMessage() {} func (x *UpdateOrganizationMemberRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[18] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1043,7 +1147,7 @@ func (x *UpdateOrganizationMemberRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateOrganizationMemberRequest.ProtoReflect.Descriptor instead. func (*UpdateOrganizationMemberRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{18} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{20} } func (x *UpdateOrganizationMemberRequest) GetOrganizationId() string { @@ -1076,7 +1180,7 @@ type UpdateOrganizationMemberResponse struct { func (x *UpdateOrganizationMemberResponse) Reset() { *x = UpdateOrganizationMemberResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[19] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1089,7 +1193,7 @@ func (x *UpdateOrganizationMemberResponse) String() string { func (*UpdateOrganizationMemberResponse) ProtoMessage() {} func (x *UpdateOrganizationMemberResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[19] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1102,7 +1206,7 @@ func (x *UpdateOrganizationMemberResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateOrganizationMemberResponse.ProtoReflect.Descriptor instead. func (*UpdateOrganizationMemberResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{19} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{21} } type RemoveOrganizationMemberRequest struct { @@ -1119,7 +1223,7 @@ type RemoveOrganizationMemberRequest struct { func (x *RemoveOrganizationMemberRequest) Reset() { *x = RemoveOrganizationMemberRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[20] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1132,7 +1236,7 @@ func (x *RemoveOrganizationMemberRequest) String() string { func (*RemoveOrganizationMemberRequest) ProtoMessage() {} func (x *RemoveOrganizationMemberRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[20] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1145,7 +1249,7 @@ func (x *RemoveOrganizationMemberRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveOrganizationMemberRequest.ProtoReflect.Descriptor instead. func (*RemoveOrganizationMemberRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{20} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{22} } func (x *RemoveOrganizationMemberRequest) GetOrganizationId() string { @@ -1171,7 +1275,7 @@ type RemoveOrganizationMemberResponse struct { func (x *RemoveOrganizationMemberResponse) Reset() { *x = RemoveOrganizationMemberResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[21] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1184,7 +1288,7 @@ func (x *RemoveOrganizationMemberResponse) String() string { func (*RemoveOrganizationMemberResponse) ProtoMessage() {} func (x *RemoveOrganizationMemberResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[21] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[23] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1197,7 +1301,7 @@ func (x *RemoveOrganizationMemberResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveOrganizationMemberResponse.ProtoReflect.Descriptor instead. func (*RemoveOrganizationMemberResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{21} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{23} } type SetOrganizationMemberRequest struct { @@ -1217,7 +1321,7 @@ type SetOrganizationMemberRequest struct { func (x *SetOrganizationMemberRequest) Reset() { *x = SetOrganizationMemberRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[22] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1230,7 +1334,7 @@ func (x *SetOrganizationMemberRequest) String() string { func (*SetOrganizationMemberRequest) ProtoMessage() {} func (x *SetOrganizationMemberRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[22] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[24] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1243,7 +1347,7 @@ func (x *SetOrganizationMemberRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SetOrganizationMemberRequest.ProtoReflect.Descriptor instead. func (*SetOrganizationMemberRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{22} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{24} } func (x *SetOrganizationMemberRequest) GetOrganizationId() string { @@ -1276,7 +1380,7 @@ type SetOrganizationMemberResponse struct { func (x *SetOrganizationMemberResponse) Reset() { *x = SetOrganizationMemberResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[23] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1289,7 +1393,7 @@ func (x *SetOrganizationMemberResponse) String() string { func (*SetOrganizationMemberResponse) ProtoMessage() {} func (x *SetOrganizationMemberResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[23] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[25] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1302,7 +1406,7 @@ func (x *SetOrganizationMemberResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SetOrganizationMemberResponse.ProtoReflect.Descriptor instead. func (*SetOrganizationMemberResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{23} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{25} } type GetOrganizationSettingsRequest struct { @@ -1317,7 +1421,7 @@ type GetOrganizationSettingsRequest struct { func (x *GetOrganizationSettingsRequest) Reset() { *x = GetOrganizationSettingsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[24] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1330,7 +1434,7 @@ func (x *GetOrganizationSettingsRequest) String() string { func (*GetOrganizationSettingsRequest) ProtoMessage() {} func (x *GetOrganizationSettingsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[24] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[26] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1343,7 +1447,7 @@ func (x *GetOrganizationSettingsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetOrganizationSettingsRequest.ProtoReflect.Descriptor instead. func (*GetOrganizationSettingsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{24} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{26} } func (x *GetOrganizationSettingsRequest) GetOrganizationId() string { @@ -1372,7 +1476,7 @@ type GetOrganizationSettingsResponse struct { func (x *GetOrganizationSettingsResponse) Reset() { *x = GetOrganizationSettingsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[25] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1385,7 +1489,7 @@ func (x *GetOrganizationSettingsResponse) String() string { func (*GetOrganizationSettingsResponse) ProtoMessage() {} func (x *GetOrganizationSettingsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[25] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[27] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1398,7 +1502,7 @@ func (x *GetOrganizationSettingsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetOrganizationSettingsResponse.ProtoReflect.Descriptor instead. func (*GetOrganizationSettingsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{25} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{27} } func (x *GetOrganizationSettingsResponse) GetRepositoryBaseRole() RepositoryRole { @@ -1464,7 +1568,7 @@ type UpdateOrganizationSettingsRequest struct { func (x *UpdateOrganizationSettingsRequest) Reset() { *x = UpdateOrganizationSettingsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[26] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1477,7 +1581,7 @@ func (x *UpdateOrganizationSettingsRequest) String() string { func (*UpdateOrganizationSettingsRequest) ProtoMessage() {} func (x *UpdateOrganizationSettingsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[26] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[28] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1490,7 +1594,7 @@ func (x *UpdateOrganizationSettingsRequest) ProtoReflect() protoreflect.Message // Deprecated: Use UpdateOrganizationSettingsRequest.ProtoReflect.Descriptor instead. func (*UpdateOrganizationSettingsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{26} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{28} } func (x *UpdateOrganizationSettingsRequest) GetOrganizationId() string { @@ -1546,7 +1650,7 @@ type UpdateOrganizationSettingsResponse struct { func (x *UpdateOrganizationSettingsResponse) Reset() { *x = UpdateOrganizationSettingsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[27] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1559,7 +1663,7 @@ func (x *UpdateOrganizationSettingsResponse) String() string { func (*UpdateOrganizationSettingsResponse) ProtoMessage() {} func (x *UpdateOrganizationSettingsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[27] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[29] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1572,7 +1676,7 @@ func (x *UpdateOrganizationSettingsResponse) ProtoReflect() protoreflect.Message // Deprecated: Use UpdateOrganizationSettingsResponse.ProtoReflect.Descriptor instead. func (*UpdateOrganizationSettingsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{27} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{29} } type AddOrganizationGroupRequest struct { @@ -1589,7 +1693,7 @@ type AddOrganizationGroupRequest struct { func (x *AddOrganizationGroupRequest) Reset() { *x = AddOrganizationGroupRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[28] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1602,7 +1706,7 @@ func (x *AddOrganizationGroupRequest) String() string { func (*AddOrganizationGroupRequest) ProtoMessage() {} func (x *AddOrganizationGroupRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[28] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[30] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1615,7 +1719,7 @@ func (x *AddOrganizationGroupRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AddOrganizationGroupRequest.ProtoReflect.Descriptor instead. func (*AddOrganizationGroupRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{28} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{30} } func (x *AddOrganizationGroupRequest) GetOrganizationId() string { @@ -1641,7 +1745,7 @@ type AddOrganizationGroupResponse struct { func (x *AddOrganizationGroupResponse) Reset() { *x = AddOrganizationGroupResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[29] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1654,7 +1758,7 @@ func (x *AddOrganizationGroupResponse) String() string { func (*AddOrganizationGroupResponse) ProtoMessage() {} func (x *AddOrganizationGroupResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[29] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1667,7 +1771,7 @@ func (x *AddOrganizationGroupResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AddOrganizationGroupResponse.ProtoReflect.Descriptor instead. func (*AddOrganizationGroupResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{29} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{31} } type RemoveOrganizationGroupRequest struct { @@ -1684,7 +1788,7 @@ type RemoveOrganizationGroupRequest struct { func (x *RemoveOrganizationGroupRequest) Reset() { *x = RemoveOrganizationGroupRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[30] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1697,7 +1801,7 @@ func (x *RemoveOrganizationGroupRequest) String() string { func (*RemoveOrganizationGroupRequest) ProtoMessage() {} func (x *RemoveOrganizationGroupRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[30] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[32] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1710,7 +1814,7 @@ func (x *RemoveOrganizationGroupRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveOrganizationGroupRequest.ProtoReflect.Descriptor instead. func (*RemoveOrganizationGroupRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{30} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{32} } func (x *RemoveOrganizationGroupRequest) GetOrganizationId() string { @@ -1736,7 +1840,7 @@ type RemoveOrganizationGroupResponse struct { func (x *RemoveOrganizationGroupResponse) Reset() { *x = RemoveOrganizationGroupResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[31] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1749,7 +1853,7 @@ func (x *RemoveOrganizationGroupResponse) String() string { func (*RemoveOrganizationGroupResponse) ProtoMessage() {} func (x *RemoveOrganizationGroupResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[31] + mi := &file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[33] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1762,7 +1866,7 @@ func (x *RemoveOrganizationGroupResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveOrganizationGroupResponse.ProtoReflect.Descriptor instead. func (*RemoveOrganizationGroupResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{31} + return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP(), []int{33} } var File_buf_alpha_registry_v1alpha1_organization_proto protoreflect.FileDescriptor @@ -1868,312 +1972,338 @@ var file_buf_alpha_registry_v1alpha1_organization_proto_rawDesc = []byte{ 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x0d, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x2f, - 0x0a, 0x19, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, - 0x6b, 0x0a, 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, - 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, - 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2b, 0x0a, 0x19, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x1c, 0x0a, 0x1a, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x35, 0x0a, 0x1f, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, - 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x22, - 0x0a, 0x20, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0xbc, 0x01, 0x0a, 0x1c, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, - 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, - 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, - 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x5a, 0x0a, 0x11, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4f, - 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x52, - 0x10, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, - 0x65, 0x22, 0x1f, 0x0a, 0x1d, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0xbf, 0x01, 0x0a, 0x1f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, - 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0e, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, - 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x5a, 0x0a, 0x11, 0x6f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, - 0x6c, 0x65, 0x52, 0x10, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x6f, 0x6c, 0x65, 0x22, 0x22, 0x0a, 0x20, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, + 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x5e, + 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, + 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, + 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, + 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x8b, + 0x01, 0x0a, 0x1b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6c, + 0x0a, 0x17, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x63, 0x0a, 0x1f, 0x52, 0x65, 0x6d, 0x6f, - 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, - 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, + 0x73, 0x68, 0x69, 0x70, 0x52, 0x16, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x22, 0x2f, 0x0a, 0x19, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x6b, 0x0a, + 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x6f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x6f, 0x72, + 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2b, 0x0a, 0x19, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x1c, 0x0a, 0x1a, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x35, 0x0a, 0x1f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x22, 0x0a, 0x20, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0xbc, 0x01, 0x0a, 0x1c, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, + 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, + 0x72, 0x49, 0x64, 0x12, 0x5a, 0x0a, 0x11, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2d, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4f, 0x72, 0x67, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x10, 0x6f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x22, + 0x1f, 0x0a, 0x1d, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0xbf, 0x01, 0x0a, 0x1f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, + 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x17, 0x0a, + 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x5a, 0x0a, 0x11, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, + 0x52, 0x10, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, + 0x6c, 0x65, 0x22, 0x22, 0x0a, 0x20, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x63, 0x0a, 0x1f, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, + 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x22, 0x0a, 0x20, 0x52, + 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0xbc, 0x01, 0x0a, 0x1c, 0x53, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, 0x6e, + 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, + 0x49, 0x64, 0x12, 0x5a, 0x0a, 0x11, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2d, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x10, 0x6f, 0x72, + 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x22, 0x1f, + 0x0a, 0x1d, 0x53, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x49, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0xf8, 0x02, 0x0a, 0x1f, 0x47, + 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5d, + 0x0a, 0x14, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x62, 0x61, 0x73, + 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x12, 0x72, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x55, 0x0a, + 0x10, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, + 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x42, 0x61, 0x73, 0x65, + 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x5b, 0x0a, 0x12, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, + 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x42, 0x02, 0x18, 0x01, 0x52, + 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, + 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x5f, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x64, 0x70, 0x5f, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x69, 0x64, 0x70, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x73, 0x22, 0xb5, 0x03, 0x0a, 0x21, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x22, 0x0a, - 0x20, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0xbc, 0x01, 0x0a, 0x1c, 0x53, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x5d, 0x0a, 0x14, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, + 0x72, 0x79, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x52, + 0x12, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x61, 0x73, 0x65, 0x52, + 0x6f, 0x6c, 0x65, 0x12, 0x55, 0x0a, 0x10, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x62, 0x61, + 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x70, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x42, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x5b, 0x0a, 0x12, 0x74, 0x65, + 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, + 0x65, 0x42, 0x02, 0x18, 0x01, 0x52, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x42, + 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x25, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x15, + 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x03, 0x75, + 0x72, 0x6c, 0x88, 0x01, 0x01, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x75, 0x72, 0x6c, 0x22, 0x24, 0x0a, + 0x22, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x65, 0x0a, 0x1b, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, - 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, - 0x65, 0x72, 0x49, 0x64, 0x12, 0x5a, 0x0a, 0x11, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4f, 0x72, - 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x10, - 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, - 0x22, 0x1f, 0x0a, 0x1d, 0x53, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x49, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, - 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0xf8, 0x02, 0x0a, - 0x1f, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x5d, 0x0a, 0x14, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x62, - 0x61, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x12, 0x72, 0x65, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, - 0x55, 0x0a, 0x10, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, - 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, - 0x6c, 0x65, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x42, 0x61, - 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x5b, 0x0a, 0x12, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x42, 0x02, 0x18, - 0x01, 0x52, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, - 0x6f, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x5f, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x6d, 0x65, 0x6d, 0x62, - 0x65, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x64, 0x70, 0x5f, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x69, 0x64, - 0x70, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x22, 0xb5, 0x03, 0x0a, 0x21, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, - 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x5d, 0x0a, 0x14, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x6f, 0x6c, - 0x65, 0x52, 0x12, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x61, 0x73, - 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x55, 0x0a, 0x10, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, - 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x27, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x70, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x42, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x5b, 0x0a, 0x12, - 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x6f, - 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x1e, 0x0a, 0x1c, 0x41, 0x64, + 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x68, 0x0a, 0x1e, 0x52, 0x65, + 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, + 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x21, 0x0a, 0x1f, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, + 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xe3, 0x12, 0x0a, 0x13, 0x4f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x81, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, - 0x6f, 0x6c, 0x65, 0x42, 0x02, 0x18, 0x01, 0x52, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, - 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x25, 0x0a, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, - 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, - 0x12, 0x15, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, - 0x03, 0x75, 0x72, 0x6c, 0x88, 0x01, 0x01, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x75, 0x72, 0x6c, 0x22, - 0x24, 0x0a, 0x22, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x65, 0x0a, 0x1b, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, - 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, - 0x0a, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x1e, 0x0a, 0x1c, - 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, - 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x68, 0x0a, 0x1e, - 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, - 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x72, 0x6f, 0x75, 0x70, - 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x72, 0x6f, - 0x75, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x21, 0x0a, 0x1f, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, - 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, - 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb0, 0x11, 0x0a, 0x13, 0x4f, 0x72, - 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x81, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x93, 0x01, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, - 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, - 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, - 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, - 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x87, 0x01, 0x0a, 0x11, - 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x12, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, + 0x90, 0x02, 0x01, 0x12, 0x93, 0x01, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, + 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x39, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, - 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x93, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, - 0x65, 0x72, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x87, 0x01, 0x0a, 0x11, 0x4c, 0x69, + 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, + 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, - 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x85, 0x01, 0x0a, 0x12, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, - 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x85, 0x01, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, - 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, - 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x97, 0x01, 0x0a, 0x18, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, - 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, - 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x8e, 0x01, 0x0a, 0x15, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, - 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, - 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x64, - 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, - 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, + 0x90, 0x02, 0x01, 0x12, 0x93, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, + 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x39, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, + 0x55, 0x73, 0x65, 0x72, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x8d, 0x01, 0x0a, 0x13, 0x47, 0x65, + 0x74, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x97, 0x01, 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, - 0x62, 0x65, 0x72, 0x12, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, + 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x8a, 0x01, 0x0a, 0x12, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x8a, 0x01, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, + 0x90, 0x02, 0x02, 0x12, 0x9c, 0x01, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, + 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3d, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, + 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, + 0x02, 0x02, 0x12, 0x93, 0x01, 0x0a, 0x15, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x39, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x4f, 0x72, + 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x97, 0x01, 0x0a, 0x18, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x3d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x3d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x97, 0x01, 0x0a, 0x18, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, - 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x3c, 0x2e, + 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x9c, 0x01, 0x0a, 0x18, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, + 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, + 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, - 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3d, 0x2e, 0x62, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, + 0x02, 0x12, 0x8e, 0x01, 0x0a, 0x15, 0x53, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, - 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, - 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x8e, 0x01, 0x0a, 0x15, 0x53, - 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, - 0x6d, 0x62, 0x65, 0x72, 0x12, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, - 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, - 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x99, 0x01, 0x0a, 0x17, - 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, - 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x9d, 0x01, 0x0a, 0x1a, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, - 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x72, 0x67, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, - 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x8b, 0x01, 0x0a, 0x14, 0x41, 0x64, 0x64, 0x4f, - 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, - 0x12, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, - 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x94, 0x01, 0x0a, 0x17, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, - 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, - 0x70, 0x12, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x99, 0x01, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6d, - 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, - 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x9e, 0x02, 0x0a, - 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x42, 0x11, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, - 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, - 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, - 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, + 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3c, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x9d, + 0x01, 0x0a, 0x1a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x3e, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x90, + 0x01, 0x0a, 0x14, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x41, 0x64, 0x64, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, + 0x02, 0x12, 0x99, 0x01, 0x0a, 0x17, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x3b, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, + 0x76, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3c, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x42, 0x9e, 0x02, + 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x42, 0x11, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, + 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, + 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, + 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2188,7 +2318,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_rawDescGZIP() []byte { return file_buf_alpha_registry_v1alpha1_organization_proto_rawDescData } -var file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes = make([]protoimpl.MessageInfo, 32) +var file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes = make([]protoimpl.MessageInfo, 34) var file_buf_alpha_registry_v1alpha1_organization_proto_goTypes = []interface{}{ (*Organization)(nil), // 0: buf.alpha.registry.v1alpha1.Organization (*OrganizationMembership)(nil), // 1: buf.alpha.registry.v1alpha1.OrganizationMembership @@ -2200,90 +2330,95 @@ var file_buf_alpha_registry_v1alpha1_organization_proto_goTypes = []interface{}{ (*ListOrganizationsResponse)(nil), // 7: buf.alpha.registry.v1alpha1.ListOrganizationsResponse (*ListUserOrganizationsRequest)(nil), // 8: buf.alpha.registry.v1alpha1.ListUserOrganizationsRequest (*ListUserOrganizationsResponse)(nil), // 9: buf.alpha.registry.v1alpha1.ListUserOrganizationsResponse - (*CreateOrganizationRequest)(nil), // 10: buf.alpha.registry.v1alpha1.CreateOrganizationRequest - (*CreateOrganizationResponse)(nil), // 11: buf.alpha.registry.v1alpha1.CreateOrganizationResponse - (*DeleteOrganizationRequest)(nil), // 12: buf.alpha.registry.v1alpha1.DeleteOrganizationRequest - (*DeleteOrganizationResponse)(nil), // 13: buf.alpha.registry.v1alpha1.DeleteOrganizationResponse - (*DeleteOrganizationByNameRequest)(nil), // 14: buf.alpha.registry.v1alpha1.DeleteOrganizationByNameRequest - (*DeleteOrganizationByNameResponse)(nil), // 15: buf.alpha.registry.v1alpha1.DeleteOrganizationByNameResponse - (*AddOrganizationMemberRequest)(nil), // 16: buf.alpha.registry.v1alpha1.AddOrganizationMemberRequest - (*AddOrganizationMemberResponse)(nil), // 17: buf.alpha.registry.v1alpha1.AddOrganizationMemberResponse - (*UpdateOrganizationMemberRequest)(nil), // 18: buf.alpha.registry.v1alpha1.UpdateOrganizationMemberRequest - (*UpdateOrganizationMemberResponse)(nil), // 19: buf.alpha.registry.v1alpha1.UpdateOrganizationMemberResponse - (*RemoveOrganizationMemberRequest)(nil), // 20: buf.alpha.registry.v1alpha1.RemoveOrganizationMemberRequest - (*RemoveOrganizationMemberResponse)(nil), // 21: buf.alpha.registry.v1alpha1.RemoveOrganizationMemberResponse - (*SetOrganizationMemberRequest)(nil), // 22: buf.alpha.registry.v1alpha1.SetOrganizationMemberRequest - (*SetOrganizationMemberResponse)(nil), // 23: buf.alpha.registry.v1alpha1.SetOrganizationMemberResponse - (*GetOrganizationSettingsRequest)(nil), // 24: buf.alpha.registry.v1alpha1.GetOrganizationSettingsRequest - (*GetOrganizationSettingsResponse)(nil), // 25: buf.alpha.registry.v1alpha1.GetOrganizationSettingsResponse - (*UpdateOrganizationSettingsRequest)(nil), // 26: buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsRequest - (*UpdateOrganizationSettingsResponse)(nil), // 27: buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsResponse - (*AddOrganizationGroupRequest)(nil), // 28: buf.alpha.registry.v1alpha1.AddOrganizationGroupRequest - (*AddOrganizationGroupResponse)(nil), // 29: buf.alpha.registry.v1alpha1.AddOrganizationGroupResponse - (*RemoveOrganizationGroupRequest)(nil), // 30: buf.alpha.registry.v1alpha1.RemoveOrganizationGroupRequest - (*RemoveOrganizationGroupResponse)(nil), // 31: buf.alpha.registry.v1alpha1.RemoveOrganizationGroupResponse - (*timestamppb.Timestamp)(nil), // 32: google.protobuf.Timestamp - (VerificationStatus)(0), // 33: buf.alpha.registry.v1alpha1.VerificationStatus - (OrganizationRole)(0), // 34: buf.alpha.registry.v1alpha1.OrganizationRole - (RepositoryRole)(0), // 35: buf.alpha.registry.v1alpha1.RepositoryRole - (PluginRole)(0), // 36: buf.alpha.registry.v1alpha1.PluginRole - (TemplateRole)(0), // 37: buf.alpha.registry.v1alpha1.TemplateRole + (*GetUserOrganizationRequest)(nil), // 10: buf.alpha.registry.v1alpha1.GetUserOrganizationRequest + (*GetUserOrganizationResponse)(nil), // 11: buf.alpha.registry.v1alpha1.GetUserOrganizationResponse + (*CreateOrganizationRequest)(nil), // 12: buf.alpha.registry.v1alpha1.CreateOrganizationRequest + (*CreateOrganizationResponse)(nil), // 13: buf.alpha.registry.v1alpha1.CreateOrganizationResponse + (*DeleteOrganizationRequest)(nil), // 14: buf.alpha.registry.v1alpha1.DeleteOrganizationRequest + (*DeleteOrganizationResponse)(nil), // 15: buf.alpha.registry.v1alpha1.DeleteOrganizationResponse + (*DeleteOrganizationByNameRequest)(nil), // 16: buf.alpha.registry.v1alpha1.DeleteOrganizationByNameRequest + (*DeleteOrganizationByNameResponse)(nil), // 17: buf.alpha.registry.v1alpha1.DeleteOrganizationByNameResponse + (*AddOrganizationMemberRequest)(nil), // 18: buf.alpha.registry.v1alpha1.AddOrganizationMemberRequest + (*AddOrganizationMemberResponse)(nil), // 19: buf.alpha.registry.v1alpha1.AddOrganizationMemberResponse + (*UpdateOrganizationMemberRequest)(nil), // 20: buf.alpha.registry.v1alpha1.UpdateOrganizationMemberRequest + (*UpdateOrganizationMemberResponse)(nil), // 21: buf.alpha.registry.v1alpha1.UpdateOrganizationMemberResponse + (*RemoveOrganizationMemberRequest)(nil), // 22: buf.alpha.registry.v1alpha1.RemoveOrganizationMemberRequest + (*RemoveOrganizationMemberResponse)(nil), // 23: buf.alpha.registry.v1alpha1.RemoveOrganizationMemberResponse + (*SetOrganizationMemberRequest)(nil), // 24: buf.alpha.registry.v1alpha1.SetOrganizationMemberRequest + (*SetOrganizationMemberResponse)(nil), // 25: buf.alpha.registry.v1alpha1.SetOrganizationMemberResponse + (*GetOrganizationSettingsRequest)(nil), // 26: buf.alpha.registry.v1alpha1.GetOrganizationSettingsRequest + (*GetOrganizationSettingsResponse)(nil), // 27: buf.alpha.registry.v1alpha1.GetOrganizationSettingsResponse + (*UpdateOrganizationSettingsRequest)(nil), // 28: buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsRequest + (*UpdateOrganizationSettingsResponse)(nil), // 29: buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsResponse + (*AddOrganizationGroupRequest)(nil), // 30: buf.alpha.registry.v1alpha1.AddOrganizationGroupRequest + (*AddOrganizationGroupResponse)(nil), // 31: buf.alpha.registry.v1alpha1.AddOrganizationGroupResponse + (*RemoveOrganizationGroupRequest)(nil), // 32: buf.alpha.registry.v1alpha1.RemoveOrganizationGroupRequest + (*RemoveOrganizationGroupResponse)(nil), // 33: buf.alpha.registry.v1alpha1.RemoveOrganizationGroupResponse + (*timestamppb.Timestamp)(nil), // 34: google.protobuf.Timestamp + (VerificationStatus)(0), // 35: buf.alpha.registry.v1alpha1.VerificationStatus + (OrganizationRole)(0), // 36: buf.alpha.registry.v1alpha1.OrganizationRole + (RepositoryRole)(0), // 37: buf.alpha.registry.v1alpha1.RepositoryRole + (PluginRole)(0), // 38: buf.alpha.registry.v1alpha1.PluginRole + (TemplateRole)(0), // 39: buf.alpha.registry.v1alpha1.TemplateRole } var file_buf_alpha_registry_v1alpha1_organization_proto_depIdxs = []int32{ - 32, // 0: buf.alpha.registry.v1alpha1.Organization.create_time:type_name -> google.protobuf.Timestamp - 32, // 1: buf.alpha.registry.v1alpha1.Organization.update_time:type_name -> google.protobuf.Timestamp - 33, // 2: buf.alpha.registry.v1alpha1.Organization.verification_status:type_name -> buf.alpha.registry.v1alpha1.VerificationStatus + 34, // 0: buf.alpha.registry.v1alpha1.Organization.create_time:type_name -> google.protobuf.Timestamp + 34, // 1: buf.alpha.registry.v1alpha1.Organization.update_time:type_name -> google.protobuf.Timestamp + 35, // 2: buf.alpha.registry.v1alpha1.Organization.verification_status:type_name -> buf.alpha.registry.v1alpha1.VerificationStatus 0, // 3: buf.alpha.registry.v1alpha1.OrganizationMembership.organization:type_name -> buf.alpha.registry.v1alpha1.Organization - 34, // 4: buf.alpha.registry.v1alpha1.OrganizationMembership.organization_role:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole + 36, // 4: buf.alpha.registry.v1alpha1.OrganizationMembership.organization_role:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole 0, // 5: buf.alpha.registry.v1alpha1.GetOrganizationResponse.organization:type_name -> buf.alpha.registry.v1alpha1.Organization 0, // 6: buf.alpha.registry.v1alpha1.GetOrganizationByNameResponse.organization:type_name -> buf.alpha.registry.v1alpha1.Organization 0, // 7: buf.alpha.registry.v1alpha1.ListOrganizationsResponse.organizations:type_name -> buf.alpha.registry.v1alpha1.Organization 1, // 8: buf.alpha.registry.v1alpha1.ListUserOrganizationsResponse.organizations:type_name -> buf.alpha.registry.v1alpha1.OrganizationMembership - 0, // 9: buf.alpha.registry.v1alpha1.CreateOrganizationResponse.organization:type_name -> buf.alpha.registry.v1alpha1.Organization - 34, // 10: buf.alpha.registry.v1alpha1.AddOrganizationMemberRequest.organization_role:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole - 34, // 11: buf.alpha.registry.v1alpha1.UpdateOrganizationMemberRequest.organization_role:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole - 34, // 12: buf.alpha.registry.v1alpha1.SetOrganizationMemberRequest.organization_role:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole - 35, // 13: buf.alpha.registry.v1alpha1.GetOrganizationSettingsResponse.repository_base_role:type_name -> buf.alpha.registry.v1alpha1.RepositoryRole - 36, // 14: buf.alpha.registry.v1alpha1.GetOrganizationSettingsResponse.plugin_base_role:type_name -> buf.alpha.registry.v1alpha1.PluginRole - 37, // 15: buf.alpha.registry.v1alpha1.GetOrganizationSettingsResponse.template_base_role:type_name -> buf.alpha.registry.v1alpha1.TemplateRole - 35, // 16: buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsRequest.repository_base_role:type_name -> buf.alpha.registry.v1alpha1.RepositoryRole - 36, // 17: buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsRequest.plugin_base_role:type_name -> buf.alpha.registry.v1alpha1.PluginRole - 37, // 18: buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsRequest.template_base_role:type_name -> buf.alpha.registry.v1alpha1.TemplateRole - 2, // 19: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganization:input_type -> buf.alpha.registry.v1alpha1.GetOrganizationRequest - 4, // 20: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganizationByName:input_type -> buf.alpha.registry.v1alpha1.GetOrganizationByNameRequest - 6, // 21: buf.alpha.registry.v1alpha1.OrganizationService.ListOrganizations:input_type -> buf.alpha.registry.v1alpha1.ListOrganizationsRequest - 8, // 22: buf.alpha.registry.v1alpha1.OrganizationService.ListUserOrganizations:input_type -> buf.alpha.registry.v1alpha1.ListUserOrganizationsRequest - 10, // 23: buf.alpha.registry.v1alpha1.OrganizationService.CreateOrganization:input_type -> buf.alpha.registry.v1alpha1.CreateOrganizationRequest - 12, // 24: buf.alpha.registry.v1alpha1.OrganizationService.DeleteOrganization:input_type -> buf.alpha.registry.v1alpha1.DeleteOrganizationRequest - 14, // 25: buf.alpha.registry.v1alpha1.OrganizationService.DeleteOrganizationByName:input_type -> buf.alpha.registry.v1alpha1.DeleteOrganizationByNameRequest - 16, // 26: buf.alpha.registry.v1alpha1.OrganizationService.AddOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.AddOrganizationMemberRequest - 18, // 27: buf.alpha.registry.v1alpha1.OrganizationService.UpdateOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationMemberRequest - 20, // 28: buf.alpha.registry.v1alpha1.OrganizationService.RemoveOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.RemoveOrganizationMemberRequest - 22, // 29: buf.alpha.registry.v1alpha1.OrganizationService.SetOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.SetOrganizationMemberRequest - 24, // 30: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganizationSettings:input_type -> buf.alpha.registry.v1alpha1.GetOrganizationSettingsRequest - 26, // 31: buf.alpha.registry.v1alpha1.OrganizationService.UpdateOrganizationSettings:input_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsRequest - 28, // 32: buf.alpha.registry.v1alpha1.OrganizationService.AddOrganizationGroup:input_type -> buf.alpha.registry.v1alpha1.AddOrganizationGroupRequest - 30, // 33: buf.alpha.registry.v1alpha1.OrganizationService.RemoveOrganizationGroup:input_type -> buf.alpha.registry.v1alpha1.RemoveOrganizationGroupRequest - 3, // 34: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganization:output_type -> buf.alpha.registry.v1alpha1.GetOrganizationResponse - 5, // 35: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganizationByName:output_type -> buf.alpha.registry.v1alpha1.GetOrganizationByNameResponse - 7, // 36: buf.alpha.registry.v1alpha1.OrganizationService.ListOrganizations:output_type -> buf.alpha.registry.v1alpha1.ListOrganizationsResponse - 9, // 37: buf.alpha.registry.v1alpha1.OrganizationService.ListUserOrganizations:output_type -> buf.alpha.registry.v1alpha1.ListUserOrganizationsResponse - 11, // 38: buf.alpha.registry.v1alpha1.OrganizationService.CreateOrganization:output_type -> buf.alpha.registry.v1alpha1.CreateOrganizationResponse - 13, // 39: buf.alpha.registry.v1alpha1.OrganizationService.DeleteOrganization:output_type -> buf.alpha.registry.v1alpha1.DeleteOrganizationResponse - 15, // 40: buf.alpha.registry.v1alpha1.OrganizationService.DeleteOrganizationByName:output_type -> buf.alpha.registry.v1alpha1.DeleteOrganizationByNameResponse - 17, // 41: buf.alpha.registry.v1alpha1.OrganizationService.AddOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.AddOrganizationMemberResponse - 19, // 42: buf.alpha.registry.v1alpha1.OrganizationService.UpdateOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationMemberResponse - 21, // 43: buf.alpha.registry.v1alpha1.OrganizationService.RemoveOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.RemoveOrganizationMemberResponse - 23, // 44: buf.alpha.registry.v1alpha1.OrganizationService.SetOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.SetOrganizationMemberResponse - 25, // 45: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganizationSettings:output_type -> buf.alpha.registry.v1alpha1.GetOrganizationSettingsResponse - 27, // 46: buf.alpha.registry.v1alpha1.OrganizationService.UpdateOrganizationSettings:output_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsResponse - 29, // 47: buf.alpha.registry.v1alpha1.OrganizationService.AddOrganizationGroup:output_type -> buf.alpha.registry.v1alpha1.AddOrganizationGroupResponse - 31, // 48: buf.alpha.registry.v1alpha1.OrganizationService.RemoveOrganizationGroup:output_type -> buf.alpha.registry.v1alpha1.RemoveOrganizationGroupResponse - 34, // [34:49] is the sub-list for method output_type - 19, // [19:34] is the sub-list for method input_type - 19, // [19:19] is the sub-list for extension type_name - 19, // [19:19] is the sub-list for extension extendee - 0, // [0:19] is the sub-list for field type_name + 1, // 9: buf.alpha.registry.v1alpha1.GetUserOrganizationResponse.organization_membership:type_name -> buf.alpha.registry.v1alpha1.OrganizationMembership + 0, // 10: buf.alpha.registry.v1alpha1.CreateOrganizationResponse.organization:type_name -> buf.alpha.registry.v1alpha1.Organization + 36, // 11: buf.alpha.registry.v1alpha1.AddOrganizationMemberRequest.organization_role:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole + 36, // 12: buf.alpha.registry.v1alpha1.UpdateOrganizationMemberRequest.organization_role:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole + 36, // 13: buf.alpha.registry.v1alpha1.SetOrganizationMemberRequest.organization_role:type_name -> buf.alpha.registry.v1alpha1.OrganizationRole + 37, // 14: buf.alpha.registry.v1alpha1.GetOrganizationSettingsResponse.repository_base_role:type_name -> buf.alpha.registry.v1alpha1.RepositoryRole + 38, // 15: buf.alpha.registry.v1alpha1.GetOrganizationSettingsResponse.plugin_base_role:type_name -> buf.alpha.registry.v1alpha1.PluginRole + 39, // 16: buf.alpha.registry.v1alpha1.GetOrganizationSettingsResponse.template_base_role:type_name -> buf.alpha.registry.v1alpha1.TemplateRole + 37, // 17: buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsRequest.repository_base_role:type_name -> buf.alpha.registry.v1alpha1.RepositoryRole + 38, // 18: buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsRequest.plugin_base_role:type_name -> buf.alpha.registry.v1alpha1.PluginRole + 39, // 19: buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsRequest.template_base_role:type_name -> buf.alpha.registry.v1alpha1.TemplateRole + 2, // 20: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganization:input_type -> buf.alpha.registry.v1alpha1.GetOrganizationRequest + 4, // 21: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganizationByName:input_type -> buf.alpha.registry.v1alpha1.GetOrganizationByNameRequest + 6, // 22: buf.alpha.registry.v1alpha1.OrganizationService.ListOrganizations:input_type -> buf.alpha.registry.v1alpha1.ListOrganizationsRequest + 8, // 23: buf.alpha.registry.v1alpha1.OrganizationService.ListUserOrganizations:input_type -> buf.alpha.registry.v1alpha1.ListUserOrganizationsRequest + 10, // 24: buf.alpha.registry.v1alpha1.OrganizationService.GetUserOrganization:input_type -> buf.alpha.registry.v1alpha1.GetUserOrganizationRequest + 12, // 25: buf.alpha.registry.v1alpha1.OrganizationService.CreateOrganization:input_type -> buf.alpha.registry.v1alpha1.CreateOrganizationRequest + 14, // 26: buf.alpha.registry.v1alpha1.OrganizationService.DeleteOrganization:input_type -> buf.alpha.registry.v1alpha1.DeleteOrganizationRequest + 16, // 27: buf.alpha.registry.v1alpha1.OrganizationService.DeleteOrganizationByName:input_type -> buf.alpha.registry.v1alpha1.DeleteOrganizationByNameRequest + 18, // 28: buf.alpha.registry.v1alpha1.OrganizationService.AddOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.AddOrganizationMemberRequest + 20, // 29: buf.alpha.registry.v1alpha1.OrganizationService.UpdateOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationMemberRequest + 22, // 30: buf.alpha.registry.v1alpha1.OrganizationService.RemoveOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.RemoveOrganizationMemberRequest + 24, // 31: buf.alpha.registry.v1alpha1.OrganizationService.SetOrganizationMember:input_type -> buf.alpha.registry.v1alpha1.SetOrganizationMemberRequest + 26, // 32: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganizationSettings:input_type -> buf.alpha.registry.v1alpha1.GetOrganizationSettingsRequest + 28, // 33: buf.alpha.registry.v1alpha1.OrganizationService.UpdateOrganizationSettings:input_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsRequest + 30, // 34: buf.alpha.registry.v1alpha1.OrganizationService.AddOrganizationGroup:input_type -> buf.alpha.registry.v1alpha1.AddOrganizationGroupRequest + 32, // 35: buf.alpha.registry.v1alpha1.OrganizationService.RemoveOrganizationGroup:input_type -> buf.alpha.registry.v1alpha1.RemoveOrganizationGroupRequest + 3, // 36: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganization:output_type -> buf.alpha.registry.v1alpha1.GetOrganizationResponse + 5, // 37: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganizationByName:output_type -> buf.alpha.registry.v1alpha1.GetOrganizationByNameResponse + 7, // 38: buf.alpha.registry.v1alpha1.OrganizationService.ListOrganizations:output_type -> buf.alpha.registry.v1alpha1.ListOrganizationsResponse + 9, // 39: buf.alpha.registry.v1alpha1.OrganizationService.ListUserOrganizations:output_type -> buf.alpha.registry.v1alpha1.ListUserOrganizationsResponse + 11, // 40: buf.alpha.registry.v1alpha1.OrganizationService.GetUserOrganization:output_type -> buf.alpha.registry.v1alpha1.GetUserOrganizationResponse + 13, // 41: buf.alpha.registry.v1alpha1.OrganizationService.CreateOrganization:output_type -> buf.alpha.registry.v1alpha1.CreateOrganizationResponse + 15, // 42: buf.alpha.registry.v1alpha1.OrganizationService.DeleteOrganization:output_type -> buf.alpha.registry.v1alpha1.DeleteOrganizationResponse + 17, // 43: buf.alpha.registry.v1alpha1.OrganizationService.DeleteOrganizationByName:output_type -> buf.alpha.registry.v1alpha1.DeleteOrganizationByNameResponse + 19, // 44: buf.alpha.registry.v1alpha1.OrganizationService.AddOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.AddOrganizationMemberResponse + 21, // 45: buf.alpha.registry.v1alpha1.OrganizationService.UpdateOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationMemberResponse + 23, // 46: buf.alpha.registry.v1alpha1.OrganizationService.RemoveOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.RemoveOrganizationMemberResponse + 25, // 47: buf.alpha.registry.v1alpha1.OrganizationService.SetOrganizationMember:output_type -> buf.alpha.registry.v1alpha1.SetOrganizationMemberResponse + 27, // 48: buf.alpha.registry.v1alpha1.OrganizationService.GetOrganizationSettings:output_type -> buf.alpha.registry.v1alpha1.GetOrganizationSettingsResponse + 29, // 49: buf.alpha.registry.v1alpha1.OrganizationService.UpdateOrganizationSettings:output_type -> buf.alpha.registry.v1alpha1.UpdateOrganizationSettingsResponse + 31, // 50: buf.alpha.registry.v1alpha1.OrganizationService.AddOrganizationGroup:output_type -> buf.alpha.registry.v1alpha1.AddOrganizationGroupResponse + 33, // 51: buf.alpha.registry.v1alpha1.OrganizationService.RemoveOrganizationGroup:output_type -> buf.alpha.registry.v1alpha1.RemoveOrganizationGroupResponse + 36, // [36:52] is the sub-list for method output_type + 20, // [20:36] is the sub-list for method input_type + 20, // [20:20] is the sub-list for extension type_name + 20, // [20:20] is the sub-list for extension extendee + 0, // [0:20] is the sub-list for field type_name } func init() { file_buf_alpha_registry_v1alpha1_organization_proto_init() } @@ -2415,7 +2550,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateOrganizationRequest); i { + switch v := v.(*GetUserOrganizationRequest); i { case 0: return &v.state case 1: @@ -2427,7 +2562,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateOrganizationResponse); i { + switch v := v.(*GetUserOrganizationResponse); i { case 0: return &v.state case 1: @@ -2439,7 +2574,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteOrganizationRequest); i { + switch v := v.(*CreateOrganizationRequest); i { case 0: return &v.state case 1: @@ -2451,7 +2586,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteOrganizationResponse); i { + switch v := v.(*CreateOrganizationResponse); i { case 0: return &v.state case 1: @@ -2463,7 +2598,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteOrganizationByNameRequest); i { + switch v := v.(*DeleteOrganizationRequest); i { case 0: return &v.state case 1: @@ -2475,7 +2610,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteOrganizationByNameResponse); i { + switch v := v.(*DeleteOrganizationResponse); i { case 0: return &v.state case 1: @@ -2487,7 +2622,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddOrganizationMemberRequest); i { + switch v := v.(*DeleteOrganizationByNameRequest); i { case 0: return &v.state case 1: @@ -2499,7 +2634,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddOrganizationMemberResponse); i { + switch v := v.(*DeleteOrganizationByNameResponse); i { case 0: return &v.state case 1: @@ -2511,7 +2646,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateOrganizationMemberRequest); i { + switch v := v.(*AddOrganizationMemberRequest); i { case 0: return &v.state case 1: @@ -2523,7 +2658,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateOrganizationMemberResponse); i { + switch v := v.(*AddOrganizationMemberResponse); i { case 0: return &v.state case 1: @@ -2535,7 +2670,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveOrganizationMemberRequest); i { + switch v := v.(*UpdateOrganizationMemberRequest); i { case 0: return &v.state case 1: @@ -2547,7 +2682,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveOrganizationMemberResponse); i { + switch v := v.(*UpdateOrganizationMemberResponse); i { case 0: return &v.state case 1: @@ -2559,7 +2694,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetOrganizationMemberRequest); i { + switch v := v.(*RemoveOrganizationMemberRequest); i { case 0: return &v.state case 1: @@ -2571,7 +2706,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetOrganizationMemberResponse); i { + switch v := v.(*RemoveOrganizationMemberResponse); i { case 0: return &v.state case 1: @@ -2583,7 +2718,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetOrganizationSettingsRequest); i { + switch v := v.(*SetOrganizationMemberRequest); i { case 0: return &v.state case 1: @@ -2595,7 +2730,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetOrganizationSettingsResponse); i { + switch v := v.(*SetOrganizationMemberResponse); i { case 0: return &v.state case 1: @@ -2607,7 +2742,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateOrganizationSettingsRequest); i { + switch v := v.(*GetOrganizationSettingsRequest); i { case 0: return &v.state case 1: @@ -2619,7 +2754,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateOrganizationSettingsResponse); i { + switch v := v.(*GetOrganizationSettingsResponse); i { case 0: return &v.state case 1: @@ -2631,7 +2766,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddOrganizationGroupRequest); i { + switch v := v.(*UpdateOrganizationSettingsRequest); i { case 0: return &v.state case 1: @@ -2643,7 +2778,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddOrganizationGroupResponse); i { + switch v := v.(*UpdateOrganizationSettingsResponse); i { case 0: return &v.state case 1: @@ -2655,7 +2790,7 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveOrganizationGroupRequest); i { + switch v := v.(*AddOrganizationGroupRequest); i { case 0: return &v.state case 1: @@ -2667,6 +2802,30 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddOrganizationGroupResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RemoveOrganizationGroupRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RemoveOrganizationGroupResponse); i { case 0: return &v.state @@ -2679,14 +2838,14 @@ func file_buf_alpha_registry_v1alpha1_organization_proto_init() { } } } - file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[26].OneofWrappers = []interface{}{} + file_buf_alpha_registry_v1alpha1_organization_proto_msgTypes[28].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_alpha_registry_v1alpha1_organization_proto_rawDesc, NumEnums: 0, - NumMessages: 32, + NumMessages: 34, NumExtensions: 0, NumServices: 1, }, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/plugin.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/plugin.pb.go index cca3c4351..7734ae27a 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/plugin.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/plugin.pb.go @@ -791,180 +791,6 @@ func (x *PluginVersionMapping) GetInaccessible() bool { return false } -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type PluginContributor struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // The ID of the plugin which the role belongs to. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PluginId string `protobuf:"bytes,2,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` - // The role that the user has been explicitly assigned against the plugin. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - ExplicitRole PluginRole `protobuf:"varint,3,opt,name=explicit_role,json=explicitRole,proto3,enum=buf.alpha.registry.v1alpha1.PluginRole" json:"explicit_role,omitempty"` - // Optionally defines the role that the user has implicitly against the plugin through the owning organization. - // If the plugin does not belong to an organization or the user is not part of the owning organization, this is unset. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - ImplicitRole PluginRole `protobuf:"varint,4,opt,name=implicit_role,json=implicitRole,proto3,enum=buf.alpha.registry.v1alpha1.PluginRole" json:"implicit_role,omitempty"` -} - -func (x *PluginContributor) Reset() { - *x = PluginContributor{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PluginContributor) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PluginContributor) ProtoMessage() {} - -func (x *PluginContributor) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PluginContributor.ProtoReflect.Descriptor instead. -func (*PluginContributor) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{6} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *PluginContributor) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *PluginContributor) GetPluginId() string { - if x != nil { - return x.PluginId - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *PluginContributor) GetExplicitRole() PluginRole { - if x != nil { - return x.ExplicitRole - } - return PluginRole_PLUGIN_ROLE_UNSPECIFIED -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *PluginContributor) GetImplicitRole() PluginRole { - if x != nil { - return x.ImplicitRole - } - return PluginRole_PLUGIN_ROLE_UNSPECIFIED -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type TemplateContributor struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // The ID of the template which the role belongs to. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - TemplateId string `protobuf:"bytes,2,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` - // The role that the user has been explicitly assigned against the template. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - ExplicitRole TemplateRole `protobuf:"varint,3,opt,name=explicit_role,json=explicitRole,proto3,enum=buf.alpha.registry.v1alpha1.TemplateRole" json:"explicit_role,omitempty"` - // Optionally defines the role that the user has implicitly against the template through the owning organization. - // If the template does not belong to an organization or the user is not part of the owning organization, this is unset. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - ImplicitRole TemplateRole `protobuf:"varint,4,opt,name=implicit_role,json=implicitRole,proto3,enum=buf.alpha.registry.v1alpha1.TemplateRole" json:"implicit_role,omitempty"` -} - -func (x *TemplateContributor) Reset() { - *x = TemplateContributor{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TemplateContributor) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TemplateContributor) ProtoMessage() {} - -func (x *TemplateContributor) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TemplateContributor.ProtoReflect.Descriptor instead. -func (*TemplateContributor) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{7} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *TemplateContributor) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *TemplateContributor) GetTemplateId() string { - if x != nil { - return x.TemplateId - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *TemplateContributor) GetExplicitRole() TemplateRole { - if x != nil { - return x.ExplicitRole - } - return TemplateRole_TEMPLATE_ROLE_UNSPECIFIED -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *TemplateContributor) GetImplicitRole() TemplateRole { - if x != nil { - return x.ImplicitRole - } - return TemplateRole_TEMPLATE_ROLE_UNSPECIFIED -} - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. type ListPluginsRequest struct { state protoimpl.MessageState @@ -984,7 +810,7 @@ type ListPluginsRequest struct { func (x *ListPluginsRequest) Reset() { *x = ListPluginsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[8] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -997,7 +823,7 @@ func (x *ListPluginsRequest) String() string { func (*ListPluginsRequest) ProtoMessage() {} func (x *ListPluginsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[8] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1010,7 +836,7 @@ func (x *ListPluginsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPluginsRequest.ProtoReflect.Descriptor instead. func (*ListPluginsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{8} + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{6} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. @@ -1054,7 +880,7 @@ type ListPluginsResponse struct { func (x *ListPluginsResponse) Reset() { *x = ListPluginsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[9] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1067,7 +893,7 @@ func (x *ListPluginsResponse) String() string { func (*ListPluginsResponse) ProtoMessage() {} func (x *ListPluginsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[9] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1080,7 +906,7 @@ func (x *ListPluginsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPluginsResponse.ProtoReflect.Descriptor instead. func (*ListPluginsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{9} + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{7} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. @@ -1122,7 +948,7 @@ type ListUserPluginsRequest struct { func (x *ListUserPluginsRequest) Reset() { *x = ListUserPluginsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[10] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1135,7 +961,7 @@ func (x *ListUserPluginsRequest) String() string { func (*ListUserPluginsRequest) ProtoMessage() {} func (x *ListUserPluginsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[10] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1148,7 +974,7 @@ func (x *ListUserPluginsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListUserPluginsRequest.ProtoReflect.Descriptor instead. func (*ListUserPluginsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{10} + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{8} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. @@ -1200,7 +1026,7 @@ type ListUserPluginsResponse struct { func (x *ListUserPluginsResponse) Reset() { *x = ListUserPluginsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[11] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1213,7 +1039,7 @@ func (x *ListUserPluginsResponse) String() string { func (*ListUserPluginsResponse) ProtoMessage() {} func (x *ListUserPluginsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[11] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1226,7 +1052,7 @@ func (x *ListUserPluginsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListUserPluginsResponse.ProtoReflect.Descriptor instead. func (*ListUserPluginsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{11} + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{9} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. @@ -1268,7 +1094,7 @@ type ListOrganizationPluginsRequest struct { func (x *ListOrganizationPluginsRequest) Reset() { *x = ListOrganizationPluginsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[12] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1281,7 +1107,7 @@ func (x *ListOrganizationPluginsRequest) String() string { func (*ListOrganizationPluginsRequest) ProtoMessage() {} func (x *ListOrganizationPluginsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[12] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1294,7 +1120,7 @@ func (x *ListOrganizationPluginsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListOrganizationPluginsRequest.ProtoReflect.Descriptor instead. func (*ListOrganizationPluginsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{12} + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{10} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. @@ -1346,7 +1172,7 @@ type ListOrganizationPluginsResponse struct { func (x *ListOrganizationPluginsResponse) Reset() { *x = ListOrganizationPluginsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[13] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1359,7 +1185,7 @@ func (x *ListOrganizationPluginsResponse) String() string { func (*ListOrganizationPluginsResponse) ProtoMessage() {} func (x *ListOrganizationPluginsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[13] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1372,7 +1198,7 @@ func (x *ListOrganizationPluginsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListOrganizationPluginsResponse.ProtoReflect.Descriptor instead. func (*ListOrganizationPluginsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{13} + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{11} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. @@ -1414,7 +1240,7 @@ type GetPluginVersionRequest struct { func (x *GetPluginVersionRequest) Reset() { *x = GetPluginVersionRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[14] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1427,7 +1253,7 @@ func (x *GetPluginVersionRequest) String() string { func (*GetPluginVersionRequest) ProtoMessage() {} func (x *GetPluginVersionRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[14] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1440,7 +1266,7 @@ func (x *GetPluginVersionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPluginVersionRequest.ProtoReflect.Descriptor instead. func (*GetPluginVersionRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{14} + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{12} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. @@ -1480,7 +1306,7 @@ type GetPluginVersionResponse struct { func (x *GetPluginVersionResponse) Reset() { *x = GetPluginVersionResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[15] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1493,7 +1319,7 @@ func (x *GetPluginVersionResponse) String() string { func (*GetPluginVersionResponse) ProtoMessage() {} func (x *GetPluginVersionResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[15] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1506,7 +1332,7 @@ func (x *GetPluginVersionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPluginVersionResponse.ProtoReflect.Descriptor instead. func (*GetPluginVersionResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{15} + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{13} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. @@ -1546,7 +1372,7 @@ type ListPluginVersionsRequest struct { func (x *ListPluginVersionsRequest) Reset() { *x = ListPluginVersionsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[16] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1559,7 +1385,7 @@ func (x *ListPluginVersionsRequest) String() string { func (*ListPluginVersionsRequest) ProtoMessage() {} func (x *ListPluginVersionsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[16] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1572,7 +1398,7 @@ func (x *ListPluginVersionsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPluginVersionsRequest.ProtoReflect.Descriptor instead. func (*ListPluginVersionsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{16} + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{14} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. @@ -1632,7 +1458,7 @@ type ListPluginVersionsResponse struct { func (x *ListPluginVersionsResponse) Reset() { *x = ListPluginVersionsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[17] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1645,7 +1471,7 @@ func (x *ListPluginVersionsResponse) String() string { func (*ListPluginVersionsResponse) ProtoMessage() {} func (x *ListPluginVersionsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[17] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1658,7 +1484,7 @@ func (x *ListPluginVersionsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPluginVersionsResponse.ProtoReflect.Descriptor instead. func (*ListPluginVersionsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{17} + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{15} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. @@ -1678,46 +1504,38 @@ func (x *ListPluginVersionsResponse) GetNextPageToken() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type CreatePluginRequest struct { +type GetPluginRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The owner of the plugin. This must be either the name - // of the authenticated user or an organization the user is - // authorized to create plugins in. + // The owner of the plugin. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - // The name of the plugin, i.e. "protoc-gen-go". + // The name of the plugin. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - // Whether the created plugin should be available to any user - // or only those authorized through organization membership - // or being the creator. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Visibility PluginVisibility `protobuf:"varint,3,opt,name=visibility,proto3,enum=buf.alpha.registry.v1alpha1.PluginVisibility" json:"visibility,omitempty"` } -func (x *CreatePluginRequest) Reset() { - *x = CreatePluginRequest{} +func (x *GetPluginRequest) Reset() { + *x = GetPluginRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[18] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *CreatePluginRequest) String() string { +func (x *GetPluginRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CreatePluginRequest) ProtoMessage() {} +func (*GetPluginRequest) ProtoMessage() {} -func (x *CreatePluginRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[18] +func (x *GetPluginRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1728,13 +1546,13 @@ func (x *CreatePluginRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CreatePluginRequest.ProtoReflect.Descriptor instead. -func (*CreatePluginRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{18} +// Deprecated: Use GetPluginRequest.ProtoReflect.Descriptor instead. +func (*GetPluginRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{16} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreatePluginRequest) GetOwner() string { +func (x *GetPluginRequest) GetOwner() string { if x != nil { return x.Owner } @@ -1742,7 +1560,7 @@ func (x *CreatePluginRequest) GetOwner() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreatePluginRequest) GetName() string { +func (x *GetPluginRequest) GetName() string { if x != nil { return x.Name } @@ -1750,42 +1568,32 @@ func (x *CreatePluginRequest) GetName() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreatePluginRequest) GetVisibility() PluginVisibility { - if x != nil { - return x.Visibility - } - return PluginVisibility_PLUGIN_VISIBILITY_UNSPECIFIED -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type CreatePluginResponse struct { +type GetPluginResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The created plugin. - // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. Plugin *Plugin `protobuf:"bytes,1,opt,name=plugin,proto3" json:"plugin,omitempty"` } -func (x *CreatePluginResponse) Reset() { - *x = CreatePluginResponse{} +func (x *GetPluginResponse) Reset() { + *x = GetPluginResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[19] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *CreatePluginResponse) String() string { +func (x *GetPluginResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CreatePluginResponse) ProtoMessage() {} +func (*GetPluginResponse) ProtoMessage() {} -func (x *CreatePluginResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[19] +func (x *GetPluginResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[17] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1796,13 +1604,13 @@ func (x *CreatePluginResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CreatePluginResponse.ProtoReflect.Descriptor instead. -func (*CreatePluginResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{19} +// Deprecated: Use GetPluginResponse.ProtoReflect.Descriptor instead. +func (*GetPluginResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{17} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreatePluginResponse) GetPlugin() *Plugin { +func (x *GetPluginResponse) GetPlugin() *Plugin { if x != nil { return x.Plugin } @@ -1810,38 +1618,38 @@ func (x *CreatePluginResponse) GetPlugin() *Plugin { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type GetPluginRequest struct { +type DeletePluginRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The owner of the plugin. + // The owner of the plugin to delete. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - // The name of the plugin. + // The name of the plugin to delete. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` } -func (x *GetPluginRequest) Reset() { - *x = GetPluginRequest{} +func (x *DeletePluginRequest) Reset() { + *x = DeletePluginRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[20] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *GetPluginRequest) String() string { +func (x *DeletePluginRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetPluginRequest) ProtoMessage() {} +func (*DeletePluginRequest) ProtoMessage() {} -func (x *GetPluginRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[20] +func (x *DeletePluginRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1852,13 +1660,13 @@ func (x *GetPluginRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetPluginRequest.ProtoReflect.Descriptor instead. -func (*GetPluginRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{20} +// Deprecated: Use DeletePluginRequest.ProtoReflect.Descriptor instead. +func (*DeletePluginRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{18} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *GetPluginRequest) GetOwner() string { +func (x *DeletePluginRequest) GetOwner() string { if x != nil { return x.Owner } @@ -1866,7 +1674,7 @@ func (x *GetPluginRequest) GetOwner() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *GetPluginRequest) GetName() string { +func (x *DeletePluginRequest) GetName() string { if x != nil { return x.Name } @@ -1874,32 +1682,29 @@ func (x *GetPluginRequest) GetName() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type GetPluginResponse struct { +type DeletePluginResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Plugin *Plugin `protobuf:"bytes,1,opt,name=plugin,proto3" json:"plugin,omitempty"` } -func (x *GetPluginResponse) Reset() { - *x = GetPluginResponse{} +func (x *DeletePluginResponse) Reset() { + *x = DeletePluginResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[21] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *GetPluginResponse) String() string { +func (x *DeletePluginResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetPluginResponse) ProtoMessage() {} +func (*DeletePluginResponse) ProtoMessage() {} -func (x *GetPluginResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[21] +func (x *DeletePluginResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1910,52 +1715,44 @@ func (x *GetPluginResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetPluginResponse.ProtoReflect.Descriptor instead. -func (*GetPluginResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{21} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *GetPluginResponse) GetPlugin() *Plugin { - if x != nil { - return x.Plugin - } - return nil +// Deprecated: Use DeletePluginResponse.ProtoReflect.Descriptor instead. +func (*DeletePluginResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{19} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type DeletePluginRequest struct { +type GetTemplateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The owner of the plugin to delete. + // The owner of the template. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - // The name of the plugin to delete. + // The name of the template. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` } -func (x *DeletePluginRequest) Reset() { - *x = DeletePluginRequest{} +func (x *GetTemplateRequest) Reset() { + *x = GetTemplateRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[22] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *DeletePluginRequest) String() string { +func (x *GetTemplateRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DeletePluginRequest) ProtoMessage() {} +func (*GetTemplateRequest) ProtoMessage() {} -func (x *DeletePluginRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[22] +func (x *GetTemplateRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1966,13 +1763,13 @@ func (x *DeletePluginRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DeletePluginRequest.ProtoReflect.Descriptor instead. -func (*DeletePluginRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{22} +// Deprecated: Use GetTemplateRequest.ProtoReflect.Descriptor instead. +func (*GetTemplateRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{20} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *DeletePluginRequest) GetOwner() string { +func (x *GetTemplateRequest) GetOwner() string { if x != nil { return x.Owner } @@ -1980,7 +1777,7 @@ func (x *DeletePluginRequest) GetOwner() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *DeletePluginRequest) GetName() string { +func (x *GetTemplateRequest) GetName() string { if x != nil { return x.Name } @@ -1988,29 +1785,32 @@ func (x *DeletePluginRequest) GetName() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type DeletePluginResponse struct { +type GetTemplateResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. + Template *Template `protobuf:"bytes,1,opt,name=template,proto3" json:"template,omitempty"` } -func (x *DeletePluginResponse) Reset() { - *x = DeletePluginResponse{} +func (x *GetTemplateResponse) Reset() { + *x = GetTemplateResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[23] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *DeletePluginResponse) String() string { +func (x *GetTemplateResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DeletePluginResponse) ProtoMessage() {} +func (*GetTemplateResponse) ProtoMessage() {} -func (x *DeletePluginResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[23] +func (x *GetTemplateResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2021,49 +1821,52 @@ func (x *DeletePluginResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DeletePluginResponse.ProtoReflect.Descriptor instead. -func (*DeletePluginResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{23} +// Deprecated: Use GetTemplateResponse.ProtoReflect.Descriptor instead. +func (*GetTemplateResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{21} +} + +// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. +func (x *GetTemplateResponse) GetTemplate() *Template { + if x != nil { + return x.Template + } + return nil } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type SetPluginContributorRequest struct { +type ListTemplatesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The ID of the plugin for which the user's role will be set. - // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PluginId string `protobuf:"bytes,1,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` - // The ID of the user whose role will be set. + PageSize uint32 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + // The first page is returned if this is empty. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - // The role to assign to the user. - // Setting UNSPECIFIED means removing the user's role. - // + PageToken string `protobuf:"bytes,2,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PluginRole PluginRole `protobuf:"varint,3,opt,name=plugin_role,json=pluginRole,proto3,enum=buf.alpha.registry.v1alpha1.PluginRole" json:"plugin_role,omitempty"` + Reverse bool `protobuf:"varint,3,opt,name=reverse,proto3" json:"reverse,omitempty"` } -func (x *SetPluginContributorRequest) Reset() { - *x = SetPluginContributorRequest{} +func (x *ListTemplatesRequest) Reset() { + *x = ListTemplatesRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[24] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *SetPluginContributorRequest) String() string { +func (x *ListTemplatesRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SetPluginContributorRequest) ProtoMessage() {} +func (*ListTemplatesRequest) ProtoMessage() {} -func (x *SetPluginContributorRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[24] +func (x *ListTemplatesRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2074,59 +1877,66 @@ func (x *SetPluginContributorRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SetPluginContributorRequest.ProtoReflect.Descriptor instead. -func (*SetPluginContributorRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{24} +// Deprecated: Use ListTemplatesRequest.ProtoReflect.Descriptor instead. +func (*ListTemplatesRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{22} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *SetPluginContributorRequest) GetPluginId() string { +func (x *ListTemplatesRequest) GetPageSize() uint32 { if x != nil { - return x.PluginId + return x.PageSize } - return "" + return 0 } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *SetPluginContributorRequest) GetUserId() string { +func (x *ListTemplatesRequest) GetPageToken() string { if x != nil { - return x.UserId + return x.PageToken } return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *SetPluginContributorRequest) GetPluginRole() PluginRole { +func (x *ListTemplatesRequest) GetReverse() bool { if x != nil { - return x.PluginRole + return x.Reverse } - return PluginRole_PLUGIN_ROLE_UNSPECIFIED + return false } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type SetPluginContributorResponse struct { +type ListTemplatesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. + Templates []*Template `protobuf:"bytes,1,rep,name=templates,proto3" json:"templates,omitempty"` + // There are no more pages if this is empty. + // + // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. + NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` } -func (x *SetPluginContributorResponse) Reset() { - *x = SetPluginContributorResponse{} +func (x *ListTemplatesResponse) Reset() { + *x = ListTemplatesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[25] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *SetPluginContributorResponse) String() string { +func (x *ListTemplatesResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SetPluginContributorResponse) ProtoMessage() {} +func (*ListTemplatesResponse) ProtoMessage() {} -func (x *SetPluginContributorResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[25] +func (x *ListTemplatesResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[23] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2137,46 +1947,60 @@ func (x *SetPluginContributorResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SetPluginContributorResponse.ProtoReflect.Descriptor instead. -func (*SetPluginContributorResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{25} +// Deprecated: Use ListTemplatesResponse.ProtoReflect.Descriptor instead. +func (*ListTemplatesResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{23} +} + +// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. +func (x *ListTemplatesResponse) GetTemplates() []*Template { + if x != nil { + return x.Templates + } + return nil +} + +// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. +func (x *ListTemplatesResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListPluginContributorsRequest struct { +type ListTemplatesUserCanAccessRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PluginId string `protobuf:"bytes,1,opt,name=plugin_id,json=pluginId,proto3" json:"plugin_id,omitempty"` - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageSize uint32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + PageSize uint32 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` // The first page is returned if this is empty. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + PageToken string `protobuf:"bytes,2,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Reverse bool `protobuf:"varint,4,opt,name=reverse,proto3" json:"reverse,omitempty"` + Reverse bool `protobuf:"varint,3,opt,name=reverse,proto3" json:"reverse,omitempty"` } -func (x *ListPluginContributorsRequest) Reset() { - *x = ListPluginContributorsRequest{} +func (x *ListTemplatesUserCanAccessRequest) Reset() { + *x = ListTemplatesUserCanAccessRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[26] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *ListPluginContributorsRequest) String() string { +func (x *ListTemplatesUserCanAccessRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ListPluginContributorsRequest) ProtoMessage() {} +func (*ListTemplatesUserCanAccessRequest) ProtoMessage() {} -func (x *ListPluginContributorsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[26] +func (x *ListTemplatesUserCanAccessRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[24] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2187,21 +2011,13 @@ func (x *ListPluginContributorsRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ListPluginContributorsRequest.ProtoReflect.Descriptor instead. -func (*ListPluginContributorsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{26} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListPluginContributorsRequest) GetPluginId() string { - if x != nil { - return x.PluginId - } - return "" +// Deprecated: Use ListTemplatesUserCanAccessRequest.ProtoReflect.Descriptor instead. +func (*ListTemplatesUserCanAccessRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{24} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListPluginContributorsRequest) GetPageSize() uint32 { +func (x *ListTemplatesUserCanAccessRequest) GetPageSize() uint32 { if x != nil { return x.PageSize } @@ -2209,7 +2025,7 @@ func (x *ListPluginContributorsRequest) GetPageSize() uint32 { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListPluginContributorsRequest) GetPageToken() string { +func (x *ListTemplatesUserCanAccessRequest) GetPageToken() string { if x != nil { return x.PageToken } @@ -2217,7 +2033,7 @@ func (x *ListPluginContributorsRequest) GetPageToken() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListPluginContributorsRequest) GetReverse() bool { +func (x *ListTemplatesUserCanAccessRequest) GetReverse() bool { if x != nil { return x.Reverse } @@ -2225,36 +2041,36 @@ func (x *ListPluginContributorsRequest) GetReverse() bool { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListPluginContributorsResponse struct { +type ListTemplatesUserCanAccessResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Users []*PluginContributor `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` + Templates []*Template `protobuf:"bytes,1,rep,name=templates,proto3" json:"templates,omitempty"` // There are no more pages if this is empty. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` } -func (x *ListPluginContributorsResponse) Reset() { - *x = ListPluginContributorsResponse{} +func (x *ListTemplatesUserCanAccessResponse) Reset() { + *x = ListTemplatesUserCanAccessResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[27] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *ListPluginContributorsResponse) String() string { +func (x *ListTemplatesUserCanAccessResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ListPluginContributorsResponse) ProtoMessage() {} +func (*ListTemplatesUserCanAccessResponse) ProtoMessage() {} -func (x *ListPluginContributorsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[27] +func (x *ListTemplatesUserCanAccessResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[25] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2265,21 +2081,21 @@ func (x *ListPluginContributorsResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ListPluginContributorsResponse.ProtoReflect.Descriptor instead. -func (*ListPluginContributorsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{27} +// Deprecated: Use ListTemplatesUserCanAccessResponse.ProtoReflect.Descriptor instead. +func (*ListTemplatesUserCanAccessResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{25} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListPluginContributorsResponse) GetUsers() []*PluginContributor { +func (x *ListTemplatesUserCanAccessResponse) GetTemplates() []*Template { if x != nil { - return x.Users + return x.Templates } return nil } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListPluginContributorsResponse) GetNextPageToken() string { +func (x *ListTemplatesUserCanAccessResponse) GetNextPageToken() string { if x != nil { return x.NextPageToken } @@ -2287,38 +2103,42 @@ func (x *ListPluginContributorsResponse) GetNextPageToken() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type GetTemplateRequest struct { +type ListUserTemplatesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The owner of the template. + // The owner of the templates to list for. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - // The name of the template. + // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. + PageSize uint32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + // The first page is returned if this is empty. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. + Reverse bool `protobuf:"varint,4,opt,name=reverse,proto3" json:"reverse,omitempty"` } -func (x *GetTemplateRequest) Reset() { - *x = GetTemplateRequest{} +func (x *ListUserTemplatesRequest) Reset() { + *x = ListUserTemplatesRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[28] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *GetTemplateRequest) String() string { +func (x *ListUserTemplatesRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetTemplateRequest) ProtoMessage() {} +func (*ListUserTemplatesRequest) ProtoMessage() {} -func (x *GetTemplateRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[28] +func (x *ListUserTemplatesRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[26] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2329,13 +2149,13 @@ func (x *GetTemplateRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetTemplateRequest.ProtoReflect.Descriptor instead. -func (*GetTemplateRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{28} +// Deprecated: Use ListUserTemplatesRequest.ProtoReflect.Descriptor instead. +func (*ListUserTemplatesRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{26} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *GetTemplateRequest) GetOwner() string { +func (x *ListUserTemplatesRequest) GetOwner() string { if x != nil { return x.Owner } @@ -2343,841 +2163,23 @@ func (x *GetTemplateRequest) GetOwner() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *GetTemplateRequest) GetName() string { +func (x *ListUserTemplatesRequest) GetPageSize() uint32 { if x != nil { - return x.Name + return x.PageSize + } + return 0 +} + +// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. +func (x *ListUserTemplatesRequest) GetPageToken() string { + if x != nil { + return x.PageToken } return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type GetTemplateResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Template *Template `protobuf:"bytes,1,opt,name=template,proto3" json:"template,omitempty"` -} - -func (x *GetTemplateResponse) Reset() { - *x = GetTemplateResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[29] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetTemplateResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetTemplateResponse) ProtoMessage() {} - -func (x *GetTemplateResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[29] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetTemplateResponse.ProtoReflect.Descriptor instead. -func (*GetTemplateResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{29} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *GetTemplateResponse) GetTemplate() *Template { - if x != nil { - return x.Template - } - return nil -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListTemplatesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageSize uint32 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` - // The first page is returned if this is empty. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageToken string `protobuf:"bytes,2,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Reverse bool `protobuf:"varint,3,opt,name=reverse,proto3" json:"reverse,omitempty"` -} - -func (x *ListTemplatesRequest) Reset() { - *x = ListTemplatesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[30] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListTemplatesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListTemplatesRequest) ProtoMessage() {} - -func (x *ListTemplatesRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[30] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListTemplatesRequest.ProtoReflect.Descriptor instead. -func (*ListTemplatesRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{30} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplatesRequest) GetPageSize() uint32 { - if x != nil { - return x.PageSize - } - return 0 -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplatesRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplatesRequest) GetReverse() bool { - if x != nil { - return x.Reverse - } - return false -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListTemplatesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Templates []*Template `protobuf:"bytes,1,rep,name=templates,proto3" json:"templates,omitempty"` - // There are no more pages if this is empty. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` -} - -func (x *ListTemplatesResponse) Reset() { - *x = ListTemplatesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[31] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListTemplatesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListTemplatesResponse) ProtoMessage() {} - -func (x *ListTemplatesResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[31] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListTemplatesResponse.ProtoReflect.Descriptor instead. -func (*ListTemplatesResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{31} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplatesResponse) GetTemplates() []*Template { - if x != nil { - return x.Templates - } - return nil -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplatesResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListTemplatesUserCanAccessRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageSize uint32 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` - // The first page is returned if this is empty. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageToken string `protobuf:"bytes,2,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Reverse bool `protobuf:"varint,3,opt,name=reverse,proto3" json:"reverse,omitempty"` -} - -func (x *ListTemplatesUserCanAccessRequest) Reset() { - *x = ListTemplatesUserCanAccessRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[32] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListTemplatesUserCanAccessRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListTemplatesUserCanAccessRequest) ProtoMessage() {} - -func (x *ListTemplatesUserCanAccessRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[32] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListTemplatesUserCanAccessRequest.ProtoReflect.Descriptor instead. -func (*ListTemplatesUserCanAccessRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{32} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplatesUserCanAccessRequest) GetPageSize() uint32 { - if x != nil { - return x.PageSize - } - return 0 -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplatesUserCanAccessRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplatesUserCanAccessRequest) GetReverse() bool { - if x != nil { - return x.Reverse - } - return false -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListTemplatesUserCanAccessResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Templates []*Template `protobuf:"bytes,1,rep,name=templates,proto3" json:"templates,omitempty"` - // There are no more pages if this is empty. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` -} - -func (x *ListTemplatesUserCanAccessResponse) Reset() { - *x = ListTemplatesUserCanAccessResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[33] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListTemplatesUserCanAccessResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListTemplatesUserCanAccessResponse) ProtoMessage() {} - -func (x *ListTemplatesUserCanAccessResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[33] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListTemplatesUserCanAccessResponse.ProtoReflect.Descriptor instead. -func (*ListTemplatesUserCanAccessResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{33} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplatesUserCanAccessResponse) GetTemplates() []*Template { - if x != nil { - return x.Templates - } - return nil -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplatesUserCanAccessResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListUserTemplatesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The owner of the templates to list for. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageSize uint32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` - // The first page is returned if this is empty. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Reverse bool `protobuf:"varint,4,opt,name=reverse,proto3" json:"reverse,omitempty"` -} - -func (x *ListUserTemplatesRequest) Reset() { - *x = ListUserTemplatesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[34] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListUserTemplatesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUserTemplatesRequest) ProtoMessage() {} - -func (x *ListUserTemplatesRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[34] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListUserTemplatesRequest.ProtoReflect.Descriptor instead. -func (*ListUserTemplatesRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{34} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListUserTemplatesRequest) GetOwner() string { - if x != nil { - return x.Owner - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListUserTemplatesRequest) GetPageSize() uint32 { - if x != nil { - return x.PageSize - } - return 0 -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListUserTemplatesRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListUserTemplatesRequest) GetReverse() bool { - if x != nil { - return x.Reverse - } - return false -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListUserTemplatesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Templates []*Template `protobuf:"bytes,1,rep,name=templates,proto3" json:"templates,omitempty"` - // There are no more pages if this is empty. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` -} - -func (x *ListUserTemplatesResponse) Reset() { - *x = ListUserTemplatesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[35] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListUserTemplatesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUserTemplatesResponse) ProtoMessage() {} - -func (x *ListUserTemplatesResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[35] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListUserTemplatesResponse.ProtoReflect.Descriptor instead. -func (*ListUserTemplatesResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{35} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListUserTemplatesResponse) GetTemplates() []*Template { - if x != nil { - return x.Templates - } - return nil -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListUserTemplatesResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type GetTemplateVersionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The owner of the template the version belongs to. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - // The name of the template the version belongs to. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - // The name of the version. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` -} - -func (x *GetTemplateVersionRequest) Reset() { - *x = GetTemplateVersionRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[36] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetTemplateVersionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetTemplateVersionRequest) ProtoMessage() {} - -func (x *GetTemplateVersionRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[36] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetTemplateVersionRequest.ProtoReflect.Descriptor instead. -func (*GetTemplateVersionRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{36} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *GetTemplateVersionRequest) GetOwner() string { - if x != nil { - return x.Owner - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *GetTemplateVersionRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *GetTemplateVersionRequest) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type GetTemplateVersionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - TemplateVersion *TemplateVersion `protobuf:"bytes,1,opt,name=template_version,json=templateVersion,proto3" json:"template_version,omitempty"` -} - -func (x *GetTemplateVersionResponse) Reset() { - *x = GetTemplateVersionResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[37] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetTemplateVersionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetTemplateVersionResponse) ProtoMessage() {} - -func (x *GetTemplateVersionResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[37] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetTemplateVersionResponse.ProtoReflect.Descriptor instead. -func (*GetTemplateVersionResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{37} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *GetTemplateVersionResponse) GetTemplateVersion() *TemplateVersion { - if x != nil { - return x.TemplateVersion - } - return nil -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListOrganizationTemplatesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The organization of the templates to list for. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Organization string `protobuf:"bytes,1,opt,name=organization,proto3" json:"organization,omitempty"` - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageSize uint32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` - // The first page is returned if this is empty. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Reverse bool `protobuf:"varint,4,opt,name=reverse,proto3" json:"reverse,omitempty"` -} - -func (x *ListOrganizationTemplatesRequest) Reset() { - *x = ListOrganizationTemplatesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[38] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListOrganizationTemplatesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListOrganizationTemplatesRequest) ProtoMessage() {} - -func (x *ListOrganizationTemplatesRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[38] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListOrganizationTemplatesRequest.ProtoReflect.Descriptor instead. -func (*ListOrganizationTemplatesRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{38} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListOrganizationTemplatesRequest) GetOrganization() string { - if x != nil { - return x.Organization - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListOrganizationTemplatesRequest) GetPageSize() uint32 { - if x != nil { - return x.PageSize - } - return 0 -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListOrganizationTemplatesRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListOrganizationTemplatesRequest) GetReverse() bool { - if x != nil { - return x.Reverse - } - return false -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListOrganizationTemplatesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Templates []*Template `protobuf:"bytes,1,rep,name=templates,proto3" json:"templates,omitempty"` - // There are no more pages if this is empty. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` -} - -func (x *ListOrganizationTemplatesResponse) Reset() { - *x = ListOrganizationTemplatesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[39] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListOrganizationTemplatesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListOrganizationTemplatesResponse) ProtoMessage() {} - -func (x *ListOrganizationTemplatesResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[39] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListOrganizationTemplatesResponse.ProtoReflect.Descriptor instead. -func (*ListOrganizationTemplatesResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{39} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListOrganizationTemplatesResponse) GetTemplates() []*Template { - if x != nil { - return x.Templates - } - return nil -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListOrganizationTemplatesResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListTemplateVersionsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The owner of the template to list versions for. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - // The name of the template to list versions for. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - // The number of items to return. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageSize uint32 `protobuf:"varint,3,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` - // The first page is returned if this is empty. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageToken string `protobuf:"bytes,4,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Reverse bool `protobuf:"varint,5,opt,name=reverse,proto3" json:"reverse,omitempty"` -} - -func (x *ListTemplateVersionsRequest) Reset() { - *x = ListTemplateVersionsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[40] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListTemplateVersionsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListTemplateVersionsRequest) ProtoMessage() {} - -func (x *ListTemplateVersionsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[40] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListTemplateVersionsRequest.ProtoReflect.Descriptor instead. -func (*ListTemplateVersionsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{40} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateVersionsRequest) GetOwner() string { - if x != nil { - return x.Owner - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateVersionsRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateVersionsRequest) GetPageSize() uint32 { - if x != nil { - return x.PageSize - } - return 0 -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateVersionsRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateVersionsRequest) GetReverse() bool { +func (x *ListUserTemplatesRequest) GetReverse() bool { if x != nil { return x.Reverse } @@ -3185,36 +2187,36 @@ func (x *ListTemplateVersionsRequest) GetReverse() bool { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListTemplateVersionsResponse struct { +type ListUserTemplatesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - TemplateVersions []*TemplateVersion `protobuf:"bytes,1,rep,name=template_versions,json=templateVersions,proto3" json:"template_versions,omitempty"` + Templates []*Template `protobuf:"bytes,1,rep,name=templates,proto3" json:"templates,omitempty"` // There are no more pages if this is empty. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` } -func (x *ListTemplateVersionsResponse) Reset() { - *x = ListTemplateVersionsResponse{} +func (x *ListUserTemplatesResponse) Reset() { + *x = ListUserTemplatesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[41] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *ListTemplateVersionsResponse) String() string { +func (x *ListUserTemplatesResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ListTemplateVersionsResponse) ProtoMessage() {} +func (*ListUserTemplatesResponse) ProtoMessage() {} -func (x *ListTemplateVersionsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[41] +func (x *ListUserTemplatesResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[27] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3225,21 +2227,21 @@ func (x *ListTemplateVersionsResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ListTemplateVersionsResponse.ProtoReflect.Descriptor instead. -func (*ListTemplateVersionsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{41} +// Deprecated: Use ListUserTemplatesResponse.ProtoReflect.Descriptor instead. +func (*ListUserTemplatesResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{27} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateVersionsResponse) GetTemplateVersions() []*TemplateVersion { +func (x *ListUserTemplatesResponse) GetTemplates() []*Template { if x != nil { - return x.TemplateVersions + return x.Templates } return nil } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateVersionsResponse) GetNextPageToken() string { +func (x *ListUserTemplatesResponse) GetNextPageToken() string { if x != nil { return x.NextPageToken } @@ -3247,50 +2249,42 @@ func (x *ListTemplateVersionsResponse) GetNextPageToken() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type CreateTemplateRequest struct { +type GetTemplateVersionRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The owner of the template. This will be either a username - // or organization name. + // The owner of the template the version belongs to. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - // The name of the template version, i.e. "grpc-go". + // The name of the template the version belongs to. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - // Whether the created template should be available to any user - // or only those authorized through organization membership - // or being the creator. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Visibility PluginVisibility `protobuf:"varint,3,opt,name=visibility,proto3,enum=buf.alpha.registry.v1alpha1.PluginVisibility" json:"visibility,omitempty"` - // The plugins and associated runtime configuration that make - // up this template. + // The name of the version. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PluginConfigs []*PluginConfig `protobuf:"bytes,4,rep,name=plugin_configs,json=pluginConfigs,proto3" json:"plugin_configs,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` } -func (x *CreateTemplateRequest) Reset() { - *x = CreateTemplateRequest{} +func (x *GetTemplateVersionRequest) Reset() { + *x = GetTemplateVersionRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[42] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *CreateTemplateRequest) String() string { +func (x *GetTemplateVersionRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CreateTemplateRequest) ProtoMessage() {} +func (*GetTemplateVersionRequest) ProtoMessage() {} -func (x *CreateTemplateRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[42] +func (x *GetTemplateVersionRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[28] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3301,13 +2295,13 @@ func (x *CreateTemplateRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CreateTemplateRequest.ProtoReflect.Descriptor instead. -func (*CreateTemplateRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{42} +// Deprecated: Use GetTemplateVersionRequest.ProtoReflect.Descriptor instead. +func (*GetTemplateVersionRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{28} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreateTemplateRequest) GetOwner() string { +func (x *GetTemplateVersionRequest) GetOwner() string { if x != nil { return x.Owner } @@ -3315,7 +2309,7 @@ func (x *CreateTemplateRequest) GetOwner() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreateTemplateRequest) GetName() string { +func (x *GetTemplateVersionRequest) GetName() string { if x != nil { return x.Name } @@ -3323,50 +2317,40 @@ func (x *CreateTemplateRequest) GetName() string { } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreateTemplateRequest) GetVisibility() PluginVisibility { - if x != nil { - return x.Visibility - } - return PluginVisibility_PLUGIN_VISIBILITY_UNSPECIFIED -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreateTemplateRequest) GetPluginConfigs() []*PluginConfig { +func (x *GetTemplateVersionRequest) GetVersion() string { if x != nil { - return x.PluginConfigs + return x.Version } - return nil + return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type CreateTemplateResponse struct { +type GetTemplateVersionResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The created template. - // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Template *Template `protobuf:"bytes,1,opt,name=template,proto3" json:"template,omitempty"` + TemplateVersion *TemplateVersion `protobuf:"bytes,1,opt,name=template_version,json=templateVersion,proto3" json:"template_version,omitempty"` } -func (x *CreateTemplateResponse) Reset() { - *x = CreateTemplateResponse{} +func (x *GetTemplateVersionResponse) Reset() { + *x = GetTemplateVersionResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[43] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *CreateTemplateResponse) String() string { +func (x *GetTemplateVersionResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CreateTemplateResponse) ProtoMessage() {} +func (*GetTemplateVersionResponse) ProtoMessage() {} -func (x *CreateTemplateResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[43] +func (x *GetTemplateVersionResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[29] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3377,165 +2361,56 @@ func (x *CreateTemplateResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CreateTemplateResponse.ProtoReflect.Descriptor instead. -func (*CreateTemplateResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{43} +// Deprecated: Use GetTemplateVersionResponse.ProtoReflect.Descriptor instead. +func (*GetTemplateVersionResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{29} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreateTemplateResponse) GetTemplate() *Template { +func (x *GetTemplateVersionResponse) GetTemplateVersion() *TemplateVersion { if x != nil { - return x.Template + return x.TemplateVersion } return nil } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type DeleteTemplateRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The owner of the template to delete. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - // The name of the template to delete. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *DeleteTemplateRequest) Reset() { - *x = DeleteTemplateRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[44] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteTemplateRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteTemplateRequest) ProtoMessage() {} - -func (x *DeleteTemplateRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[44] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteTemplateRequest.ProtoReflect.Descriptor instead. -func (*DeleteTemplateRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{44} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *DeleteTemplateRequest) GetOwner() string { - if x != nil { - return x.Owner - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *DeleteTemplateRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type DeleteTemplateResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *DeleteTemplateResponse) Reset() { - *x = DeleteTemplateResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[45] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteTemplateResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteTemplateResponse) ProtoMessage() {} - -func (x *DeleteTemplateResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[45] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteTemplateResponse.ProtoReflect.Descriptor instead. -func (*DeleteTemplateResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{45} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type CreateTemplateVersionRequest struct { +type ListOrganizationTemplatesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The name of the template version, i.e. "v1". + // The organization of the templates to list for. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // The owner of the template. - // + Organization string `protobuf:"bytes,1,opt,name=organization,proto3" json:"organization,omitempty"` // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - TemplateOwner string `protobuf:"bytes,2,opt,name=template_owner,json=templateOwner,proto3" json:"template_owner,omitempty"` - // The name of the template. + PageSize uint32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + // The first page is returned if this is empty. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - TemplateName string `protobuf:"bytes,3,opt,name=template_name,json=templateName,proto3" json:"template_name,omitempty"` - // A map from plugin owner and name to version for the plugins - // defined in the template. Every plugin in the template - // must have a corresponding version in this array. - // + PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PluginVersions []*PluginVersionMapping `protobuf:"bytes,4,rep,name=plugin_versions,json=pluginVersions,proto3" json:"plugin_versions,omitempty"` + Reverse bool `protobuf:"varint,4,opt,name=reverse,proto3" json:"reverse,omitempty"` } -func (x *CreateTemplateVersionRequest) Reset() { - *x = CreateTemplateVersionRequest{} +func (x *ListOrganizationTemplatesRequest) Reset() { + *x = ListOrganizationTemplatesRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[46] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *CreateTemplateVersionRequest) String() string { +func (x *ListOrganizationTemplatesRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CreateTemplateVersionRequest) ProtoMessage() {} +func (*ListOrganizationTemplatesRequest) ProtoMessage() {} -func (x *CreateTemplateVersionRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[46] +func (x *ListOrganizationTemplatesRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[30] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3546,72 +2421,74 @@ func (x *CreateTemplateVersionRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CreateTemplateVersionRequest.ProtoReflect.Descriptor instead. -func (*CreateTemplateVersionRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{46} +// Deprecated: Use ListOrganizationTemplatesRequest.ProtoReflect.Descriptor instead. +func (*ListOrganizationTemplatesRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{30} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreateTemplateVersionRequest) GetName() string { +func (x *ListOrganizationTemplatesRequest) GetOrganization() string { if x != nil { - return x.Name + return x.Organization } return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreateTemplateVersionRequest) GetTemplateOwner() string { +func (x *ListOrganizationTemplatesRequest) GetPageSize() uint32 { if x != nil { - return x.TemplateOwner + return x.PageSize } - return "" + return 0 } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreateTemplateVersionRequest) GetTemplateName() string { +func (x *ListOrganizationTemplatesRequest) GetPageToken() string { if x != nil { - return x.TemplateName + return x.PageToken } return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreateTemplateVersionRequest) GetPluginVersions() []*PluginVersionMapping { +func (x *ListOrganizationTemplatesRequest) GetReverse() bool { if x != nil { - return x.PluginVersions + return x.Reverse } - return nil + return false } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type CreateTemplateVersionResponse struct { +type ListOrganizationTemplatesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The created template version. + // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. + Templates []*Template `protobuf:"bytes,1,rep,name=templates,proto3" json:"templates,omitempty"` + // There are no more pages if this is empty. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - TemplateVersion *TemplateVersion `protobuf:"bytes,1,opt,name=template_version,json=templateVersion,proto3" json:"template_version,omitempty"` + NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` } -func (x *CreateTemplateVersionResponse) Reset() { - *x = CreateTemplateVersionResponse{} +func (x *ListOrganizationTemplatesResponse) Reset() { + *x = ListOrganizationTemplatesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[47] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *CreateTemplateVersionResponse) String() string { +func (x *ListOrganizationTemplatesResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CreateTemplateVersionResponse) ProtoMessage() {} +func (*ListOrganizationTemplatesResponse) ProtoMessage() {} -func (x *CreateTemplateVersionResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[47] +func (x *ListOrganizationTemplatesResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3622,57 +2499,70 @@ func (x *CreateTemplateVersionResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CreateTemplateVersionResponse.ProtoReflect.Descriptor instead. -func (*CreateTemplateVersionResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{47} +// Deprecated: Use ListOrganizationTemplatesResponse.ProtoReflect.Descriptor instead. +func (*ListOrganizationTemplatesResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{31} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *CreateTemplateVersionResponse) GetTemplateVersion() *TemplateVersion { +func (x *ListOrganizationTemplatesResponse) GetTemplates() []*Template { if x != nil { - return x.TemplateVersion + return x.Templates } return nil } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type SetTemplateContributorRequest struct { +func (x *ListOrganizationTemplatesResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. +type ListTemplateVersionsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The ID of the template for which the user's role will be set. + // The owner of the template to list versions for. + // + // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // The name of the template to list versions for. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - TemplateId string `protobuf:"bytes,1,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` - // The ID of the user whose role will be set. + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // The number of items to return. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - // The role to assign to the user. - // Setting UNSPECIFIED means removing the user's role. + PageSize uint32 `protobuf:"varint,3,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + // The first page is returned if this is empty. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - TemplateRole TemplateRole `protobuf:"varint,3,opt,name=template_role,json=templateRole,proto3,enum=buf.alpha.registry.v1alpha1.TemplateRole" json:"template_role,omitempty"` + PageToken string `protobuf:"bytes,4,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. + Reverse bool `protobuf:"varint,5,opt,name=reverse,proto3" json:"reverse,omitempty"` } -func (x *SetTemplateContributorRequest) Reset() { - *x = SetTemplateContributorRequest{} +func (x *ListTemplateVersionsRequest) Reset() { + *x = ListTemplateVersionsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[48] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *SetTemplateContributorRequest) String() string { +func (x *ListTemplateVersionsRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SetTemplateContributorRequest) ProtoMessage() {} +func (*ListTemplateVersionsRequest) ProtoMessage() {} -func (x *SetTemplateContributorRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[48] +func (x *ListTemplateVersionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[32] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3683,59 +2573,82 @@ func (x *SetTemplateContributorRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SetTemplateContributorRequest.ProtoReflect.Descriptor instead. -func (*SetTemplateContributorRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{48} +// Deprecated: Use ListTemplateVersionsRequest.ProtoReflect.Descriptor instead. +func (*ListTemplateVersionsRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{32} +} + +// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. +func (x *ListTemplateVersionsRequest) GetOwner() string { + if x != nil { + return x.Owner + } + return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *SetTemplateContributorRequest) GetTemplateId() string { +func (x *ListTemplateVersionsRequest) GetName() string { if x != nil { - return x.TemplateId + return x.Name } return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *SetTemplateContributorRequest) GetUserId() string { +func (x *ListTemplateVersionsRequest) GetPageSize() uint32 { + if x != nil { + return x.PageSize + } + return 0 +} + +// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. +func (x *ListTemplateVersionsRequest) GetPageToken() string { if x != nil { - return x.UserId + return x.PageToken } return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *SetTemplateContributorRequest) GetTemplateRole() TemplateRole { +func (x *ListTemplateVersionsRequest) GetReverse() bool { if x != nil { - return x.TemplateRole + return x.Reverse } - return TemplateRole_TEMPLATE_ROLE_UNSPECIFIED + return false } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type SetTemplateContributorResponse struct { +type ListTemplateVersionsResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. + TemplateVersions []*TemplateVersion `protobuf:"bytes,1,rep,name=template_versions,json=templateVersions,proto3" json:"template_versions,omitempty"` + // There are no more pages if this is empty. + // + // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. + NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` } -func (x *SetTemplateContributorResponse) Reset() { - *x = SetTemplateContributorResponse{} +func (x *ListTemplateVersionsResponse) Reset() { + *x = ListTemplateVersionsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[49] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *SetTemplateContributorResponse) String() string { +func (x *ListTemplateVersionsResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SetTemplateContributorResponse) ProtoMessage() {} +func (*ListTemplateVersionsResponse) ProtoMessage() {} -func (x *SetTemplateContributorResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[49] +func (x *ListTemplateVersionsResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[33] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3746,46 +2659,60 @@ func (x *SetTemplateContributorResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SetTemplateContributorResponse.ProtoReflect.Descriptor instead. -func (*SetTemplateContributorResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{49} +// Deprecated: Use ListTemplateVersionsResponse.ProtoReflect.Descriptor instead. +func (*ListTemplateVersionsResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{33} +} + +// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. +func (x *ListTemplateVersionsResponse) GetTemplateVersions() []*TemplateVersion { + if x != nil { + return x.TemplateVersions + } + return nil +} + +// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. +func (x *ListTemplateVersionsResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListTemplateContributorsRequest struct { +type DeleteTemplateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - TemplateId string `protobuf:"bytes,1,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageSize uint32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` - // The first page is returned if this is empty. + // The owner of the template to delete. // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // The name of the template to delete. + // // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Reverse bool `protobuf:"varint,4,opt,name=reverse,proto3" json:"reverse,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` } -func (x *ListTemplateContributorsRequest) Reset() { - *x = ListTemplateContributorsRequest{} +func (x *DeleteTemplateRequest) Reset() { + *x = DeleteTemplateRequest{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[50] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *ListTemplateContributorsRequest) String() string { +func (x *DeleteTemplateRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ListTemplateContributorsRequest) ProtoMessage() {} +func (*DeleteTemplateRequest) ProtoMessage() {} -func (x *ListTemplateContributorsRequest) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[50] +func (x *DeleteTemplateRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[34] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3796,74 +2723,51 @@ func (x *ListTemplateContributorsRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ListTemplateContributorsRequest.ProtoReflect.Descriptor instead. -func (*ListTemplateContributorsRequest) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{50} +// Deprecated: Use DeleteTemplateRequest.ProtoReflect.Descriptor instead. +func (*DeleteTemplateRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{34} } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateContributorsRequest) GetTemplateId() string { +func (x *DeleteTemplateRequest) GetOwner() string { if x != nil { - return x.TemplateId + return x.Owner } return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateContributorsRequest) GetPageSize() uint32 { - if x != nil { - return x.PageSize - } - return 0 -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateContributorsRequest) GetPageToken() string { +func (x *DeleteTemplateRequest) GetName() string { if x != nil { - return x.PageToken + return x.Name } return "" } // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateContributorsRequest) GetReverse() bool { - if x != nil { - return x.Reverse - } - return false -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -type ListTemplateContributorsResponse struct { +type DeleteTemplateResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - Users []*TemplateContributor `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` - // There are no more pages if this is empty. - // - // Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. - NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` } -func (x *ListTemplateContributorsResponse) Reset() { - *x = ListTemplateContributorsResponse{} +func (x *DeleteTemplateResponse) Reset() { + *x = DeleteTemplateResponse{} if protoimpl.UnsafeEnabled { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[51] + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *ListTemplateContributorsResponse) String() string { +func (x *DeleteTemplateResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ListTemplateContributorsResponse) ProtoMessage() {} +func (*DeleteTemplateResponse) ProtoMessage() {} -func (x *ListTemplateContributorsResponse) ProtoReflect() protoreflect.Message { - mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[51] +func (x *DeleteTemplateResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[35] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3874,25 +2778,9 @@ func (x *ListTemplateContributorsResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ListTemplateContributorsResponse.ProtoReflect.Descriptor instead. -func (*ListTemplateContributorsResponse) Descriptor() ([]byte, []int) { - return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{51} -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateContributorsResponse) GetUsers() []*TemplateContributor { - if x != nil { - return x.Users - } - return nil -} - -// Deprecated: The entire proto file buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated. -func (x *ListTemplateContributorsResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" +// Deprecated: Use DeleteTemplateResponse.ProtoReflect.Descriptor instead. +func (*DeleteTemplateResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP(), []int{35} } var File_buf_alpha_registry_v1alpha1_plugin_proto protoreflect.FileDescriptor @@ -3905,11 +2793,6 @@ var file_buf_alpha_registry_v1alpha1_plugin_proto_rawDesc = []byte{ 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x2a, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x26, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2f, 0x72, 0x6f, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x26, 0x62, 0x75, 0x66, - 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xdc, 0x02, 0x0a, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, @@ -4013,464 +2896,287 @@ var file_buf_alpha_registry_v1alpha1_plugin_proto_rawDesc = []byte{ 0x22, 0x0a, 0x0c, 0x69, 0x6e, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x6e, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x64, 0x22, 0x83, 0x02, 0x0a, 0x11, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, - 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x12, 0x35, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, - 0x1b, 0x0a, 0x09, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x4c, 0x0a, 0x0d, - 0x65, 0x78, 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0c, 0x65, 0x78, - 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x4c, 0x0a, 0x0d, 0x69, 0x6d, - 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x27, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0c, 0x69, 0x6d, 0x70, 0x6c, - 0x69, 0x63, 0x69, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x22, 0x8d, 0x02, 0x0a, 0x13, 0x54, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, - 0x12, 0x35, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x73, 0x65, - 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x4e, 0x0a, 0x0d, 0x65, 0x78, 0x70, 0x6c, - 0x69, 0x63, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0c, 0x65, 0x78, 0x70, 0x6c, - 0x69, 0x63, 0x69, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x4e, 0x0a, 0x0d, 0x69, 0x6d, 0x70, 0x6c, - 0x69, 0x63, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0c, 0x69, 0x6d, 0x70, 0x6c, - 0x69, 0x63, 0x69, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x22, 0x6a, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, - 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, - 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, - 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, - 0x65, 0x72, 0x73, 0x65, 0x22, 0x7c, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x07, 0x70, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, - 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x52, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, - 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x22, 0x84, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, - 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, - 0x6e, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, - 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, - 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x80, 0x01, 0x0a, 0x17, 0x4c, 0x69, - 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, + 0x65, 0x64, 0x22, 0x6a, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, + 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, + 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x7c, + 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, - 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x9a, 0x01, 0x0a, - 0x1e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, - 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, - 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x1f, 0x4c, 0x69, - 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, - 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x52, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0f, - 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x5d, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x22, 0x6d, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x51, 0x0a, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x22, 0x9b, 0x01, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, - 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, - 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, - 0x22, 0x99, 0x01, 0x0a, 0x1a, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x53, 0x0a, 0x0f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x84, 0x01, 0x0a, + 0x16, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x1b, 0x0a, + 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, + 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, + 0x65, 0x72, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, + 0x72, 0x73, 0x65, 0x22, 0x80, 0x01, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, + 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x3d, 0x0a, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x23, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x26, + 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, + 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x9a, 0x01, 0x0a, 0x1e, 0x4c, 0x69, 0x73, 0x74, 0x4f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, + 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, + 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, + 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, + 0x65, 0x72, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, + 0x72, 0x73, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x1f, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, - 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, - 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x8e, 0x01, 0x0a, - 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x4d, - 0x0a, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, - 0x79, 0x52, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x22, 0x53, 0x0a, - 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x06, 0x70, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x22, 0x3c, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x22, 0x50, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x06, 0x70, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x22, 0x3f, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x07, 0x70, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, + 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x5d, + 0x0a, 0x17, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x22, 0x16, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x9d, 0x01, 0x0a, 0x1b, - 0x53, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, - 0x64, 0x12, 0x48, 0x0a, 0x0b, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x52, - 0x0a, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x22, 0x1e, 0x0a, 0x1c, 0x53, - 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x92, 0x01, 0x0a, 0x1d, - 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, - 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, - 0x09, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, - 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, - 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, - 0x22, 0x8e, 0x01, 0x0a, 0x1e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, - 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x6d, 0x0a, + 0x18, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x51, 0x0a, 0x0e, 0x70, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x70, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x9b, 0x01, 0x0a, + 0x19, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, + 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, + 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x99, 0x01, 0x0a, 0x1a, 0x4c, + 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0f, 0x70, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x6f, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, - 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x22, 0x3e, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x22, 0x58, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x08, 0x74, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, - 0x65, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x22, 0x6c, 0x0a, 0x14, 0x4c, - 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0e, + 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, + 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, + 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x3c, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, + 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x50, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x70, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x06, + 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x22, 0x3f, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, + 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x16, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x3e, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, + 0x58, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, + 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x22, 0x6c, 0x0a, 0x14, 0x4c, 0x69, 0x73, + 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, + 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, + 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x84, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, + 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x43, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x09, 0x74, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, + 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x79, + 0x0a, 0x21, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x55, + 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x84, 0x01, 0x0a, 0x15, 0x4c, 0x69, - 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x09, 0x74, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, - 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, - 0x22, 0x79, 0x0a, 0x21, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x73, 0x55, 0x73, 0x65, 0x72, 0x43, 0x61, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, - 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, - 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x91, 0x01, 0x0a, 0x22, - 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x55, 0x73, 0x65, - 0x72, 0x43, 0x61, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x43, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x09, 0x74, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, - 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, - 0x86, 0x01, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x54, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, - 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, - 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, - 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x19, 0x4c, 0x69, 0x73, - 0x74, 0x55, 0x73, 0x65, 0x72, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x52, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, - 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x22, 0x5f, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x75, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x57, 0x0a, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x62, - 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x74, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x9c, 0x01, 0x0a, 0x20, - 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, - 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, - 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x21, 0x4c, - 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x91, 0x01, 0x0a, 0x22, 0x4c, 0x69, + 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x55, 0x73, 0x65, 0x72, 0x43, + 0x61, 0x6e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, - 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x9d, 0x01, - 0x0a, 0x1b, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, - 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, - 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, - 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, - 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0xa1, 0x01, - 0x0a, 0x1c, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, - 0x0a, 0x11, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, - 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, + 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x86, 0x01, + 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, + 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, + 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, + 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, + 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, + 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x55, + 0x73, 0x65, 0x72, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x09, + 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x22, 0xe2, 0x01, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, - 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, - 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x4d, 0x0a, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, - 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x69, - 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, - 0x6c, 0x69, 0x74, 0x79, 0x12, 0x50, 0x0a, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x62, - 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x22, 0x5b, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x41, 0x0a, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x22, 0x41, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, - 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0xda, 0x01, 0x0a, 0x1c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, - 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x0d, - 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x5a, 0x0a, 0x0f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x0e, 0x70, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x78, 0x0a, - 0x1d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x57, - 0x0a, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xa9, 0x01, 0x0a, 0x1d, 0x53, 0x65, 0x74, 0x54, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, - 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x12, 0x4e, 0x0a, 0x0d, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, - 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, + 0x6e, 0x22, 0x5f, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, + 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, + 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x22, 0x75, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, + 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x57, 0x0a, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, - 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0c, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, - 0x6f, 0x6c, 0x65, 0x22, 0x20, 0x0a, 0x1e, 0x53, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x98, 0x01, 0x0a, 0x1f, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, - 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, - 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, - 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, - 0x22, 0x92, 0x01, 0x0a, 0x20, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, - 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, - 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x26, 0x0a, - 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x2a, 0x72, 0x0a, 0x10, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, - 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x4c, 0x55, - 0x47, 0x49, 0x4e, 0x5f, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x55, - 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1c, 0x0a, 0x18, - 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, - 0x59, 0x5f, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x10, 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x50, 0x4c, - 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, - 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x10, 0x02, 0x32, 0xdb, 0x17, 0x0a, 0x0d, 0x50, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x75, 0x0a, 0x0b, 0x4c, - 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x2f, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, - 0x02, 0x01, 0x12, 0x81, 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, - 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x99, 0x01, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x4f, - 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x73, 0x12, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, - 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, - 0x02, 0x01, 0x12, 0x84, 0x01, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x9c, 0x01, 0x0a, 0x20, 0x4c, 0x69, + 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, + 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, + 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, + 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, + 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x21, 0x4c, 0x69, 0x73, + 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, + 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, + 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, + 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x9d, 0x01, 0x0a, 0x1b, + 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, + 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, + 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, + 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, + 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, + 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x22, 0xa1, 0x01, 0x0a, 0x1c, + 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x11, + 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, + 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, + 0x41, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x72, 0x0a, 0x10, + 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, + 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x56, 0x49, 0x53, 0x49, 0x42, + 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x1c, 0x0a, 0x18, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x56, 0x49, + 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x10, + 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x56, 0x49, 0x53, 0x49, + 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x10, 0x02, + 0x32, 0x8a, 0x10, 0x0a, 0x0d, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x75, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x73, 0x12, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x81, 0x01, 0x0a, 0x0f, 0x4c, 0x69, + 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x8a, 0x01, 0x0a, 0x12, 0x4c, 0x69, - 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, - 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x73, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x30, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, + 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x99, 0x01, + 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, + 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6f, 0x0a, 0x09, 0x47, - 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x73, 0x0a, 0x0c, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x30, 0x2e, 0x62, - 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x84, 0x01, 0x0a, 0x10, 0x47, 0x65, + 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x8b, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, - 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x12, 0x38, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, + 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x96, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x6f, - 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x3a, 0x2e, 0x62, 0x75, 0x66, + 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, + 0x12, 0x8a, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x6f, 0x0a, + 0x09, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, - 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x75, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x78, + 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x30, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x75, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, @@ -4532,69 +3238,34 @@ var file_buf_alpha_registry_v1alpha1_plugin_proto_rawDesc = []byte{ 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x79, 0x0a, - 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x7e, 0x0a, + 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x32, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x79, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x32, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x8e, 0x01, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x2e, - 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x91, 0x01, 0x0a, 0x16, 0x53, 0x65, 0x74, 0x54, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x12, - 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, - 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x54, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x9c, 0x01, 0x0a, 0x18, 0x4c, 0x69, 0x73, - 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x3c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x3d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x42, 0x9b, 0x02, + 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x6f, - 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, 0x9b, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, - 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0b, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, - 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0xb8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, - 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, - 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, - 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, - 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, - 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x31, 0x42, 0x0b, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, + 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, + 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xb8, 0x01, 0x01, 0xa2, 0x02, + 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, + 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -4610,7 +3281,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_rawDescGZIP() []byte { } var file_buf_alpha_registry_v1alpha1_plugin_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 52) +var file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 36) var file_buf_alpha_registry_v1alpha1_plugin_proto_goTypes = []interface{}{ (PluginVisibility)(0), // 0: buf.alpha.registry.v1alpha1.PluginVisibility (*Plugin)(nil), // 1: buf.alpha.registry.v1alpha1.Plugin @@ -4619,147 +3290,97 @@ var file_buf_alpha_registry_v1alpha1_plugin_proto_goTypes = []interface{}{ (*PluginConfig)(nil), // 4: buf.alpha.registry.v1alpha1.PluginConfig (*TemplateVersion)(nil), // 5: buf.alpha.registry.v1alpha1.TemplateVersion (*PluginVersionMapping)(nil), // 6: buf.alpha.registry.v1alpha1.PluginVersionMapping - (*PluginContributor)(nil), // 7: buf.alpha.registry.v1alpha1.PluginContributor - (*TemplateContributor)(nil), // 8: buf.alpha.registry.v1alpha1.TemplateContributor - (*ListPluginsRequest)(nil), // 9: buf.alpha.registry.v1alpha1.ListPluginsRequest - (*ListPluginsResponse)(nil), // 10: buf.alpha.registry.v1alpha1.ListPluginsResponse - (*ListUserPluginsRequest)(nil), // 11: buf.alpha.registry.v1alpha1.ListUserPluginsRequest - (*ListUserPluginsResponse)(nil), // 12: buf.alpha.registry.v1alpha1.ListUserPluginsResponse - (*ListOrganizationPluginsRequest)(nil), // 13: buf.alpha.registry.v1alpha1.ListOrganizationPluginsRequest - (*ListOrganizationPluginsResponse)(nil), // 14: buf.alpha.registry.v1alpha1.ListOrganizationPluginsResponse - (*GetPluginVersionRequest)(nil), // 15: buf.alpha.registry.v1alpha1.GetPluginVersionRequest - (*GetPluginVersionResponse)(nil), // 16: buf.alpha.registry.v1alpha1.GetPluginVersionResponse - (*ListPluginVersionsRequest)(nil), // 17: buf.alpha.registry.v1alpha1.ListPluginVersionsRequest - (*ListPluginVersionsResponse)(nil), // 18: buf.alpha.registry.v1alpha1.ListPluginVersionsResponse - (*CreatePluginRequest)(nil), // 19: buf.alpha.registry.v1alpha1.CreatePluginRequest - (*CreatePluginResponse)(nil), // 20: buf.alpha.registry.v1alpha1.CreatePluginResponse - (*GetPluginRequest)(nil), // 21: buf.alpha.registry.v1alpha1.GetPluginRequest - (*GetPluginResponse)(nil), // 22: buf.alpha.registry.v1alpha1.GetPluginResponse - (*DeletePluginRequest)(nil), // 23: buf.alpha.registry.v1alpha1.DeletePluginRequest - (*DeletePluginResponse)(nil), // 24: buf.alpha.registry.v1alpha1.DeletePluginResponse - (*SetPluginContributorRequest)(nil), // 25: buf.alpha.registry.v1alpha1.SetPluginContributorRequest - (*SetPluginContributorResponse)(nil), // 26: buf.alpha.registry.v1alpha1.SetPluginContributorResponse - (*ListPluginContributorsRequest)(nil), // 27: buf.alpha.registry.v1alpha1.ListPluginContributorsRequest - (*ListPluginContributorsResponse)(nil), // 28: buf.alpha.registry.v1alpha1.ListPluginContributorsResponse - (*GetTemplateRequest)(nil), // 29: buf.alpha.registry.v1alpha1.GetTemplateRequest - (*GetTemplateResponse)(nil), // 30: buf.alpha.registry.v1alpha1.GetTemplateResponse - (*ListTemplatesRequest)(nil), // 31: buf.alpha.registry.v1alpha1.ListTemplatesRequest - (*ListTemplatesResponse)(nil), // 32: buf.alpha.registry.v1alpha1.ListTemplatesResponse - (*ListTemplatesUserCanAccessRequest)(nil), // 33: buf.alpha.registry.v1alpha1.ListTemplatesUserCanAccessRequest - (*ListTemplatesUserCanAccessResponse)(nil), // 34: buf.alpha.registry.v1alpha1.ListTemplatesUserCanAccessResponse - (*ListUserTemplatesRequest)(nil), // 35: buf.alpha.registry.v1alpha1.ListUserTemplatesRequest - (*ListUserTemplatesResponse)(nil), // 36: buf.alpha.registry.v1alpha1.ListUserTemplatesResponse - (*GetTemplateVersionRequest)(nil), // 37: buf.alpha.registry.v1alpha1.GetTemplateVersionRequest - (*GetTemplateVersionResponse)(nil), // 38: buf.alpha.registry.v1alpha1.GetTemplateVersionResponse - (*ListOrganizationTemplatesRequest)(nil), // 39: buf.alpha.registry.v1alpha1.ListOrganizationTemplatesRequest - (*ListOrganizationTemplatesResponse)(nil), // 40: buf.alpha.registry.v1alpha1.ListOrganizationTemplatesResponse - (*ListTemplateVersionsRequest)(nil), // 41: buf.alpha.registry.v1alpha1.ListTemplateVersionsRequest - (*ListTemplateVersionsResponse)(nil), // 42: buf.alpha.registry.v1alpha1.ListTemplateVersionsResponse - (*CreateTemplateRequest)(nil), // 43: buf.alpha.registry.v1alpha1.CreateTemplateRequest - (*CreateTemplateResponse)(nil), // 44: buf.alpha.registry.v1alpha1.CreateTemplateResponse - (*DeleteTemplateRequest)(nil), // 45: buf.alpha.registry.v1alpha1.DeleteTemplateRequest - (*DeleteTemplateResponse)(nil), // 46: buf.alpha.registry.v1alpha1.DeleteTemplateResponse - (*CreateTemplateVersionRequest)(nil), // 47: buf.alpha.registry.v1alpha1.CreateTemplateVersionRequest - (*CreateTemplateVersionResponse)(nil), // 48: buf.alpha.registry.v1alpha1.CreateTemplateVersionResponse - (*SetTemplateContributorRequest)(nil), // 49: buf.alpha.registry.v1alpha1.SetTemplateContributorRequest - (*SetTemplateContributorResponse)(nil), // 50: buf.alpha.registry.v1alpha1.SetTemplateContributorResponse - (*ListTemplateContributorsRequest)(nil), // 51: buf.alpha.registry.v1alpha1.ListTemplateContributorsRequest - (*ListTemplateContributorsResponse)(nil), // 52: buf.alpha.registry.v1alpha1.ListTemplateContributorsResponse - (*timestamppb.Timestamp)(nil), // 53: google.protobuf.Timestamp - (*RuntimeLibrary)(nil), // 54: buf.alpha.registry.v1alpha1.RuntimeLibrary - (*User)(nil), // 55: buf.alpha.registry.v1alpha1.User - (PluginRole)(0), // 56: buf.alpha.registry.v1alpha1.PluginRole - (TemplateRole)(0), // 57: buf.alpha.registry.v1alpha1.TemplateRole + (*ListPluginsRequest)(nil), // 7: buf.alpha.registry.v1alpha1.ListPluginsRequest + (*ListPluginsResponse)(nil), // 8: buf.alpha.registry.v1alpha1.ListPluginsResponse + (*ListUserPluginsRequest)(nil), // 9: buf.alpha.registry.v1alpha1.ListUserPluginsRequest + (*ListUserPluginsResponse)(nil), // 10: buf.alpha.registry.v1alpha1.ListUserPluginsResponse + (*ListOrganizationPluginsRequest)(nil), // 11: buf.alpha.registry.v1alpha1.ListOrganizationPluginsRequest + (*ListOrganizationPluginsResponse)(nil), // 12: buf.alpha.registry.v1alpha1.ListOrganizationPluginsResponse + (*GetPluginVersionRequest)(nil), // 13: buf.alpha.registry.v1alpha1.GetPluginVersionRequest + (*GetPluginVersionResponse)(nil), // 14: buf.alpha.registry.v1alpha1.GetPluginVersionResponse + (*ListPluginVersionsRequest)(nil), // 15: buf.alpha.registry.v1alpha1.ListPluginVersionsRequest + (*ListPluginVersionsResponse)(nil), // 16: buf.alpha.registry.v1alpha1.ListPluginVersionsResponse + (*GetPluginRequest)(nil), // 17: buf.alpha.registry.v1alpha1.GetPluginRequest + (*GetPluginResponse)(nil), // 18: buf.alpha.registry.v1alpha1.GetPluginResponse + (*DeletePluginRequest)(nil), // 19: buf.alpha.registry.v1alpha1.DeletePluginRequest + (*DeletePluginResponse)(nil), // 20: buf.alpha.registry.v1alpha1.DeletePluginResponse + (*GetTemplateRequest)(nil), // 21: buf.alpha.registry.v1alpha1.GetTemplateRequest + (*GetTemplateResponse)(nil), // 22: buf.alpha.registry.v1alpha1.GetTemplateResponse + (*ListTemplatesRequest)(nil), // 23: buf.alpha.registry.v1alpha1.ListTemplatesRequest + (*ListTemplatesResponse)(nil), // 24: buf.alpha.registry.v1alpha1.ListTemplatesResponse + (*ListTemplatesUserCanAccessRequest)(nil), // 25: buf.alpha.registry.v1alpha1.ListTemplatesUserCanAccessRequest + (*ListTemplatesUserCanAccessResponse)(nil), // 26: buf.alpha.registry.v1alpha1.ListTemplatesUserCanAccessResponse + (*ListUserTemplatesRequest)(nil), // 27: buf.alpha.registry.v1alpha1.ListUserTemplatesRequest + (*ListUserTemplatesResponse)(nil), // 28: buf.alpha.registry.v1alpha1.ListUserTemplatesResponse + (*GetTemplateVersionRequest)(nil), // 29: buf.alpha.registry.v1alpha1.GetTemplateVersionRequest + (*GetTemplateVersionResponse)(nil), // 30: buf.alpha.registry.v1alpha1.GetTemplateVersionResponse + (*ListOrganizationTemplatesRequest)(nil), // 31: buf.alpha.registry.v1alpha1.ListOrganizationTemplatesRequest + (*ListOrganizationTemplatesResponse)(nil), // 32: buf.alpha.registry.v1alpha1.ListOrganizationTemplatesResponse + (*ListTemplateVersionsRequest)(nil), // 33: buf.alpha.registry.v1alpha1.ListTemplateVersionsRequest + (*ListTemplateVersionsResponse)(nil), // 34: buf.alpha.registry.v1alpha1.ListTemplateVersionsResponse + (*DeleteTemplateRequest)(nil), // 35: buf.alpha.registry.v1alpha1.DeleteTemplateRequest + (*DeleteTemplateResponse)(nil), // 36: buf.alpha.registry.v1alpha1.DeleteTemplateResponse + (*timestamppb.Timestamp)(nil), // 37: google.protobuf.Timestamp + (*RuntimeLibrary)(nil), // 38: buf.alpha.registry.v1alpha1.RuntimeLibrary } var file_buf_alpha_registry_v1alpha1_plugin_proto_depIdxs = []int32{ 0, // 0: buf.alpha.registry.v1alpha1.Plugin.visibility:type_name -> buf.alpha.registry.v1alpha1.PluginVisibility - 53, // 1: buf.alpha.registry.v1alpha1.Plugin.create_time:type_name -> google.protobuf.Timestamp - 53, // 2: buf.alpha.registry.v1alpha1.Plugin.update_time:type_name -> google.protobuf.Timestamp - 54, // 3: buf.alpha.registry.v1alpha1.PluginVersion.runtime_libraries:type_name -> buf.alpha.registry.v1alpha1.RuntimeLibrary + 37, // 1: buf.alpha.registry.v1alpha1.Plugin.create_time:type_name -> google.protobuf.Timestamp + 37, // 2: buf.alpha.registry.v1alpha1.Plugin.update_time:type_name -> google.protobuf.Timestamp + 38, // 3: buf.alpha.registry.v1alpha1.PluginVersion.runtime_libraries:type_name -> buf.alpha.registry.v1alpha1.RuntimeLibrary 4, // 4: buf.alpha.registry.v1alpha1.Template.plugin_configs:type_name -> buf.alpha.registry.v1alpha1.PluginConfig 0, // 5: buf.alpha.registry.v1alpha1.Template.visibility:type_name -> buf.alpha.registry.v1alpha1.PluginVisibility - 53, // 6: buf.alpha.registry.v1alpha1.Template.create_time:type_name -> google.protobuf.Timestamp - 53, // 7: buf.alpha.registry.v1alpha1.Template.update_time:type_name -> google.protobuf.Timestamp + 37, // 6: buf.alpha.registry.v1alpha1.Template.create_time:type_name -> google.protobuf.Timestamp + 37, // 7: buf.alpha.registry.v1alpha1.Template.update_time:type_name -> google.protobuf.Timestamp 6, // 8: buf.alpha.registry.v1alpha1.TemplateVersion.plugin_versions:type_name -> buf.alpha.registry.v1alpha1.PluginVersionMapping - 55, // 9: buf.alpha.registry.v1alpha1.PluginContributor.user:type_name -> buf.alpha.registry.v1alpha1.User - 56, // 10: buf.alpha.registry.v1alpha1.PluginContributor.explicit_role:type_name -> buf.alpha.registry.v1alpha1.PluginRole - 56, // 11: buf.alpha.registry.v1alpha1.PluginContributor.implicit_role:type_name -> buf.alpha.registry.v1alpha1.PluginRole - 55, // 12: buf.alpha.registry.v1alpha1.TemplateContributor.user:type_name -> buf.alpha.registry.v1alpha1.User - 57, // 13: buf.alpha.registry.v1alpha1.TemplateContributor.explicit_role:type_name -> buf.alpha.registry.v1alpha1.TemplateRole - 57, // 14: buf.alpha.registry.v1alpha1.TemplateContributor.implicit_role:type_name -> buf.alpha.registry.v1alpha1.TemplateRole - 1, // 15: buf.alpha.registry.v1alpha1.ListPluginsResponse.plugins:type_name -> buf.alpha.registry.v1alpha1.Plugin - 1, // 16: buf.alpha.registry.v1alpha1.ListUserPluginsResponse.plugins:type_name -> buf.alpha.registry.v1alpha1.Plugin - 1, // 17: buf.alpha.registry.v1alpha1.ListOrganizationPluginsResponse.plugins:type_name -> buf.alpha.registry.v1alpha1.Plugin - 2, // 18: buf.alpha.registry.v1alpha1.GetPluginVersionResponse.plugin_version:type_name -> buf.alpha.registry.v1alpha1.PluginVersion - 2, // 19: buf.alpha.registry.v1alpha1.ListPluginVersionsResponse.plugin_versions:type_name -> buf.alpha.registry.v1alpha1.PluginVersion - 0, // 20: buf.alpha.registry.v1alpha1.CreatePluginRequest.visibility:type_name -> buf.alpha.registry.v1alpha1.PluginVisibility - 1, // 21: buf.alpha.registry.v1alpha1.CreatePluginResponse.plugin:type_name -> buf.alpha.registry.v1alpha1.Plugin - 1, // 22: buf.alpha.registry.v1alpha1.GetPluginResponse.plugin:type_name -> buf.alpha.registry.v1alpha1.Plugin - 56, // 23: buf.alpha.registry.v1alpha1.SetPluginContributorRequest.plugin_role:type_name -> buf.alpha.registry.v1alpha1.PluginRole - 7, // 24: buf.alpha.registry.v1alpha1.ListPluginContributorsResponse.users:type_name -> buf.alpha.registry.v1alpha1.PluginContributor - 3, // 25: buf.alpha.registry.v1alpha1.GetTemplateResponse.template:type_name -> buf.alpha.registry.v1alpha1.Template - 3, // 26: buf.alpha.registry.v1alpha1.ListTemplatesResponse.templates:type_name -> buf.alpha.registry.v1alpha1.Template - 3, // 27: buf.alpha.registry.v1alpha1.ListTemplatesUserCanAccessResponse.templates:type_name -> buf.alpha.registry.v1alpha1.Template - 3, // 28: buf.alpha.registry.v1alpha1.ListUserTemplatesResponse.templates:type_name -> buf.alpha.registry.v1alpha1.Template - 5, // 29: buf.alpha.registry.v1alpha1.GetTemplateVersionResponse.template_version:type_name -> buf.alpha.registry.v1alpha1.TemplateVersion - 3, // 30: buf.alpha.registry.v1alpha1.ListOrganizationTemplatesResponse.templates:type_name -> buf.alpha.registry.v1alpha1.Template - 5, // 31: buf.alpha.registry.v1alpha1.ListTemplateVersionsResponse.template_versions:type_name -> buf.alpha.registry.v1alpha1.TemplateVersion - 0, // 32: buf.alpha.registry.v1alpha1.CreateTemplateRequest.visibility:type_name -> buf.alpha.registry.v1alpha1.PluginVisibility - 4, // 33: buf.alpha.registry.v1alpha1.CreateTemplateRequest.plugin_configs:type_name -> buf.alpha.registry.v1alpha1.PluginConfig - 3, // 34: buf.alpha.registry.v1alpha1.CreateTemplateResponse.template:type_name -> buf.alpha.registry.v1alpha1.Template - 6, // 35: buf.alpha.registry.v1alpha1.CreateTemplateVersionRequest.plugin_versions:type_name -> buf.alpha.registry.v1alpha1.PluginVersionMapping - 5, // 36: buf.alpha.registry.v1alpha1.CreateTemplateVersionResponse.template_version:type_name -> buf.alpha.registry.v1alpha1.TemplateVersion - 57, // 37: buf.alpha.registry.v1alpha1.SetTemplateContributorRequest.template_role:type_name -> buf.alpha.registry.v1alpha1.TemplateRole - 8, // 38: buf.alpha.registry.v1alpha1.ListTemplateContributorsResponse.users:type_name -> buf.alpha.registry.v1alpha1.TemplateContributor - 9, // 39: buf.alpha.registry.v1alpha1.PluginService.ListPlugins:input_type -> buf.alpha.registry.v1alpha1.ListPluginsRequest - 11, // 40: buf.alpha.registry.v1alpha1.PluginService.ListUserPlugins:input_type -> buf.alpha.registry.v1alpha1.ListUserPluginsRequest - 13, // 41: buf.alpha.registry.v1alpha1.PluginService.ListOrganizationPlugins:input_type -> buf.alpha.registry.v1alpha1.ListOrganizationPluginsRequest - 15, // 42: buf.alpha.registry.v1alpha1.PluginService.GetPluginVersion:input_type -> buf.alpha.registry.v1alpha1.GetPluginVersionRequest - 17, // 43: buf.alpha.registry.v1alpha1.PluginService.ListPluginVersions:input_type -> buf.alpha.registry.v1alpha1.ListPluginVersionsRequest - 19, // 44: buf.alpha.registry.v1alpha1.PluginService.CreatePlugin:input_type -> buf.alpha.registry.v1alpha1.CreatePluginRequest - 21, // 45: buf.alpha.registry.v1alpha1.PluginService.GetPlugin:input_type -> buf.alpha.registry.v1alpha1.GetPluginRequest - 23, // 46: buf.alpha.registry.v1alpha1.PluginService.DeletePlugin:input_type -> buf.alpha.registry.v1alpha1.DeletePluginRequest - 25, // 47: buf.alpha.registry.v1alpha1.PluginService.SetPluginContributor:input_type -> buf.alpha.registry.v1alpha1.SetPluginContributorRequest - 27, // 48: buf.alpha.registry.v1alpha1.PluginService.ListPluginContributors:input_type -> buf.alpha.registry.v1alpha1.ListPluginContributorsRequest - 29, // 49: buf.alpha.registry.v1alpha1.PluginService.GetTemplate:input_type -> buf.alpha.registry.v1alpha1.GetTemplateRequest - 31, // 50: buf.alpha.registry.v1alpha1.PluginService.ListTemplates:input_type -> buf.alpha.registry.v1alpha1.ListTemplatesRequest - 33, // 51: buf.alpha.registry.v1alpha1.PluginService.ListTemplatesUserCanAccess:input_type -> buf.alpha.registry.v1alpha1.ListTemplatesUserCanAccessRequest - 35, // 52: buf.alpha.registry.v1alpha1.PluginService.ListUserTemplates:input_type -> buf.alpha.registry.v1alpha1.ListUserTemplatesRequest - 39, // 53: buf.alpha.registry.v1alpha1.PluginService.ListOrganizationTemplates:input_type -> buf.alpha.registry.v1alpha1.ListOrganizationTemplatesRequest - 37, // 54: buf.alpha.registry.v1alpha1.PluginService.GetTemplateVersion:input_type -> buf.alpha.registry.v1alpha1.GetTemplateVersionRequest - 41, // 55: buf.alpha.registry.v1alpha1.PluginService.ListTemplateVersions:input_type -> buf.alpha.registry.v1alpha1.ListTemplateVersionsRequest - 43, // 56: buf.alpha.registry.v1alpha1.PluginService.CreateTemplate:input_type -> buf.alpha.registry.v1alpha1.CreateTemplateRequest - 45, // 57: buf.alpha.registry.v1alpha1.PluginService.DeleteTemplate:input_type -> buf.alpha.registry.v1alpha1.DeleteTemplateRequest - 47, // 58: buf.alpha.registry.v1alpha1.PluginService.CreateTemplateVersion:input_type -> buf.alpha.registry.v1alpha1.CreateTemplateVersionRequest - 49, // 59: buf.alpha.registry.v1alpha1.PluginService.SetTemplateContributor:input_type -> buf.alpha.registry.v1alpha1.SetTemplateContributorRequest - 51, // 60: buf.alpha.registry.v1alpha1.PluginService.ListTemplateContributors:input_type -> buf.alpha.registry.v1alpha1.ListTemplateContributorsRequest - 10, // 61: buf.alpha.registry.v1alpha1.PluginService.ListPlugins:output_type -> buf.alpha.registry.v1alpha1.ListPluginsResponse - 12, // 62: buf.alpha.registry.v1alpha1.PluginService.ListUserPlugins:output_type -> buf.alpha.registry.v1alpha1.ListUserPluginsResponse - 14, // 63: buf.alpha.registry.v1alpha1.PluginService.ListOrganizationPlugins:output_type -> buf.alpha.registry.v1alpha1.ListOrganizationPluginsResponse - 16, // 64: buf.alpha.registry.v1alpha1.PluginService.GetPluginVersion:output_type -> buf.alpha.registry.v1alpha1.GetPluginVersionResponse - 18, // 65: buf.alpha.registry.v1alpha1.PluginService.ListPluginVersions:output_type -> buf.alpha.registry.v1alpha1.ListPluginVersionsResponse - 20, // 66: buf.alpha.registry.v1alpha1.PluginService.CreatePlugin:output_type -> buf.alpha.registry.v1alpha1.CreatePluginResponse - 22, // 67: buf.alpha.registry.v1alpha1.PluginService.GetPlugin:output_type -> buf.alpha.registry.v1alpha1.GetPluginResponse - 24, // 68: buf.alpha.registry.v1alpha1.PluginService.DeletePlugin:output_type -> buf.alpha.registry.v1alpha1.DeletePluginResponse - 26, // 69: buf.alpha.registry.v1alpha1.PluginService.SetPluginContributor:output_type -> buf.alpha.registry.v1alpha1.SetPluginContributorResponse - 28, // 70: buf.alpha.registry.v1alpha1.PluginService.ListPluginContributors:output_type -> buf.alpha.registry.v1alpha1.ListPluginContributorsResponse - 30, // 71: buf.alpha.registry.v1alpha1.PluginService.GetTemplate:output_type -> buf.alpha.registry.v1alpha1.GetTemplateResponse - 32, // 72: buf.alpha.registry.v1alpha1.PluginService.ListTemplates:output_type -> buf.alpha.registry.v1alpha1.ListTemplatesResponse - 34, // 73: buf.alpha.registry.v1alpha1.PluginService.ListTemplatesUserCanAccess:output_type -> buf.alpha.registry.v1alpha1.ListTemplatesUserCanAccessResponse - 36, // 74: buf.alpha.registry.v1alpha1.PluginService.ListUserTemplates:output_type -> buf.alpha.registry.v1alpha1.ListUserTemplatesResponse - 40, // 75: buf.alpha.registry.v1alpha1.PluginService.ListOrganizationTemplates:output_type -> buf.alpha.registry.v1alpha1.ListOrganizationTemplatesResponse - 38, // 76: buf.alpha.registry.v1alpha1.PluginService.GetTemplateVersion:output_type -> buf.alpha.registry.v1alpha1.GetTemplateVersionResponse - 42, // 77: buf.alpha.registry.v1alpha1.PluginService.ListTemplateVersions:output_type -> buf.alpha.registry.v1alpha1.ListTemplateVersionsResponse - 44, // 78: buf.alpha.registry.v1alpha1.PluginService.CreateTemplate:output_type -> buf.alpha.registry.v1alpha1.CreateTemplateResponse - 46, // 79: buf.alpha.registry.v1alpha1.PluginService.DeleteTemplate:output_type -> buf.alpha.registry.v1alpha1.DeleteTemplateResponse - 48, // 80: buf.alpha.registry.v1alpha1.PluginService.CreateTemplateVersion:output_type -> buf.alpha.registry.v1alpha1.CreateTemplateVersionResponse - 50, // 81: buf.alpha.registry.v1alpha1.PluginService.SetTemplateContributor:output_type -> buf.alpha.registry.v1alpha1.SetTemplateContributorResponse - 52, // 82: buf.alpha.registry.v1alpha1.PluginService.ListTemplateContributors:output_type -> buf.alpha.registry.v1alpha1.ListTemplateContributorsResponse - 61, // [61:83] is the sub-list for method output_type - 39, // [39:61] is the sub-list for method input_type - 39, // [39:39] is the sub-list for extension type_name - 39, // [39:39] is the sub-list for extension extendee - 0, // [0:39] is the sub-list for field type_name + 1, // 9: buf.alpha.registry.v1alpha1.ListPluginsResponse.plugins:type_name -> buf.alpha.registry.v1alpha1.Plugin + 1, // 10: buf.alpha.registry.v1alpha1.ListUserPluginsResponse.plugins:type_name -> buf.alpha.registry.v1alpha1.Plugin + 1, // 11: buf.alpha.registry.v1alpha1.ListOrganizationPluginsResponse.plugins:type_name -> buf.alpha.registry.v1alpha1.Plugin + 2, // 12: buf.alpha.registry.v1alpha1.GetPluginVersionResponse.plugin_version:type_name -> buf.alpha.registry.v1alpha1.PluginVersion + 2, // 13: buf.alpha.registry.v1alpha1.ListPluginVersionsResponse.plugin_versions:type_name -> buf.alpha.registry.v1alpha1.PluginVersion + 1, // 14: buf.alpha.registry.v1alpha1.GetPluginResponse.plugin:type_name -> buf.alpha.registry.v1alpha1.Plugin + 3, // 15: buf.alpha.registry.v1alpha1.GetTemplateResponse.template:type_name -> buf.alpha.registry.v1alpha1.Template + 3, // 16: buf.alpha.registry.v1alpha1.ListTemplatesResponse.templates:type_name -> buf.alpha.registry.v1alpha1.Template + 3, // 17: buf.alpha.registry.v1alpha1.ListTemplatesUserCanAccessResponse.templates:type_name -> buf.alpha.registry.v1alpha1.Template + 3, // 18: buf.alpha.registry.v1alpha1.ListUserTemplatesResponse.templates:type_name -> buf.alpha.registry.v1alpha1.Template + 5, // 19: buf.alpha.registry.v1alpha1.GetTemplateVersionResponse.template_version:type_name -> buf.alpha.registry.v1alpha1.TemplateVersion + 3, // 20: buf.alpha.registry.v1alpha1.ListOrganizationTemplatesResponse.templates:type_name -> buf.alpha.registry.v1alpha1.Template + 5, // 21: buf.alpha.registry.v1alpha1.ListTemplateVersionsResponse.template_versions:type_name -> buf.alpha.registry.v1alpha1.TemplateVersion + 7, // 22: buf.alpha.registry.v1alpha1.PluginService.ListPlugins:input_type -> buf.alpha.registry.v1alpha1.ListPluginsRequest + 9, // 23: buf.alpha.registry.v1alpha1.PluginService.ListUserPlugins:input_type -> buf.alpha.registry.v1alpha1.ListUserPluginsRequest + 11, // 24: buf.alpha.registry.v1alpha1.PluginService.ListOrganizationPlugins:input_type -> buf.alpha.registry.v1alpha1.ListOrganizationPluginsRequest + 13, // 25: buf.alpha.registry.v1alpha1.PluginService.GetPluginVersion:input_type -> buf.alpha.registry.v1alpha1.GetPluginVersionRequest + 15, // 26: buf.alpha.registry.v1alpha1.PluginService.ListPluginVersions:input_type -> buf.alpha.registry.v1alpha1.ListPluginVersionsRequest + 17, // 27: buf.alpha.registry.v1alpha1.PluginService.GetPlugin:input_type -> buf.alpha.registry.v1alpha1.GetPluginRequest + 19, // 28: buf.alpha.registry.v1alpha1.PluginService.DeletePlugin:input_type -> buf.alpha.registry.v1alpha1.DeletePluginRequest + 21, // 29: buf.alpha.registry.v1alpha1.PluginService.GetTemplate:input_type -> buf.alpha.registry.v1alpha1.GetTemplateRequest + 23, // 30: buf.alpha.registry.v1alpha1.PluginService.ListTemplates:input_type -> buf.alpha.registry.v1alpha1.ListTemplatesRequest + 25, // 31: buf.alpha.registry.v1alpha1.PluginService.ListTemplatesUserCanAccess:input_type -> buf.alpha.registry.v1alpha1.ListTemplatesUserCanAccessRequest + 27, // 32: buf.alpha.registry.v1alpha1.PluginService.ListUserTemplates:input_type -> buf.alpha.registry.v1alpha1.ListUserTemplatesRequest + 31, // 33: buf.alpha.registry.v1alpha1.PluginService.ListOrganizationTemplates:input_type -> buf.alpha.registry.v1alpha1.ListOrganizationTemplatesRequest + 29, // 34: buf.alpha.registry.v1alpha1.PluginService.GetTemplateVersion:input_type -> buf.alpha.registry.v1alpha1.GetTemplateVersionRequest + 33, // 35: buf.alpha.registry.v1alpha1.PluginService.ListTemplateVersions:input_type -> buf.alpha.registry.v1alpha1.ListTemplateVersionsRequest + 35, // 36: buf.alpha.registry.v1alpha1.PluginService.DeleteTemplate:input_type -> buf.alpha.registry.v1alpha1.DeleteTemplateRequest + 8, // 37: buf.alpha.registry.v1alpha1.PluginService.ListPlugins:output_type -> buf.alpha.registry.v1alpha1.ListPluginsResponse + 10, // 38: buf.alpha.registry.v1alpha1.PluginService.ListUserPlugins:output_type -> buf.alpha.registry.v1alpha1.ListUserPluginsResponse + 12, // 39: buf.alpha.registry.v1alpha1.PluginService.ListOrganizationPlugins:output_type -> buf.alpha.registry.v1alpha1.ListOrganizationPluginsResponse + 14, // 40: buf.alpha.registry.v1alpha1.PluginService.GetPluginVersion:output_type -> buf.alpha.registry.v1alpha1.GetPluginVersionResponse + 16, // 41: buf.alpha.registry.v1alpha1.PluginService.ListPluginVersions:output_type -> buf.alpha.registry.v1alpha1.ListPluginVersionsResponse + 18, // 42: buf.alpha.registry.v1alpha1.PluginService.GetPlugin:output_type -> buf.alpha.registry.v1alpha1.GetPluginResponse + 20, // 43: buf.alpha.registry.v1alpha1.PluginService.DeletePlugin:output_type -> buf.alpha.registry.v1alpha1.DeletePluginResponse + 22, // 44: buf.alpha.registry.v1alpha1.PluginService.GetTemplate:output_type -> buf.alpha.registry.v1alpha1.GetTemplateResponse + 24, // 45: buf.alpha.registry.v1alpha1.PluginService.ListTemplates:output_type -> buf.alpha.registry.v1alpha1.ListTemplatesResponse + 26, // 46: buf.alpha.registry.v1alpha1.PluginService.ListTemplatesUserCanAccess:output_type -> buf.alpha.registry.v1alpha1.ListTemplatesUserCanAccessResponse + 28, // 47: buf.alpha.registry.v1alpha1.PluginService.ListUserTemplates:output_type -> buf.alpha.registry.v1alpha1.ListUserTemplatesResponse + 32, // 48: buf.alpha.registry.v1alpha1.PluginService.ListOrganizationTemplates:output_type -> buf.alpha.registry.v1alpha1.ListOrganizationTemplatesResponse + 30, // 49: buf.alpha.registry.v1alpha1.PluginService.GetTemplateVersion:output_type -> buf.alpha.registry.v1alpha1.GetTemplateVersionResponse + 34, // 50: buf.alpha.registry.v1alpha1.PluginService.ListTemplateVersions:output_type -> buf.alpha.registry.v1alpha1.ListTemplateVersionsResponse + 36, // 51: buf.alpha.registry.v1alpha1.PluginService.DeleteTemplate:output_type -> buf.alpha.registry.v1alpha1.DeleteTemplateResponse + 37, // [37:52] is the sub-list for method output_type + 22, // [22:37] is the sub-list for method input_type + 22, // [22:22] is the sub-list for extension type_name + 22, // [22:22] is the sub-list for extension extendee + 0, // [0:22] is the sub-list for field type_name } func init() { file_buf_alpha_registry_v1alpha1_plugin_proto_init() } @@ -4768,8 +3389,6 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return } file_buf_alpha_registry_v1alpha1_generate_proto_init() - file_buf_alpha_registry_v1alpha1_role_proto_init() - file_buf_alpha_registry_v1alpha1_user_proto_init() if !protoimpl.UnsafeEnabled { file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Plugin); i { @@ -4844,30 +3463,6 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { } } file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PluginContributor); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TemplateContributor); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListPluginsRequest); i { case 0: return &v.state @@ -4879,7 +3474,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListPluginsResponse); i { case 0: return &v.state @@ -4891,7 +3486,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListUserPluginsRequest); i { case 0: return &v.state @@ -4903,7 +3498,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListUserPluginsResponse); i { case 0: return &v.state @@ -4915,7 +3510,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListOrganizationPluginsRequest); i { case 0: return &v.state @@ -4927,7 +3522,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListOrganizationPluginsResponse); i { case 0: return &v.state @@ -4939,7 +3534,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetPluginVersionRequest); i { case 0: return &v.state @@ -4951,7 +3546,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetPluginVersionResponse); i { case 0: return &v.state @@ -4963,7 +3558,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListPluginVersionsRequest); i { case 0: return &v.state @@ -4975,7 +3570,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListPluginVersionsResponse); i { case 0: return &v.state @@ -4987,31 +3582,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreatePluginRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreatePluginResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetPluginRequest); i { case 0: return &v.state @@ -5023,7 +3594,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetPluginResponse); i { case 0: return &v.state @@ -5035,7 +3606,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeletePluginRequest); i { case 0: return &v.state @@ -5047,7 +3618,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeletePluginResponse); i { case 0: return &v.state @@ -5059,55 +3630,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetPluginContributorRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetPluginContributorResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListPluginContributorsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListPluginContributorsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetTemplateRequest); i { case 0: return &v.state @@ -5119,7 +3642,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetTemplateResponse); i { case 0: return &v.state @@ -5131,7 +3654,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListTemplatesRequest); i { case 0: return &v.state @@ -5143,7 +3666,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListTemplatesResponse); i { case 0: return &v.state @@ -5155,7 +3678,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListTemplatesUserCanAccessRequest); i { case 0: return &v.state @@ -5167,7 +3690,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListTemplatesUserCanAccessResponse); i { case 0: return &v.state @@ -5179,7 +3702,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListUserTemplatesRequest); i { case 0: return &v.state @@ -5191,7 +3714,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListUserTemplatesResponse); i { case 0: return &v.state @@ -5203,7 +3726,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetTemplateVersionRequest); i { case 0: return &v.state @@ -5215,7 +3738,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetTemplateVersionResponse); i { case 0: return &v.state @@ -5227,7 +3750,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListOrganizationTemplatesRequest); i { case 0: return &v.state @@ -5239,7 +3762,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListOrganizationTemplatesResponse); i { case 0: return &v.state @@ -5251,7 +3774,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListTemplateVersionsRequest); i { case 0: return &v.state @@ -5263,7 +3786,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListTemplateVersionsResponse); i { case 0: return &v.state @@ -5275,31 +3798,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateTemplateRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateTemplateResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeleteTemplateRequest); i { case 0: return &v.state @@ -5311,7 +3810,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { + file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeleteTemplateResponse); i { case 0: return &v.state @@ -5323,78 +3822,6 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { return nil } } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateTemplateVersionRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateTemplateVersionResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetTemplateContributorRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetTemplateContributorResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[50].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListTemplateContributorsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_alpha_registry_v1alpha1_plugin_proto_msgTypes[51].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListTemplateContributorsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -5402,7 +3829,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_alpha_registry_v1alpha1_plugin_proto_rawDesc, NumEnums: 1, - NumMessages: 52, + NumMessages: 36, NumExtensions: 0, NumServices: 1, }, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/plugin_curation.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/plugin_curation.pb.go index 7e404e060..58adbb173 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/plugin_curation.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/plugin_curation.pb.go @@ -1008,11 +1008,13 @@ type GenerateCodeRequest struct { // If you want to include imports, set include_imports. Image *v1.Image `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` Requests []*PluginGenerationRequest `protobuf:"bytes,2,rep,name=requests,proto3" json:"requests,omitempty"` - // Include imports from the Image in generation. + // Include imports from the Image in generation. If include_imports is also set + // in one of requests, use the request's value for that plugin. IncludeImports bool `protobuf:"varint,3,opt,name=include_imports,json=includeImports,proto3" json:"include_imports,omitempty"` // Include Well-Known Types from the Image in generation. // - // include_imports must be set if include_well_known_types is set. + // include_imports must be set if include_well_known_types is set. If include_well_known_types + // is also set in one of requests, use the request's value for that plugin. IncludeWellKnownTypes bool `protobuf:"varint,4,opt,name=include_well_known_types,json=includeWellKnownTypes,proto3" json:"include_well_known_types,omitempty"` } @@ -1136,6 +1138,12 @@ type PluginGenerationRequest struct { // The options to pass to the plugin. These will // be merged into a single, comma-separated string. Options []string `protobuf:"bytes,2,rep,name=options,proto3" json:"options,omitempty"` + // Include imports from the Image in generation. + IncludeImports *bool `protobuf:"varint,3,opt,name=include_imports,json=includeImports,proto3,oneof" json:"include_imports,omitempty"` + // Include Well-Known Types from the Image in generation. + // + // include_imports must be set if include_well_known_types is set. + IncludeWellKnownTypes *bool `protobuf:"varint,4,opt,name=include_well_known_types,json=includeWellKnownTypes,proto3,oneof" json:"include_well_known_types,omitempty"` } func (x *PluginGenerationRequest) Reset() { @@ -1184,6 +1192,20 @@ func (x *PluginGenerationRequest) GetOptions() []string { return nil } +func (x *PluginGenerationRequest) GetIncludeImports() bool { + if x != nil && x.IncludeImports != nil { + return *x.IncludeImports + } + return false +} + +func (x *PluginGenerationRequest) GetIncludeWellKnownTypes() bool { + if x != nil && x.IncludeWellKnownTypes != nil { + return *x.IncludeWellKnownTypes + } + return false +} + // Response from code generation for a given plugin. type PluginGenerationResponse struct { state protoimpl.MessageState @@ -2369,7 +2391,7 @@ type SwiftConfig_RuntimeLibrary struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The source of the runtime library package, e.g. github.com/apple/swift-protobuf. + // The source of the runtime library package, e.g. https://github.com/apple/swift-protobuf.git. Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source,omitempty"` // The name of the runtime library package, e.g. "swift-protobuf". Package string `protobuf:"bytes,2,opt,name=package,proto3" json:"package,omitempty"` @@ -2379,6 +2401,8 @@ type SwiftConfig_RuntimeLibrary struct { Products []string `protobuf:"bytes,4,rep,name=products,proto3" json:"products,omitempty"` // The minimum compatible platform versions of the runtime library. Platforms []*SwiftConfig_RuntimeLibrary_Platform `protobuf:"bytes,5,rep,name=platforms,proto3" json:"platforms,omitempty"` + // The supported Swift language versions of the runtime library, e.g. ".v5". + SwiftVersions []string `protobuf:"bytes,6,rep,name=swift_versions,json=swiftVersions,proto3" json:"swift_versions,omitempty"` } func (x *SwiftConfig_RuntimeLibrary) Reset() { @@ -2448,6 +2472,13 @@ func (x *SwiftConfig_RuntimeLibrary) GetPlatforms() []*SwiftConfig_RuntimeLibrar return nil } +func (x *SwiftConfig_RuntimeLibrary) GetSwiftVersions() []string { + if x != nil { + return x.SwiftVersions + } + return nil +} + // The minimum compatible platform versions of the runtime library. type SwiftConfig_RuntimeLibrary_Platform struct { state protoimpl.MessageState @@ -2624,14 +2655,14 @@ var file_buf_alpha_registry_v1alpha1_plugin_curation_proto_rawDesc = []byte{ 0x72, 0x61, 0x72, 0x79, 0x52, 0x10, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x22, 0xb8, 0x03, 0x0a, 0x0b, 0x53, 0x77, 0x69, 0x66, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x22, 0xdf, 0x03, 0x0a, 0x0b, 0x53, 0x77, 0x69, 0x66, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x64, 0x0a, 0x11, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x77, 0x69, 0x66, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x10, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x4c, 0x69, 0x62, - 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x1a, 0xc2, 0x02, 0x0a, 0x0e, 0x52, 0x75, 0x6e, 0x74, 0x69, + 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x1a, 0xe9, 0x02, 0x0a, 0x0e, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, @@ -2645,388 +2676,401 @@ var file_buf_alpha_registry_v1alpha1_plugin_curation_proto_rawDesc = []byte{ 0x61, 0x31, 0x2e, 0x53, 0x77, 0x69, 0x66, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x09, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, - 0x73, 0x1a, 0x68, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x42, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2e, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x77, 0x69, 0x66, 0x74, 0x50, - 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xf0, 0x02, 0x0a, 0x0e, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x44, - 0x0a, 0x09, 0x67, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x47, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x08, 0x67, 0x6f, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x47, 0x0a, 0x0a, 0x6e, 0x70, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4e, 0x50, 0x4d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x48, 0x00, 0x52, 0x09, 0x6e, 0x70, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4d, 0x0a, - 0x0c, 0x6d, 0x61, 0x76, 0x65, 0x6e, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x4d, 0x61, 0x76, 0x65, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, - 0x0b, 0x6d, 0x61, 0x76, 0x65, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4d, 0x0a, 0x0c, - 0x73, 0x77, 0x69, 0x66, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x77, 0x69, 0x66, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x77, 0x69, 0x66, 0x74, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x68, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, + 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x42, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x53, 0x77, 0x69, 0x66, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x0b, - 0x73, 0x77, 0x69, 0x66, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x6f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x11, 0x0a, 0x0f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x0a, 0x22, 0x78, - 0x0a, 0x16, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, - 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, - 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, - 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x9c, 0x07, 0x0a, 0x0d, 0x43, 0x75, 0x72, - 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, - 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x54, 0x0a, 0x0d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0c, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x34, 0x0a, 0x16, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, - 0x72, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, - 0x6d, 0x61, 0x67, 0x65, 0x44, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x57, 0x0a, 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, - 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x33, 0x2e, - 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, - 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, - 0x63, 0x65, 0x52, 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, - 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x72, 0x6c, 0x12, - 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x54, 0x0a, 0x0f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5f, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x77, 0x69, 0x66, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x22, 0xf0, 0x02, 0x0a, 0x0e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x44, 0x0a, 0x09, 0x67, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, + 0x00, 0x52, 0x08, 0x67, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x47, 0x0a, 0x0a, 0x6e, + 0x70, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x26, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4e, 0x50, + 0x4d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x09, 0x6e, 0x70, 0x6d, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4d, 0x0a, 0x0c, 0x6d, 0x61, 0x76, 0x65, 0x6e, 0x5f, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x56, 0x0a, 0x10, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x6c, 0x61, - 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x2b, 0x2e, - 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x52, 0x0f, 0x6f, 0x75, 0x74, 0x70, - 0x75, 0x74, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x73, - 0x70, 0x64, 0x78, 0x5f, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x0f, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x70, 0x64, 0x78, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, - 0x65, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x75, - 0x72, 0x6c, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, - 0x65, 0x55, 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, - 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, - 0x12, 0x54, 0x0a, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x12, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x61, 0x76, 0x65, 0x6e, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x0b, 0x6d, 0x61, 0x76, 0x65, 0x6e, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x12, 0x4d, 0x0a, 0x0c, 0x73, 0x77, 0x69, 0x66, 0x74, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x77, 0x69, 0x66, 0x74, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x77, 0x69, 0x66, 0x74, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0a, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x11, 0x0a, 0x0f, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4a, + 0x04, 0x08, 0x05, 0x10, 0x0a, 0x22, 0x78, 0x0a, 0x16, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, + 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x22, + 0x9c, 0x07, 0x0a, 0x0d, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x54, 0x0a, 0x0d, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x54, + 0x79, 0x70, 0x65, 0x52, 0x0c, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x34, 0x0a, 0x16, 0x63, + 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x64, + 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x63, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x44, 0x69, 0x67, 0x65, 0x73, + 0x74, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x57, + 0x0a, 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x18, 0x09, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x0a, 0x76, 0x69, 0x73, 0x69, - 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, - 0x61, 0x74, 0x65, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, - 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x2f, 0x0a, 0x13, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x14, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x12, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xfa, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x6e, 0x65, - 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x2f, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, - 0x12, 0x50, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x69, 0x6d, - 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x69, 0x6e, 0x63, - 0x6c, 0x75, 0x64, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x37, 0x0a, 0x18, 0x69, - 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x77, 0x65, 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, - 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x69, - 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, - 0x79, 0x70, 0x65, 0x73, 0x22, 0x6b, 0x0a, 0x14, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, - 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x09, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x73, 0x22, 0x93, 0x01, 0x0a, 0x17, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x47, 0x65, 0x6e, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x5e, 0x0a, - 0x10, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0f, 0x70, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, - 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, - 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x67, 0x0a, 0x18, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, - 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x60, 0x0a, 0x1a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, - 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, - 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, - 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x22, 0x1d, 0x0a, 0x1b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, - 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0xef, 0x05, 0x0a, 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, - 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x54, 0x0a, 0x0d, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, + 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x54, 0x0a, 0x0f, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x54, 0x79, - 0x70, 0x65, 0x52, 0x0c, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x34, 0x0a, 0x16, 0x63, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x64, 0x69, - 0x67, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x63, 0x6f, 0x6e, 0x74, - 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x44, 0x69, 0x67, 0x65, 0x73, 0x74, - 0x12, 0x57, 0x0a, 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, - 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0c, 0x64, 0x65, 0x70, - 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x54, 0x0a, 0x0f, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x0c, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x56, 0x0a, 0x10, - 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x73, - 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x4c, 0x61, 0x6e, 0x67, 0x75, - 0x61, 0x67, 0x65, 0x52, 0x0f, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x4c, 0x61, 0x6e, 0x67, 0x75, - 0x61, 0x67, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x73, 0x70, 0x64, 0x78, 0x5f, 0x6c, 0x69, 0x63, - 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, - 0x70, 0x64, 0x78, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, - 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x10, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x54, 0x0a, - 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x11, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x69, 0x73, - 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, - 0x69, 0x74, 0x79, 0x22, 0x6f, 0x0a, 0x1b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x75, 0x72, - 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1a, + 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x56, 0x0a, 0x10, 0x6f, 0x75, + 0x74, 0x70, 0x75, 0x74, 0x5f, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x73, 0x18, 0x0e, + 0x20, 0x03, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, + 0x65, 0x52, 0x0f, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, + 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x73, 0x70, 0x64, 0x78, 0x5f, 0x6c, 0x69, 0x63, 0x65, 0x6e, + 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x70, 0x64, + 0x78, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, + 0x63, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x76, + 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x76, + 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x12, 0x54, 0x0a, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, + 0x69, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x34, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, + 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, + 0x79, 0x52, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x1e, 0x0a, + 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x2f, 0x0a, + 0x13, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x64, 0x65, 0x70, 0x72, + 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xfa, + 0x01, 0x0a, 0x13, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, + 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x50, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xda, 0x01, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x75, 0x72, - 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, - 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, - 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x18, 0x73, 0x75, 0x70, 0x70, - 0x6f, 0x72, 0x74, 0x73, 0x5f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, - 0x61, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x73, 0x75, 0x70, 0x70, - 0x6f, 0x72, 0x74, 0x73, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x64, 0x65, - 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, - 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, - 0x64, 0x22, 0x8a, 0x01, 0x0a, 0x1a, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, - 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x44, 0x0a, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x2a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x07, 0x70, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, - 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xb9, - 0x01, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, - 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x38, 0x0a, 0x18, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x5f, 0x72, 0x65, 0x6d, - 0x6f, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x16, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x52, 0x65, 0x6d, 0x6f, - 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x22, 0xbc, 0x01, 0x0a, 0x1e, 0x47, - 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, - 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x47, 0x65, + 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, + 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x69, 0x6e, 0x63, + 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0e, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, + 0x74, 0x73, 0x12, 0x37, 0x0a, 0x18, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x77, 0x65, + 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x57, 0x65, 0x6c, + 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x22, 0x6b, 0x0a, 0x14, 0x47, + 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x47, 0x65, 0x6e, 0x65, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x09, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0xb0, 0x02, 0x0a, 0x17, 0x50, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x5e, 0x0a, 0x10, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, + 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x0f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2c, + 0x0a, 0x0f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, + 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0e, 0x69, 0x6e, 0x63, 0x6c, 0x75, + 0x64, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x88, 0x01, 0x01, 0x12, 0x3c, 0x0a, 0x18, + 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x77, 0x65, 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, + 0x77, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, 0x01, + 0x52, 0x15, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, + 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x88, 0x01, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x69, + 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x42, 0x1b, + 0x0a, 0x19, 0x5f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x77, 0x65, 0x6c, 0x6c, 0x5f, + 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0x67, 0x0a, 0x18, 0x50, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x63, 0x6f, 0x6d, 0x70, + 0x69, 0x6c, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, + 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x60, 0x0a, 0x1a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x75, + 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x1d, 0x0a, 0x1b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xef, 0x05, 0x0a, 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x54, + 0x0a, 0x0d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0c, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x34, + 0x0a, 0x16, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6d, 0x61, 0x67, + 0x65, 0x5f, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, + 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x44, 0x69, + 0x67, 0x65, 0x73, 0x74, 0x12, 0x57, 0x0a, 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, + 0x63, 0x69, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, + 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, + 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x12, 0x1d, 0x0a, + 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x20, 0x0a, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x54, + 0x0a, 0x0f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x56, 0x0a, 0x10, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x6c, 0x61, 0x6e, 0x67, 0x75, + 0x61, 0x67, 0x65, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x4c, + 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x52, 0x0f, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x4c, + 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x73, 0x70, 0x64, 0x78, + 0x5f, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x73, 0x70, 0x64, 0x78, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x49, 0x64, + 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, + 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x55, 0x72, + 0x6c, 0x12, 0x54, 0x0a, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x18, + 0x11, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x0a, 0x76, 0x69, 0x73, + 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x22, 0x6f, 0x0a, 0x1b, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, - 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x12, 0x56, 0x0a, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, - 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x57, 0x0a, 0x1d, 0x43, 0x75, 0x72, - 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x73, 0x2a, 0x91, 0x01, 0x0a, 0x17, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x29, - 0x0a, 0x25, 0x43, 0x55, 0x52, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, - 0x5f, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x55, 0x52, - 0x41, 0x54, 0x45, 0x44, 0x5f, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x56, 0x49, 0x53, 0x49, - 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x10, 0x01, 0x12, - 0x25, 0x0a, 0x21, 0x43, 0x55, 0x52, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x50, 0x4c, 0x55, 0x47, 0x49, - 0x4e, 0x5f, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x50, 0x52, 0x49, - 0x56, 0x41, 0x54, 0x45, 0x10, 0x02, 0x2a, 0xb5, 0x01, 0x0a, 0x12, 0x50, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, - 0x20, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, 0x59, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x52, 0x45, - 0x47, 0x49, 0x53, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x4f, 0x10, 0x01, - 0x12, 0x1c, 0x0a, 0x18, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, - 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x50, 0x4d, 0x10, 0x02, 0x12, 0x1e, - 0x0a, 0x1a, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, - 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4d, 0x41, 0x56, 0x45, 0x4e, 0x10, 0x03, 0x12, 0x1e, - 0x0a, 0x1a, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, - 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x57, 0x49, 0x46, 0x54, 0x10, 0x04, 0x2a, 0xce, - 0x03, 0x0a, 0x0e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, - 0x65, 0x12, 0x1f, 0x0a, 0x1b, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, - 0x55, 0x41, 0x47, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, - 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, - 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x47, 0x4f, 0x10, 0x01, 0x12, 0x1e, 0x0a, 0x1a, 0x50, 0x4c, - 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x4a, 0x41, - 0x56, 0x41, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x10, 0x02, 0x12, 0x1e, 0x0a, 0x1a, 0x50, 0x4c, - 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x10, 0x03, 0x12, 0x19, 0x0a, 0x15, 0x50, 0x4c, - 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x53, 0x57, - 0x49, 0x46, 0x54, 0x10, 0x04, 0x12, 0x17, 0x0a, 0x13, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, - 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x43, 0x50, 0x50, 0x10, 0x05, 0x12, 0x18, - 0x0a, 0x14, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, - 0x45, 0x5f, 0x4a, 0x41, 0x56, 0x41, 0x10, 0x06, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x4c, 0x55, 0x47, - 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x44, 0x41, 0x52, 0x54, - 0x10, 0x07, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, - 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x52, 0x55, 0x53, 0x54, 0x10, 0x08, 0x12, 0x1a, 0x0a, 0x16, + 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xda, 0x01, 0x0a, 0x19, 0x4c, 0x69, 0x73, + 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, + 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, + 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x18, + 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x5f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5f, + 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, + 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, + 0x65, 0x5f, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x11, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x44, 0x65, 0x70, 0x72, 0x65, + 0x63, 0x61, 0x74, 0x65, 0x64, 0x22, 0x8a, 0x01, 0x0a, 0x1a, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x75, + 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x52, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, + 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x22, 0xb9, 0x01, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, + 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x18, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x73, + 0x5f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x73, + 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x22, 0xbc, + 0x01, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, + 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x42, 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x06, 0x70, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x56, 0x0a, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0x52, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x57, 0x0a, + 0x1d, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x18, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2a, 0x91, 0x01, 0x0a, 0x17, 0x43, 0x75, 0x72, 0x61, 0x74, + 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, + 0x74, 0x79, 0x12, 0x29, 0x0a, 0x25, 0x43, 0x55, 0x52, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x50, 0x4c, + 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, + 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x24, 0x0a, + 0x20, 0x43, 0x55, 0x52, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, + 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x50, 0x55, 0x42, 0x4c, 0x49, + 0x43, 0x10, 0x01, 0x12, 0x25, 0x0a, 0x21, 0x43, 0x55, 0x52, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x50, + 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, + 0x5f, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x10, 0x02, 0x2a, 0xb5, 0x01, 0x0a, 0x12, 0x50, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x24, 0x0a, 0x20, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x49, + 0x53, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x50, 0x4c, 0x55, 0x47, 0x49, + 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, + 0x47, 0x4f, 0x10, 0x01, 0x12, 0x1c, 0x0a, 0x18, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x52, + 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x50, 0x4d, + 0x10, 0x02, 0x12, 0x1e, 0x0a, 0x1a, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x52, 0x45, 0x47, + 0x49, 0x53, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4d, 0x41, 0x56, 0x45, 0x4e, + 0x10, 0x03, 0x12, 0x1e, 0x0a, 0x1a, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x52, 0x45, 0x47, + 0x49, 0x53, 0x54, 0x52, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x57, 0x49, 0x46, 0x54, + 0x10, 0x04, 0x2a, 0xce, 0x03, 0x0a, 0x0e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x4c, 0x61, 0x6e, + 0x67, 0x75, 0x61, 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x1b, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, + 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, + 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, + 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x47, 0x4f, 0x10, 0x01, 0x12, 0x1e, + 0x0a, 0x1a, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, + 0x45, 0x5f, 0x4a, 0x41, 0x56, 0x41, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x10, 0x02, 0x12, 0x1e, + 0x0a, 0x1a, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, + 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x10, 0x03, 0x12, 0x19, + 0x0a, 0x15, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, + 0x45, 0x5f, 0x53, 0x57, 0x49, 0x46, 0x54, 0x10, 0x04, 0x12, 0x17, 0x0a, 0x13, 0x50, 0x4c, 0x55, + 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x43, 0x50, 0x50, + 0x10, 0x05, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, + 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x4a, 0x41, 0x56, 0x41, 0x10, 0x06, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, - 0x50, 0x59, 0x54, 0x48, 0x4f, 0x4e, 0x10, 0x09, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x4c, 0x55, 0x47, - 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x52, 0x55, 0x42, 0x59, - 0x10, 0x0a, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, - 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x4b, 0x4f, 0x54, 0x4c, 0x49, 0x4e, 0x10, 0x0b, 0x12, 0x1f, - 0x0a, 0x1b, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, - 0x45, 0x5f, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x49, 0x56, 0x45, 0x5f, 0x43, 0x10, 0x0c, 0x12, - 0x17, 0x0a, 0x13, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, - 0x47, 0x45, 0x5f, 0x50, 0x48, 0x50, 0x10, 0x0d, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x4c, 0x55, 0x47, - 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x43, 0x53, 0x48, 0x41, - 0x52, 0x50, 0x10, 0x0e, 0x12, 0x19, 0x0a, 0x15, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, - 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x53, 0x43, 0x41, 0x4c, 0x41, 0x10, 0x0f, 0x2a, - 0x6e, 0x0a, 0x0e, 0x4e, 0x50, 0x4d, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x79, 0x6c, - 0x65, 0x12, 0x20, 0x0a, 0x1c, 0x4e, 0x50, 0x4d, 0x5f, 0x49, 0x4d, 0x50, 0x4f, 0x52, 0x54, 0x5f, - 0x53, 0x54, 0x59, 0x4c, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x50, 0x4d, 0x5f, 0x49, 0x4d, 0x50, 0x4f, 0x52, - 0x54, 0x5f, 0x53, 0x54, 0x59, 0x4c, 0x45, 0x5f, 0x4d, 0x4f, 0x44, 0x55, 0x4c, 0x45, 0x10, 0x01, - 0x12, 0x1d, 0x0a, 0x19, 0x4e, 0x50, 0x4d, 0x5f, 0x49, 0x4d, 0x50, 0x4f, 0x52, 0x54, 0x5f, 0x53, - 0x54, 0x59, 0x4c, 0x45, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x4f, 0x4e, 0x4a, 0x53, 0x10, 0x02, 0x2a, - 0xb3, 0x01, 0x0a, 0x11, 0x53, 0x77, 0x69, 0x66, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, - 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x23, 0x0a, 0x1f, 0x53, 0x57, 0x49, 0x46, 0x54, 0x5f, 0x50, - 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, - 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1d, 0x0a, 0x19, 0x53, 0x57, - 0x49, 0x46, 0x54, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x54, 0x59, 0x50, - 0x45, 0x5f, 0x4d, 0x41, 0x43, 0x4f, 0x53, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x53, 0x57, 0x49, + 0x44, 0x41, 0x52, 0x54, 0x10, 0x07, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, + 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x52, 0x55, 0x53, 0x54, 0x10, 0x08, + 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, + 0x41, 0x47, 0x45, 0x5f, 0x50, 0x59, 0x54, 0x48, 0x4f, 0x4e, 0x10, 0x09, 0x12, 0x18, 0x0a, 0x14, + 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, + 0x52, 0x55, 0x42, 0x59, 0x10, 0x0a, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, + 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x4b, 0x4f, 0x54, 0x4c, 0x49, 0x4e, + 0x10, 0x0b, 0x12, 0x1f, 0x0a, 0x1b, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, + 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x49, 0x56, 0x45, 0x5f, + 0x43, 0x10, 0x0c, 0x12, 0x17, 0x0a, 0x13, 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, + 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x50, 0x48, 0x50, 0x10, 0x0d, 0x12, 0x1a, 0x0a, 0x16, + 0x50, 0x4c, 0x55, 0x47, 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, + 0x43, 0x53, 0x48, 0x41, 0x52, 0x50, 0x10, 0x0e, 0x12, 0x19, 0x0a, 0x15, 0x50, 0x4c, 0x55, 0x47, + 0x49, 0x4e, 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x5f, 0x53, 0x43, 0x41, 0x4c, + 0x41, 0x10, 0x0f, 0x2a, 0x6e, 0x0a, 0x0e, 0x4e, 0x50, 0x4d, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, + 0x53, 0x74, 0x79, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x1c, 0x4e, 0x50, 0x4d, 0x5f, 0x49, 0x4d, 0x50, + 0x4f, 0x52, 0x54, 0x5f, 0x53, 0x54, 0x59, 0x4c, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x50, 0x4d, 0x5f, 0x49, + 0x4d, 0x50, 0x4f, 0x52, 0x54, 0x5f, 0x53, 0x54, 0x59, 0x4c, 0x45, 0x5f, 0x4d, 0x4f, 0x44, 0x55, + 0x4c, 0x45, 0x10, 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x4e, 0x50, 0x4d, 0x5f, 0x49, 0x4d, 0x50, 0x4f, + 0x52, 0x54, 0x5f, 0x53, 0x54, 0x59, 0x4c, 0x45, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x4f, 0x4e, 0x4a, + 0x53, 0x10, 0x02, 0x2a, 0xb3, 0x01, 0x0a, 0x11, 0x53, 0x77, 0x69, 0x66, 0x74, 0x50, 0x6c, 0x61, + 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x23, 0x0a, 0x1f, 0x53, 0x57, 0x49, 0x46, 0x54, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x54, 0x59, 0x50, 0x45, - 0x5f, 0x49, 0x4f, 0x53, 0x10, 0x02, 0x12, 0x1f, 0x0a, 0x1b, 0x53, 0x57, 0x49, 0x46, 0x54, 0x5f, - 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x57, 0x41, - 0x54, 0x43, 0x48, 0x4f, 0x53, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x57, 0x49, 0x46, 0x54, - 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, - 0x56, 0x4f, 0x53, 0x10, 0x04, 0x32, 0xd3, 0x04, 0x0a, 0x15, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x43, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x8a, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x88, 0x01, 0x0a, - 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x12, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, - 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x96, 0x01, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x4c, - 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x12, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1d, + 0x0a, 0x19, 0x53, 0x57, 0x49, 0x46, 0x54, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, + 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4d, 0x41, 0x43, 0x4f, 0x53, 0x10, 0x01, 0x12, 0x1b, 0x0a, + 0x17, 0x53, 0x57, 0x49, 0x46, 0x54, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, + 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x4f, 0x53, 0x10, 0x02, 0x12, 0x1f, 0x0a, 0x1b, 0x53, 0x57, + 0x49, 0x46, 0x54, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x57, 0x41, 0x54, 0x43, 0x48, 0x4f, 0x53, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18, 0x53, + 0x57, 0x49, 0x46, 0x54, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x54, 0x56, 0x4f, 0x53, 0x10, 0x04, 0x32, 0xdd, 0x04, 0x0a, 0x15, 0x50, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x8a, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, + 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x75, 0x72, + 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, - 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, - 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, - 0x12, 0x88, 0x01, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, + 0x12, 0x8d, 0x01, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x75, 0x72, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, + 0x12, 0x96, 0x01, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, 0x75, + 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x3a, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, + 0x65, 0x73, 0x74, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, + 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x8d, 0x01, 0x0a, 0x13, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x12, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x8c, 0x01, 0x0a, 0x15, - 0x43, 0x6f, 0x64, 0x65, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x73, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, - 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x30, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, + 0x75, 0x72, 0x61, 0x74, 0x65, 0x64, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x32, 0x8c, 0x01, 0x0a, 0x15, 0x43, 0x6f, + 0x64, 0x65, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x73, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, + 0x6f, 0x64, 0x65, 0x12, 0x30, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, - 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xa0, 0x02, 0x0a, 0x1f, 0x63, - 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x13, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, - 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, - 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xa0, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x13, 0x50, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x43, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, + 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, + 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, + 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, - 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, + 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -3497,6 +3541,7 @@ func file_buf_alpha_registry_v1alpha1_plugin_curation_proto_init() { (*RegistryConfig_MavenConfig)(nil), (*RegistryConfig_SwiftConfig)(nil), } + file_buf_alpha_registry_v1alpha1_plugin_curation_proto_msgTypes[9].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/push.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/push.pb.go index 0729c9a4c..6c1bbe554 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/push.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/push.pb.go @@ -391,41 +391,42 @@ var file_buf_alpha_registry_v1alpha1_push_proto_rawDesc = []byte{ 0x0b, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x52, 0x0e, - 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x32, 0xf8, - 0x01, 0x0a, 0x0b, 0x50, 0x75, 0x73, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5b, + 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x32, 0x82, + 0x02, 0x0a, 0x0b, 0x50, 0x75, 0x73, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x04, 0x50, 0x75, 0x73, 0x68, 0x12, 0x28, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, - 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x8b, 0x01, 0x0a, 0x14, - 0x50, 0x75, 0x73, 0x68, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x41, 0x6e, 0x64, 0x42, - 0x6c, 0x6f, 0x62, 0x73, 0x12, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x41, - 0x6e, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x75, 0x73, - 0x68, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x41, 0x6e, 0x64, 0x42, 0x6c, 0x6f, 0x62, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x96, 0x02, 0x0a, 0x1f, 0x63, 0x6f, - 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x09, 0x50, - 0x75, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, - 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, - 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, - 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, - 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, + 0x12, 0x90, 0x01, 0x0a, 0x14, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, + 0x74, 0x41, 0x6e, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x12, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x61, 0x6e, 0x69, + 0x66, 0x65, 0x73, 0x74, 0x41, 0x6e, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x41, 0x6e, + 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, + 0x90, 0x02, 0x02, 0x42, 0x96, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x09, 0x50, 0x75, 0x73, 0x68, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, + 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, + 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, + 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/recommendation.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/recommendation.pb.go index c842b46a6..9ff74064e 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/recommendation.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/recommendation.pb.go @@ -664,7 +664,7 @@ var file_buf_alpha_registry_v1alpha1_recommendation_proto_rawDesc = []byte{ 0x64, 0x65, 0x64, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x22, 0x21, 0x0a, 0x1f, 0x53, 0x65, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xff, 0x04, 0x0a, 0x15, 0x52, 0x65, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x84, 0x05, 0x0a, 0x15, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x99, 0x01, 0x0a, 0x17, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, @@ -695,7 +695,7 @@ var file_buf_alpha_registry_v1alpha1_recommendation_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x03, 0x90, 0x02, 0x01, 0x12, 0x94, 0x01, 0x0a, 0x17, 0x53, 0x65, 0x74, 0x52, 0x65, 0x63, 0x6f, + 0x03, 0x90, 0x02, 0x01, 0x12, 0x99, 0x01, 0x0a, 0x17, 0x53, 0x65, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, @@ -704,26 +704,26 @@ var file_buf_alpha_registry_v1alpha1_recommendation_proto_rawDesc = []byte{ 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xa0, 0x02, 0x0a, 0x1f, - 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, - 0x13, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, - 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, - 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, - 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, + 0x42, 0xa0, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x42, 0x13, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, + 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, + 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, + 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, + 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, + 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/reference.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/reference.pb.go index 4f93805ba..b60f763e8 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/reference.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/reference.pb.go @@ -375,6 +375,129 @@ func (x *GetReferenceByNameResponse) GetReference() *Reference { return nil } +type ListGitCommitMetadataForReferenceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Name of the requested reference. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Owner of the repository the reference belongs to. + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + // Name of the repository the reference belongs to. + RepositoryName string `protobuf:"bytes,3,opt,name=repository_name,json=repositoryName,proto3" json:"repository_name,omitempty"` +} + +func (x *ListGitCommitMetadataForReferenceRequest) Reset() { + *x = ListGitCommitMetadataForReferenceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_reference_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListGitCommitMetadataForReferenceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListGitCommitMetadataForReferenceRequest) ProtoMessage() {} + +func (x *ListGitCommitMetadataForReferenceRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_reference_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListGitCommitMetadataForReferenceRequest.ProtoReflect.Descriptor instead. +func (*ListGitCommitMetadataForReferenceRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_reference_proto_rawDescGZIP(), []int{5} +} + +func (x *ListGitCommitMetadataForReferenceRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ListGitCommitMetadataForReferenceRequest) GetOwner() string { + if x != nil { + return x.Owner + } + return "" +} + +func (x *ListGitCommitMetadataForReferenceRequest) GetRepositoryName() string { + if x != nil { + return x.RepositoryName + } + return "" +} + +type ListGitCommitMetadataForReferenceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // ID of the BSR commit the reference resolved to. + CommitId string `protobuf:"bytes,1,opt,name=commit_id,json=commitId,proto3" json:"commit_id,omitempty"` + // List of git commits and metadata associated with the resolved reference. + GitCommitMetadatas []*GitCommitMetadata `protobuf:"bytes,2,rep,name=git_commit_metadatas,json=gitCommitMetadatas,proto3" json:"git_commit_metadatas,omitempty"` +} + +func (x *ListGitCommitMetadataForReferenceResponse) Reset() { + *x = ListGitCommitMetadataForReferenceResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_reference_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListGitCommitMetadataForReferenceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListGitCommitMetadataForReferenceResponse) ProtoMessage() {} + +func (x *ListGitCommitMetadataForReferenceResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_reference_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListGitCommitMetadataForReferenceResponse.ProtoReflect.Descriptor instead. +func (*ListGitCommitMetadataForReferenceResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_reference_proto_rawDescGZIP(), []int{6} +} + +func (x *ListGitCommitMetadataForReferenceResponse) GetCommitId() string { + if x != nil { + return x.CommitId + } + return "" +} + +func (x *ListGitCommitMetadataForReferenceResponse) GetGitCommitMetadatas() []*GitCommitMetadata { + if x != nil { + return x.GitCommitMetadatas + } + return nil +} + var File_buf_alpha_registry_v1alpha1_reference_proto protoreflect.FileDescriptor var file_buf_alpha_registry_v1alpha1_reference_proto_rawDesc = []byte{ @@ -382,7 +505,10 @@ var file_buf_alpha_registry_v1alpha1_reference_proto_rawDesc = []byte{ 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x33, 0x62, 0x75, 0x66, 0x2f, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x2e, 0x62, 0x75, 0x66, 0x2f, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x67, 0x69, 0x74, 0x5f, 0x6d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x33, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, @@ -437,36 +563,66 @@ var file_buf_alpha_registry_v1alpha1_reference_proto_rawDesc = []byte{ 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, - 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x32, 0x9f, 0x01, 0x0a, 0x10, 0x52, - 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x8a, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, - 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, - 0x65, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, - 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, 0x9b, 0x02, 0x0a, - 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x7d, 0x0a, 0x28, 0x4c, 0x69, + 0x73, 0x74, 0x47, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x46, 0x6f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, + 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, + 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x72, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xaa, 0x01, 0x0a, 0x29, 0x4c, 0x69, + 0x73, 0x74, 0x47, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x46, 0x6f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x49, 0x64, 0x12, 0x60, 0x0a, 0x14, 0x67, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x47, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x52, 0x12, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x73, 0x32, 0xd9, 0x02, 0x0a, 0x10, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x8a, 0x01, 0x0a, 0x12, + 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x79, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x42, 0x0e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, - 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, - 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, - 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, - 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, - 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, - 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x79, 0x4e, + 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0xb7, 0x01, 0x0a, 0x21, 0x4c, 0x69, 0x73, + 0x74, 0x47, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x46, 0x6f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x45, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x47, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x46, 0x6f, 0x72, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x46, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x47, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x46, 0x6f, 0x72, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, + 0x02, 0x01, 0x42, 0x9b, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, + 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, + 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, + 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, + 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -481,31 +637,37 @@ func file_buf_alpha_registry_v1alpha1_reference_proto_rawDescGZIP() []byte { return file_buf_alpha_registry_v1alpha1_reference_proto_rawDescData } -var file_buf_alpha_registry_v1alpha1_reference_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_buf_alpha_registry_v1alpha1_reference_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_buf_alpha_registry_v1alpha1_reference_proto_goTypes = []interface{}{ - (*Reference)(nil), // 0: buf.alpha.registry.v1alpha1.Reference - (*RepositoryMainReference)(nil), // 1: buf.alpha.registry.v1alpha1.RepositoryMainReference - (*RepositoryDraft)(nil), // 2: buf.alpha.registry.v1alpha1.RepositoryDraft - (*GetReferenceByNameRequest)(nil), // 3: buf.alpha.registry.v1alpha1.GetReferenceByNameRequest - (*GetReferenceByNameResponse)(nil), // 4: buf.alpha.registry.v1alpha1.GetReferenceByNameResponse - (*RepositoryTag)(nil), // 5: buf.alpha.registry.v1alpha1.RepositoryTag - (*RepositoryCommit)(nil), // 6: buf.alpha.registry.v1alpha1.RepositoryCommit + (*Reference)(nil), // 0: buf.alpha.registry.v1alpha1.Reference + (*RepositoryMainReference)(nil), // 1: buf.alpha.registry.v1alpha1.RepositoryMainReference + (*RepositoryDraft)(nil), // 2: buf.alpha.registry.v1alpha1.RepositoryDraft + (*GetReferenceByNameRequest)(nil), // 3: buf.alpha.registry.v1alpha1.GetReferenceByNameRequest + (*GetReferenceByNameResponse)(nil), // 4: buf.alpha.registry.v1alpha1.GetReferenceByNameResponse + (*ListGitCommitMetadataForReferenceRequest)(nil), // 5: buf.alpha.registry.v1alpha1.ListGitCommitMetadataForReferenceRequest + (*ListGitCommitMetadataForReferenceResponse)(nil), // 6: buf.alpha.registry.v1alpha1.ListGitCommitMetadataForReferenceResponse + (*RepositoryTag)(nil), // 7: buf.alpha.registry.v1alpha1.RepositoryTag + (*RepositoryCommit)(nil), // 8: buf.alpha.registry.v1alpha1.RepositoryCommit + (*GitCommitMetadata)(nil), // 9: buf.alpha.registry.v1alpha1.GitCommitMetadata } var file_buf_alpha_registry_v1alpha1_reference_proto_depIdxs = []int32{ - 5, // 0: buf.alpha.registry.v1alpha1.Reference.tag:type_name -> buf.alpha.registry.v1alpha1.RepositoryTag - 6, // 1: buf.alpha.registry.v1alpha1.Reference.commit:type_name -> buf.alpha.registry.v1alpha1.RepositoryCommit - 1, // 2: buf.alpha.registry.v1alpha1.Reference.main:type_name -> buf.alpha.registry.v1alpha1.RepositoryMainReference - 2, // 3: buf.alpha.registry.v1alpha1.Reference.draft:type_name -> buf.alpha.registry.v1alpha1.RepositoryDraft - 6, // 4: buf.alpha.registry.v1alpha1.RepositoryMainReference.commit:type_name -> buf.alpha.registry.v1alpha1.RepositoryCommit - 6, // 5: buf.alpha.registry.v1alpha1.RepositoryDraft.commit:type_name -> buf.alpha.registry.v1alpha1.RepositoryCommit - 0, // 6: buf.alpha.registry.v1alpha1.GetReferenceByNameResponse.reference:type_name -> buf.alpha.registry.v1alpha1.Reference - 3, // 7: buf.alpha.registry.v1alpha1.ReferenceService.GetReferenceByName:input_type -> buf.alpha.registry.v1alpha1.GetReferenceByNameRequest - 4, // 8: buf.alpha.registry.v1alpha1.ReferenceService.GetReferenceByName:output_type -> buf.alpha.registry.v1alpha1.GetReferenceByNameResponse - 8, // [8:9] is the sub-list for method output_type - 7, // [7:8] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 7, // 0: buf.alpha.registry.v1alpha1.Reference.tag:type_name -> buf.alpha.registry.v1alpha1.RepositoryTag + 8, // 1: buf.alpha.registry.v1alpha1.Reference.commit:type_name -> buf.alpha.registry.v1alpha1.RepositoryCommit + 1, // 2: buf.alpha.registry.v1alpha1.Reference.main:type_name -> buf.alpha.registry.v1alpha1.RepositoryMainReference + 2, // 3: buf.alpha.registry.v1alpha1.Reference.draft:type_name -> buf.alpha.registry.v1alpha1.RepositoryDraft + 8, // 4: buf.alpha.registry.v1alpha1.RepositoryMainReference.commit:type_name -> buf.alpha.registry.v1alpha1.RepositoryCommit + 8, // 5: buf.alpha.registry.v1alpha1.RepositoryDraft.commit:type_name -> buf.alpha.registry.v1alpha1.RepositoryCommit + 0, // 6: buf.alpha.registry.v1alpha1.GetReferenceByNameResponse.reference:type_name -> buf.alpha.registry.v1alpha1.Reference + 9, // 7: buf.alpha.registry.v1alpha1.ListGitCommitMetadataForReferenceResponse.git_commit_metadatas:type_name -> buf.alpha.registry.v1alpha1.GitCommitMetadata + 3, // 8: buf.alpha.registry.v1alpha1.ReferenceService.GetReferenceByName:input_type -> buf.alpha.registry.v1alpha1.GetReferenceByNameRequest + 5, // 9: buf.alpha.registry.v1alpha1.ReferenceService.ListGitCommitMetadataForReference:input_type -> buf.alpha.registry.v1alpha1.ListGitCommitMetadataForReferenceRequest + 4, // 10: buf.alpha.registry.v1alpha1.ReferenceService.GetReferenceByName:output_type -> buf.alpha.registry.v1alpha1.GetReferenceByNameResponse + 6, // 11: buf.alpha.registry.v1alpha1.ReferenceService.ListGitCommitMetadataForReference:output_type -> buf.alpha.registry.v1alpha1.ListGitCommitMetadataForReferenceResponse + 10, // [10:12] is the sub-list for method output_type + 8, // [8:10] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_buf_alpha_registry_v1alpha1_reference_proto_init() } @@ -513,6 +675,7 @@ func file_buf_alpha_registry_v1alpha1_reference_proto_init() { if File_buf_alpha_registry_v1alpha1_reference_proto != nil { return } + file_buf_alpha_registry_v1alpha1_git_metadata_proto_init() file_buf_alpha_registry_v1alpha1_repository_commit_proto_init() file_buf_alpha_registry_v1alpha1_repository_tag_proto_init() if !protoimpl.UnsafeEnabled { @@ -576,6 +739,30 @@ func file_buf_alpha_registry_v1alpha1_reference_proto_init() { return nil } } + file_buf_alpha_registry_v1alpha1_reference_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListGitCommitMetadataForReferenceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_reference_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListGitCommitMetadataForReferenceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_buf_alpha_registry_v1alpha1_reference_proto_msgTypes[0].OneofWrappers = []interface{}{ (*Reference_Tag)(nil), @@ -589,7 +776,7 @@ func file_buf_alpha_registry_v1alpha1_reference_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_alpha_registry_v1alpha1_reference_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository.pb.go index c222dcabd..156225732 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository.pb.go @@ -2769,8 +2769,8 @@ var file_buf_alpha_registry_v1alpha1_repository_proto_rawDesc = []byte{ 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, - 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x10, 0x02, 0x32, 0xfe, - 0x15, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, + 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x10, 0x02, 0x32, 0x8e, + 0x16, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7b, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, @@ -2828,7 +2828,7 @@ var file_buf_alpha_registry_v1alpha1_repository_proto_rawDesc = []byte{ 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, - 0x12, 0x9d, 0x01, 0x0a, 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, + 0x12, 0xa2, 0x01, 0x0a, 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x79, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, @@ -2838,25 +2838,26 @@ var file_buf_alpha_registry_v1alpha1_repository_proto_rawDesc = []byte{ 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x79, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x7f, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x6f, 0x72, 0x79, 0x12, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x62, 0x75, 0x66, + 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x84, 0x01, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, - 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x9d, 0x01, 0x0a, 0x1a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x79, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x3e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, - 0x79, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x3f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, - 0x79, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x9a, 0x01, 0x0a, 0x19, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x52, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0xa2, 0x01, 0x0a, + 0x1a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, + 0x79, 0x42, 0x79, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3e, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x79, 0x46, 0x75, 0x6c, 0x6c, + 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x79, 0x46, 0x75, 0x6c, 0x6c, + 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, + 0x02, 0x12, 0x9a, 0x01, 0x0a, 0x19, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_branch.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_branch.pb.go new file mode 100644 index 000000000..dd32965d0 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_branch.pb.go @@ -0,0 +1,410 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc (unknown) +// source: buf/alpha/registry/v1alpha1/repository_branch.proto + +package registryv1alpha1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type RepositoryBranch struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // primary key, unique, immutable + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // The name of the repository branch. + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // The name of the latest commit on the branch. + LatestCommitName string `protobuf:"bytes,3,opt,name=latest_commit_name,json=latestCommitName,proto3" json:"latest_commit_name,omitempty"` + // is_main_branch denotes whether this branch is considered the main branch of the repository. + IsMainBranch bool `protobuf:"varint,4,opt,name=is_main_branch,json=isMainBranch,proto3" json:"is_main_branch,omitempty"` + // The last update time of the branch. + LastUpdateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=last_update_time,json=lastUpdateTime,proto3" json:"last_update_time,omitempty"` +} + +func (x *RepositoryBranch) Reset() { + *x = RepositoryBranch{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RepositoryBranch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RepositoryBranch) ProtoMessage() {} + +func (x *RepositoryBranch) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RepositoryBranch.ProtoReflect.Descriptor instead. +func (*RepositoryBranch) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDescGZIP(), []int{0} +} + +func (x *RepositoryBranch) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *RepositoryBranch) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *RepositoryBranch) GetLatestCommitName() string { + if x != nil { + return x.LatestCommitName + } + return "" +} + +func (x *RepositoryBranch) GetIsMainBranch() bool { + if x != nil { + return x.IsMainBranch + } + return false +} + +func (x *RepositoryBranch) GetLastUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.LastUpdateTime + } + return nil +} + +type ListRepositoryBranchesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The ID of the repository whose branches should be listed. + RepositoryId string `protobuf:"bytes,1,opt,name=repository_id,json=repositoryId,proto3" json:"repository_id,omitempty"` + PageSize uint32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + // The first page is returned if this is empty. + PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` +} + +func (x *ListRepositoryBranchesRequest) Reset() { + *x = ListRepositoryBranchesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListRepositoryBranchesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRepositoryBranchesRequest) ProtoMessage() {} + +func (x *ListRepositoryBranchesRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRepositoryBranchesRequest.ProtoReflect.Descriptor instead. +func (*ListRepositoryBranchesRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDescGZIP(), []int{1} +} + +func (x *ListRepositoryBranchesRequest) GetRepositoryId() string { + if x != nil { + return x.RepositoryId + } + return "" +} + +func (x *ListRepositoryBranchesRequest) GetPageSize() uint32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListRepositoryBranchesRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +type ListRepositoryBranchesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RepositoryBranches []*RepositoryBranch `protobuf:"bytes,1,rep,name=repository_branches,json=repositoryBranches,proto3" json:"repository_branches,omitempty"` + // There are no more pages if this is empty. + NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` +} + +func (x *ListRepositoryBranchesResponse) Reset() { + *x = ListRepositoryBranchesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListRepositoryBranchesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRepositoryBranchesResponse) ProtoMessage() {} + +func (x *ListRepositoryBranchesResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRepositoryBranchesResponse.ProtoReflect.Descriptor instead. +func (*ListRepositoryBranchesResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDescGZIP(), []int{2} +} + +func (x *ListRepositoryBranchesResponse) GetRepositoryBranches() []*RepositoryBranch { + if x != nil { + return x.RepositoryBranches + } + return nil +} + +func (x *ListRepositoryBranchesResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +var File_buf_alpha_registry_v1alpha1_repository_branch_proto protoreflect.FileDescriptor + +var file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDesc = []byte{ + 0x0a, 0x33, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x72, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0xd0, 0x01, 0x0a, 0x10, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, + 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x12, + 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, + 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x4d, 0x61, 0x69, 0x6e, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, + 0x12, 0x44, 0x0a, 0x10, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x80, 0x01, 0x0a, 0x1d, 0x4c, 0x69, 0x73, 0x74, 0x52, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x1b, 0x0a, + 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, + 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xa8, 0x01, 0x0a, 0x1e, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, + 0x63, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5e, 0x0a, 0x13, + 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, + 0x68, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, + 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x12, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x6f, 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, + 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x32, 0xb2, 0x01, 0x0a, 0x17, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x96, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x12, 0x3a, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x6f, 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, 0xa2, 0x02, 0x0a, 0x1f, 0x63, 0x6f, + 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x15, 0x52, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, + 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, + 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, + 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDescOnce sync.Once + file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDescData = file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDesc +) + +func file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDescGZIP() []byte { + file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDescOnce.Do(func() { + file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDescData = protoimpl.X.CompressGZIP(file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDescData) + }) + return file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDescData +} + +var file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_buf_alpha_registry_v1alpha1_repository_branch_proto_goTypes = []interface{}{ + (*RepositoryBranch)(nil), // 0: buf.alpha.registry.v1alpha1.RepositoryBranch + (*ListRepositoryBranchesRequest)(nil), // 1: buf.alpha.registry.v1alpha1.ListRepositoryBranchesRequest + (*ListRepositoryBranchesResponse)(nil), // 2: buf.alpha.registry.v1alpha1.ListRepositoryBranchesResponse + (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp +} +var file_buf_alpha_registry_v1alpha1_repository_branch_proto_depIdxs = []int32{ + 3, // 0: buf.alpha.registry.v1alpha1.RepositoryBranch.last_update_time:type_name -> google.protobuf.Timestamp + 0, // 1: buf.alpha.registry.v1alpha1.ListRepositoryBranchesResponse.repository_branches:type_name -> buf.alpha.registry.v1alpha1.RepositoryBranch + 1, // 2: buf.alpha.registry.v1alpha1.RepositoryBranchService.ListRepositoryBranches:input_type -> buf.alpha.registry.v1alpha1.ListRepositoryBranchesRequest + 2, // 3: buf.alpha.registry.v1alpha1.RepositoryBranchService.ListRepositoryBranches:output_type -> buf.alpha.registry.v1alpha1.ListRepositoryBranchesResponse + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_buf_alpha_registry_v1alpha1_repository_branch_proto_init() } +func file_buf_alpha_registry_v1alpha1_repository_branch_proto_init() { + if File_buf_alpha_registry_v1alpha1_repository_branch_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RepositoryBranch); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRepositoryBranchesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRepositoryBranchesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_buf_alpha_registry_v1alpha1_repository_branch_proto_goTypes, + DependencyIndexes: file_buf_alpha_registry_v1alpha1_repository_branch_proto_depIdxs, + MessageInfos: file_buf_alpha_registry_v1alpha1_repository_branch_proto_msgTypes, + }.Build() + File_buf_alpha_registry_v1alpha1_repository_branch_proto = out.File + file_buf_alpha_registry_v1alpha1_repository_branch_proto_rawDesc = nil + file_buf_alpha_registry_v1alpha1_repository_branch_proto_goTypes = nil + file_buf_alpha_registry_v1alpha1_repository_branch_proto_depIdxs = nil +} diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_commit.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_commit.pb.go index 8f216d1aa..d0377dd1d 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_commit.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_commit.pb.go @@ -69,7 +69,7 @@ type RepositoryCommit struct { // https://spdx.org/licenses, and will be not set if the license file is not // presented or cannot be classified into a known license. SpdxLicenseId string `protobuf:"bytes,10,opt,name=spdx_license_id,json=spdxLicenseId,proto3" json:"spdx_license_id,omitempty"` - // The manifest digest of the commit. Populated via Tamper Proofing. + // The manifest digest of the commit. ManifestDigest string `protobuf:"bytes,11,opt,name=manifest_digest,json=manifestDigest,proto3" json:"manifest_digest,omitempty"` } @@ -1125,7 +1125,7 @@ var file_buf_alpha_registry_v1alpha1_repository_commit_proto_rawDesc = []byte{ 0x09, 0x64, 0x72, 0x61, 0x66, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x25, 0x0a, 0x23, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x72, 0x61, 0x66, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x32, 0xae, 0x08, 0x0a, 0x17, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x65, 0x32, 0xb3, 0x08, 0x0a, 0x17, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xae, 0x01, 0x0a, 0x1d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x42, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, @@ -1182,7 +1182,7 @@ var file_buf_alpha_registry_v1alpha1_repository_commit_proto_rawDesc = []byte{ 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x72, 0x61, 0x66, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, - 0xa0, 0x01, 0x0a, 0x1b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0xa5, 0x01, 0x0a, 0x1b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x72, 0x61, 0x66, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x3f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, @@ -1192,25 +1192,26 @@ var file_buf_alpha_registry_v1alpha1_repository_commit_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x72, 0x61, 0x66, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0xa2, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x15, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, - 0x72, 0x79, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, - 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, - 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, - 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, - 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, - 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, - 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x42, 0xa2, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x15, 0x52, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, + 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, + 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, + 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_tag.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_tag.pb.go index 8b7e5f0c6..ec0ecc59a 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_tag.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/repository_tag.pb.go @@ -417,9 +417,9 @@ var file_buf_alpha_registry_v1alpha1_repository_tag_proto_rawDesc = []byte{ 0x54, 0x61, 0x67, 0x52, 0x0e, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, - 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x32, 0xae, 0x02, 0x0a, 0x14, + 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x32, 0xb3, 0x02, 0x0a, 0x14, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x67, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x88, 0x01, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x8d, 0x01, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x67, 0x12, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, @@ -427,35 +427,35 @@ var file_buf_alpha_registry_v1alpha1_repository_tag_proto_rawDesc = []byte{ 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x8a, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, - 0x72, 0x79, 0x54, 0x61, 0x67, 0x73, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x67, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, 0x9f, 0x02, 0x0a, - 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x42, 0x12, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x67, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, - 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, - 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, - 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x03, 0x90, 0x02, 0x02, 0x12, 0x8a, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x67, 0x73, 0x12, 0x36, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, + 0x01, 0x42, 0x9f, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x12, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, + 0x79, 0x54, 0x61, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, + 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, + 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, + 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, + 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, + 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/resolve.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/resolve.pb.go index e90f0e64f..f15012c56 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/resolve.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/resolve.pb.go @@ -370,6 +370,498 @@ func (x *GetLocalModulePinsResponse) GetDependencies() []*v1alpha1.ModulePin { return nil } +type GetGoVersionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The plugin reference to resolve. + PluginReference *GetRemotePackageVersionPlugin `protobuf:"bytes,1,opt,name=plugin_reference,json=pluginReference,proto3" json:"plugin_reference,omitempty"` + // The module reference to resolve. + ModuleReference *LocalModuleReference `protobuf:"bytes,2,opt,name=module_reference,json=moduleReference,proto3" json:"module_reference,omitempty"` +} + +func (x *GetGoVersionRequest) Reset() { + *x = GetGoVersionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetGoVersionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetGoVersionRequest) ProtoMessage() {} + +func (x *GetGoVersionRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetGoVersionRequest.ProtoReflect.Descriptor instead. +func (*GetGoVersionRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_resolve_proto_rawDescGZIP(), []int{5} +} + +func (x *GetGoVersionRequest) GetPluginReference() *GetRemotePackageVersionPlugin { + if x != nil { + return x.PluginReference + } + return nil +} + +func (x *GetGoVersionRequest) GetModuleReference() *LocalModuleReference { + if x != nil { + return x.ModuleReference + } + return nil +} + +type GetGoVersionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // version is the resolved version to be used with the go module proxy. + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` +} + +func (x *GetGoVersionResponse) Reset() { + *x = GetGoVersionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetGoVersionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetGoVersionResponse) ProtoMessage() {} + +func (x *GetGoVersionResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetGoVersionResponse.ProtoReflect.Descriptor instead. +func (*GetGoVersionResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_resolve_proto_rawDescGZIP(), []int{6} +} + +func (x *GetGoVersionResponse) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +type GetMavenVersionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The plugin reference to resolve. + PluginReference *GetRemotePackageVersionPlugin `protobuf:"bytes,1,opt,name=plugin_reference,json=pluginReference,proto3" json:"plugin_reference,omitempty"` + // The module reference to resolve. + ModuleReference *LocalModuleReference `protobuf:"bytes,2,opt,name=module_reference,json=moduleReference,proto3" json:"module_reference,omitempty"` +} + +func (x *GetMavenVersionRequest) Reset() { + *x = GetMavenVersionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetMavenVersionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetMavenVersionRequest) ProtoMessage() {} + +func (x *GetMavenVersionRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetMavenVersionRequest.ProtoReflect.Descriptor instead. +func (*GetMavenVersionRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_resolve_proto_rawDescGZIP(), []int{7} +} + +func (x *GetMavenVersionRequest) GetPluginReference() *GetRemotePackageVersionPlugin { + if x != nil { + return x.PluginReference + } + return nil +} + +func (x *GetMavenVersionRequest) GetModuleReference() *LocalModuleReference { + if x != nil { + return x.ModuleReference + } + return nil +} + +type GetMavenVersionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // version is the resolved version to be used with the maven repository. + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` +} + +func (x *GetMavenVersionResponse) Reset() { + *x = GetMavenVersionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetMavenVersionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetMavenVersionResponse) ProtoMessage() {} + +func (x *GetMavenVersionResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetMavenVersionResponse.ProtoReflect.Descriptor instead. +func (*GetMavenVersionResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_resolve_proto_rawDescGZIP(), []int{8} +} + +func (x *GetMavenVersionResponse) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +type GetNPMVersionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The plugin reference to resolve. + PluginReference *GetRemotePackageVersionPlugin `protobuf:"bytes,1,opt,name=plugin_reference,json=pluginReference,proto3" json:"plugin_reference,omitempty"` + // The module reference to resolve. + ModuleReference *LocalModuleReference `protobuf:"bytes,2,opt,name=module_reference,json=moduleReference,proto3" json:"module_reference,omitempty"` +} + +func (x *GetNPMVersionRequest) Reset() { + *x = GetNPMVersionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetNPMVersionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNPMVersionRequest) ProtoMessage() {} + +func (x *GetNPMVersionRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNPMVersionRequest.ProtoReflect.Descriptor instead. +func (*GetNPMVersionRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_resolve_proto_rawDescGZIP(), []int{9} +} + +func (x *GetNPMVersionRequest) GetPluginReference() *GetRemotePackageVersionPlugin { + if x != nil { + return x.PluginReference + } + return nil +} + +func (x *GetNPMVersionRequest) GetModuleReference() *LocalModuleReference { + if x != nil { + return x.ModuleReference + } + return nil +} + +type GetNPMVersionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // version is the resolved version to be used with the npm registry. + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` +} + +func (x *GetNPMVersionResponse) Reset() { + *x = GetNPMVersionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetNPMVersionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNPMVersionResponse) ProtoMessage() {} + +func (x *GetNPMVersionResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNPMVersionResponse.ProtoReflect.Descriptor instead. +func (*GetNPMVersionResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_resolve_proto_rawDescGZIP(), []int{10} +} + +func (x *GetNPMVersionResponse) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +type GetSwiftVersionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The plugin reference to resolve. + PluginReference *GetRemotePackageVersionPlugin `protobuf:"bytes,1,opt,name=plugin_reference,json=pluginReference,proto3" json:"plugin_reference,omitempty"` + // The module reference to resolve. + ModuleReference *LocalModuleReference `protobuf:"bytes,2,opt,name=module_reference,json=moduleReference,proto3" json:"module_reference,omitempty"` +} + +func (x *GetSwiftVersionRequest) Reset() { + *x = GetSwiftVersionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetSwiftVersionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSwiftVersionRequest) ProtoMessage() {} + +func (x *GetSwiftVersionRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSwiftVersionRequest.ProtoReflect.Descriptor instead. +func (*GetSwiftVersionRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_resolve_proto_rawDescGZIP(), []int{11} +} + +func (x *GetSwiftVersionRequest) GetPluginReference() *GetRemotePackageVersionPlugin { + if x != nil { + return x.PluginReference + } + return nil +} + +func (x *GetSwiftVersionRequest) GetModuleReference() *LocalModuleReference { + if x != nil { + return x.ModuleReference + } + return nil +} + +type GetSwiftVersionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // version is the resolved version to be used with the swift registry. + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` +} + +func (x *GetSwiftVersionResponse) Reset() { + *x = GetSwiftVersionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetSwiftVersionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSwiftVersionResponse) ProtoMessage() {} + +func (x *GetSwiftVersionResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSwiftVersionResponse.ProtoReflect.Descriptor instead. +func (*GetSwiftVersionResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_resolve_proto_rawDescGZIP(), []int{12} +} + +func (x *GetSwiftVersionResponse) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +// GetRemotePackageVersionPlugin is a plugin reference. +// If the version is empty, this is a reference to the latest version. +type GetRemotePackageVersionPlugin struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The owner of the plugin. + // example: bufbuild + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // The name of the plugin. + // example: connect-go + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // The version of the plugin. + // If empty, this is a reference to the latest version. + // example: v1.0.0 + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` +} + +func (x *GetRemotePackageVersionPlugin) Reset() { + *x = GetRemotePackageVersionPlugin{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRemotePackageVersionPlugin) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRemotePackageVersionPlugin) ProtoMessage() {} + +func (x *GetRemotePackageVersionPlugin) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRemotePackageVersionPlugin.ProtoReflect.Descriptor instead. +func (*GetRemotePackageVersionPlugin) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_resolve_proto_rawDescGZIP(), []int{13} +} + +func (x *GetRemotePackageVersionPlugin) GetOwner() string { + if x != nil { + return x.Owner + } + return "" +} + +func (x *GetRemotePackageVersionPlugin) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *GetRemotePackageVersionPlugin) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + var File_buf_alpha_registry_v1alpha1_resolve_proto protoreflect.FileDescriptor var file_buf_alpha_registry_v1alpha1_resolve_proto_rawDesc = []byte{ @@ -441,60 +933,167 @@ var file_buf_alpha_registry_v1alpha1_resolve_proto_rawDesc = []byte{ 0x0b, 0x32, 0x24, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x52, 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, - 0x6e, 0x63, 0x69, 0x65, 0x73, 0x2a, 0xf3, 0x01, 0x0a, 0x15, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, - 0x65, 0x64, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x27, 0x0a, 0x23, 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, - 0x52, 0x45, 0x4e, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, - 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x22, 0x0a, 0x1e, 0x52, 0x45, 0x53, 0x4f, - 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, 0x43, 0x45, 0x5f, 0x54, - 0x59, 0x50, 0x45, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x01, 0x12, 0x1f, 0x0a, 0x1b, - 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, - 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x41, 0x47, 0x10, 0x03, 0x12, 0x21, 0x0a, - 0x1d, 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, - 0x4e, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x44, 0x52, 0x41, 0x46, 0x54, 0x10, 0x05, - 0x22, 0x04, 0x08, 0x02, 0x10, 0x02, 0x22, 0x04, 0x08, 0x04, 0x10, 0x04, 0x2a, 0x1e, 0x52, 0x45, - 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, 0x43, 0x45, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x52, 0x41, 0x4e, 0x43, 0x48, 0x2a, 0x1d, 0x52, 0x45, - 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, 0x43, 0x45, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x43, 0x4b, 0x32, 0x8d, 0x01, 0x0a, 0x0e, - 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7b, - 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x73, 0x12, - 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x6e, 0x63, 0x69, 0x65, 0x73, 0x22, 0xda, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x47, 0x6f, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x65, 0x0a, + 0x10, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x52, 0x0f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x12, 0x5c, 0x0a, 0x10, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x72, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x63, + 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x52, 0x0f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x22, 0x30, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x47, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xdd, 0x01, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x76, 0x65, + 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x65, 0x0a, 0x10, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x6d, 0x6f, 0x74, + 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x50, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x0f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x5c, 0x0a, 0x10, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, + 0x6f, 0x63, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x0f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x22, 0x33, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x76, 0x65, 0x6e, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xdb, 0x01, 0x0a, 0x14, 0x47, 0x65, + 0x74, 0x4e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x65, 0x0a, 0x10, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, + 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x0f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x5c, 0x0a, 0x10, 0x6d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, + 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x31, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x4e, 0x50, + 0x4d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xdd, 0x01, 0x0a, 0x16, 0x47, + 0x65, 0x74, 0x53, 0x77, 0x69, 0x66, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x65, 0x0a, 0x10, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, + 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, - 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x32, 0xa2, 0x01, 0x0a, 0x13, - 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x8a, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x63, 0x61, 0x6c, - 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x73, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x63, 0x61, - 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, - 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, - 0x42, 0x99, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x74, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x52, 0x0f, 0x70, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x5c, 0x0a, 0x10, + 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x42, 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, - 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, - 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, - 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, - 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, + 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x33, 0x0a, 0x17, 0x47, 0x65, + 0x74, 0x53, 0x77, 0x69, 0x66, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, + 0x63, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x2a, 0xf3, 0x01, 0x0a, 0x15, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, + 0x64, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x27, + 0x0a, 0x23, 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, + 0x45, 0x4e, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x22, 0x0a, 0x1e, 0x52, 0x45, 0x53, 0x4f, 0x4c, + 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, 0x43, 0x45, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x01, 0x12, 0x1f, 0x0a, 0x1b, 0x52, + 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, 0x43, + 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x41, 0x47, 0x10, 0x03, 0x12, 0x21, 0x0a, 0x1d, + 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, + 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x44, 0x52, 0x41, 0x46, 0x54, 0x10, 0x05, 0x22, + 0x04, 0x08, 0x02, 0x10, 0x02, 0x22, 0x04, 0x08, 0x04, 0x10, 0x04, 0x2a, 0x1e, 0x52, 0x45, 0x53, + 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, 0x43, 0x45, 0x5f, + 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x52, 0x41, 0x4e, 0x43, 0x48, 0x2a, 0x1d, 0x52, 0x45, 0x53, + 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, 0x43, 0x45, 0x5f, + 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x43, 0x4b, 0x32, 0x8c, 0x05, 0x0a, 0x0e, 0x52, + 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7b, 0x0a, + 0x0d, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x73, 0x12, 0x31, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x32, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x78, 0x0a, 0x0c, 0x47, 0x65, + 0x74, 0x47, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x6f, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x6f, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x03, 0x90, 0x02, 0x01, 0x12, 0x81, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x77, 0x69, 0x66, + 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x77, 0x69, 0x66, 0x74, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, + 0x77, 0x69, 0x66, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x81, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, + 0x4d, 0x61, 0x76, 0x65, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x61, + 0x76, 0x65, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x47, 0x65, 0x74, 0x4d, 0x61, 0x76, 0x65, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x7b, 0x0a, 0x0d, + 0x47, 0x65, 0x74, 0x4e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x31, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4e, + 0x50, 0x4d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x32, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, + 0x65, 0x74, 0x4e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x32, 0xa2, 0x01, 0x0a, 0x13, 0x4c, 0x6f, + 0x63, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x8a, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x73, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, + 0x65, 0x74, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x69, 0x6e, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, 0x99, + 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x42, 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, + 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, + 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, + 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, + 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, + 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, + 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -510,38 +1109,63 @@ func file_buf_alpha_registry_v1alpha1_resolve_proto_rawDescGZIP() []byte { } var file_buf_alpha_registry_v1alpha1_resolve_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_buf_alpha_registry_v1alpha1_resolve_proto_goTypes = []interface{}{ - (ResolvedReferenceType)(0), // 0: buf.alpha.registry.v1alpha1.ResolvedReferenceType - (*GetModulePinsRequest)(nil), // 1: buf.alpha.registry.v1alpha1.GetModulePinsRequest - (*GetModulePinsResponse)(nil), // 2: buf.alpha.registry.v1alpha1.GetModulePinsResponse - (*GetLocalModulePinsRequest)(nil), // 3: buf.alpha.registry.v1alpha1.GetLocalModulePinsRequest - (*LocalModuleResolveResult)(nil), // 4: buf.alpha.registry.v1alpha1.LocalModuleResolveResult - (*GetLocalModulePinsResponse)(nil), // 5: buf.alpha.registry.v1alpha1.GetLocalModulePinsResponse - (*v1alpha1.ModuleReference)(nil), // 6: buf.alpha.module.v1alpha1.ModuleReference - (*v1alpha1.ModulePin)(nil), // 7: buf.alpha.module.v1alpha1.ModulePin - (*LocalModuleReference)(nil), // 8: buf.alpha.registry.v1alpha1.LocalModuleReference - (*LocalModulePin)(nil), // 9: buf.alpha.registry.v1alpha1.LocalModulePin + (ResolvedReferenceType)(0), // 0: buf.alpha.registry.v1alpha1.ResolvedReferenceType + (*GetModulePinsRequest)(nil), // 1: buf.alpha.registry.v1alpha1.GetModulePinsRequest + (*GetModulePinsResponse)(nil), // 2: buf.alpha.registry.v1alpha1.GetModulePinsResponse + (*GetLocalModulePinsRequest)(nil), // 3: buf.alpha.registry.v1alpha1.GetLocalModulePinsRequest + (*LocalModuleResolveResult)(nil), // 4: buf.alpha.registry.v1alpha1.LocalModuleResolveResult + (*GetLocalModulePinsResponse)(nil), // 5: buf.alpha.registry.v1alpha1.GetLocalModulePinsResponse + (*GetGoVersionRequest)(nil), // 6: buf.alpha.registry.v1alpha1.GetGoVersionRequest + (*GetGoVersionResponse)(nil), // 7: buf.alpha.registry.v1alpha1.GetGoVersionResponse + (*GetMavenVersionRequest)(nil), // 8: buf.alpha.registry.v1alpha1.GetMavenVersionRequest + (*GetMavenVersionResponse)(nil), // 9: buf.alpha.registry.v1alpha1.GetMavenVersionResponse + (*GetNPMVersionRequest)(nil), // 10: buf.alpha.registry.v1alpha1.GetNPMVersionRequest + (*GetNPMVersionResponse)(nil), // 11: buf.alpha.registry.v1alpha1.GetNPMVersionResponse + (*GetSwiftVersionRequest)(nil), // 12: buf.alpha.registry.v1alpha1.GetSwiftVersionRequest + (*GetSwiftVersionResponse)(nil), // 13: buf.alpha.registry.v1alpha1.GetSwiftVersionResponse + (*GetRemotePackageVersionPlugin)(nil), // 14: buf.alpha.registry.v1alpha1.GetRemotePackageVersionPlugin + (*v1alpha1.ModuleReference)(nil), // 15: buf.alpha.module.v1alpha1.ModuleReference + (*v1alpha1.ModulePin)(nil), // 16: buf.alpha.module.v1alpha1.ModulePin + (*LocalModuleReference)(nil), // 17: buf.alpha.registry.v1alpha1.LocalModuleReference + (*LocalModulePin)(nil), // 18: buf.alpha.registry.v1alpha1.LocalModulePin } var file_buf_alpha_registry_v1alpha1_resolve_proto_depIdxs = []int32{ - 6, // 0: buf.alpha.registry.v1alpha1.GetModulePinsRequest.module_references:type_name -> buf.alpha.module.v1alpha1.ModuleReference - 7, // 1: buf.alpha.registry.v1alpha1.GetModulePinsRequest.current_module_pins:type_name -> buf.alpha.module.v1alpha1.ModulePin - 7, // 2: buf.alpha.registry.v1alpha1.GetModulePinsResponse.module_pins:type_name -> buf.alpha.module.v1alpha1.ModulePin - 8, // 3: buf.alpha.registry.v1alpha1.GetLocalModulePinsRequest.local_module_references:type_name -> buf.alpha.registry.v1alpha1.LocalModuleReference - 8, // 4: buf.alpha.registry.v1alpha1.LocalModuleResolveResult.reference:type_name -> buf.alpha.registry.v1alpha1.LocalModuleReference - 9, // 5: buf.alpha.registry.v1alpha1.LocalModuleResolveResult.pin:type_name -> buf.alpha.registry.v1alpha1.LocalModulePin + 15, // 0: buf.alpha.registry.v1alpha1.GetModulePinsRequest.module_references:type_name -> buf.alpha.module.v1alpha1.ModuleReference + 16, // 1: buf.alpha.registry.v1alpha1.GetModulePinsRequest.current_module_pins:type_name -> buf.alpha.module.v1alpha1.ModulePin + 16, // 2: buf.alpha.registry.v1alpha1.GetModulePinsResponse.module_pins:type_name -> buf.alpha.module.v1alpha1.ModulePin + 17, // 3: buf.alpha.registry.v1alpha1.GetLocalModulePinsRequest.local_module_references:type_name -> buf.alpha.registry.v1alpha1.LocalModuleReference + 17, // 4: buf.alpha.registry.v1alpha1.LocalModuleResolveResult.reference:type_name -> buf.alpha.registry.v1alpha1.LocalModuleReference + 18, // 5: buf.alpha.registry.v1alpha1.LocalModuleResolveResult.pin:type_name -> buf.alpha.registry.v1alpha1.LocalModulePin 0, // 6: buf.alpha.registry.v1alpha1.LocalModuleResolveResult.resolved_reference_type:type_name -> buf.alpha.registry.v1alpha1.ResolvedReferenceType 4, // 7: buf.alpha.registry.v1alpha1.GetLocalModulePinsResponse.local_module_resolve_results:type_name -> buf.alpha.registry.v1alpha1.LocalModuleResolveResult - 7, // 8: buf.alpha.registry.v1alpha1.GetLocalModulePinsResponse.dependencies:type_name -> buf.alpha.module.v1alpha1.ModulePin - 1, // 9: buf.alpha.registry.v1alpha1.ResolveService.GetModulePins:input_type -> buf.alpha.registry.v1alpha1.GetModulePinsRequest - 3, // 10: buf.alpha.registry.v1alpha1.LocalResolveService.GetLocalModulePins:input_type -> buf.alpha.registry.v1alpha1.GetLocalModulePinsRequest - 2, // 11: buf.alpha.registry.v1alpha1.ResolveService.GetModulePins:output_type -> buf.alpha.registry.v1alpha1.GetModulePinsResponse - 5, // 12: buf.alpha.registry.v1alpha1.LocalResolveService.GetLocalModulePins:output_type -> buf.alpha.registry.v1alpha1.GetLocalModulePinsResponse - 11, // [11:13] is the sub-list for method output_type - 9, // [9:11] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 16, // 8: buf.alpha.registry.v1alpha1.GetLocalModulePinsResponse.dependencies:type_name -> buf.alpha.module.v1alpha1.ModulePin + 14, // 9: buf.alpha.registry.v1alpha1.GetGoVersionRequest.plugin_reference:type_name -> buf.alpha.registry.v1alpha1.GetRemotePackageVersionPlugin + 17, // 10: buf.alpha.registry.v1alpha1.GetGoVersionRequest.module_reference:type_name -> buf.alpha.registry.v1alpha1.LocalModuleReference + 14, // 11: buf.alpha.registry.v1alpha1.GetMavenVersionRequest.plugin_reference:type_name -> buf.alpha.registry.v1alpha1.GetRemotePackageVersionPlugin + 17, // 12: buf.alpha.registry.v1alpha1.GetMavenVersionRequest.module_reference:type_name -> buf.alpha.registry.v1alpha1.LocalModuleReference + 14, // 13: buf.alpha.registry.v1alpha1.GetNPMVersionRequest.plugin_reference:type_name -> buf.alpha.registry.v1alpha1.GetRemotePackageVersionPlugin + 17, // 14: buf.alpha.registry.v1alpha1.GetNPMVersionRequest.module_reference:type_name -> buf.alpha.registry.v1alpha1.LocalModuleReference + 14, // 15: buf.alpha.registry.v1alpha1.GetSwiftVersionRequest.plugin_reference:type_name -> buf.alpha.registry.v1alpha1.GetRemotePackageVersionPlugin + 17, // 16: buf.alpha.registry.v1alpha1.GetSwiftVersionRequest.module_reference:type_name -> buf.alpha.registry.v1alpha1.LocalModuleReference + 1, // 17: buf.alpha.registry.v1alpha1.ResolveService.GetModulePins:input_type -> buf.alpha.registry.v1alpha1.GetModulePinsRequest + 6, // 18: buf.alpha.registry.v1alpha1.ResolveService.GetGoVersion:input_type -> buf.alpha.registry.v1alpha1.GetGoVersionRequest + 12, // 19: buf.alpha.registry.v1alpha1.ResolveService.GetSwiftVersion:input_type -> buf.alpha.registry.v1alpha1.GetSwiftVersionRequest + 8, // 20: buf.alpha.registry.v1alpha1.ResolveService.GetMavenVersion:input_type -> buf.alpha.registry.v1alpha1.GetMavenVersionRequest + 10, // 21: buf.alpha.registry.v1alpha1.ResolveService.GetNPMVersion:input_type -> buf.alpha.registry.v1alpha1.GetNPMVersionRequest + 3, // 22: buf.alpha.registry.v1alpha1.LocalResolveService.GetLocalModulePins:input_type -> buf.alpha.registry.v1alpha1.GetLocalModulePinsRequest + 2, // 23: buf.alpha.registry.v1alpha1.ResolveService.GetModulePins:output_type -> buf.alpha.registry.v1alpha1.GetModulePinsResponse + 7, // 24: buf.alpha.registry.v1alpha1.ResolveService.GetGoVersion:output_type -> buf.alpha.registry.v1alpha1.GetGoVersionResponse + 13, // 25: buf.alpha.registry.v1alpha1.ResolveService.GetSwiftVersion:output_type -> buf.alpha.registry.v1alpha1.GetSwiftVersionResponse + 9, // 26: buf.alpha.registry.v1alpha1.ResolveService.GetMavenVersion:output_type -> buf.alpha.registry.v1alpha1.GetMavenVersionResponse + 11, // 27: buf.alpha.registry.v1alpha1.ResolveService.GetNPMVersion:output_type -> buf.alpha.registry.v1alpha1.GetNPMVersionResponse + 5, // 28: buf.alpha.registry.v1alpha1.LocalResolveService.GetLocalModulePins:output_type -> buf.alpha.registry.v1alpha1.GetLocalModulePinsResponse + 23, // [23:29] is the sub-list for method output_type + 17, // [17:23] is the sub-list for method input_type + 17, // [17:17] is the sub-list for extension type_name + 17, // [17:17] is the sub-list for extension extendee + 0, // [0:17] is the sub-list for field type_name } func init() { file_buf_alpha_registry_v1alpha1_resolve_proto_init() } @@ -611,6 +1235,114 @@ func file_buf_alpha_registry_v1alpha1_resolve_proto_init() { return nil } } + file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetGoVersionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetGoVersionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetMavenVersionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetMavenVersionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetNPMVersionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetNPMVersionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetSwiftVersionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetSwiftVersionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_resolve_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetRemotePackageVersionPlugin); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -618,7 +1350,7 @@ func file_buf_alpha_registry_v1alpha1_resolve_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_alpha_registry_v1alpha1_resolve_proto_rawDesc, NumEnums: 1, - NumMessages: 5, + NumMessages: 14, NumExtensions: 0, NumServices: 2, }, diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/scim_token.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/scim_token.pb.go index 2964ae8f0..1d3e98f41 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/scim_token.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/scim_token.pb.go @@ -447,7 +447,7 @@ var file_buf_alpha_registry_v1alpha1_scim_token_proto_rawDesc = []byte{ 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x64, 0x22, 0x19, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x43, 0x49, - 0x4d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x8e, + 0x4d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x94, 0x03, 0x0a, 0x10, 0x53, 0x43, 0x49, 0x4d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7c, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x43, 0x49, 0x4d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, @@ -465,33 +465,33 @@ var file_buf_alpha_registry_v1alpha1_scim_token_proto_rawDesc = []byte{ 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x43, 0x49, 0x4d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, - 0x01, 0x12, 0x7c, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x43, 0x49, 0x4d, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x43, 0x49, 0x4d, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x43, - 0x49, 0x4d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, - 0x9b, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x01, 0x12, 0x81, 0x01, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x43, 0x49, 0x4d, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x42, 0x0e, 0x53, 0x63, 0x69, 0x6d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, - 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, - 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, - 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x43, 0x49, 0x4d, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, + 0x43, 0x49, 0x4d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x03, 0x90, 0x02, 0x02, 0x42, 0x9b, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0e, 0x53, 0x63, 0x69, 0x6d, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, + 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, + 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, + 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, + 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, + 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/studio_request.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/studio_request.pb.go index 30cb8950c..8c40f60ae 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/studio_request.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/studio_request.pb.go @@ -917,7 +917,7 @@ var file_buf_alpha_registry_v1alpha1_studio_request_proto_rawDesc = []byte{ 0x4f, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x47, 0x52, 0x50, 0x43, 0x10, 0x02, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x54, 0x55, 0x44, 0x49, 0x4f, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x47, 0x52, 0x50, 0x43, 0x5f, 0x57, 0x45, 0x42, 0x10, 0x03, 0x32, - 0xca, 0x04, 0x0a, 0x14, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0xcd, 0x04, 0x0a, 0x14, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x8a, 0x01, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, @@ -936,7 +936,7 @@ var file_buf_alpha_registry_v1alpha1_studio_request_proto_rawDesc = []byte{ 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x8a, 0x01, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x74, 0x75, + 0x22, 0x00, 0x12, 0x8d, 0x01, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, @@ -944,35 +944,35 @@ var file_buf_alpha_registry_v1alpha1_studio_request_proto_rawDesc = []byte{ 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x8a, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, - 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, 0x9f, 0x02, 0x0a, - 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x42, 0x12, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, - 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, - 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, - 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, + 0x02, 0x02, 0x12, 0x8a, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x74, 0x75, 0x64, 0x69, + 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x74, 0x75, 0x64, + 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x4c, 0x69, 0x73, 0x74, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, + 0x9f, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x42, 0x12, 0x53, 0x74, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, + 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, + 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, + 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, + 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/sync.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/sync.pb.go new file mode 100644 index 000000000..009121aa6 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/sync.pb.go @@ -0,0 +1,633 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc (unknown) +// source: buf/alpha/registry/v1alpha1/sync.proto + +package registryv1alpha1 + +import ( + v1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/module/v1alpha1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// GitSyncPoint is the sync point for a particular module contained in a Git repository. +type GitSyncPoint struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + Repository string `protobuf:"bytes,2,opt,name=repository,proto3" json:"repository,omitempty"` + Branch string `protobuf:"bytes,3,opt,name=branch,proto3" json:"branch,omitempty"` + GitCommitHash string `protobuf:"bytes,4,opt,name=git_commit_hash,json=gitCommitHash,proto3" json:"git_commit_hash,omitempty"` + BsrCommitName string `protobuf:"bytes,5,opt,name=bsr_commit_name,json=bsrCommitName,proto3" json:"bsr_commit_name,omitempty"` +} + +func (x *GitSyncPoint) Reset() { + *x = GitSyncPoint{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GitSyncPoint) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GitSyncPoint) ProtoMessage() {} + +func (x *GitSyncPoint) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GitSyncPoint.ProtoReflect.Descriptor instead. +func (*GitSyncPoint) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_sync_proto_rawDescGZIP(), []int{0} +} + +func (x *GitSyncPoint) GetOwner() string { + if x != nil { + return x.Owner + } + return "" +} + +func (x *GitSyncPoint) GetRepository() string { + if x != nil { + return x.Repository + } + return "" +} + +func (x *GitSyncPoint) GetBranch() string { + if x != nil { + return x.Branch + } + return "" +} + +func (x *GitSyncPoint) GetGitCommitHash() string { + if x != nil { + return x.GitCommitHash + } + return "" +} + +func (x *GitSyncPoint) GetBsrCommitName() string { + if x != nil { + return x.BsrCommitName + } + return "" +} + +type GetGitSyncPointRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Owner is the owner of the BSR repository. + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // Repository is the name of the BSR repository. + Repository string `protobuf:"bytes,2,opt,name=repository,proto3" json:"repository,omitempty"` + // Branch is the Git branch for which to look up the commit. + Branch string `protobuf:"bytes,3,opt,name=branch,proto3" json:"branch,omitempty"` +} + +func (x *GetGitSyncPointRequest) Reset() { + *x = GetGitSyncPointRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetGitSyncPointRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetGitSyncPointRequest) ProtoMessage() {} + +func (x *GetGitSyncPointRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetGitSyncPointRequest.ProtoReflect.Descriptor instead. +func (*GetGitSyncPointRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_sync_proto_rawDescGZIP(), []int{1} +} + +func (x *GetGitSyncPointRequest) GetOwner() string { + if x != nil { + return x.Owner + } + return "" +} + +func (x *GetGitSyncPointRequest) GetRepository() string { + if x != nil { + return x.Repository + } + return "" +} + +func (x *GetGitSyncPointRequest) GetBranch() string { + if x != nil { + return x.Branch + } + return "" +} + +type GetGitSyncPointResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // SyncPoint is the latest syncpoint for the specified owner/repo/branch. + SyncPoint *GitSyncPoint `protobuf:"bytes,1,opt,name=sync_point,json=syncPoint,proto3" json:"sync_point,omitempty"` +} + +func (x *GetGitSyncPointResponse) Reset() { + *x = GetGitSyncPointResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetGitSyncPointResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetGitSyncPointResponse) ProtoMessage() {} + +func (x *GetGitSyncPointResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetGitSyncPointResponse.ProtoReflect.Descriptor instead. +func (*GetGitSyncPointResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_sync_proto_rawDescGZIP(), []int{2} +} + +func (x *GetGitSyncPointResponse) GetSyncPoint() *GitSyncPoint { + if x != nil { + return x.SyncPoint + } + return nil +} + +type SyncGitCommitRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Owner is the owner of the BSR repository. + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // Repository is the name of the BSR repository. + Repository string `protobuf:"bytes,2,opt,name=repository,proto3" json:"repository,omitempty"` + // Branch is the Git branch that this commit belongs to. + Branch string `protobuf:"bytes,3,opt,name=branch,proto3" json:"branch,omitempty"` + // Manifest with all the module files being pushed. + Manifest *v1alpha1.Blob `protobuf:"bytes,4,opt,name=manifest,proto3" json:"manifest,omitempty"` + // Referenced blobs in the manifest. Keep in mind there is not necessarily one + // blob per file, but one blob per digest, so for files with exactly the same + // content, you can send just one blob. + Blobs []*v1alpha1.Blob `protobuf:"bytes,5,rep,name=blobs,proto3" json:"blobs,omitempty"` + // Hash is the SHA1 hash of the Git commit. + Hash string `protobuf:"bytes,6,opt,name=hash,proto3" json:"hash,omitempty"` + // Author is the author of the Git commit. This is typically an end-user. + Author *GitIdentity `protobuf:"bytes,7,opt,name=author,proto3" json:"author,omitempty"` + // Commiter is the commiter of the Git commit. This typically a CI system. + Commiter *GitIdentity `protobuf:"bytes,8,opt,name=commiter,proto3" json:"commiter,omitempty"` + // Tags are the Git tags which point to this commit. + Tags []string `protobuf:"bytes,9,rep,name=tags,proto3" json:"tags,omitempty"` +} + +func (x *SyncGitCommitRequest) Reset() { + *x = SyncGitCommitRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SyncGitCommitRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SyncGitCommitRequest) ProtoMessage() {} + +func (x *SyncGitCommitRequest) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SyncGitCommitRequest.ProtoReflect.Descriptor instead. +func (*SyncGitCommitRequest) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_sync_proto_rawDescGZIP(), []int{3} +} + +func (x *SyncGitCommitRequest) GetOwner() string { + if x != nil { + return x.Owner + } + return "" +} + +func (x *SyncGitCommitRequest) GetRepository() string { + if x != nil { + return x.Repository + } + return "" +} + +func (x *SyncGitCommitRequest) GetBranch() string { + if x != nil { + return x.Branch + } + return "" +} + +func (x *SyncGitCommitRequest) GetManifest() *v1alpha1.Blob { + if x != nil { + return x.Manifest + } + return nil +} + +func (x *SyncGitCommitRequest) GetBlobs() []*v1alpha1.Blob { + if x != nil { + return x.Blobs + } + return nil +} + +func (x *SyncGitCommitRequest) GetHash() string { + if x != nil { + return x.Hash + } + return "" +} + +func (x *SyncGitCommitRequest) GetAuthor() *GitIdentity { + if x != nil { + return x.Author + } + return nil +} + +func (x *SyncGitCommitRequest) GetCommiter() *GitIdentity { + if x != nil { + return x.Commiter + } + return nil +} + +func (x *SyncGitCommitRequest) GetTags() []string { + if x != nil { + return x.Tags + } + return nil +} + +type SyncGitCommitResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // SyncPoint is the latest syncpoint for the SyncGitCommit request. + SyncPoint *GitSyncPoint `protobuf:"bytes,1,opt,name=sync_point,json=syncPoint,proto3" json:"sync_point,omitempty"` +} + +func (x *SyncGitCommitResponse) Reset() { + *x = SyncGitCommitResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SyncGitCommitResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SyncGitCommitResponse) ProtoMessage() {} + +func (x *SyncGitCommitResponse) ProtoReflect() protoreflect.Message { + mi := &file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SyncGitCommitResponse.ProtoReflect.Descriptor instead. +func (*SyncGitCommitResponse) Descriptor() ([]byte, []int) { + return file_buf_alpha_registry_v1alpha1_sync_proto_rawDescGZIP(), []int{4} +} + +func (x *SyncGitCommitResponse) GetSyncPoint() *GitSyncPoint { + if x != nil { + return x.SyncPoint + } + return nil +} + +var File_buf_alpha_registry_v1alpha1_sync_proto protoreflect.FileDescriptor + +var file_buf_alpha_registry_v1alpha1_sync_proto_rawDesc = []byte{ + 0x0a, 0x26, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x73, 0x79, + 0x6e, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x26, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x62, + 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x67, 0x69, 0x74, 0x5f, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xac, 0x01, + 0x0a, 0x0c, 0x47, 0x69, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x14, + 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, + 0x77, 0x6e, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, + 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x6f, 0x72, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x26, 0x0a, 0x0f, + 0x67, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x48, 0x61, 0x73, 0x68, 0x12, 0x26, 0x0a, 0x0f, 0x62, 0x73, 0x72, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x62, + 0x73, 0x72, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x66, 0x0a, 0x16, + 0x47, 0x65, 0x74, 0x47, 0x69, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, + 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x16, 0x0a, 0x06, + 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x72, + 0x61, 0x6e, 0x63, 0x68, 0x22, 0x63, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x47, 0x69, 0x74, 0x53, 0x79, + 0x6e, 0x63, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x48, 0x0a, 0x0a, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x47, 0x69, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x09, + 0x73, 0x79, 0x6e, 0x63, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x88, 0x03, 0x0a, 0x14, 0x53, 0x79, + 0x6e, 0x63, 0x47, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x72, 0x61, 0x6e, + 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, + 0x12, 0x3b, 0x0a, 0x08, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x6d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, + 0x6c, 0x6f, 0x62, 0x52, 0x08, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x12, 0x35, 0x0a, + 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x05, 0x62, + 0x6c, 0x6f, 0x62, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x40, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, + 0x6f, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x69, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x52, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x12, 0x44, 0x0a, 0x08, 0x63, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x69, 0x74, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x65, 0x72, + 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, + 0x74, 0x61, 0x67, 0x73, 0x22, 0x61, 0x0a, 0x15, 0x53, 0x79, 0x6e, 0x63, 0x47, 0x69, 0x74, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, + 0x0a, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x29, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x47, 0x69, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x09, 0x73, 0x79, + 0x6e, 0x63, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x32, 0x8e, 0x02, 0x0a, 0x0b, 0x53, 0x79, 0x6e, 0x63, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x81, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x47, + 0x69, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x33, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x69, 0x74, + 0x53, 0x79, 0x6e, 0x63, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x34, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, + 0x65, 0x74, 0x47, 0x69, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x7b, 0x0a, 0x0d, 0x53, + 0x79, 0x6e, 0x63, 0x47, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x31, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x47, + 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x32, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, + 0x6e, 0x63, 0x47, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x42, 0x96, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x09, 0x53, 0x79, + 0x6e, 0x63, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, + 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, + 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, + 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, + 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_buf_alpha_registry_v1alpha1_sync_proto_rawDescOnce sync.Once + file_buf_alpha_registry_v1alpha1_sync_proto_rawDescData = file_buf_alpha_registry_v1alpha1_sync_proto_rawDesc +) + +func file_buf_alpha_registry_v1alpha1_sync_proto_rawDescGZIP() []byte { + file_buf_alpha_registry_v1alpha1_sync_proto_rawDescOnce.Do(func() { + file_buf_alpha_registry_v1alpha1_sync_proto_rawDescData = protoimpl.X.CompressGZIP(file_buf_alpha_registry_v1alpha1_sync_proto_rawDescData) + }) + return file_buf_alpha_registry_v1alpha1_sync_proto_rawDescData +} + +var file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_buf_alpha_registry_v1alpha1_sync_proto_goTypes = []interface{}{ + (*GitSyncPoint)(nil), // 0: buf.alpha.registry.v1alpha1.GitSyncPoint + (*GetGitSyncPointRequest)(nil), // 1: buf.alpha.registry.v1alpha1.GetGitSyncPointRequest + (*GetGitSyncPointResponse)(nil), // 2: buf.alpha.registry.v1alpha1.GetGitSyncPointResponse + (*SyncGitCommitRequest)(nil), // 3: buf.alpha.registry.v1alpha1.SyncGitCommitRequest + (*SyncGitCommitResponse)(nil), // 4: buf.alpha.registry.v1alpha1.SyncGitCommitResponse + (*v1alpha1.Blob)(nil), // 5: buf.alpha.module.v1alpha1.Blob + (*GitIdentity)(nil), // 6: buf.alpha.registry.v1alpha1.GitIdentity +} +var file_buf_alpha_registry_v1alpha1_sync_proto_depIdxs = []int32{ + 0, // 0: buf.alpha.registry.v1alpha1.GetGitSyncPointResponse.sync_point:type_name -> buf.alpha.registry.v1alpha1.GitSyncPoint + 5, // 1: buf.alpha.registry.v1alpha1.SyncGitCommitRequest.manifest:type_name -> buf.alpha.module.v1alpha1.Blob + 5, // 2: buf.alpha.registry.v1alpha1.SyncGitCommitRequest.blobs:type_name -> buf.alpha.module.v1alpha1.Blob + 6, // 3: buf.alpha.registry.v1alpha1.SyncGitCommitRequest.author:type_name -> buf.alpha.registry.v1alpha1.GitIdentity + 6, // 4: buf.alpha.registry.v1alpha1.SyncGitCommitRequest.commiter:type_name -> buf.alpha.registry.v1alpha1.GitIdentity + 0, // 5: buf.alpha.registry.v1alpha1.SyncGitCommitResponse.sync_point:type_name -> buf.alpha.registry.v1alpha1.GitSyncPoint + 1, // 6: buf.alpha.registry.v1alpha1.SyncService.GetGitSyncPoint:input_type -> buf.alpha.registry.v1alpha1.GetGitSyncPointRequest + 3, // 7: buf.alpha.registry.v1alpha1.SyncService.SyncGitCommit:input_type -> buf.alpha.registry.v1alpha1.SyncGitCommitRequest + 2, // 8: buf.alpha.registry.v1alpha1.SyncService.GetGitSyncPoint:output_type -> buf.alpha.registry.v1alpha1.GetGitSyncPointResponse + 4, // 9: buf.alpha.registry.v1alpha1.SyncService.SyncGitCommit:output_type -> buf.alpha.registry.v1alpha1.SyncGitCommitResponse + 8, // [8:10] is the sub-list for method output_type + 6, // [6:8] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name +} + +func init() { file_buf_alpha_registry_v1alpha1_sync_proto_init() } +func file_buf_alpha_registry_v1alpha1_sync_proto_init() { + if File_buf_alpha_registry_v1alpha1_sync_proto != nil { + return + } + file_buf_alpha_registry_v1alpha1_git_metadata_proto_init() + if !protoimpl.UnsafeEnabled { + file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GitSyncPoint); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetGitSyncPointRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetGitSyncPointResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncGitCommitRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncGitCommitResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_buf_alpha_registry_v1alpha1_sync_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_buf_alpha_registry_v1alpha1_sync_proto_goTypes, + DependencyIndexes: file_buf_alpha_registry_v1alpha1_sync_proto_depIdxs, + MessageInfos: file_buf_alpha_registry_v1alpha1_sync_proto_msgTypes, + }.Build() + File_buf_alpha_registry_v1alpha1_sync_proto = out.File + file_buf_alpha_registry_v1alpha1_sync_proto_rawDesc = nil + file_buf_alpha_registry_v1alpha1_sync_proto_goTypes = nil + file_buf_alpha_registry_v1alpha1_sync_proto_depIdxs = nil +} diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/token.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/token.pb.go index ca1e6a7f2..04448e099 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/token.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/token.pb.go @@ -591,7 +591,7 @@ var file_buf_alpha_registry_v1alpha1_token_proto_rawDesc = []byte{ 0x08, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, - 0xd4, 0x03, 0x0a, 0x0c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0xd9, 0x03, 0x0a, 0x0c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x70, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, @@ -613,32 +613,32 @@ var file_buf_alpha_registry_v1alpha1_token_proto_rawDesc = []byte{ 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x03, 0x90, 0x02, 0x01, 0x12, 0x70, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x6f, + 0x03, 0x90, 0x02, 0x01, 0x12, 0x75, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x97, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, - 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0a, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, - 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, - 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, - 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, - 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x42, 0x97, 0x02, 0x0a, 0x1f, + 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, + 0x0a, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, + 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, + 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, + 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, + 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, + 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/user.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/user.pb.go index a9e4a04a0..00a0c5c27 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/user.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/user.pb.go @@ -1513,104 +1513,104 @@ var file_buf_alpha_registry_v1alpha1_user_proto_rawDesc = []byte{ 0x41, 0x4c, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4d, 0x41, 0x43, 0x48, 0x49, 0x4e, 0x45, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x10, - 0x03, 0x32, 0xec, 0x09, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x6d, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, + 0x03, 0x32, 0xfb, 0x09, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x72, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x69, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x2b, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x87, 0x01, 0x0a, 0x11, - 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, - 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x6f, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x73, 0x12, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x93, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x4f, - 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x65, 0x72, 0x73, - 0x12, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x69, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, + 0x12, 0x2b, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, + 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, + 0x12, 0x87, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x55, 0x73, + 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x35, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x55, 0x73, + 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, + 0x73, 0x65, 0x72, 0x42, 0x79, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x6f, 0x0a, 0x09, 0x4c, 0x69, + 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x2d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x93, 0x01, 0x0a, 0x15, + 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, - 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x62, 0x75, + 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, + 0x01, 0x12, 0x72, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, + 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x7e, 0x0a, 0x0e, 0x44, 0x65, 0x61, 0x63, 0x74, 0x69, 0x76, + 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x32, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, + 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, - 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x6d, 0x0a, 0x0a, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x2e, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x79, 0x0a, 0x0e, 0x44, - 0x65, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x32, 0x2e, - 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x61, 0x63, - 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x33, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x61, 0x63, 0x74, 0x69, + 0x76, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x8b, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x38, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x6f, 0x6c, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, + 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x72, 0x0a, 0x0a, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, + 0x73, 0x12, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x44, 0x65, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x8b, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x12, - 0x38, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x6f, - 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, - 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x72, 0x0a, 0x0a, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x73, 0x12, 0x2e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x85, 0x01, 0x0a, 0x12, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, - 0x36, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, - 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x42, 0x96, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x2f, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x12, 0x85, 0x01, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x36, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x42, 0x09, 0x55, 0x73, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, - 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, - 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, - 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, - 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, - 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, - 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, - 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x96, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x42, 0x09, 0x55, 0x73, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, + 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, + 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, + 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, + 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, + 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, + 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/webhook.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/webhook.pb.go index a67e1096c..e2059f2df 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/webhook.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1/webhook.pb.go @@ -612,8 +612,8 @@ var file_buf_alpha_registry_v1alpha1_webhook_proto_rawDesc = []byte{ 0x4f, 0x4f, 0x4b, 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x21, 0x0a, 0x1d, 0x57, 0x45, 0x42, 0x48, 0x4f, 0x4f, 0x4b, 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x52, 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54, - 0x4f, 0x52, 0x59, 0x5f, 0x50, 0x55, 0x53, 0x48, 0x10, 0x01, 0x32, 0xfe, 0x02, 0x0a, 0x0e, 0x57, - 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x78, 0x0a, + 0x4f, 0x52, 0x59, 0x5f, 0x50, 0x55, 0x53, 0x48, 0x10, 0x01, 0x32, 0x84, 0x03, 0x0a, 0x0e, 0x57, + 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7b, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x12, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, @@ -621,40 +621,41 @@ var file_buf_alpha_registry_v1alpha1_webhook_proto_rawDesc = []byte{ 0x74, 0x1a, 0x32, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x78, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x12, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x57, 0x65, 0x62, - 0x68, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x62, 0x75, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x7b, 0x0a, 0x0d, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x12, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x78, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, - 0x73, 0x12, 0x30, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x01, 0x42, 0x99, 0x02, 0x0a, 0x1f, - 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, - 0x0c, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, - 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, - 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, - 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, - 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, - 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, - 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, 0x02, 0x12, 0x78, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x57, + 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x73, 0x12, 0x30, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, + 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x65, 0x62, 0x68, + 0x6f, 0x6f, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x90, 0x02, + 0x01, 0x42, 0x99, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0c, 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x59, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x70, + 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0xa2, 0x02, 0x03, 0x42, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x2e, 0x41, 0x6c, 0x70, + 0x68, 0x61, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x56, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, + 0x5c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0xe2, 0x02, 0x27, 0x42, 0x75, 0x66, 0x5c, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x5c, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x42, + 0x75, 0x66, 0x3a, 0x3a, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x3a, 0x3a, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/bufbuild/buf/private/gen/proto/go/grpc/reflection/v1/reflection.pb.go b/vendor/github.com/bufbuild/buf/private/gen/proto/go/grpc/reflection/v1/reflection.pb.go index 008f13232..15a7d4876 100644 --- a/vendor/github.com/bufbuild/buf/private/gen/proto/go/grpc/reflection/v1/reflection.pb.go +++ b/vendor/github.com/bufbuild/buf/private/gen/proto/go/grpc/reflection/v1/reflection.pb.go @@ -12,6 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Service exported by server reflection. A more complete description of how +// server reflection works can be found at +// https://github.com/grpc/grpc/blob/master/doc/server-reflection.md +// +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.30.0 @@ -34,12 +41,17 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// The message sent by the client when calling ServerReflectionInfo method. type ServerReflectionRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + // To use reflection service, the client should set one of the following + // fields in message_request. The server distinguishes requests by their + // defined field and then handles them using corresponding methods. + // // Types that are assignable to MessageRequest: // // *ServerReflectionRequest_FileByFilename @@ -136,22 +148,38 @@ type isServerReflectionRequest_MessageRequest interface { } type ServerReflectionRequest_FileByFilename struct { + // Find a proto file by the file name. FileByFilename string `protobuf:"bytes,3,opt,name=file_by_filename,json=fileByFilename,proto3,oneof"` } type ServerReflectionRequest_FileContainingSymbol struct { + // Find the proto file that declares the given fully-qualified symbol name. + // This field should be a fully-qualified symbol name + // (e.g. .[.] or .). FileContainingSymbol string `protobuf:"bytes,4,opt,name=file_containing_symbol,json=fileContainingSymbol,proto3,oneof"` } type ServerReflectionRequest_FileContainingExtension struct { + // Find the proto file which defines an extension extending the given + // message type with the given field number. FileContainingExtension *ExtensionRequest `protobuf:"bytes,5,opt,name=file_containing_extension,json=fileContainingExtension,proto3,oneof"` } type ServerReflectionRequest_AllExtensionNumbersOfType struct { + // Finds the tag numbers used by all known extensions of the given message + // type, and appends them to ExtensionNumberResponse in an undefined order. + // Its corresponding method is best-effort: it's not guaranteed that the + // reflection service will implement this method, and it's not guaranteed + // that this method will provide all extensions. Returns + // StatusCode::UNIMPLEMENTED if it's not implemented. + // This field should be a fully-qualified type name. The format is + // . AllExtensionNumbersOfType string `protobuf:"bytes,6,opt,name=all_extension_numbers_of_type,json=allExtensionNumbersOfType,proto3,oneof"` } type ServerReflectionRequest_ListServices struct { + // List the full names of registered services. The content will not be + // checked. ListServices string `protobuf:"bytes,7,opt,name=list_services,json=listServices,proto3,oneof"` } @@ -166,11 +194,14 @@ func (*ServerReflectionRequest_AllExtensionNumbersOfType) isServerReflectionRequ func (*ServerReflectionRequest_ListServices) isServerReflectionRequest_MessageRequest() {} +// The type name and extension number sent by the client when requesting +// file_containing_extension. type ExtensionRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // Fully-qualified type name. The format should be . ContainingType string `protobuf:"bytes,1,opt,name=containing_type,json=containingType,proto3" json:"containing_type,omitempty"` ExtensionNumber int32 `protobuf:"varint,2,opt,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"` } @@ -221,6 +252,7 @@ func (x *ExtensionRequest) GetExtensionNumber() int32 { return 0 } +// The message sent by the server to answer ServerReflectionInfo method. type ServerReflectionResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -228,6 +260,9 @@ type ServerReflectionResponse struct { ValidHost string `protobuf:"bytes,1,opt,name=valid_host,json=validHost,proto3" json:"valid_host,omitempty"` OriginalRequest *ServerReflectionRequest `protobuf:"bytes,2,opt,name=original_request,json=originalRequest,proto3" json:"original_request,omitempty"` + // The server sets one of the following fields according to the message_request + // in the request. + // // Types that are assignable to MessageResponse: // // *ServerReflectionResponse_FileDescriptorResponse @@ -323,18 +358,27 @@ type isServerReflectionResponse_MessageResponse interface { } type ServerReflectionResponse_FileDescriptorResponse struct { + // This message is used to answer file_by_filename, file_containing_symbol, + // file_containing_extension requests with transitive dependencies. + // As the repeated label is not allowed in oneof fields, we use a + // FileDescriptorResponse message to encapsulate the repeated fields. + // The reflection service is allowed to avoid sending FileDescriptorProtos + // that were previously sent in response to earlier requests in the stream. FileDescriptorResponse *FileDescriptorResponse `protobuf:"bytes,4,opt,name=file_descriptor_response,json=fileDescriptorResponse,proto3,oneof"` } type ServerReflectionResponse_AllExtensionNumbersResponse struct { + // This message is used to answer all_extension_numbers_of_type requests. AllExtensionNumbersResponse *ExtensionNumberResponse `protobuf:"bytes,5,opt,name=all_extension_numbers_response,json=allExtensionNumbersResponse,proto3,oneof"` } type ServerReflectionResponse_ListServicesResponse struct { + // This message is used to answer list_services requests. ListServicesResponse *ListServiceResponse `protobuf:"bytes,6,opt,name=list_services_response,json=listServicesResponse,proto3,oneof"` } type ServerReflectionResponse_ErrorResponse struct { + // This message is used when an error occurs. ErrorResponse *ErrorResponse `protobuf:"bytes,7,opt,name=error_response,json=errorResponse,proto3,oneof"` } @@ -348,11 +392,17 @@ func (*ServerReflectionResponse_ListServicesResponse) isServerReflectionResponse func (*ServerReflectionResponse_ErrorResponse) isServerReflectionResponse_MessageResponse() {} +// Serialized FileDescriptorProto messages sent by the server answering +// a file_by_filename, file_containing_symbol, or file_containing_extension +// request. type FileDescriptorResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // Serialized FileDescriptorProto messages. We avoid taking a dependency on + // descriptor.proto, which uses proto2 only features, by making them opaque + // bytes instead. FileDescriptorProto [][]byte `protobuf:"bytes,1,rep,name=file_descriptor_proto,json=fileDescriptorProto,proto3" json:"file_descriptor_proto,omitempty"` } @@ -395,11 +445,15 @@ func (x *FileDescriptorResponse) GetFileDescriptorProto() [][]byte { return nil } +// A list of extension numbers sent by the server answering +// all_extension_numbers_of_type request. type ExtensionNumberResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // Full name of the base type, including the package name. The format + // is . BaseTypeName string `protobuf:"bytes,1,opt,name=base_type_name,json=baseTypeName,proto3" json:"base_type_name,omitempty"` ExtensionNumber []int32 `protobuf:"varint,2,rep,packed,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"` } @@ -450,11 +504,14 @@ func (x *ExtensionNumberResponse) GetExtensionNumber() []int32 { return nil } +// A list of ServiceResponse sent by the server answering list_services request. type ListServiceResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // The information of each service may be expanded in the future, so we use + // ServiceResponse message to encapsulate it. Service []*ServiceResponse `protobuf:"bytes,1,rep,name=service,proto3" json:"service,omitempty"` } @@ -497,11 +554,15 @@ func (x *ListServiceResponse) GetService() []*ServiceResponse { return nil } +// The information of a single service used by ListServiceResponse to answer +// list_services request. type ServiceResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // Full name of a registered service, including its package name. The format + // is . Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } @@ -544,11 +605,13 @@ func (x *ServiceResponse) GetName() string { return "" } +// The error code and error message sent by the server when an error occurs. type ErrorResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // This field uses the error codes defined in grpc::StatusCode. ErrorCode int32 `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` } diff --git a/vendor/github.com/bufbuild/buf/private/pkg/app/app.go b/vendor/github.com/bufbuild/buf/private/pkg/app/app.go index 05d2c0a86..e0e842e19 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/app/app.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/app/app.go @@ -291,6 +291,12 @@ func IsDevNull(path string) bool { return path != "" && path == DevNullFilePath } +// IsDevPath returns true if the path is the equivalent of /dev/stdin, /dev/stdout, +// /dev/stderr, or /dev/null. +func IsDevPath(path string) bool { + return IsDevStdin(path) || IsDevStdout(path) || IsDevStderr(path) || IsDevNull(path) +} + // Main runs the application using the OS Container and calling os.Exit on the return value of Run. func Main(ctx context.Context, f func(context.Context, Container) error) { container, err := NewContainerForOS() diff --git a/vendor/github.com/bufbuild/buf/private/pkg/app/appflag/builder.go b/vendor/github.com/bufbuild/buf/private/pkg/app/appflag/builder.go index 2fb18de53..90d259b0f 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/app/appflag/builder.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/app/appflag/builder.go @@ -67,7 +67,7 @@ func (b *builder) BindRoot(flagSet *pflag.FlagSet) { flagSet.BoolVar(&b.debug, "debug", false, "Turn on debug logging") flagSet.StringVar(&b.logFormat, "log-format", "color", "The log format [text,color,json]") if b.defaultTimeout > 0 { - flagSet.DurationVar(&b.timeout, "timeout", b.defaultTimeout, `The duration until timing out`) + flagSet.DurationVar(&b.timeout, "timeout", b.defaultTimeout, `The duration until timing out, setting it to zero means no timeout`) } flagSet.BoolVar(&b.profile, "profile", false, "Run profiling") diff --git a/vendor/github.com/bufbuild/buf/private/pkg/dag/dag.go b/vendor/github.com/bufbuild/buf/private/pkg/dag/dag.go new file mode 100644 index 000000000..b0a477701 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/dag/dag.go @@ -0,0 +1,450 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 dag + +import ( + "bytes" + "errors" + "fmt" + "strings" +) + +// Largely adopted from https://github.com/stevenle/topsort, with modifications. +// +// Copyright 2013 Steven Le. 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. +// +// See https://github.com/stevenle/topsort/blob/master/LICENSE. + +// CycleError is an error if the Graph had a cycle. +type CycleError[Key comparable] struct { + Keys []Key +} + +// Error implements error. +func (c *CycleError[Key]) Error() string { + strs := make([]string, len(c.Keys)) + for i, key := range c.Keys { + strs[i] = fmt.Sprintf("%v", key) + } + return fmt.Sprintf("cycle error: %s", strings.Join(strs, " -> ")) +} + +// Graph is a directed acyclic graph structure with comparable keys. +type Graph[Key comparable] struct { + keyToNode map[Key]*node[Key] + // need to store order so that we can create a deterministic CycleError + // in the case of Walk where we have no source nodes, so that we can Walk + // deterministically and find the cycle. + keys []Key +} + +// NewGraph returns a new Graph. +// +// Graphs can also safely be instantiated with &Graph{}. +func NewGraph[Key comparable]() *Graph[Key] { + graph := &Graph[Key]{} + graph.init() + return graph +} + +// AddNode adds a node. +func (g *Graph[Key]) AddNode(key Key) { + g.init() + g.getOrAddNode(key) +} + +// AddEdge adds an edge. +func (g *Graph[Key]) AddEdge(from Key, to Key) { + g.init() + fromNode := g.getOrAddNode(from) + toNode := g.getOrAddNode(to) + fromNode.addOutboundEdge(to) + toNode.addInboundEdge(from) +} + +// ContainsNode returns true if the graph contains the given node. +func (g *Graph[Key]) ContainsNode(key Key) bool { + g.init() + _, ok := g.keyToNode[key] + return ok +} + +// NumNodes returns the number of nodes in the graph. +func (g *Graph[Key]) NumNodes() int { + g.init() + return len(g.keys) +} + +// NumNodes returns the number of edges in the graph. +func (g *Graph[Key]) NumEdges() int { + g.init() + var numEdges int + for _, node := range g.keyToNode { + numEdges += len(node.outboundEdges) + } + return numEdges +} + +// WalkNodes visited each node in the Graph based on insertion order. +// +// f is called for each node. The first argument is the key for the node, +// the second argument is all inbound edges, the third argument +// is all outbound edges. +func (g *Graph[Key]) WalkNodes(f func(Key, []Key, []Key) error) error { + g.init() + for _, key := range g.keys { + node, ok := g.keyToNode[key] + if !ok { + return fmt.Errorf("key not present: %v", key) + } + inboundEdges := make([]Key, len(node.inboundEdges)) + copy(inboundEdges, node.inboundEdges) + outboundEdges := make([]Key, len(node.outboundEdges)) + copy(outboundEdges, node.outboundEdges) + if err := f(key, inboundEdges, outboundEdges); err != nil { + return err + } + } + return nil +} + +// WalkEdges visits each edge in the Graph starting at the source keys. +// +// f is called for each directed edge. The first argument is the source +// node, the second is the destination node. +// +// Returns a *CycleError if there is a cycle in the graph. +func (g *Graph[Key]) WalkEdges(f func(Key, Key) error) error { + g.init() + if g.NumEdges() == 0 { + // No edges, do not walk. + return nil + } + sourceKeys, err := g.getSourceKeys() + if err != nil { + return err + } + switch len(sourceKeys) { + case 0: + // If we have no source nodes, we have a cycle in the graph. To print the cycle, + // we walk starting at all keys We will hit a cycle in this process, however just to check our + // assumptions, we also verify the the walk returns a CycleError, and if not, + // return a system error. + allVisited := make(map[Key]struct{}) + for _, key := range g.keys { + if err := g.edgeVisit( + key, + func(Key, Key) error { return nil }, + newOrderedSet[Key](), + allVisited, + ); err != nil { + return err + } + } + return errors.New("graph had cycle based on source node count being zero, but this was not detected during edge walking") + case 1: + return g.edgeVisit( + sourceKeys[0], + f, + newOrderedSet[Key](), + make(map[Key]struct{}), + ) + default: + allVisited := make(map[Key]struct{}) + for _, key := range sourceKeys { + if err := g.edgeVisit( + key, + f, + newOrderedSet[Key](), + allVisited, + ); err != nil { + return err + } + } + return nil + } +} + +// TopoSort topologically sorts the nodes in the Graph starting at the given key. +// +// Returns a *CycleError if there is a cycle in the graph. +func (g *Graph[Key]) TopoSort(start Key) ([]Key, error) { + g.init() + results := newOrderedSet[Key]() + if err := g.topoVisit(start, results, newOrderedSet[Key]()); err != nil { + return nil, err + } + return results.keys, nil +} + +// DOTString returns a DOT representation of the graph. +// +// keyToString is used to print out the label for each node. +// https://graphviz.org/doc/info/lang.html +func (g *Graph[Key]) DOTString(keyToString func(Key) string) (string, error) { + keyToIndex := make(map[Key]int) + nextIndex := 1 + var nodeStrings []string + var edgeStrings []string + if err := g.WalkEdges( + func(from Key, to Key) error { + fromIndex, ok := keyToIndex[from] + if !ok { + fromIndex = nextIndex + nextIndex++ + keyToIndex[from] = fromIndex + nodeStrings = append( + nodeStrings, + fmt.Sprintf("%d [label=%q]", fromIndex, keyToString(from)), + ) + } + toIndex, ok := keyToIndex[to] + if !ok { + toIndex = nextIndex + nextIndex++ + keyToIndex[to] = toIndex + nodeStrings = append( + nodeStrings, + fmt.Sprintf("%d [label=%q]", toIndex, keyToString(to)), + ) + } + edgeStrings = append( + edgeStrings, + fmt.Sprintf("%d -> %d", fromIndex, toIndex), + ) + return nil + }, + ); err != nil { + return "", err + } + // We also want to pick up any nodes that do not have edges, and display them. + if err := g.WalkNodes( + func(key Key, inboundEdges []Key, outboundEdges []Key) error { + if _, ok := keyToIndex[key]; ok { + return nil + } + if len(inboundEdges) == 0 && len(outboundEdges) == 0 { + nodeStrings = append( + nodeStrings, + fmt.Sprintf("%d [label=%q]", nextIndex, keyToString(key)), + ) + edgeStrings = append( + edgeStrings, + fmt.Sprintf("%d", nextIndex), + ) + nextIndex++ + return nil + } + // This is a system error. + return fmt.Errorf("got node %v with %d inbound edges and %d outbound edges, but this was not processed during WalkEdges", key, len(inboundEdges), len(outboundEdges)) + }, + ); err != nil { + return "", err + } + if len(nodeStrings) == 0 { + return "digraph {}", nil + } + buffer := bytes.NewBuffer(nil) + _, _ = buffer.WriteString("digraph {\n\n") + for _, nodeString := range nodeStrings { + _, _ = buffer.WriteString(" ") + _, _ = buffer.WriteString(nodeString) + _, _ = buffer.WriteString("\n") + } + _, _ = buffer.WriteString("\n") + for _, edgeString := range edgeStrings { + _, _ = buffer.WriteString(" ") + _, _ = buffer.WriteString(edgeString) + _, _ = buffer.WriteString("\n") + } + _, _ = buffer.WriteString("\n}") + return buffer.String(), nil +} + +func (g *Graph[Key]) init() { + if g.keyToNode == nil { + g.keyToNode = make(map[Key]*node[Key]) + } +} + +func (g *Graph[Key]) getOrAddNode(key Key) *node[Key] { + node, ok := g.keyToNode[key] + if !ok { + node = newNode[Key]() + g.keyToNode[key] = node + g.keys = append(g.keys, key) + } + return node +} + +func (g *Graph[Key]) getSourceKeys() ([]Key, error) { + var sourceKeys []Key + // need to get in deterministic order + for _, key := range g.keys { + node, ok := g.keyToNode[key] + if !ok { + return nil, fmt.Errorf("key not present in keyToNode: %v", key) + } + if len(node.inboundEdgeMap) == 0 { + sourceKeys = append(sourceKeys, key) + } + } + return sourceKeys, nil +} + +func (g *Graph[Key]) edgeVisit( + from Key, + f func(Key, Key) error, + thisSourceVisited *orderedSet[Key], + allSourcesVisited map[Key]struct{}, +) error { + // this is based on this source. we want to make sure we don't + // have any cycles based on starting at a single source. + if !thisSourceVisited.add(from) { + index := thisSourceVisited.index(from) + cycle := append(thisSourceVisited.keys[index:], from) + return &CycleError[Key]{Keys: cycle} + } + // If we visited this from all edge visiting from other + // sources, do nothing, we've evaluated all cycles and visited this + // node properly. It's OK to return here, as we've already checked + // for cycles with thisSourceVisited. + if _, ok := allSourcesVisited[from]; ok { + return nil + } + // Add to the map. We'll be needing this for future iterations. + allSourcesVisited[from] = struct{}{} + + fromNode, ok := g.keyToNode[from] + if !ok { + return fmt.Errorf("key not present: %v", from) + } + for _, to := range fromNode.outboundEdges { + if err := f(from, to); err != nil { + return err + } + if err := g.edgeVisit(to, f, thisSourceVisited.copy(), allSourcesVisited); err != nil { + return err + } + } + + return nil +} + +func (g *Graph[Key]) topoVisit( + from Key, + results *orderedSet[Key], + visited *orderedSet[Key], +) error { + if !visited.add(from) { + index := visited.index(from) + cycle := append(visited.keys[index:], from) + return &CycleError[Key]{Keys: cycle} + } + + fromNode, ok := g.keyToNode[from] + if !ok { + return fmt.Errorf("key not present: %v", from) + } + for _, to := range fromNode.outboundEdges { + if err := g.topoVisit(to, results, visited.copy()); err != nil { + return err + } + } + + results.add(from) + return nil +} + +type node[Key comparable] struct { + outboundEdgeMap map[Key]struct{} + // need to store order for deterministic visits + outboundEdges []Key + inboundEdgeMap map[Key]struct{} + // need to store order for deterministic visits + inboundEdges []Key +} + +func newNode[Key comparable]() *node[Key] { + return &node[Key]{ + outboundEdgeMap: make(map[Key]struct{}), + inboundEdgeMap: make(map[Key]struct{}), + } +} + +func (n *node[Key]) addOutboundEdge(key Key) { + if _, ok := n.outboundEdgeMap[key]; !ok { + n.outboundEdgeMap[key] = struct{}{} + n.outboundEdges = append(n.outboundEdges, key) + } +} + +func (n *node[Key]) addInboundEdge(key Key) { + if _, ok := n.inboundEdgeMap[key]; !ok { + n.inboundEdgeMap[key] = struct{}{} + n.inboundEdges = append(n.inboundEdges, key) + } +} + +type orderedSet[Key comparable] struct { + keyToIndex map[Key]int + keys []Key + length int +} + +func newOrderedSet[Key comparable]() *orderedSet[Key] { + return &orderedSet[Key]{ + keyToIndex: make(map[Key]int), + } +} + +// returns false if already added +func (s *orderedSet[Key]) add(key Key) bool { + if _, ok := s.keyToIndex[key]; !ok { + s.keyToIndex[key] = s.length + s.keys = append(s.keys, key) + s.length++ + return true + } + return false +} + +func (s *orderedSet[Key]) copy() *orderedSet[Key] { + clone := newOrderedSet[Key]() + for _, item := range s.keys { + clone.add(item) + } + return clone +} + +func (s *orderedSet[Key]) index(item Key) int { + index, ok := s.keyToIndex[item] + if ok { + return index + } + return -1 +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/dag/usage.gen.go b/vendor/github.com/bufbuild/buf/private/pkg/dag/usage.gen.go new file mode 100644 index 000000000..f90329fe8 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/dag/usage.gen.go @@ -0,0 +1,19 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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. + +// Generated. DO NOT EDIT. + +package dag + +import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/pkg/filelock/filelock.go b/vendor/github.com/bufbuild/buf/private/pkg/filelock/filelock.go deleted file mode 100644 index 231e11406..000000000 --- a/vendor/github.com/bufbuild/buf/private/pkg/filelock/filelock.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 filelock - -import ( - "context" - "time" -) - -const ( - // DefaultLockTimeout is the default lock timeout. - DefaultLockTimeout = 3 * time.Second - // DefaultLockRetryDelay is the default lock retry delay. - DefaultLockRetryDelay = 200 * time.Millisecond -) - -// Unlocker unlocks a file lock. -type Unlocker interface { - Unlock() error -} - -// Lock locks a file lock. -// -// Use in cases where you need a lock for a specific system file, such as in testing, -// otherwise use a Locker to manage your file locks. -func Lock(ctx context.Context, filePath string, options ...LockOption) (Unlocker, error) { - return lock(ctx, filePath, options...) -} - -// RLock read-locks a file lock. -// -// Use in cases where you need a lock for a specific system file, such as in testing, -// otherwise use a Locker to manage your file locks. -func RLock(ctx context.Context, filePath string, options ...LockOption) (Unlocker, error) { - return rlock(ctx, filePath, options...) -} - -// Locker provides file locks. -type Locker interface { - // Lock locks a file lock within the root directory of the Locker. - // - // The given path must be normalized and relative. - Lock(ctx context.Context, path string, options ...LockOption) (Unlocker, error) - // RLock read-locks a file lock within the root directory of the Locker. - // - // The given path must be normalized and relative. - RLock(ctx context.Context, path string, options ...LockOption) (Unlocker, error) -} - -// NewLocker returns a new Locker for the given root directory path. -// -// The root directory path should generally be a data directory path. -// The root directory must exist. -func NewLocker(rootDirPath string) (Locker, error) { - return newLocker(rootDirPath) -} - -// LockOption is an option for lock. -type LockOption func(*lockOptions) - -// LockWithTimeout returns a new LockOption that sets the lock timeout. -// -// Lock returns error if the lock cannot be acquired after this amount of time. -// If this is set to 0, the lock will never timeout. -func LockWithTimeout(timeout time.Duration) LockOption { - return func(lockOptions *lockOptions) { - lockOptions.timeout = timeout - } -} - -// LockWithRetryDelay returns a new LockOption that sets the lock retry delay. -// -// Lock will try to lock on this delay up until the lock timeout. -func LockWithRetryDelay(retryDelay time.Duration) LockOption { - return func(lockOptions *lockOptions) { - lockOptions.retryDelay = retryDelay - } -} - -// NewNopLocker returns a new no-op Locker. -func NewNopLocker() Locker { - return newNopLocker() -} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/filelock/lock.go b/vendor/github.com/bufbuild/buf/private/pkg/filelock/lock.go deleted file mode 100644 index 2a3240732..000000000 --- a/vendor/github.com/bufbuild/buf/private/pkg/filelock/lock.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 filelock - -import ( - "context" - "fmt" - "os" - "path/filepath" - "time" - - "github.com/gofrs/flock" -) - -func lock( - ctx context.Context, - filePath string, - options ...LockOption, -) (Unlocker, error) { - return lockForFunc( - ctx, - filePath, - (*flock.Flock).TryLockContext, - options..., - ) -} - -func rlock( - ctx context.Context, - filePath string, - options ...LockOption, -) (Unlocker, error) { - return lockForFunc( - ctx, - filePath, - (*flock.Flock).TryRLockContext, - options..., - ) -} - -func lockForFunc( - ctx context.Context, - filePath string, - tryLockContextFunc func(*flock.Flock, context.Context, time.Duration) (bool, error), - options ...LockOption, -) (Unlocker, error) { - lockOptions := newLockOptions() - for _, option := range options { - option(lockOptions) - } - // mkdir is an atomic operation - if err := os.MkdirAll(filepath.Dir(filePath), 0755); err != nil { - return nil, err - } - var cancel context.CancelFunc - if lockOptions.timeout != 0 { - ctx, cancel = context.WithTimeout(ctx, lockOptions.timeout) - defer cancel() - } - flock := flock.New(filePath) - locked, err := tryLockContextFunc(flock, ctx, lockOptions.retryDelay) - if err != nil { - return nil, fmt.Errorf("could not get file lock %q: %w", filePath, err) - } - if !locked { - return nil, fmt.Errorf("could not lock %q", filePath) - } - return flock, nil -} - -type lockOptions struct { - timeout time.Duration - retryDelay time.Duration -} - -func newLockOptions() *lockOptions { - return &lockOptions{ - timeout: DefaultLockTimeout, - retryDelay: DefaultLockRetryDelay, - } -} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/filelock/locker.go b/vendor/github.com/bufbuild/buf/private/pkg/filelock/locker.go deleted file mode 100644 index e5350506a..000000000 --- a/vendor/github.com/bufbuild/buf/private/pkg/filelock/locker.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2020-2023 Buf Technologies, Inc. -// -// 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 filelock - -import ( - "context" - "fmt" - "os" - - "github.com/bufbuild/buf/private/pkg/normalpath" -) - -type locker struct { - rootDirPath string -} - -func newLocker(rootDirPath string) (*locker, error) { - // allow symlinks - fileInfo, err := os.Stat(normalpath.Unnormalize(rootDirPath)) - if err != nil { - return nil, err - } - if !fileInfo.IsDir() { - return nil, fmt.Errorf("%q is not a directory", rootDirPath) - } - return &locker{ - // do not validate - allow anything including absolute paths and jumping context - rootDirPath: normalpath.Normalize(rootDirPath), - }, nil -} - -func (l *locker) Lock(ctx context.Context, path string, options ...LockOption) (Unlocker, error) { - if err := validatePath(path); err != nil { - return nil, err - } - return lock( - ctx, - normalpath.Unnormalize(normalpath.Join(l.rootDirPath, path)), - options..., - ) -} - -func (l *locker) RLock(ctx context.Context, path string, options ...LockOption) (Unlocker, error) { - if err := validatePath(path); err != nil { - return nil, err - } - return rlock( - ctx, - normalpath.Unnormalize(normalpath.Join(l.rootDirPath, path)), - options..., - ) -} - -func validatePath(path string) error { - normalPath, err := normalpath.NormalizeAndValidate(path) - if err != nil { - return err - } - if path != normalPath { - // just extra safety - return fmt.Errorf("expected file lock path %q to be equal to normalized path %q", path, normalPath) - } - return nil -} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/git/annotated_tag.go b/vendor/github.com/bufbuild/buf/private/pkg/git/annotated_tag.go new file mode 100644 index 000000000..1bb477639 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/git/annotated_tag.go @@ -0,0 +1,75 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 git + +import ( + "bytes" + "io" + "strings" +) + +type annotatedTag struct { + hash Hash + commit Hash + name string + tagger Ident + message string +} + +func (t *annotatedTag) Hash() Hash { + return t.hash +} +func (t *annotatedTag) Commit() Hash { + return t.commit +} +func (t *annotatedTag) Name() string { + return t.name +} +func (t *annotatedTag) Tagger() Ident { + return t.tagger +} +func (t *annotatedTag) Message() string { + return t.message +} + +func parseAnnotatedTag(hash Hash, data []byte) (*annotatedTag, error) { + t := &annotatedTag{ + hash: hash, + } + buffer := bytes.NewBuffer(data) + line, err := buffer.ReadString('\n') + for err != io.EOF && line != "\n" { + header, value, _ := strings.Cut(line, " ") + value = strings.TrimRight(value, "\n") + switch header { + case "object": + if t.commit, err = parseHashFromHex(value); err != nil { + return nil, err + } + case "tagger": + if t.tagger, err = parseIdent([]byte(value)); err != nil { + return nil, err + } + case "tag": + t.name = value + default: + // We do not parse the remaining headers. + } + line, err = buffer.ReadString('\n') + } + t.message = buffer.String() + t.message = strings.TrimRight(t.message, "\n") + return t, err +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/git/commit.go b/vendor/github.com/bufbuild/buf/private/pkg/git/commit.go new file mode 100644 index 000000000..3eca0c731 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/git/commit.go @@ -0,0 +1,91 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 git + +import ( + "bytes" + "errors" + "io" + "strings" +) + +type commit struct { + hash Hash + tree Hash + parents []Hash + author Ident + committer Ident + message string +} + +func (c *commit) Hash() Hash { + return c.hash +} +func (c *commit) Tree() Hash { + return c.tree +} +func (c *commit) Parents() []Hash { + return c.parents +} +func (c *commit) Author() Ident { + return c.author +} +func (c *commit) Committer() Ident { + return c.committer +} +func (c *commit) Message() string { + return c.message +} + +func parseCommit(hash Hash, data []byte) (*commit, error) { + c := &commit{ + hash: hash, + } + buffer := bytes.NewBuffer(data) + line, err := buffer.ReadString('\n') + for err != io.EOF && line != "\n" { + header, value, _ := strings.Cut(line, " ") + value = strings.TrimRight(value, "\n") + switch header { + case "tree": + if c.tree != nil { + return nil, errors.New("too many tree headers") + } + if c.tree, err = parseHashFromHex(value); err != nil { + return nil, err + } + case "parent": + if parent, err := parseHashFromHex(value); err != nil { + return nil, err + } else { + c.parents = append(c.parents, parent) + } + case "author": + if c.author, err = parseIdent([]byte(value)); err != nil { + return nil, err + } + case "committer": + if c.committer, err = parseIdent([]byte(value)); err != nil { + return nil, err + } + default: + // We do not parse the remaining headers. + } + line, err = buffer.ReadString('\n') + } + c.message = buffer.String() + c.message = strings.TrimRight(c.message, "\n") + return c, err +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/git/git.go b/vendor/github.com/bufbuild/buf/private/pkg/git/git.go index e1c031cb2..11ffcf4fa 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/git/git.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/git/git.go @@ -16,7 +16,9 @@ package git import ( "context" + "errors" "regexp" + "time" "github.com/bufbuild/buf/private/pkg/app" "github.com/bufbuild/buf/private/pkg/command" @@ -25,6 +27,38 @@ import ( "go.uber.org/zap" ) +const ( + // DotGitDir is a relative path to the `.git` directory. + DotGitDir = ".git" + + // ModeUnknown is a mode's zero value. + ModeUnknown ObjectMode = 0 + // ModeFile is a blob that should be written as a plain file. + ModeFile ObjectMode = 010_0644 + // ModeExec is a blob that should be written with the executable bit set. + ModeExe ObjectMode = 010_0755 + // ModeDir is a tree to be unpacked as a subdirectory in the current + // directory. + ModeDir ObjectMode = 004_0000 + // ModeSymlink is a blob with its content being the path linked to. + ModeSymlink ObjectMode = 012_0000 + // ModeSubmodule is a commit that the submodule is checked out at. + ModeSubmodule ObjectMode = 016_0000 +) + +var ( + // ErrTreeNodeNotFound is an error found in the error chain when + // Tree#Descendant is unable to find the target tree node. + ErrTreeNodeNotFound = errors.New("node not found") + // ErrTreeNodeNotFound is an error found in the error chain when + // ObjectReader is unable to find the target object. + ErrObjectNotFound = errors.New("object not found") +) + +// ObjectMode is how to interpret a tree node's object. See the Mode* constants +// for how to interpret each mode value. +type ObjectMode uint32 + // Name is a name identifiable by git. type Name interface { // If cloneBranch returns a non-empty string, any clones will be performed with --branch set to the value. @@ -133,3 +167,153 @@ type ListFilesAndUnstagedFilesOptions struct { // is being applied to. IgnorePathRegexps []*regexp.Regexp } + +// Hash represents the hash of a Git object (tree, blob, or commit). +type Hash interface { + // Hex is the hexadecimal representation of this ID. + Hex() string + // String returns the hexadecimal representation of this ID. + String() string +} + +// NewHashFromHex creates a new hash that is validated. +func NewHashFromHex(value string) (Hash, error) { + return parseHashFromHex(value) +} + +// Ident is a git user identifier. These typically represent authors and committers. +type Ident interface { + // Name is the name of the user. + Name() string + // Email is the email of the user. + Email() string + // Timestamp is the time at which this identity was created. For authors it's the + // commit's author time, and for committers it's the commit's commit time. + Timestamp() time.Time +} + +// Commit represents a commit object. +// +// All commits will have a non-nil Tree. All but the root commit will contain >0 parents. +type Commit interface { + // Hash is the Hash for this commit. + Hash() Hash + // Tree is the ID to the git tree for this commit. + Tree() Hash + // Parents is the set of parents for this commit. It may be empty. + // + // By convention, the first parent in a multi-parent commit is the merge target. + Parents() []Hash + // Author is the user who authored the commit. + Author() Ident + // Committer is the user who created the commit. + Committer() Ident + // Message is the commit message. + Message() string +} + +// AnnotatedTag represents an annotated tag object. +type AnnotatedTag interface { + // Hash is the Hash for this tag. + Hash() Hash + // Commit is the ID to the git commit that this tag points to. + Commit() Hash + // Tagger is the user who tagged the commit. + Tagger() Ident + // Name is the value of the tag. + Name() string + // Message is the commit message. + Message() string +} + +// ObjectReader reads objects (commits, trees, blobs, tags) from a `.git` directory. +type ObjectReader interface { + // Blob reads the blob identified by the hash. + Blob(id Hash) ([]byte, error) + // Commit reads the commit identified by the hash. + Commit(id Hash) (Commit, error) + // Tree reads the tree identified by the hash. + Tree(id Hash) (Tree, error) + // Tag reads the tag identified by the hash. + Tag(id Hash) (AnnotatedTag, error) +} + +// Tree is a git tree, which are a manifest of other git objects, including other trees. +type Tree interface { + // Hash is the Hash for this Tree. + Hash() Hash + // Nodes is the set of nodes in this Tree. + Nodes() []TreeNode + // Descendant walks down a tree, following the path specified, + // and returns the terminal Node. If no node is found, it returns + // ErrTreeNodeNotFound. + Descendant(path string, objectReader ObjectReader) (TreeNode, error) +} + +// TreeNode is a reference to an object contained in a tree. These objects have +// a file mode associated with them, which hints at the type of object located +// at ID (tree or blob). +type TreeNode interface { + // Hash is the Hash of the object referenced by this Node. + Hash() Hash + // Name is the name of the object referenced by this Node. + Name() string + // Mode is the file mode of the object referenced by this Node. + Mode() ObjectMode +} + +// Repository is a git repository that is backed by a `.git` directory. +type Repository interface { + // BaseBranch is the base branch of the repository. This is either configured + // via the `OpenRepositoryWithBaseBranch` option, or discovered via the remote + // named `origin`. Therefore, discovery requires that the repository is pushed + // to the remote. + BaseBranch() string + // ForEachBranch ranges over branches in the repository in an undefined order. + // + // Only pushed (i.e., remote) branches are visited. + ForEachBranch(func(branch string, headHash Hash) error) error + // ForEachCommit ranges over commits for the target branch in reverse topological order. + // + // Only commits pushed to the 'origin' remote are visited. + // + // Parents are visited before children, and only left parents are visited (i.e., + // commits from branches merged into the target branch are not visited). + ForEachCommit(branch string, f func(commit Commit) error) error + // ForEachTag ranges over tags in the repository in an undefined order. + // + // All tags are ranged, including local (unpushed) tags. + ForEachTag(func(tag string, commitHash Hash) error) error + // Objects exposes the underlying object reader to read objects directly from the + // `.git` directory. + Objects() ObjectReader + // Close closes the repository. + Close() error +} + +// OpenRepository opens a new Repository from a `.git` directory. The provided path to the +// `.git` dir need not be normalized or cleaned. +// +// Internally, OpenRepository will spawns a new process to communicate with `git-cat-file`, +// so the caller must close the repository to clean up resources. +// +// By default, OpenRepository will attempt to detect the base branch if the repository +// has been pushed. This may fail if the repository is not pushed. In this case, use the +// `OpenRepositoryWithBaseBranch` option. +func OpenRepository(gitDirPath string, runner command.Runner, options ...OpenRepositoryOption) (Repository, error) { + return openGitRepository(gitDirPath, runner, options...) +} + +// OpenRepositoryOption configures the opening of a repository. +type OpenRepositoryOption func(*openRepositoryOpts) error + +// CommitIteratorWithBaseBranch configures the base branch for this iterator. +func OpenRepositoryWithBaseBranch(name string) OpenRepositoryOption { + return func(r *openRepositoryOpts) error { + if name == "" { + return errors.New("base branch cannot be empty") + } + r.baseBranch = name + return nil + } +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/git/hash.go b/vendor/github.com/bufbuild/buf/private/pkg/git/hash.go new file mode 100644 index 000000000..1ddb2f606 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/git/hash.go @@ -0,0 +1,66 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 git + +import ( + "encoding/hex" + "fmt" +) + +// hashLength is the length, in bytes, of digests/hashes in object format SHA1 +const hashLength = 20 + +// hashHexLength is the length, in hexadecimal characters, of digests/hashes in object format SHA1 +var hashHexLength = hex.EncodedLen(hashLength) + +type hash struct { + raw []byte + hex string +} + +func (i *hash) Raw() []byte { + return i.raw +} + +func (i *hash) Hex() string { + return i.hex +} + +func (i *hash) String() string { + return i.hex +} + +func newHashFromBytes(data []byte) (*hash, error) { + if len(data) != hashLength { + return nil, fmt.Errorf("hash is not %d bytes", hashLength) + } + dst := make([]byte, hex.EncodedLen(len(data))) + hex.Encode(dst, data) + return &hash{ + raw: data, + hex: string(dst), + }, nil +} + +func parseHashFromHex(data string) (*hash, error) { + if len(data) != hashHexLength { + return nil, fmt.Errorf("hash is not %d characters", hashHexLength) + } + raw, err := hex.DecodeString(data) + return &hash{ + raw: raw, + hex: data, + }, err +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/git/ident.go b/vendor/github.com/bufbuild/buf/private/pkg/git/ident.go new file mode 100644 index 000000000..35bcffabc --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/git/ident.go @@ -0,0 +1,87 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 git + +import ( + "errors" + "fmt" + "strconv" + "strings" + "time" +) + +type ident struct { + name string + email string + timestamp time.Time +} + +func (i *ident) Name() string { + return i.name +} +func (i *ident) Email() string { + return i.email +} +func (i *ident) Timestamp() time.Time { + return i.timestamp +} + +func parseIdent(data []byte) (*ident, error) { + var i ident + // Name (optional) + // Many spaces between name and email are allowed. + name, emailAndTime, found := strings.Cut(string(data), "<") + if !found { + // Mail is required. + return nil, errors.New("ident: no email component") + } + i.name = strings.TrimRight(name, " ") + + // Email (required) + idx := strings.LastIndex(emailAndTime, ">") + if idx == -1 { + return nil, errors.New("ident: malformed email component") + } + i.email = emailAndTime[:idx] + + // Timestamp (optional) + // The stamp is in Unix Epoc and the user's UTC offset in [+-]HHMM when the + // time was taken. + timestr := strings.TrimLeft(emailAndTime[idx+1:], " ") + if timestr != "" { + timesecstr, timezonestr, found := strings.Cut(timestr, " ") + if !found { + return nil, errors.New("ident: malformed timestamp: missing UTC offset") + } + timesec, err := strconv.ParseInt(timesecstr, 10, 64) + if err != nil { + return nil, fmt.Errorf("ident: malformed timestamp: %w", err) + } + tzHourStr := timezonestr[:len(timezonestr)-2] + tzHour, err := strconv.ParseInt(tzHourStr, 10, 32) + if err != nil { + return nil, fmt.Errorf("ident: malformed timestamp: %w", err) + } + tzMinStr := timezonestr[len(timezonestr)-2:] + tzMin, err := strconv.ParseInt(tzMinStr, 10, 32) + if err != nil { + return nil, fmt.Errorf("ident: malformed timestamp: %w", err) + } + tzOffset := int(tzHour)*60*60 + int(tzMin)*60 + location := time.FixedZone("UTC"+timezonestr, tzOffset) + i.timestamp = time.Unix(timesec, 0).In(location) + } + return &i, nil +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/git/object_reader.go b/vendor/github.com/bufbuild/buf/private/pkg/git/object_reader.go new file mode 100644 index 000000000..9ef6516f6 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/git/object_reader.go @@ -0,0 +1,170 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 git + +import ( + "bufio" + "context" + "errors" + "fmt" + "io" + "strconv" + "strings" + "time" + + "github.com/bufbuild/buf/private/pkg/command" + "go.uber.org/multierr" +) + +const ( + objectTypeBlob = "blob" + objectTypeCommit = "commit" + objectTypeTree = "tree" + objectTypeTag = "tag" +) + +// exitTime is the amount of time we'll wait for git-cat-file(1) to exit. +var exitTime = 5 * time.Second +var errObjectTypeMismatch = errors.New("object type mismatch") + +type objectReader struct { + rx *bufio.Reader + tx io.WriteCloser + process command.Process +} + +func newObjectReader(gitDirPath string, runner command.Runner) (*objectReader, error) { + rx, stdout := io.Pipe() + stdin, tx := io.Pipe() + process, err := runner.Start( + "git", + command.StartWithArgs("cat-file", "--batch"), + command.StartWithStdin(stdin), + command.StartWithStdout(stdout), + command.StartWithEnv(map[string]string{ + "GIT_DIR": gitDirPath, + }), + ) + if err != nil { + return nil, err + } + return &objectReader{ + rx: bufio.NewReader(rx), + tx: tx, + process: process, + }, nil +} + +func (o *objectReader) close() error { + ctx, cancel := context.WithDeadline( + context.Background(), + time.Now().Add(exitTime), + ) + defer cancel() + return multierr.Combine( + o.tx.Close(), + o.process.Wait(ctx), + ) +} + +func (o *objectReader) Blob(hash Hash) ([]byte, error) { + return o.read(objectTypeBlob, hash) +} + +func (o *objectReader) Commit(hash Hash) (Commit, error) { + data, err := o.read(objectTypeCommit, hash) + if err != nil { + return nil, err + } + return parseCommit(hash, data) +} + +func (o *objectReader) Tree(hash Hash) (Tree, error) { + data, err := o.read(objectTypeTree, hash) + if err != nil { + return nil, err + } + return parseTree(hash, data) +} + +func (o *objectReader) Tag(hash Hash) (AnnotatedTag, error) { + data, err := o.read(objectTypeTag, hash) + if err != nil { + return nil, err + } + return parseAnnotatedTag(hash, data) +} + +func (o *objectReader) read(objectType string, id Hash) ([]byte, error) { + // request + if _, err := fmt.Fprintf(o.tx, "%s\n", id.Hex()); err != nil { + return nil, err + } + // response + header, err := o.rx.ReadBytes('\n') + if err != nil { + return nil, err + } + headerStr := strings.TrimRight(string(header), "\n") + parts := strings.Split(headerStr, " ") + if len(parts) == 2 && parts[1] == "missing" { + return nil, fmt.Errorf( + "git-cat-file: %s: %w", + parts[0], + ErrObjectNotFound, + ) + } + if len(parts) != 3 { + return nil, fmt.Errorf("git-cat-file: malformed header: %q", headerStr) + } + objID, err := parseHashFromHex(parts[0]) + if err != nil { + return nil, err + } + if id.Hex() != objID.Hex() { + return nil, fmt.Errorf("git-cat-file: mismatched object ID: %s, %s", id.Hex(), objID.Hex()) + } + objType := parts[1] + objLenStr := parts[2] + objLen, err := strconv.ParseInt(objLenStr, 10, 64) + if err != nil { + return nil, err + } + objContent := make([]byte, objLen) + if _, err := io.ReadAtLeast(o.rx, objContent, int(objLen)); err != nil { + return nil, err + } + // TODO: We can verify the object content if we move from opaque object IDs + // to ones that know about being hardened SHA1 or SHA256. + trailer, err := o.rx.ReadBytes('\n') + if err != nil { + return nil, err + } + if len(trailer) != 1 { + return nil, errors.New("git-cat-file: unexpected trailer") + } + // Check the response type. It's check here to consume the complete request + // first. + if objType != objectType { + return nil, fmt.Errorf( + "git-cat-file: object %q is a %s, not a %s: %w", + id, + objType, + objectType, + errObjectTypeMismatch, + ) + } + return objContent, nil +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/git/packed_refs.go b/vendor/github.com/bufbuild/buf/private/pkg/git/packed_refs.go new file mode 100644 index 000000000..0aa1b4f3a --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/git/packed_refs.go @@ -0,0 +1,106 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 git + +import ( + "bufio" + "bytes" + "errors" + "fmt" + "strings" +) + +const ( + // packedRefsHeader is the head for the `packed-refs` file + // based on https://github.com/git/git/blob/master/refs/packed-backend.c#LL1084C41-L1084C41 + packedRefsHeader = "# pack-refs with: peeled fully-peeled sorted " + tagRefPrefix = "refs/tags/" + originBranchRefPrefix = "refs/remotes/origin/" + unpeeledRefPrefix = '^' +) + +// parsePackedRefs reads a `packed-refs` file, returning the packed branches and tags +func parsePackedRefs(data []byte) ( + map[string]Hash, // branches + map[string]Hash, // tags + error, +) { + var ( + packedBranches = map[string]Hash{} + packedTags = map[string]Hash{} + ) + /* + data is in the format + \n + repeated: + \n + (optional for tags if unpeeled)^\n + + for branches, the hash is the commit object + for tags, the hash is the tag object; the following line is the commit hash + */ + var lines []string + scanner := bufio.NewScanner(bytes.NewReader(data)) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + if scanner.Err() != nil { + return nil, nil, scanner.Err() + } + for i := 0; i < len(lines); i++ { + line := lines[i] + if strings.HasPrefix(line, "#") { + // Git tells us the way that these refs are packed. In theory the refs + // may be packed in different ways, but as of today's writing, they are + // always packed fully-peeled. + // + // The comment should match `packedRefsHeader`. We can safely skip this comment if so. + if line != packedRefsHeader { + return nil, nil, fmt.Errorf("unknown packed-refs header: %q", line) + } + continue + } + hashHex, ref, found := strings.Cut(line, " ") + if !found { + return nil, nil, errors.New("invalid packed-refs file") + } + hash, err := parseHashFromHex(hashHex) + if err != nil { + return nil, nil, err + } + if strings.HasPrefix(ref, originBranchRefPrefix) { + branchName := strings.TrimPrefix(ref, originBranchRefPrefix) + packedBranches[branchName] = hash + } else if strings.HasPrefix(ref, tagRefPrefix) { + tagName := strings.TrimPrefix(ref, tagRefPrefix) + // We're looking at a tag. If the tag is annotated, the next line is our actual + // commit hash, prefixed with '^'. If not, the already read hash is our commit hash. + // We need to look ahead to see the next line. + if len(lines) > i+1 && lines[i+1][0] == unpeeledRefPrefix { + // We have an annotated tag that's been peeled. Let's read it. + i++ + nextLine := lines[i] + nextLine = strings.TrimPrefix(nextLine, string(unpeeledRefPrefix)) + hash, err = parseHashFromHex(nextLine) + if err != nil { + return nil, nil, err + } + } + packedTags[tagName] = hash + } + // We ignore all kinds of refs. + } + return packedBranches, packedTags, nil +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/git/repository.go b/vendor/github.com/bufbuild/buf/private/pkg/git/repository.go new file mode 100644 index 000000000..20007ba40 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/git/repository.go @@ -0,0 +1,325 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 git + +import ( + "bytes" + "errors" + "fmt" + "io/fs" + "os" + "path" + "path/filepath" + "sync" + + "github.com/bufbuild/buf/private/pkg/command" + "github.com/bufbuild/buf/private/pkg/filepathextended" + "github.com/bufbuild/buf/private/pkg/normalpath" +) + +const defaultRemoteName = "origin" + +var baseBranchRefPrefix = []byte("ref: refs/remotes/" + defaultRemoteName + "/") + +type openRepositoryOpts struct { + baseBranch string +} + +type repository struct { + gitDirPath string + baseBranch string + objectReader *objectReader + + // packedOnce controls the fields below related to reading the `packed-refs` file + packedOnce sync.Once + packedReadError error + packedBranches map[string]Hash + packedTags map[string]Hash +} + +func openGitRepository( + gitDirPath string, + runner command.Runner, + options ...OpenRepositoryOption, +) (Repository, error) { + opts := &openRepositoryOpts{} + for _, opt := range options { + if err := opt(opts); err != nil { + return nil, err + } + } + gitDirPath = normalpath.Unnormalize(gitDirPath) + if err := validateDirPathExists(gitDirPath); err != nil { + return nil, err + } + gitDirPath, err := filepath.Abs(gitDirPath) + if err != nil { + return nil, err + } + reader, err := newObjectReader(gitDirPath, runner) + if err != nil { + return nil, err + } + if opts.baseBranch == "" { + opts.baseBranch, err = detectBaseBranch(gitDirPath) + if err != nil { + return nil, fmt.Errorf("automatically determine base branch: %w", err) + } + } + return &repository{ + gitDirPath: gitDirPath, + baseBranch: opts.baseBranch, + objectReader: reader, + }, nil +} + +func (r *repository) Close() error { + return r.objectReader.close() +} + +func (r *repository) Objects() ObjectReader { + return r.objectReader +} + +func (r *repository) ForEachBranch(f func(string, Hash) error) error { + seen := map[string]struct{}{} + // Read unpacked branch refs. + dir := path.Join(r.gitDirPath, "refs", "remotes", defaultRemoteName) + if err := filepathextended.Walk(dir, func(path string, info fs.FileInfo, err error) error { + if err != nil { + return err + } + if info.Name() == "HEAD" || info.IsDir() { + return nil + } + branchName, err := filepath.Rel(dir, path) + if err != nil { + return err + } + branchName = normalpath.Normalize(branchName) + hashBytes, err := os.ReadFile(path) + if err != nil { + return err + } + hashBytes = bytes.TrimSuffix(hashBytes, []byte{'\n'}) + hash, err := parseHashFromHex(string(hashBytes)) + if err != nil { + return err + } + seen[branchName] = struct{}{} + return f(branchName, hash) + }); err != nil { + return err + } + // Read packed branch refs that haven't been seen yet. + if err := r.readPackedRefs(); err != nil { + return err + } + for branchName, hash := range r.packedBranches { + if _, found := seen[branchName]; !found { + if err := f(branchName, hash); err != nil { + return err + } + } + } + return nil +} +func (r *repository) BaseBranch() string { + return r.baseBranch +} + +func (r *repository) ForEachCommit(branch string, f func(Commit) error) error { + branch = normalpath.Unnormalize(branch) + commit, err := r.resolveBranch(branch) + if err != nil { + return err + } + var commits []Commit + // TODO: this only works for the base branch; for non-base branches, + // we have to be much more careful about not ranging over commits belonging + // to other branches (i.e., running past the origin of our branch). + // In order to do this, we will want to preload the HEADs of all known branches, + // and halt iteration for a given branch when we encounter the head of another branch. + for { + commits = append(commits, commit) + if len(commit.Parents()) == 0 { + // We've reach the root of the graph. + break + } + // When traversing a commit graph, follow only the first parent commit upon seeing a + // merge commit. This allows us to ignore the individual commits brought in to a branch's + // history by such a merge, as those commits are usually updating the state of the target + // branch. + commit, err = r.objectReader.Commit(commit.Parents()[0]) + if err != nil { + return err + } + } + // Visit in reverse order, starting with the root of the graph first. + for i := len(commits) - 1; i >= 0; i-- { + if err := f(commits[i]); err != nil { + return err + } + } + return nil +} + +func (r *repository) ForEachTag(f func(string, Hash) error) error { + seen := map[string]struct{}{} + // Read unpacked tag refs. + dir := path.Join(r.gitDirPath, "refs", "tags") + if err := filepathextended.Walk(dir, func(path string, info fs.FileInfo, err error) error { + if err != nil { + return err + } + if !info.Mode().IsRegular() { + return nil + } + tagName, err := filepath.Rel(dir, path) + if err != nil { + return err + } + tagName = normalpath.Normalize(tagName) + hashBytes, err := os.ReadFile(path) + if err != nil { + return err + } + hashBytes = bytes.TrimSuffix(hashBytes, []byte{'\n'}) + hash, err := parseHashFromHex(string(hashBytes)) + if err != nil { + return err + } + // Tags are either annotated or lightweight. Depending on the type, + // they are stored differently. First, we try to load the tag + // as an annnotated tag. If this fails, we try a commit. + // Finally, we fail. + tag, err := r.objectReader.Tag(hash) + if err == nil { + seen[tagName] = struct{}{} + return f(tagName, tag.Commit()) + } + if !errors.Is(err, errObjectTypeMismatch) { + return err + } + _, err = r.objectReader.Commit(hash) + if err == nil { + seen[tagName] = struct{}{} + return f(tagName, hash) + } + if !errors.Is(err, errObjectTypeMismatch) { + return err + } + return fmt.Errorf( + "failed to determine target of tag %q; it is neither a tag nor a commit", + tagName, + ) + }); err != nil { + return err + } + // Read packed tag refs that haven't been seen yet. + if err := r.readPackedRefs(); err != nil { + return err + } + for tagName, commit := range r.packedTags { + if _, found := seen[tagName]; !found { + if err := f(tagName, commit); err != nil { + return err + } + } + } + return nil +} + +func (r *repository) resolveBranch(branch string) (Commit, error) { + commitBytes, err := os.ReadFile(path.Join(r.gitDirPath, "refs", "remotes", defaultRemoteName, branch)) + if errors.Is(err, fs.ErrNotExist) { + // it may be that the branch ref is packed; let's read the packed refs + if err := r.readPackedRefs(); err != nil { + return nil, err + } + if commitID, ok := r.packedBranches[branch]; ok { + commit, err := r.objectReader.Commit(commitID) + if err != nil { + return nil, err + } + return commit, nil + } + return nil, fmt.Errorf("branch %q not found", branch) + } + if err != nil { + return nil, err + } + commitBytes = bytes.TrimRight(commitBytes, "\n") + commitID, err := NewHashFromHex(string(commitBytes)) + if err != nil { + return nil, err + } + commit, err := r.objectReader.Commit(commitID) + if err != nil { + return nil, err + } + return commit, nil +} + +func (r *repository) readPackedRefs() error { + r.packedOnce.Do(func() { + packedRefsPath := path.Join(r.gitDirPath, "packed-refs") + if _, err := os.Stat(packedRefsPath); err != nil { + if errors.Is(err, os.ErrNotExist) { + r.packedBranches = map[string]Hash{} + r.packedTags = map[string]Hash{} + return + } + r.packedReadError = err + return + } + allBytes, err := os.ReadFile(packedRefsPath) + if err != nil { + r.packedReadError = err + return + } + r.packedBranches, r.packedTags, r.packedReadError = parsePackedRefs(allBytes) + }) + return r.packedReadError +} + +func detectBaseBranch(gitDirPath string) (string, error) { + path := path.Join(gitDirPath, "refs", "remotes", defaultRemoteName, "HEAD") + data, err := os.ReadFile(path) + if err != nil { + return "", err + } + if !bytes.HasPrefix(data, baseBranchRefPrefix) { + return "", errors.New("invalid contents in " + path) + } + data = bytes.TrimPrefix(data, baseBranchRefPrefix) + data = bytes.TrimSuffix(data, []byte("\n")) + return string(data), nil +} + +// validateDirPathExists returns a non-nil error if the given dirPath +// is not a valid directory path. +func validateDirPathExists(dirPath string) error { + var fileInfo os.FileInfo + // We do not follow symlinks + fileInfo, err := os.Lstat(dirPath) + if err != nil { + return err + } + if !fileInfo.IsDir() { + return normalpath.NewError(dirPath, errors.New("not a directory")) + } + return nil +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/git/tree.go b/vendor/github.com/bufbuild/buf/private/pkg/git/tree.go new file mode 100644 index 000000000..400caa405 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/git/tree.go @@ -0,0 +1,115 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 git + +import ( + "bytes" + "errors" + "fmt" + + "github.com/bufbuild/buf/private/pkg/normalpath" +) + +type tree struct { + hash Hash + nodes []TreeNode +} + +func parseTree(hash Hash, data []byte) (*tree, error) { + t := &tree{ + hash: hash, + } + /* + data is in the format + \0 + repeated + */ + for len(data) > 0 { + // We can find the \0 character before the + // and slice to the index of \0 + the length of a hash. + // That gives us a single node. + i := bytes.Index(data, []byte{0}) + if i == -1 { + return nil, errors.New("parse tree") + } + length := i + 1 + hashLength + node, err := parseTreeNode(data[:length]) + if err != nil { + return nil, fmt.Errorf("parse tree: %w", err) + } + t.nodes = append(t.nodes, node) + data = data[length:] + } + return t, nil +} + +func (t *tree) Hash() Hash { + return t.hash +} + +func (t *tree) Nodes() []TreeNode { + return t.nodes +} + +func (t *tree) Descendant(path string, objectReader ObjectReader) (TreeNode, error) { + if path == "" { + return nil, errors.New("empty path") + } + return descendant(objectReader, t, normalpath.Components(path)) +} + +func descendant( + objectReader ObjectReader, + root Tree, + names []string, +) (TreeNode, error) { + // split by the name of the next node we're looking for + // and the names of the descendant nodes + name := names[0] + if len(names) >= 2 { + names = names[1:] + } else { + names = nil + } + // Find node with that name in this tree. + var found TreeNode + for _, node := range root.Nodes() { + if node.Name() == name { + found = node + break + } + } + if found == nil { + // No node with that name in this tree. + return nil, ErrTreeNodeNotFound + } + if len(names) == 0 { + // No more descendants, we've found our terminal node. + return found, nil + } + if found.Mode() != ModeDir { + // This is an intermediate (non-terminal) node, which are expected to be + // directories. This is node is not a directory, so we fail with a non-found + // errror. + return nil, ErrTreeNodeNotFound + } + // TODO: support symlinks (on intermediate dirs) with descendant option + // Descend down and traverse. + tree, err := objectReader.Tree(found.Hash()) + if err != nil { + return nil, err + } + return descendant(objectReader, tree, names) +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/git/tree_node.go b/vendor/github.com/bufbuild/buf/private/pkg/git/tree_node.go new file mode 100644 index 000000000..bc376631e --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/git/tree_node.go @@ -0,0 +1,86 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 git + +import ( + "bytes" + "errors" + "fmt" + "strconv" +) + +type treeNode struct { + name string + mode ObjectMode + hash Hash +} + +func parseTreeNode(data []byte) (*treeNode, error) { + /* + data is in the format + \0 + */ + modeAndName, hash, found := bytes.Cut(data, []byte{0}) + if !found { + return nil, errors.New("parse tree node") + } + parsedHash, err := newHashFromBytes(hash) + if err != nil { + return nil, fmt.Errorf("parse tree node hash: %w", err) + } + mode, name, found := bytes.Cut(modeAndName, []byte{' '}) + if !found { + return nil, errors.New("parse tree node") + } + parsedFileMode, err := parseObjectMode(mode) + if err != nil { + return nil, fmt.Errorf("parse tree node object mode: %w", err) + } + return &treeNode{ + hash: parsedHash, + name: string(name), + mode: parsedFileMode, + }, nil +} + +func (e *treeNode) Name() string { + return e.name +} + +func (e *treeNode) Mode() ObjectMode { + return e.mode +} + +func (e *treeNode) Hash() Hash { + return e.hash +} + +// decodes the octal form of a object mode into one of the valid Mode* values. +func parseObjectMode(data []byte) (ObjectMode, error) { + mode, err := strconv.ParseUint(string(data), 8, 32) + if err != nil { + return 0, err + } + switch ObjectMode(mode) { + case ModeFile: + case ModeExe: + case ModeDir: + case ModeSymlink: + case ModeSubmodule: + default: + return 0, fmt.Errorf("unknown object mode: %o", mode) + } + return ObjectMode(mode), nil +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/manifest/manifest.go b/vendor/github.com/bufbuild/buf/private/pkg/manifest/manifest.go index 00e5a41ef..d0d9813a1 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/manifest/manifest.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/manifest/manifest.go @@ -49,6 +49,8 @@ import ( "io" "sort" "strings" + + "github.com/bufbuild/buf/private/pkg/normalpath" ) var errNoFinalNewline = errors.New("partial record: missing newline") @@ -106,6 +108,10 @@ func (m *Manifest) AddEntry(path string, digest Digest) error { if path == "" { return errors.New("empty path") } + path, err := normalpath.NormalizeAndValidate(path) + if err != nil { + return fmt.Errorf("invalid path: %w", err) + } if digest.Type() == "" || digest.Hex() == "" { return errors.New("invalid digest") } diff --git a/vendor/github.com/bufbuild/buf/private/pkg/manifest/module.go b/vendor/github.com/bufbuild/buf/private/pkg/manifest/module.go index 5db006e03..75c6d7cb3 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/manifest/module.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/manifest/module.go @@ -99,6 +99,7 @@ type BlobSet struct { type blobSetOptions struct { validateContent bool + skipNilBlobs bool } // BlobSetOption are options passed when creating a new blob set. @@ -115,6 +116,16 @@ func BlobSetWithContentValidation() BlobSetOption { } } +// BlobSetWithSkipNilBlobs allows passing nil blobs in the slice of blobs. The default behavior is +// that if you pass a nil blob in the slice, you'll get an error from the `NewBlobSet` constructor. +// If you pass this option, any nil blob will be skipped and the blob set will be built only from +// the non-nil ones. +func BlobSetWithSkipNilBlobs() BlobSetOption { + return func(opts *blobSetOptions) { + opts.skipNilBlobs = true + } +} + // NewBlobSet receives a slice of blobs, and de-duplicates them into a BlobSet. func NewBlobSet(ctx context.Context, blobs []Blob, opts ...BlobSetOption) (*BlobSet, error) { var config blobSetOptions @@ -122,7 +133,13 @@ func NewBlobSet(ctx context.Context, blobs []Blob, opts ...BlobSetOption) (*Blob option(&config) } digestToBlobs := make(map[string]Blob, len(blobs)) - for _, b := range blobs { + for i, b := range blobs { + if b == nil { + if config.skipNilBlobs { + continue + } + return nil, fmt.Errorf("blobs[%d]: nil blob", i) + } digestStr := b.Digest().String() if config.validateContent { existingBlob, alreadyPresent := digestToBlobs[digestStr] diff --git a/vendor/github.com/bufbuild/buf/private/pkg/observabilityzap/zapexporter.go b/vendor/github.com/bufbuild/buf/private/pkg/observabilityzap/zapexporter.go index 25c3f7438..85ba2e6fd 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/observabilityzap/zapexporter.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/observabilityzap/zapexporter.go @@ -43,7 +43,7 @@ func (z *zapExporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpa zap.Duration("duration", span.EndTime().Sub(span.StartTime())), } for _, attribute := range span.Attributes() { - fields = append(fields, zap.Any(string(attribute.Key), attribute.Value)) + fields = append(fields, zap.Any(string(attribute.Key), attribute.Value.AsInterface())) } checkedEntry.Write(fields...) } diff --git a/vendor/github.com/bufbuild/buf/private/pkg/protoencoding/json_marshaler.go b/vendor/github.com/bufbuild/buf/private/pkg/protoencoding/json_marshaler.go index ec365a4bf..22cba9cd9 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/protoencoding/json_marshaler.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/protoencoding/json_marshaler.go @@ -23,17 +23,20 @@ import ( ) type jsonMarshaler struct { - resolver Resolver - indent string - useProtoNames bool + resolver Resolver + indent string + useProtoNames bool + emitUnpopulated bool } -func newJSONMarshaler(resolver Resolver, indent string, useProtoNames bool) Marshaler { - return &jsonMarshaler{ - resolver: resolver, - indent: indent, - useProtoNames: useProtoNames, +func newJSONMarshaler(resolver Resolver, options ...JSONMarshalerOption) Marshaler { + jsonMarshaler := &jsonMarshaler{ + resolver: resolver, } + for _, option := range options { + option(jsonMarshaler) + } + return jsonMarshaler } func (m *jsonMarshaler) Marshal(message proto.Message) ([]byte, error) { @@ -41,9 +44,9 @@ func (m *jsonMarshaler) Marshal(message proto.Message) ([]byte, error) { return nil, err } options := protojson.MarshalOptions{ - Resolver: m.resolver, - Indent: m.indent, - UseProtoNames: m.useProtoNames, + Resolver: m.resolver, + UseProtoNames: m.useProtoNames, + EmitUnpopulated: m.emitUnpopulated, } data, err := options.Marshal(message) if err != nil { @@ -58,8 +61,14 @@ func (m *jsonMarshaler) Marshal(message proto.Message) ([]byte, error) { // We may need to do a full encoding/json encode/decode in the future if protojson // produces non-deterministic output. buffer := bytes.NewBuffer(nil) - if err := json.Compact(buffer, data); err != nil { - return nil, err + if m.indent != "" { + if err := json.Indent(buffer, data, "", m.indent); err != nil { + return nil, err + } + } else { + if err := json.Compact(buffer, data); err != nil { + return nil, err + } } return buffer.Bytes(), nil } diff --git a/vendor/github.com/bufbuild/buf/private/pkg/protoencoding/protoencoding.go b/vendor/github.com/bufbuild/buf/private/pkg/protoencoding/protoencoding.go index f8803f8dd..20b8119d7 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/protoencoding/protoencoding.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/protoencoding/protoencoding.go @@ -67,24 +67,32 @@ func NewWireMarshaler() Marshaler { // // This has the potential to be unstable over time. // resolver can be nil if unknown and are only needed for extensions. -func NewJSONMarshaler(resolver Resolver) Marshaler { - return newJSONMarshaler(resolver, "", false) +func NewJSONMarshaler(resolver Resolver, options ...JSONMarshalerOption) Marshaler { + return newJSONMarshaler(resolver, options...) } -// NewJSONMarshalerIndent returns a new Marshaler for JSON with indents. -// -// This has the potential to be unstable over time. -// resolver can be nil if unknown and are only needed for extensions. -func NewJSONMarshalerIndent(resolver Resolver) Marshaler { - return newJSONMarshaler(resolver, " ", false) +// JSONMarshalerOption is an option for a new JSONMarshaler. +type JSONMarshalerOption func(*jsonMarshaler) + +// JSONMarshalerWithIndent says to use an indent of two spaces. +func JSONMarshalerWithIndent() JSONMarshalerOption { + return func(jsonMarshaler *jsonMarshaler) { + jsonMarshaler.indent = " " + } } -// NewJSONMarshalerUseProtoNames returns a new Marshaler for JSON using the proto names for keys. -// -// This has the potential to be unstable over time. -// resolver can be nil if unknown and are only needed for extensions. -func NewJSONMarshalerUseProtoNames(resolver Resolver) Marshaler { - return newJSONMarshaler(resolver, "", true) +// JSONMarshalerWithUseProtoNames says to use an use proto names. +func JSONMarshalerWithUseProtoNames() JSONMarshalerOption { + return func(jsonMarshaler *jsonMarshaler) { + jsonMarshaler.useProtoNames = true + } +} + +// JSONMarshalerWithEmitUnpopulated says to emit unpopulated values +func JSONMarshalerWithEmitUnpopulated() JSONMarshalerOption { + return func(jsonMarshaler *jsonMarshaler) { + jsonMarshaler.emitUnpopulated = true + } } // Unmarshaler unmarshals Messages. diff --git a/vendor/github.com/bufbuild/buf/private/pkg/protosource/file.go b/vendor/github.com/bufbuild/buf/private/pkg/protosource/file.go index f4b78b404..67ee1d78c 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/protosource/file.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/protosource/file.go @@ -229,17 +229,20 @@ func (f *file) SyntaxLocation() Location { // does not validation of the fileDescriptorProto - this is assumed to be done elsewhere // does no duplicate checking by name - could just have maps ie importToFileImport, enumNameToEnum, etc func newFile(inputFile InputFile) (*file, error) { + locationStore := newLocationStore(inputFile.FileDescriptor().GetSourceCodeInfo().GetLocation()) f := &file{ FileInfo: inputFile, fileDescriptor: inputFile.FileDescriptor(), optionExtensionDescriptor: newOptionExtensionDescriptor( inputFile.FileDescriptor().GetOptions(), + []int32{8}, + locationStore, ), edition: inputFile.FileDescriptor().GetEdition(), } descriptor := newDescriptor( f, - newLocationStore(f.fileDescriptor.GetSourceCodeInfo().GetLocation()), + locationStore, ) f.descriptor = descriptor @@ -377,6 +380,8 @@ func (f *file) populateEnum( enumNamedDescriptor, newOptionExtensionDescriptor( enumDescriptorProto.GetOptions(), + getEnumOptionsPath(enumIndex, nestedMessageIndexes...), + f.descriptor.locationStore, ), enumDescriptorProto.GetOptions().GetAllowAlias(), enumDescriptorProto.GetOptions().GetDeprecatedLegacyJsonFieldConflicts(), @@ -402,6 +407,8 @@ func (f *file) populateEnum( enumValueNamedDescriptor, newOptionExtensionDescriptor( enumValueDescriptorProto.GetOptions(), + getEnumValueOptionsPath(enumIndex, enumValueIndex, nestedMessageIndexes...), + f.descriptor.locationStore, ), enum, int(enumValueDescriptorProto.GetNumber()), @@ -467,6 +474,8 @@ func (f *file) populateMessage( messageNamedDescriptor, newOptionExtensionDescriptor( descriptorProto.GetOptions(), + getMessageOptionsPath(topLevelMessageIndex, nestedMessageIndexes...), + f.descriptor.locationStore, ), parent, descriptorProto.GetOptions().GetMapEntry(), @@ -495,6 +504,8 @@ func (f *file) populateMessage( oneofNamedDescriptor, newOptionExtensionDescriptor( oneofDescriptorProto.GetOptions(), + getMessageOneofOptionsPath(oneofIndex, topLevelMessageIndex, nestedMessageIndexes...), + f.descriptor.locationStore, ), message, ) @@ -532,6 +543,8 @@ func (f *file) populateMessage( fieldNamedDescriptor, newOptionExtensionDescriptor( fieldDescriptorProto.GetOptions(), + getMessageFieldOptionsPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...), + f.descriptor.locationStore, ), message, int(fieldDescriptorProto.GetNumber()), @@ -593,6 +606,8 @@ func (f *file) populateMessage( fieldNamedDescriptor, newOptionExtensionDescriptor( fieldDescriptorProto.GetOptions(), + getMessageExtensionOptionsPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...), + f.descriptor.locationStore, ), message, int(fieldDescriptorProto.GetNumber()), @@ -666,6 +681,8 @@ func (f *file) populateMessage( int(extensionRangeDescriptorProto.GetEnd()), newOptionExtensionDescriptor( extensionRangeDescriptorProto.GetOptions(), + getMessageExtensionRangeOptionsPath(extensionRangeIndex, topLevelMessageIndex, nestedMessageIndexes...), + f.descriptor.locationStore, ), ) message.addExtensionRange(extensionMessageRange) @@ -721,6 +738,8 @@ func (f *file) populateService( serviceNamedDescriptor, newOptionExtensionDescriptor( serviceDescriptorProto.GetOptions(), + getServiceOptionsPath(serviceIndex), + f.descriptor.locationStore, ), serviceDescriptorProto.GetOptions().GetDeprecated(), ) @@ -741,6 +760,8 @@ func (f *file) populateService( methodNamedDescriptor, newOptionExtensionDescriptor( methodDescriptorProto.GetOptions(), + getMethodOptionsPath(serviceIndex, methodIndex), + f.descriptor.locationStore, ), service, strings.TrimPrefix(methodDescriptorProto.GetInputType(), "."), @@ -785,6 +806,8 @@ func (f *file) populateExtension( fieldNamedDescriptor, newOptionExtensionDescriptor( fieldDescriptorProto.GetOptions(), + getFileExtensionOptionsPath(fieldIndex), + f.descriptor.locationStore, ), nil, int(fieldDescriptorProto.GetNumber()), diff --git a/vendor/github.com/bufbuild/buf/private/pkg/protosource/location_store.go b/vendor/github.com/bufbuild/buf/private/pkg/protosource/location_store.go index 378576528..e05931a59 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/protosource/location_store.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/protosource/location_store.go @@ -23,10 +23,8 @@ import ( type locationStore struct { sourceCodeInfoLocations []*descriptorpb.SourceCodeInfo_Location - pathToLocation map[string]Location - pathToSourceCodeInfoLocation map[string]*descriptorpb.SourceCodeInfo_Location - locationLock sync.RWMutex - sourceCodeInfoLocationLock sync.RWMutex + initLocations sync.Once + pathToLocation map[string]Location } func newLocationStore(sourceCodeInfoLocations []*descriptorpb.SourceCodeInfo_Location) *locationStore { @@ -40,54 +38,23 @@ func (l *locationStore) getLocation(path []int32) Location { return l.getLocationByPathKey(getPathKey(path)) } -// optimization for keys we know ahead of time such as package location, certain file options func (l *locationStore) getLocationByPathKey(pathKey string) Location { - // check cache first - l.locationLock.RLock() - location, ok := l.pathToLocation[pathKey] - l.locationLock.RUnlock() - if ok { - return location - } - - // build index and get sourceCodeInfoLocation - l.sourceCodeInfoLocationLock.RLock() - pathToSourceCodeInfoLocation := l.pathToSourceCodeInfoLocation - l.sourceCodeInfoLocationLock.RUnlock() - if pathToSourceCodeInfoLocation == nil { - l.sourceCodeInfoLocationLock.Lock() - pathToSourceCodeInfoLocation = l.pathToSourceCodeInfoLocation - if pathToSourceCodeInfoLocation == nil { - pathToSourceCodeInfoLocation = make(map[string]*descriptorpb.SourceCodeInfo_Location) - for _, sourceCodeInfoLocation := range l.sourceCodeInfoLocations { - pathKey := getPathKey(sourceCodeInfoLocation.Path) - // - Multiple locations may have the same path. This happens when a single - // logical declaration is spread out across multiple places. The most - // obvious example is the "extend" block again -- there may be multiple - // extend blocks in the same scope, each of which will have the same path. - if _, ok := pathToSourceCodeInfoLocation[pathKey]; !ok { - pathToSourceCodeInfoLocation[pathKey] = sourceCodeInfoLocation - } + l.initLocations.Do(func() { + pathToLocation := make(map[string]Location) + for _, sourceCodeInfoLocation := range l.sourceCodeInfoLocations { + pathKey := getPathKey(sourceCodeInfoLocation.Path) + // - Multiple locations may have the same path. This happens when a single + // logical declaration is spread out across multiple places. The most + // obvious example is the "extend" block again -- there may be multiple + // extend blocks in the same scope, each of which will have the same path. + if _, ok := pathToLocation[pathKey]; !ok { + pathToLocation[pathKey] = newLocation(sourceCodeInfoLocation) } } - l.pathToSourceCodeInfoLocation = pathToSourceCodeInfoLocation - l.sourceCodeInfoLocationLock.Unlock() - } - sourceCodeInfoLocation, ok := pathToSourceCodeInfoLocation[pathKey] - if !ok { - return nil - } + l.pathToLocation = pathToLocation + }) - // populate cache and return - if sourceCodeInfoLocation == nil { - location = nil - } else { - location = newLocation(sourceCodeInfoLocation) - } - l.locationLock.Lock() - l.pathToLocation[pathKey] = location - l.locationLock.Unlock() - return location + return l.pathToLocation[pathKey] } func getPathKey(path []int32) string { diff --git a/vendor/github.com/bufbuild/buf/private/pkg/protosource/option_extension_descriptor.go b/vendor/github.com/bufbuild/buf/private/pkg/protosource/option_extension_descriptor.go index 09d0ef1d0..97c5b86cf 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/protosource/option_extension_descriptor.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/protosource/option_extension_descriptor.go @@ -18,15 +18,20 @@ import ( "google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" ) type optionExtensionDescriptor struct { - message proto.Message + message proto.Message + optionsPath []int32 + locationStore *locationStore } -func newOptionExtensionDescriptor(message proto.Message) optionExtensionDescriptor { +func newOptionExtensionDescriptor(message proto.Message, optionsPath []int32, locationStore *locationStore) optionExtensionDescriptor { return optionExtensionDescriptor{ - message: message, + message: message, + optionsPath: optionsPath, + locationStore: locationStore, } } @@ -40,6 +45,43 @@ func (o *optionExtensionDescriptor) OptionExtension(extensionType protoreflect.E return proto.GetExtension(o.message, extensionType), true } +func (o *optionExtensionDescriptor) OptionExtensionLocation(extensionType protoreflect.ExtensionType, extraPath ...int32) Location { + if extensionType.TypeDescriptor().ContainingMessage().FullName() != o.message.ProtoReflect().Descriptor().FullName() { + return nil + } + if o.locationStore == nil { + return nil + } + path := make([]int32, len(o.optionsPath), len(o.optionsPath)+1+len(extraPath)) + copy(path, o.optionsPath) + path = append(path, int32(extensionType.TypeDescriptor().Number())) + extensionPathLen := len(path) // length of path to extension (without extraPath) + path = append(path, extraPath...) + loc := o.locationStore.getLocation(path) + if loc != nil { + // Found an exact match! + return loc + } + // "Fuzzy" search: find a location whose path is at least extensionPathLen long, + // preferring the longest matching ancestor path (i.e. as many extraPath elements + // as can be found). If we find a *sub*path (a descendant path, that points INTO + // the path we are trying to find), use the first such one encountered. + var bestMatch *descriptorpb.SourceCodeInfo_Location + var bestMatchPathLen int + for _, loc := range o.locationStore.sourceCodeInfoLocations { + if len(loc.Path) >= extensionPathLen && isDescendantPath(path, loc.Path) && len(loc.Path) > bestMatchPathLen { + bestMatch = loc + bestMatchPathLen = len(loc.Path) + } else if isDescendantPath(loc.Path, path) { + return newLocation(loc) + } + } + if bestMatch != nil { + return newLocation(bestMatch) + } + return nil +} + func (o *optionExtensionDescriptor) PresentExtensionNumbers() []int32 { fieldNumbersSet := map[int32]struct{}{} var fieldNumbers []int32 @@ -72,3 +114,15 @@ func (o *optionExtensionDescriptor) PresentExtensionNumbers() []int32 { return fieldNumbers } + +func isDescendantPath(descendant, ancestor []int32) bool { + if len(descendant) < len(ancestor) { + return false + } + for i := range ancestor { + if descendant[i] != ancestor[i] { + return false + } + } + return true +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/protosource/paths.go b/vendor/github.com/bufbuild/buf/private/pkg/protosource/paths.go index f6e8cd02b..aa6e2aa7e 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/protosource/paths.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/protosource/paths.go @@ -53,6 +53,10 @@ func getMessageNamePath(messageIndex int, nestedMessageIndexes ...int) []int32 { return append(getMessagePath(messageIndex, nestedMessageIndexes...), 1) } +func getMessageOptionsPath(messageIndex int, nestedMessageIndexes ...int) []int32 { + return append(getMessagePath(messageIndex, nestedMessageIndexes...), 7) +} + func getMessageMessageSetWireFormatPath(messageIndex int, nestedMessageIndexes ...int) []int32 { return append(getMessagePath(messageIndex, nestedMessageIndexes...), 7, 1) } @@ -85,6 +89,10 @@ func getMessageFieldJSONNamePath(fieldIndex int, topLevelMessageIndex int, neste return append(getMessageFieldPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...), 10) } +func getMessageFieldOptionsPath(fieldIndex int, topLevelMessageIndex int, nestedMessageIndexes ...int) []int32 { + return append(getMessageFieldPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...), 8) +} + func getMessageFieldJSTypePath(fieldIndex int, topLevelMessageIndex int, nestedMessageIndexes ...int) []int32 { return append(getMessageFieldPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...), 8, 6) } @@ -125,6 +133,10 @@ func getMessageExtensionJSONNamePath(extensionIndex int, topLevelMessageIndex in return append(getMessageExtensionPath(extensionIndex, topLevelMessageIndex, nestedMessageIndexes...), 10) } +func getMessageExtensionOptionsPath(extensionIndex int, topLevelMessageIndex int, nestedMessageIndexes ...int) []int32 { + return append(getMessageExtensionPath(extensionIndex, topLevelMessageIndex, nestedMessageIndexes...), 8) +} + func getMessageExtensionJSTypePath(extensionIndex int, topLevelMessageIndex int, nestedMessageIndexes ...int) []int32 { return append(getMessageExtensionPath(extensionIndex, topLevelMessageIndex, nestedMessageIndexes...), 8, 6) } @@ -149,6 +161,10 @@ func getMessageOneofNamePath(oneofIndex int, topLevelMessageIndex int, nestedMes return append(getMessageOneofPath(oneofIndex, topLevelMessageIndex, nestedMessageIndexes...), 1) } +func getMessageOneofOptionsPath(oneofIndex int, topLevelMessageIndex int, nestedMessageIndexes ...int) []int32 { + return append(getMessageOneofPath(oneofIndex, topLevelMessageIndex, nestedMessageIndexes...), 2) +} + func getMessageReservedRangePath(reservedRangeIndex int, topLevelMessageIndex int, nestedMessageIndexes ...int) []int32 { return append(getMessagePath(topLevelMessageIndex, nestedMessageIndexes...), 9, int32(reservedRangeIndex)) } @@ -161,6 +177,10 @@ func getMessageExtensionRangePath(extensionRangeIndex int, topLevelMessageIndex return append(getMessagePath(topLevelMessageIndex, nestedMessageIndexes...), 5, int32(extensionRangeIndex)) } +func getMessageExtensionRangeOptionsPath(extensionRangeIndex int, topLevelMessageIndex int, nestedMessageIndexes ...int) []int32 { + return append(getMessagePath(topLevelMessageIndex, nestedMessageIndexes...), 5, int32(extensionRangeIndex), 3) +} + func getEnumPath(enumIndex int, nestedMessageIndexes ...int) []int32 { if len(nestedMessageIndexes) == 0 { return []int32{5, int32(enumIndex)} @@ -171,10 +191,15 @@ func getEnumPath(enumIndex int, nestedMessageIndexes ...int) []int32 { } return append(path, 4, int32(enumIndex)) } + func getEnumNamePath(enumIndex int, nestedMessageIndexes ...int) []int32 { return append(getEnumPath(enumIndex, nestedMessageIndexes...), 1) } +func getEnumOptionsPath(enumIndex int, nestedMessageIndexes ...int) []int32 { + return append(getEnumPath(enumIndex, nestedMessageIndexes...), 3) +} + func getEnumAllowAliasPath(enumIndex int, nestedMessageIndexes ...int) []int32 { return append(getEnumPath(enumIndex, nestedMessageIndexes...), 3, 2) } @@ -191,6 +216,10 @@ func getEnumValueNumberPath(enumIndex int, enumValueIndex int, nestedMessageInde return append(getEnumValuePath(enumIndex, enumValueIndex, nestedMessageIndexes...), 2) } +func getEnumValueOptionsPath(enumIndex int, enumValueIndex int, nestedMessageIndexes ...int) []int32 { + return append(getEnumValuePath(enumIndex, enumValueIndex, nestedMessageIndexes...), 3) +} + func getEnumReservedRangePath(enumIndex int, reservedRangeIndex int, nestedMessageIndexes ...int) []int32 { return append(getEnumPath(enumIndex, nestedMessageIndexes...), 4, int32(reservedRangeIndex)) } @@ -207,6 +236,10 @@ func getServiceNamePath(serviceIndex int) []int32 { return append(getServicePath(serviceIndex), 1) } +func getServiceOptionsPath(serviceIndex int) []int32 { + return append(getServicePath(serviceIndex), 3) +} + func getMethodPath(serviceIndex int, methodIndex int) []int32 { return []int32{6, int32(serviceIndex), 2, int32(methodIndex)} } @@ -223,6 +256,10 @@ func getMethodOutputTypePath(serviceIndex int, methodIndex int) []int32 { return append(getMethodPath(serviceIndex, methodIndex), 3) } +func getMethodOptionsPath(serviceIndex int, methodIndex int) []int32 { + return append(getMethodPath(serviceIndex, methodIndex), 4) +} + func getMethodIdempotencyLevelPath(serviceIndex int, methodIndex int) []int32 { return append(getMethodPath(serviceIndex, methodIndex), 4, 34) } @@ -251,6 +288,10 @@ func getFileExtensionJSONNamePath(fieldIndex int) []int32 { return append(getFileExtensionPath(fieldIndex), 10) } +func getFileExtensionOptionsPath(fieldIndex int) []int32 { + return append(getFileExtensionPath(fieldIndex), 8) +} + func getFileExtensionJSTypePath(fieldIndex int) []int32 { return append(getFileExtensionPath(fieldIndex), 8, 6) } diff --git a/vendor/github.com/bufbuild/buf/private/pkg/protosource/protosource.go b/vendor/github.com/bufbuild/buf/private/pkg/protosource/protosource.go index 811d162e5..28cfc9a8a 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/protosource/protosource.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/protosource/protosource.go @@ -131,6 +131,23 @@ type OptionExtensionDescriptor interface { // See https://pkg.go.dev/google.golang.org/protobuf/proto#GetExtension OptionExtension(extensionType protoreflect.ExtensionType) (interface{}, bool) + // OptionExtensionLocation returns the source location where the given extension + // field value is defined. The extra path can be additional path elements, for + // getting the location of specific elements inside the extension, for message + // and repeated values. + // + // If a precise location cannot be found, but a general one can be, the general + // location will be returned. For example, if a specific field inside a message + // extension is requested but the source code info only includes information + // about the message itself (and not that particular field), the location of the + // message value is returned. Conversely, if a message location is requested but + // the source code info only has information about specific fields inside that + // message, the first such location is returned. Similarly, if multiple locations + // are in source code info for the requested value, the first one is returned. + // + // If no relevant location is found in source code info, this returns nil. + OptionExtensionLocation(extensionType protoreflect.ExtensionType, extraPath ...int32) Location + // PresentExtensionNumbers returns field numbers for all options that // have a set value on this descriptor. PresentExtensionNumbers() []int32 diff --git a/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/bucket.go b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/bucket.go new file mode 100644 index 000000000..93b3dc1dd --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/bucket.go @@ -0,0 +1,210 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 storagegit + +import ( + "bytes" + "context" + "errors" + "fmt" + "io" + + "github.com/bufbuild/buf/private/pkg/git" + "github.com/bufbuild/buf/private/pkg/normalpath" + "github.com/bufbuild/buf/private/pkg/storage" + "github.com/bufbuild/buf/private/pkg/storage/storageutil" +) + +type bucket struct { + objectReader git.ObjectReader + symlinks bool + root git.Tree +} + +func newBucket( + objectReader git.ObjectReader, + symlinksIfSupported bool, + root git.Tree, +) (storage.ReadBucket, error) { + return &bucket{ + objectReader: objectReader, + symlinks: symlinksIfSupported, + root: root, + }, nil +} + +func (b *bucket) Get(ctx context.Context, path string) (storage.ReadObjectCloser, error) { + node, err := b.root.Descendant(path, b.objectReader) + if err != nil { + if errors.Is(err, git.ErrTreeNodeNotFound) { + return nil, storage.NewErrNotExist(path) + } + return nil, err + } + switch node.Mode() { + case git.ModeFile, git.ModeExe: + data, err := b.objectReader.Blob(node.Hash()) + if err != nil { + return nil, err + } + return &namedReader{ + info: b.newObjectInfo(path), + reader: bytes.NewReader(data), + }, nil + case git.ModeSymlink: + if !b.symlinks { + return nil, storage.NewErrNotExist(path) + } + // Symlinks are stored as blobs that reference the target path as a relative + // path. We can follow this symlink trivially. + data, err := b.objectReader.Blob(node.Hash()) + if err != nil { + return nil, err + } + path, err := normalpath.NormalizeAndValidate( + normalpath.Join( + normalpath.Base(path), + normalpath.Normalize(string(data)), + ), + ) + if err != nil { + return nil, fmt.Errorf("invalid path %q: %w", path, err) + } + return b.Get(ctx, path) + default: + return nil, storage.NewErrNotExist(path) + } +} + +func (b *bucket) Stat(ctx context.Context, path string) (storage.ObjectInfo, error) { + node, err := b.root.Descendant(path, b.objectReader) + if err != nil { + if errors.Is(err, git.ErrTreeNodeNotFound) { + return nil, storage.NewErrNotExist(path) + } + return nil, err + } + switch node.Mode() { + case git.ModeFile, git.ModeExe: + return b.newObjectInfo(path), nil + case git.ModeSymlink: + if !b.symlinks { + return nil, storage.NewErrNotExist(path) + } + return b.newObjectInfo(path), nil + default: + return nil, storage.NewErrNotExist(path) + } +} + +func (b *bucket) Walk(ctx context.Context, prefix string, f func(storage.ObjectInfo) error) error { + walkChecker := storageutil.NewWalkChecker() + return b.walk(b.root, b.objectReader, prefix, func(path string) error { + if err := walkChecker.Check(ctx); err != nil { + return err + } + return f(b.newObjectInfo(path)) + }) +} + +func (b *bucket) walk( + parent git.Tree, + objectReader git.ObjectReader, + prefix string, + walkFn func(string) error, +) error { + prefix = normalpath.Normalize(prefix) + if prefix != "." { + node, err := parent.Descendant(prefix, b.objectReader) + if err != nil { + if errors.Is(err, git.ErrTreeNodeNotFound) { + return storage.NewErrNotExist(prefix) + } + return err + } + if node.Mode() != git.ModeDir { + return errors.New("prefix is not a directory") + } + subTree, err := b.objectReader.Tree(node.Hash()) + if err != nil { + return err + } + parent = subTree + } + return b.walkTree(parent, objectReader, prefix, walkFn) +} + +func (b *bucket) walkTree( + parent git.Tree, + objectReader git.ObjectReader, + prefix string, + walkFn func(string) error, +) error { + for _, node := range parent.Nodes() { + path := normalpath.Join(prefix, node.Name()) + switch node.Mode() { + case git.ModeFile, git.ModeExe: + if err := walkFn(path); err != nil { + return err + } + case git.ModeSymlink: + if b.symlinks { + if err := walkFn(path); err != nil { + return err + } + } + case git.ModeDir: + subTree, err := objectReader.Tree(node.Hash()) + if err != nil { + return err + } + if err := b.walkTree(subTree, objectReader, path, walkFn); err != nil { + return err + } + default: + // ignored + } + } + return nil +} + +func (b *bucket) newObjectInfo(path string) storage.ObjectInfo { + return storageutil.NewObjectInfo( + normalpath.Normalize(path), + normalpath.Unnormalize(path), + ) +} + +type namedReader struct { + info storage.ObjectInfo + reader io.Reader +} + +var _ storage.ReadObjectCloser = (*namedReader)(nil) + +func (br *namedReader) Path() string { + return br.info.Path() +} +func (br *namedReader) ExternalPath() string { + return br.info.ExternalPath() +} + +func (br *namedReader) Read(p []byte) (n int, err error) { + return br.reader.Read(p) +} + +func (br *namedReader) Close() error { + return nil +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/doc.go b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/doc.go new file mode 100644 index 000000000..25f866168 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/doc.go @@ -0,0 +1,16 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 storagegit implements a storage abstraction for Git repositories. +package storagegit diff --git a/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/provider.go b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/provider.go new file mode 100644 index 000000000..cf37697fe --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/provider.go @@ -0,0 +1,58 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 storagegit + +import ( + "github.com/bufbuild/buf/private/pkg/git" + "github.com/bufbuild/buf/private/pkg/storage" +) + +type provider struct { + objectReader git.ObjectReader + symlinks bool +} + +func newProvider(objectReader git.ObjectReader, opts ...ProviderOption) *provider { + p := &provider{ + objectReader: objectReader, + } + for _, opt := range opts { + opt(p) + } + return p +} + +func (p *provider) NewReadBucket(treeHash git.Hash, options ...ReadBucketOption) (storage.ReadBucket, error) { + var opts readBucketOptions + for _, opt := range options { + opt(&opts) + } + tree, err := p.objectReader.Tree(treeHash) + if err != nil { + return nil, err + } + return newBucket( + p.objectReader, + p.symlinks && opts.symlinksIfSupported, + tree, + ) +} + +// doing this as a separate struct so that it's clear this is resolved +// as a combination of the provider options and read write bucket options +// so there's no potential issues in newBucket +type readBucketOptions struct { + symlinksIfSupported bool +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/storagegit.go b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/storagegit.go new file mode 100644 index 000000000..a9bc67cbf --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/storagegit.go @@ -0,0 +1,60 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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 storagegit + +import ( + "github.com/bufbuild/buf/private/pkg/git" + "github.com/bufbuild/buf/private/pkg/storage" +) + +// Provider provides storage buckets for a git repository. +type Provider interface { + // NewReadBucket returns a new ReadBucket that represents + // the state of the working tree at the particular tree. + // + // Typically, callers will want to source the tree from a commit, but + // they can also use a subtree of another tree. + NewReadBucket(hash git.Hash, options ...ReadBucketOption) (storage.ReadBucket, error) +} + +// ProviderOption is an option for a new Provider. +type ProviderOption func(*provider) + +// ProviderWithSymlinks returns a ProviderOption that results in symlink support. +// +// Note that ReadBucketWithSymlinksIfSupported still needs to be passed for a given +// ReadBucket to have symlinks followed. +func ProviderWithSymlinks() ProviderOption { + return func(provider *provider) { + provider.symlinks = true + } +} + +// ReadBucketOption is an option for a new ReadBucket. +type ReadBucketOption func(*readBucketOptions) + +// ReadBucketWithSymlinksIfSupported returns a ReadBucketOption that results +// in symlink support being enabled for this bucket. If the Provider did not have symlink +// support, this is a no-op. +func ReadBucketWithSymlinksIfSupported() ReadBucketOption { + return func(b *readBucketOptions) { + b.symlinksIfSupported = true + } +} + +// NewProvider creates a new Provider for a git repository. +func NewProvider(objectReader git.ObjectReader, options ...ProviderOption) Provider { + return newProvider(objectReader, options...) +} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/usage.gen.go b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/usage.gen.go new file mode 100644 index 000000000..7b7ce36c2 --- /dev/null +++ b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagegit/usage.gen.go @@ -0,0 +1,19 @@ +// Copyright 2020-2023 Buf Technologies, Inc. +// +// 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. + +// Generated. DO NOT EDIT. + +package storagegit + +import _ "github.com/bufbuild/buf/private/usage" diff --git a/vendor/github.com/bufbuild/buf/private/pkg/storage/storagemem/storagemem.go b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagemem/storagemem.go index a9f807b8a..c937fa50a 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/storage/storagemem/storagemem.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/storage/storagemem/storagemem.go @@ -25,42 +25,15 @@ import ( var errDuplicatePath = errors.New("duplicate path") -type options struct { - pathToData map[string][]byte -} - -// Option is provided by NewReadWriteBucketWithOptions options. -type Option interface { - apply(*options) -} - -type pathData map[string][]byte - -func (pd pathData) apply(opts *options) { - opts.pathToData = pd -} - -// WithFiles adds files by path to their content into the bucket. -func WithFiles(pathToData map[string][]byte) Option { - return (pathData)(pathToData) -} - // NewReadWriteBucket returns a new in-memory ReadWriteBucket. -// Deprecated: Use NewReadWriteBucketWithOptions without any options. func NewReadWriteBucket() storage.ReadWriteBucket { return newBucket(nil) } -// NewReadWriteBucketWithOptions returns a new in-memory ReadWriteBucket. -// Errors are returned with invalid options. -func NewReadWriteBucketWithOptions(opts ...Option) (storage.ReadWriteBucket, error) { - opt := options{} - for _, o := range opts { - o.apply(&opt) - } - - pathToImmutableObject := make(map[string]*internal.ImmutableObject, len(opt.pathToData)) - for path, data := range opt.pathToData { +// NewReadBucket returns a new ReadBucket. +func NewReadBucket(pathToData map[string][]byte) (storage.ReadBucket, error) { + pathToImmutableObject := make(map[string]*internal.ImmutableObject, len(pathToData)) + for path, data := range pathToData { path, err := storageutil.ValidatePath(path) if err != nil { return nil, err @@ -73,8 +46,3 @@ func NewReadWriteBucketWithOptions(opts ...Option) (storage.ReadWriteBucket, err } return newBucket(pathToImmutableObject), nil } - -// NewReadBucket returns a new ReadBucket. -func NewReadBucket(pathToData map[string][]byte) (storage.ReadBucket, error) { - return NewReadWriteBucketWithOptions(WithFiles(pathToData)) -} diff --git a/vendor/github.com/bufbuild/buf/private/pkg/storage/storageos/storageos.go b/vendor/github.com/bufbuild/buf/private/pkg/storage/storageos/storageos.go index 2854e6d0b..4798ad9cf 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/storage/storageos/storageos.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/storage/storageos/storageos.go @@ -56,7 +56,7 @@ func ReadWriteBucketWithSymlinksIfSupported() ReadWriteBucketOption { // ProviderWithSymlinks returns a ProviderOption that results in symlink support. // -// Note that ReadWriteBucketWithSymlinksEnabled still needs to be passed for a given +// Note that ReadWriteBucketWithSymlinksIfSupported still needs to be passed for a given // ReadWriteBucket to have symlinks followed. func ProviderWithSymlinks() ProviderOption { return func(provider *provider) { diff --git a/vendor/github.com/bufbuild/buf/private/pkg/thread/thread.go b/vendor/github.com/bufbuild/buf/private/pkg/thread/thread.go index 75c811196..ed781dd98 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/thread/thread.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/thread/thread.go @@ -77,7 +77,6 @@ func Parallelize(ctx context.Context, jobs []func(context.Context) error, option if stop { break } - job := job // We always want context cancellation/deadline expiration to take // precedence over the semaphore unblocking, but select statements choose // among the unblocked non-default cases pseudorandomly. To correctly @@ -87,11 +86,14 @@ func Parallelize(ctx context.Context, jobs []func(context.Context) error, option select { case <-ctx.Done(): stop = true + retErr = multierr.Append(retErr, ctx.Err()) case semaphoreC <- struct{}{}: select { case <-ctx.Done(): stop = true + retErr = multierr.Append(retErr, ctx.Err()) default: + job := job wg.Add(1) go func() { if err := job(ctx); err != nil { diff --git a/vendor/github.com/bufbuild/buf/private/pkg/transport/http/httpserver/httpserver.go b/vendor/github.com/bufbuild/buf/private/pkg/transport/http/httpserver/httpserver.go index 27e610de7..ab5a3094b 100644 --- a/vendor/github.com/bufbuild/buf/private/pkg/transport/http/httpserver/httpserver.go +++ b/vendor/github.com/bufbuild/buf/private/pkg/transport/http/httpserver/httpserver.go @@ -42,6 +42,7 @@ type runner struct { readHeaderTimeout time.Duration tlsConfig *tls.Config walkFunc chi.WalkFunc + disableH2C bool } // RunOption is an option for a new Run. @@ -87,6 +88,13 @@ func RunWithWalkFunc(walkFunc chi.WalkFunc) RunOption { } } +// RunWithoutH2C disables use of H2C (used when RunWithTLSConfig is not called). +func RunWithoutH2C() RunOption { + return func(runner *runner) { + runner.disableH2C = true + } +} + // Run will start a HTTP server listening on the provided listener and // serving the provided handler. This call is blocking and the run // is cancelled when the input context is cancelled, the listener is @@ -117,7 +125,7 @@ func Run( ErrorLog: stdLogger, TLSConfig: s.tlsConfig, } - if s.tlsConfig == nil { + if s.tlsConfig == nil && !s.disableH2C { httpServer.Handler = h2c.NewHandler(handler, &http2.Server{ IdleTimeout: DefaultIdleTimeout, }) diff --git a/vendor/github.com/bufbuild/connect-go/.golangci.yml b/vendor/github.com/bufbuild/connect-go/.golangci.yml index d2735f98a..b8afb03b9 100644 --- a/vendor/github.com/bufbuild/connect-go/.golangci.yml +++ b/vendor/github.com/bufbuild/connect-go/.golangci.yml @@ -98,3 +98,20 @@ issues: # In examples, it's okay to use http.ListenAndServe. - linters: [gosec] path: error_not_modified_example_test.go + # There are many instances where we want to keep unused parameters + # as a matter of style or convention, for example when a context.Context + # is the first parameter, we choose to just globally ignore this. + - linters: [revive] + text: "^unused-parameter: " + # We want to return explicit nils in protocol_grpc.go + - linters: [revive] + text: "^if-return: " + path: protocol_grpc.go + # We want to return explicit nils in protocol_connect.go + - linters: [revive] + text: "^if-return: " + path: protocol_connect.go + # We want to return explicit nils in error_writer.go + - linters: [revive] + text: "^if-return: " + path: error_writer.go diff --git a/vendor/github.com/bufbuild/connect-go/Makefile b/vendor/github.com/bufbuild/connect-go/Makefile index a872b47aa..e26694a60 100644 --- a/vendor/github.com/bufbuild/connect-go/Makefile +++ b/vendor/github.com/bufbuild/connect-go/Makefile @@ -54,7 +54,7 @@ lintfix: $(BIN)/golangci-lint $(BIN)/buf ## Automatically fix some lint errors .PHONY: generate generate: $(BIN)/buf $(BIN)/protoc-gen-go $(BIN)/protoc-gen-connect-go $(BIN)/license-header ## Regenerate code and licenses rm -rf internal/gen - PATH=$(abspath $(BIN)) $(BIN)/buf generate + PATH="$(abspath $(BIN))" $(BIN)/buf generate $(BIN)/license-header \ --license-type apache \ --copyright-holder "Buf Technologies, Inc." \ @@ -76,19 +76,19 @@ $(BIN)/protoc-gen-connect-go: $(BIN)/buf: Makefile @mkdir -p $(@D) - GOBIN=$(abspath $(@D)) $(GO) install github.com/bufbuild/buf/cmd/buf@v1.13.1 + GOBIN="$(abspath $(@D))" $(GO) install github.com/bufbuild/buf/cmd/buf@v1.18.0 $(BIN)/license-header: Makefile @mkdir -p $(@D) - GOBIN=$(abspath $(@D)) $(GO) install \ - github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@90fa81df0e9ef86ed505956be1ab1e8ccd49aa52 + GOBIN="$(abspath $(@D))" $(GO) install \ + github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v1.18.0 $(BIN)/golangci-lint: Makefile @mkdir -p $(@D) - GOBIN=$(abspath $(@D)) $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0 + GOBIN="$(abspath $(@D))" $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 $(BIN)/protoc-gen-go: Makefile go.mod @mkdir -p $(@D) @# The version of protoc-gen-go is determined by the version in go.mod - GOBIN=$(abspath $(@D)) $(GO) install google.golang.org/protobuf/cmd/protoc-gen-go + GOBIN="$(abspath $(@D))" $(GO) install google.golang.org/protobuf/cmd/protoc-gen-go diff --git a/vendor/github.com/bufbuild/connect-go/client.go b/vendor/github.com/bufbuild/connect-go/client.go index 08a1c066b..c1179e44a 100644 --- a/vendor/github.com/bufbuild/connect-go/client.go +++ b/vendor/github.com/bufbuild/connect-go/client.go @@ -77,6 +77,9 @@ func NewClient[Req, Res any](httpClient HTTPClient, url string, options ...Clien unarySpec := config.newSpec(StreamTypeUnary) unaryFunc := UnaryFunc(func(ctx context.Context, request AnyRequest) (AnyResponse, error) { conn := client.protocolClient.NewConn(ctx, unarySpec, request.Header()) + conn.onRequestSend(func(r *http.Request) { + request.setRequestMethod(r.Method) + }) // Send always returns an io.EOF unless the error is from the client-side. // We want the user to continue to call Receive in those cases to get the // full error from the server-side. @@ -132,7 +135,7 @@ func (c *Client[Req, Res]) CallClientStream(ctx context.Context) *ClientStreamFo if c.err != nil { return &ClientStreamForClient[Req, Res]{err: c.err} } - return &ClientStreamForClient[Req, Res]{conn: c.newConn(ctx, StreamTypeClient)} + return &ClientStreamForClient[Req, Res]{conn: c.newConn(ctx, StreamTypeClient, nil)} } // CallServerStream calls a server streaming procedure. @@ -140,7 +143,9 @@ func (c *Client[Req, Res]) CallServerStream(ctx context.Context, request *Reques if c.err != nil { return nil, c.err } - conn := c.newConn(ctx, StreamTypeServer) + conn := c.newConn(ctx, StreamTypeServer, func(r *http.Request) { + request.method = r.Method + }) request.spec = conn.Spec() request.peer = conn.Peer() mergeHeaders(conn.RequestHeader(), request.header) @@ -163,14 +168,16 @@ func (c *Client[Req, Res]) CallBidiStream(ctx context.Context) *BidiStreamForCli if c.err != nil { return &BidiStreamForClient[Req, Res]{err: c.err} } - return &BidiStreamForClient[Req, Res]{conn: c.newConn(ctx, StreamTypeBidi)} + return &BidiStreamForClient[Req, Res]{conn: c.newConn(ctx, StreamTypeBidi, nil)} } -func (c *Client[Req, Res]) newConn(ctx context.Context, streamType StreamType) StreamingClientConn { +func (c *Client[Req, Res]) newConn(ctx context.Context, streamType StreamType, onRequestSend func(r *http.Request)) StreamingClientConn { newConn := func(ctx context.Context, spec Spec) StreamingClientConn { header := make(http.Header, 8) // arbitrary power of two, prevent immediate resizing c.protocolClient.WriteRequestHeader(streamType, header) - return c.protocolClient.NewConn(ctx, spec, header) + conn := c.protocolClient.NewConn(ctx, spec, header) + conn.onRequestSend(onRequestSend) + return conn } if interceptor := c.config.Interceptor; interceptor != nil { newConn = interceptor.WrapStreamingClient(newConn) diff --git a/vendor/github.com/bufbuild/connect-go/connect.go b/vendor/github.com/bufbuild/connect-go/connect.go index b1bb64f76..adc5e5814 100644 --- a/vendor/github.com/bufbuild/connect-go/connect.go +++ b/vendor/github.com/bufbuild/connect-go/connect.go @@ -26,13 +26,14 @@ package connect import ( "errors" + "fmt" "io" "net/http" "net/url" ) // Version is the semantic version of the connect module. -const Version = "1.7.0" +const Version = "1.8.0" // These constants are used in compile-time handshakes with connect's generated // code. @@ -53,6 +54,20 @@ const ( StreamTypeBidi = StreamTypeClient | StreamTypeServer ) +func (s StreamType) String() string { + switch s { + case StreamTypeUnary: + return "unary" + case StreamTypeClient: + return "client" + case StreamTypeServer: + return "server" + case StreamTypeBidi: + return "bidi" + } + return fmt.Sprintf("stream_%d", s) +} + // StreamingHandlerConn is the server's view of a bidirectional message // exchange. Interceptors for streaming RPCs may wrap StreamingHandlerConns. // @@ -135,6 +150,7 @@ type Request[T any] struct { spec Spec peer Peer header http.Header + method string } // NewRequest wraps a generated request message. @@ -172,9 +188,28 @@ func (r *Request[_]) Header() http.Header { return r.header } +// HTTPMethod returns the HTTP method for this request. This is nearly always +// POST, but side-effect-free unary RPCs could be made via a GET. +// +// On a newly created request, via NewRequest, this will return the empty +// string until the actual request is actually sent and the HTTP method +// determined. This means that client interceptor functions will see the +// empty string until *after* they delegate to the handler they wrapped. It +// is even possible for this to return the empty string after such delegation, +// if the request was never actually sent to the server (and thus no +// determination ever made about the HTTP method). +func (r *Request[_]) HTTPMethod() string { + return r.method +} + // internalOnly implements AnyRequest. func (r *Request[_]) internalOnly() {} +// setRequestMethod sets the request method to the given value. +func (r *Request[_]) setRequestMethod(method string) { + r.method = method +} + // AnyRequest is the common method set of every [Request], regardless of type // parameter. It's used in unary interceptors. // @@ -190,8 +225,10 @@ type AnyRequest interface { Spec() Spec Peer() Peer Header() http.Header + HTTPMethod() string internalOnly() + setRequestMethod(string) } // Response is a wrapper around a generated response message. It provides @@ -307,7 +344,7 @@ func newPeerFromURL(url *url.URL, protocol string) Peer { } } -// handlerConnCloser extends HandlerConn with a method for handlers to +// handlerConnCloser extends StreamingHandlerConn with a method for handlers to // terminate the message exchange (and optionally send an error to the client). type handlerConnCloser interface { StreamingHandlerConn diff --git a/vendor/github.com/bufbuild/connect-go/duplex_http_call.go b/vendor/github.com/bufbuild/connect-go/duplex_http_call.go index 77a09a4d2..03d4c912d 100644 --- a/vendor/github.com/bufbuild/connect-go/duplex_http_call.go +++ b/vendor/github.com/bufbuild/connect-go/duplex_http_call.go @@ -33,6 +33,7 @@ type duplexHTTPCall struct { ctx context.Context httpClient HTTPClient streamType StreamType + onRequestSend func(*http.Request) validateResponse func(*http.Response) *Error // We'll use a pipe as the request body. We hand the read side of the pipe to @@ -179,6 +180,7 @@ func (d *duplexHTTPCall) CloseRead() error { return nil } if err := discard(d.response.Body); err != nil { + _ = d.response.Body.Close() return wrapIfRSTError(err) } return wrapIfRSTError(d.response.Body.Close()) @@ -255,6 +257,9 @@ func (d *duplexHTTPCall) makeRequest() { // on d.responseReady, so we can't race with them. defer close(d.responseReady) + if d.onRequestSend != nil { + d.onRequestSend(d.request) + } // Once we send a message to the server, they send a message back and // establish the receive side of the stream. response, err := d.httpClient.Do(d.request) //nolint:bodyclose diff --git a/vendor/github.com/bufbuild/connect-go/error.go b/vendor/github.com/bufbuild/connect-go/error.go index aac269094..16de28da5 100644 --- a/vendor/github.com/bufbuild/connect-go/error.go +++ b/vendor/github.com/bufbuild/connect-go/error.go @@ -295,7 +295,7 @@ func wrapIfContextError(err error) error { return err } -// wrapIfLikelyWithGRPCNotUsedError adds a wrapping error that has a message +// wrapIfLikelyH2CNotConfiguredError adds a wrapping error that has a message // telling the caller that they likely need to use h2c but are using a raw http.Client{}. // // This happens when running a gRPC-only server. @@ -400,3 +400,12 @@ func wrapIfRSTError(err error) error { return err } } + +func asMaxBytesError(err error, tmpl string, args ...any) *Error { + var maxBytesErr *http.MaxBytesError + if ok := errors.As(err, &maxBytesErr); !ok { + return nil + } + prefix := fmt.Sprintf(tmpl, args...) + return errorf(CodeResourceExhausted, "%s: exceeded %d byte http.MaxBytesReader limit", prefix, maxBytesErr.Limit) +} diff --git a/vendor/github.com/bufbuild/connect-go/handler.go b/vendor/github.com/bufbuild/connect-go/handler.go index 89ceea13e..af3d215b7 100644 --- a/vendor/github.com/bufbuild/connect-go/handler.go +++ b/vendor/github.com/bufbuild/connect-go/handler.go @@ -67,11 +67,16 @@ func NewUnaryHandler[Req, Res any]( if err := conn.Receive(&msg); err != nil { return err } + method := http.MethodPost + if hasRequestMethod, ok := conn.(interface{ getHTTPMethod() string }); ok { + method = hasRequestMethod.getHTTPMethod() + } request := &Request[Req]{ Msg: &msg, spec: conn.Spec(), peer: conn.Peer(), header: conn.RequestHeader(), + method: method, } response, err := untyped(ctx, request) if err != nil { @@ -141,6 +146,7 @@ func NewServerStreamHandler[Req, Res any]( spec: conn.Spec(), peer: conn.Peer(), header: conn.RequestHeader(), + method: http.MethodPost, }, &ServerStream[Res]{conn: conn}, ) diff --git a/vendor/github.com/bufbuild/connect-go/header.go b/vendor/github.com/bufbuild/connect-go/header.go index ea3a47072..f827aba29 100644 --- a/vendor/github.com/bufbuild/connect-go/header.go +++ b/vendor/github.com/bufbuild/connect-go/header.go @@ -51,7 +51,7 @@ func mergeHeaders(into, from http.Header) { } } -// getCanonicalHeader is a shortcut for Header.Get() which +// getHeaderCanonical is a shortcut for Header.Get() which // bypasses the CanonicalMIMEHeaderKey operation when we // know the key is already in canonical form. func getHeaderCanonical(h http.Header, key string) string { diff --git a/vendor/github.com/bufbuild/connect-go/maxbytes.go b/vendor/github.com/bufbuild/connect-go/maxbytes.go deleted file mode 100644 index 8e9505e4e..000000000 --- a/vendor/github.com/bufbuild/connect-go/maxbytes.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021-2023 Buf Technologies, Inc. -// -// 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. - -//go:build go1.19 - -package connect - -import ( - "errors" - "fmt" - "net/http" -) - -func asMaxBytesError(err error, tmpl string, args ...any) *Error { - var maxBytesErr *http.MaxBytesError - if ok := errors.As(err, &maxBytesErr); !ok { - return nil - } - prefix := fmt.Sprintf(tmpl, args...) - return errorf(CodeResourceExhausted, "%s: exceeded %d byte http.MaxBytesReader limit", prefix, maxBytesErr.Limit) -} diff --git a/vendor/github.com/bufbuild/connect-go/protocol.go b/vendor/github.com/bufbuild/connect-go/protocol.go index 77e899ed8..b5954290f 100644 --- a/vendor/github.com/bufbuild/connect-go/protocol.go +++ b/vendor/github.com/bufbuild/connect-go/protocol.go @@ -145,7 +145,15 @@ type protocolClient interface { // been populated by WriteRequestHeader. When constructing a stream for a // unary call, implementations may assume that the Sender's Send and Close // methods return before the Receiver's Receive or Close methods are called. - NewConn(context.Context, Spec, http.Header) StreamingClientConn + NewConn(context.Context, Spec, http.Header) streamingClientConn +} + +// streamingClientConn extends StreamingClientConn with a method for registering +// a hook when the HTTP request is actually sent. +type streamingClientConn interface { + StreamingClientConn + + onRequestSend(fn func(*http.Request)) } // errorTranslatingHandlerConnCloser wraps a handlerConnCloser to ensure that @@ -173,30 +181,41 @@ func (hc *errorTranslatingHandlerConnCloser) Close(err error) error { return hc.fromWire(closeErr) } +func (hc *errorTranslatingHandlerConnCloser) getHTTPMethod() string { + if methoder, ok := hc.handlerConnCloser.(interface{ getHTTPMethod() string }); ok { + return methoder.getHTTPMethod() + } + return http.MethodPost +} + // errorTranslatingClientConn wraps a StreamingClientConn to make sure that we always // return coded errors from clients. // // It's used in protocol implementations. type errorTranslatingClientConn struct { - StreamingClientConn + streamingClientConn fromWire func(error) error } func (cc *errorTranslatingClientConn) Send(msg any) error { - return cc.fromWire(cc.StreamingClientConn.Send(msg)) + return cc.fromWire(cc.streamingClientConn.Send(msg)) } func (cc *errorTranslatingClientConn) Receive(msg any) error { - return cc.fromWire(cc.StreamingClientConn.Receive(msg)) + return cc.fromWire(cc.streamingClientConn.Receive(msg)) } func (cc *errorTranslatingClientConn) CloseRequest() error { - return cc.fromWire(cc.StreamingClientConn.CloseRequest()) + return cc.fromWire(cc.streamingClientConn.CloseRequest()) } func (cc *errorTranslatingClientConn) CloseResponse() error { - return cc.fromWire(cc.StreamingClientConn.CloseResponse()) + return cc.fromWire(cc.streamingClientConn.CloseResponse()) +} + +func (cc *errorTranslatingClientConn) onRequestSend(fn func(*http.Request)) { + cc.streamingClientConn.onRequestSend(fn) } // wrapHandlerConnWithCodedErrors ensures that we (1) automatically code @@ -212,9 +231,9 @@ func wrapHandlerConnWithCodedErrors(conn handlerConnCloser) handlerConnCloser { // wrapClientConnWithCodedErrors ensures that we always return *Errors from // public APIs. -func wrapClientConnWithCodedErrors(conn StreamingClientConn) StreamingClientConn { +func wrapClientConnWithCodedErrors(conn streamingClientConn) streamingClientConn { return &errorTranslatingClientConn{ - StreamingClientConn: conn, + streamingClientConn: conn, fromWire: wrapIfUncoded, } } diff --git a/vendor/github.com/bufbuild/connect-go/protocol_connect.go b/vendor/github.com/bufbuild/connect-go/protocol_connect.go index 0232b1cd1..8e6294c74 100644 --- a/vendor/github.com/bufbuild/connect-go/protocol_connect.go +++ b/vendor/github.com/bufbuild/connect-go/protocol_connect.go @@ -356,7 +356,7 @@ func (c *connectClient) NewConn( ctx context.Context, spec Spec, header http.Header, -) StreamingClientConn { +) streamingClientConn { if deadline, ok := ctx.Deadline(); ok { millis := int64(time.Until(deadline) / time.Millisecond) if millis > 0 { @@ -367,7 +367,7 @@ func (c *connectClient) NewConn( } } duplexCall := newDuplexHTTPCall(ctx, c.HTTPClient, c.URL, spec, header) - var conn StreamingClientConn + var conn streamingClientConn if spec.StreamType == StreamTypeUnary { unaryConn := &connectUnaryClientConn{ spec: spec, @@ -499,6 +499,10 @@ func (cc *connectUnaryClientConn) CloseResponse() error { return cc.duplexCall.CloseRead() } +func (cc *connectUnaryClientConn) onRequestSend(fn func(*http.Request)) { + cc.duplexCall.onRequestSend = fn +} + func (cc *connectUnaryClientConn) validateResponse(response *http.Response) *Error { for k, v := range response.Header { if !strings.HasPrefix(k, connectUnaryTrailerPrefix) { @@ -624,6 +628,10 @@ func (cc *connectStreamingClientConn) CloseResponse() error { return cc.duplexCall.CloseRead() } +func (cc *connectStreamingClientConn) onRequestSend(fn func(*http.Request)) { + cc.duplexCall.onRequestSend = fn +} + func (cc *connectStreamingClientConn) validateResponse(response *http.Response) *Error { if response.StatusCode != http.StatusOK { return errorf(connectHTTPToCode(response.StatusCode), "HTTP status %v", response.Status) @@ -719,6 +727,10 @@ func (hc *connectUnaryHandlerConn) Close(err error) error { return hc.request.Body.Close() } +func (hc *connectUnaryHandlerConn) getHTTPMethod() string { + return hc.request.Method +} + func (hc *connectUnaryHandlerConn) writeResponseHeader(err error) { header := hc.responseWriter.Header() if hc.request.Method == http.MethodGet { @@ -928,7 +940,7 @@ type connectUnaryRequestMarshaler struct { func (m *connectUnaryRequestMarshaler) Marshal(message any) *Error { if m.enableGet { if m.stableCodec == nil && !m.getUseFallback { - return errorf(CodeInternal, "codec %s doesn't support stable marshal; cam't use get", m.codec.Name()) + return errorf(CodeInternal, "codec %s doesn't support stable marshal; can't use get", m.codec.Name()) } if m.stableCodec != nil { return m.marshalWithGet(message) diff --git a/vendor/github.com/bufbuild/connect-go/protocol_grpc.go b/vendor/github.com/bufbuild/connect-go/protocol_grpc.go index df188702d..7113a6be7 100644 --- a/vendor/github.com/bufbuild/connect-go/protocol_grpc.go +++ b/vendor/github.com/bufbuild/connect-go/protocol_grpc.go @@ -274,7 +274,7 @@ func (g *grpcClient) NewConn( ctx context.Context, spec Spec, header http.Header, -) StreamingClientConn { +) streamingClientConn { if deadline, ok := ctx.Deadline(); ok { if encodedDeadline, err := grpcEncodeTimeout(time.Until(deadline)); err == nil { // Tests verify that the error in encodeTimeout is unreachable, so we @@ -424,6 +424,10 @@ func (cc *grpcClientConn) CloseResponse() error { return cc.duplexCall.CloseRead() } +func (cc *grpcClientConn) onRequestSend(fn func(*http.Request)) { + cc.duplexCall.onRequestSend = fn +} + func (cc *grpcClientConn) validateResponse(response *http.Response) *Error { if err := grpcValidateResponse( response, diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/.gitignore b/vendor/github.com/bufbuild/connect-opentelemetry-go/.gitignore new file mode 100644 index 000000000..987d6a1c8 --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/.gitignore @@ -0,0 +1,4 @@ +/.tmp/ +*.pprof +*.svg +cover.out diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/.golangci.yml b/vendor/github.com/bufbuild/connect-opentelemetry-go/.golangci.yml new file mode 100644 index 000000000..6fab6ccd7 --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/.golangci.yml @@ -0,0 +1,67 @@ +run: + skip-dirs-use-default: false +linters-settings: + dupl: + threshold: 200 + errcheck: + check-type-assertions: true + exhaustruct: + include: + # No zero values for param structs. + - 'github\.com/bufbuild/connect-opentelemetry-go\..*[pP]arams' + forbidigo: + forbid: + - '^fmt\.Print' + - '^log\.' + - '^print$' + - '^println$' + - '^panic$' + godox: + # TODO, OPT, etc. comments are fine to commit. Use FIXME comments for + # temporary hacks, and use godox to prevent committing them. + keywords: [FIXME] + varnamelen: + ignore-decls: + - T any + - i int + - wg sync.WaitGroup +linters: + enable-all: true + disable: + - cyclop # covered by gocyclo + - deadcode # abandoned + - exhaustivestruct # replaced by exhaustruct + - funlen # rely on code review to limit function length + - gocognit # dubious "cognitive overhead" quantification + - gofumpt # prefer standard gofmt + - goimports # rely on gci instead + - golint # deprecated by Go team + - gomnd # some unnamed constants are okay + - ifshort # deprecated by author + - interfacer # deprecated by author + - ireturn # "accept interfaces, return structs" isn't ironclad + - lll # don't want hard limits for line length + - maintidx # covered by gocyclo + - maligned # readability trumps efficient struct packing + - nlreturn # generous whitespace violates house style + - nosnakecase # deprecated in https://github.com/golangci/golangci-lint/pull/3065 + - scopelint # deprecated by author + - structcheck # abandoned + - testpackage # internal tests are fine + - varcheck # abandoned + - wrapcheck # don't _always_ need to wrap errors + - wsl # generous whitespace violates house style +issues: + exclude: + # Don't ban use of fmt.Errorf to create new errors, but the remaining + # checks from err113 are useful. + - "err113: do not define dynamic errors.*" + + exclude-rules: + # If-else is clearer than switch here. + - linters: [gocritic] + path: trace.go + # interceptor_test tests a lot of data structure equality so naturally there are + # a lot of duplications + - path: interceptor_test.go + linters: [dupl] diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/LICENSE b/vendor/github.com/bufbuild/connect-opentelemetry-go/LICENSE new file mode 100644 index 000000000..55f1dcc15 --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/LICENSE @@ -0,0 +1,201 @@ + 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 2022-2023 Buf Technologies, Inc. + + 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/bufbuild/connect-opentelemetry-go/Makefile b/vendor/github.com/bufbuild/connect-opentelemetry-go/Makefile new file mode 100644 index 000000000..9b0e6fb4b --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/Makefile @@ -0,0 +1,98 @@ +# See https://tech.davis-hansson.com/p/make/ +SHELL := bash +.DELETE_ON_ERROR: +.SHELLFLAGS := -eu -o pipefail -c +.DEFAULT_GOAL := all +MAKEFLAGS += --warn-undefined-variables +MAKEFLAGS += --no-builtin-rules +MAKEFLAGS += --no-print-directory +BIN := $(abspath .tmp/bin) +COPYRIGHT_YEARS := 2022-2023 +LICENSE_IGNORE := -e /gen/ +# Set to use a different compiler. For example, `GO=go1.18rc1 make test`. +GO ?= go + +.PHONY: help +help: ## Describe useful make targets + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-30s %s\n", $$1, $$2}' + +.PHONY: all +all: ## Build, test, and lint (default) + $(MAKE) test + $(MAKE) lint + +.PHONY: clean +clean: ## Delete intermediate build artifacts + @# -X only removes untracked files, -d recurses into directories, -f actually removes files/dirs + git clean -Xdf + +.PHONY: test +test: build ## Run unit tests + $(GO) test -vet=off -race -cover ./... + +.PHONY: build +build: generate ## Build all packages + $(GO) build ./... + +.PHONY: lint +lint: $(BIN)/golangci-lint $(BIN)/buf ## Lint Go and protobuf + test -z "$$($(BIN)/buf format -d . | tee /dev/stderr)" + $(GO) vet ./... + $(BIN)/golangci-lint run + $(BIN)/buf lint + +.PHONY: lintfix +lintfix: $(BIN)/golangci-lint $(BIN)/buf ## Automatically fix some lint errors + $(BIN)/golangci-lint run --fix + $(BIN)/buf format -w . + +.PHONY: generate +generate: $(BIN)/buf $(BIN)/protoc-gen-go $(BIN)/protoc-gen-connect-go $(BIN)/license-header ## Regenerate code and licenses + rm -rf internal/gen + PATH=$(BIN) $(BIN)/buf generate + @# We want to operate on a list of modified and new files, excluding + @# deleted and ignored files. git-ls-files can't do this alone. comm -23 takes + @# two files and prints the union, dropping lines common to both (-3) and + @# those only in the second file (-2). We make one git-ls-files call for + @# the modified, cached, and new (--others) files, and a second for the + @# deleted files. + comm -23 \ + <(git ls-files --cached --modified --others --no-empty-directory --exclude-standard | sort -u | grep -v $(LICENSE_IGNORE) ) \ + <(git ls-files --deleted | sort -u) | \ + xargs $(BIN)/license-header \ + --license-type apache \ + --copyright-holder "Buf Technologies, Inc." \ + --year-range "$(COPYRIGHT_YEARS)" + +.PHONY: upgrade +upgrade: ## Upgrade dependencies + go get -u -t ./... && go mod tidy -v + +.PHONY: checkgenerate +checkgenerate: + @# Used in CI to verify that `make generate` doesn't produce a diff. + test -z "$$(git status --porcelain | tee /dev/stderr)" + +$(BIN)/protoc-gen-connect-go: go.mod + @mkdir -p $(@D) + @# The version of protoc-gen-connect-go is determined by the version in go.mod + GOBIN=$(abspath $(@D)) $(GO) install github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go + +$(BIN)/buf: Makefile + @mkdir -p $(@D) + GOBIN=$(abspath $(@D)) $(GO) install github.com/bufbuild/buf/cmd/buf@v1.9.0 + +$(BIN)/license-header: Makefile + @mkdir -p $(@D) + GOBIN=$(abspath $(@D)) $(GO) install \ + github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v1.9.0 + +$(BIN)/golangci-lint: Makefile + @mkdir -p $(@D) + GOBIN=$(abspath $(@D)) $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.0 + +$(BIN)/protoc-gen-go: Makefile + @mkdir -p $(@D) + @# The version of protoc-gen-go is determined by the version in go.mod + GOBIN=$(abspath $(@D)) $(GO) install google.golang.org/protobuf/cmd/protoc-gen-go + diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/README.md b/vendor/github.com/bufbuild/connect-opentelemetry-go/README.md new file mode 100644 index 000000000..dc830f7de --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/README.md @@ -0,0 +1,139 @@ +connect-opentelemetry-go +======================== + +[![Build](https://github.com/bufbuild/connect-opentelemetry-go/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/bufbuild/connect-opentelemetry-go/actions/workflows/ci.yaml) +[![Report Card](https://goreportcard.com/badge/github.com/bufbuild/connect-opentelemetry-go)](https://goreportcard.com/report/github.com/bufbuild/connect-opentelemetry-go) +[![GoDoc](https://pkg.go.dev/badge/github.com/bufbuild/connect-opentelemetry-go.svg)][godoc] + +`connect-opentelemetry-go` adds support for [OpenTelemetry][opentelemetry.io] +tracing and metrics collection to [connect-go] servers and clients. + +For more on Connect, OpenTelemetry, and `otelconnect`, see the [Connect +announcement blog post][blog] and the observability documentation on +[connect.build](https://connect.build/docs/go/observability/). + +## An example + +```go +package main + +import ( + "context" + "fmt" + "log" + "net/http" + + "github.com/bufbuild/connect-go" + otelconnect "github.com/bufbuild/connect-opentelemetry-go" + // Generated from your protobuf schema by protoc-gen-go and + // protoc-gen-connect-go. + pingv1 "github.com/bufbuild/connect-opentelemetry-go/internal/gen/observability/ping/v1" + "github.com/bufbuild/connect-opentelemetry-go/internal/gen/observability/ping/v1/pingv1connect" +) + +func main() { + mux := http.NewServeMux() + + // otelconnect.NewInterceptor provides an interceptor that adds tracing and + // metrics to both clients and handlers. By default, it uses OpenTelemetry's + // global TracerProvider and MeterProvider, which you can configure by + // following the OpenTelemetry documentation. If you'd prefer to avoid + // globals, use otelconnect.WithTracerProvider and + // otelconnect.WithMeterProvider. + mux.Handle(pingv1connect.NewPingServiceHandler( + &pingv1connect.UnimplementedPingServiceHandler{}, + connect.WithInterceptors(otelconnect.NewInterceptor()), + )) + + http.ListenAndServe("localhost:8080", mux) +} + +func makeRequest() { + client := pingv1connect.NewPingServiceClient( + http.DefaultClient, + "http://localhost:8080", + connect.WithInterceptors(otelconnect.NewInterceptor()), + ) + resp, err := client.Ping( + context.Background(), + connect.NewRequest(&pingv1.PingRequest{}), + ) + if err != nil { + log.Fatal(err) + } + fmt.Println(resp) +} + +``` + +## Configuration for internal services + +By default, instrumented servers are conservative and behave as though they're +internet-facing. They don't trust any tracing information sent by the client, +and will create new trace spans for each request. The new spans are linked to +the remote span for reference (using OpenTelemetry's +[`trace.Link`](https://pkg.go.dev/go.opentelemetry.io/otel/trace#Link)), but +tracing UIs will display the request as a new top-level transaction. + +If your server is deployed as an internal service, configure `otelconnect` to +trust the client's tracing information using +[`otelconnect.WithTrustRemote`][WithTrustRemote]. With this option, servers +will create child spans for each request. + +## Reducing metrics and tracing cardinality + +By default, the [OpenTelemetry RPC conventions][otel-rpc-conventions] produce +high-cardinality server-side metric and tracing output. In particular, servers +tag all metrics and trace data with the server's IP address and the remote port +number. To drop these attributes, use +[`otelconnect.WithoutServerPeerAttributes`][WithoutServerPeerAttributes]. For +more customizable attribute filtering, use +[otelconnect.WithFilter][WithFilter]. + +## Status + +| | Unary | Streaming Client | Streaming Handler | +|---------|:-----:|:----------------:|:-----------------:| +| Metrics | ✅ | ✅ | ✅ | +| Tracing | ✅ | ✅ | ✅ | + +## Ecosystem + +* [connect-go]: Service handlers and clients for GoLang +* [connect-swift]: Swift clients for idiomatic gRPC & Connect RPC +* [connect-kotlin]: Kotlin clients for idiomatic gRPC & Connect RPC +* [connect-web]: TypeScript clients for web browsers +* [Buf Studio]: web UI for ad-hoc RPCs +* [connect-crosstest]: gRPC and gRPC-Web interoperability tests + +## Support and Versioning + +`connect-opentelemetry-go` supports: + +* The [two most recent major releases][go-support-policy] of Go. +* v1 of the `go.opentelemetry.io/otel` tracing and metrics SDK. + +## Legal + +Offered under the [Apache 2 license][license]. + +[Buf Studio]: https://studio.buf.build/ +[Getting Started]: https://connect.build/docs/go/getting-started +[WithFilter]: https://pkg.go.dev/github.com/bufbuild/connect-opentelemetry-go#WithFilter +[WithTrustRemote]: https://pkg.go.dev/github.com/bufbuild/connect-opentelemetry-go#WithTrustRemote +[WithoutServerPeerAttributes]: https://pkg.go.dev/github.com/bufbuild/connect-opentelemetry-go#WithoutServerPeerAttributes +[blog]: https://buf.build/blog/connect-a-better-grpc +[connect-crosstest]: https://github.com/bufbuild/connect-crosstest +[connect-go]: https://github.com/bufbuild/connect-go +[connect-kotlin]: https://github.com/bufbuild/connect-kotlin +[connect-swift]: https://github.com/bufbuild/connect-swift +[connect-web]: https://www.npmjs.com/package/@bufbuild/connect-web +[demo]: https://github.com/bufbuild/connect-demo +[docs]: https://connect.build +[go-support-policy]: https://golang.org/doc/devel/release#policy +[godoc]: https://pkg.go.dev/github.com/bufbuild/connect-opentelemetry-go +[license]: https://github.com/bufbuild/connect-opentelemetry-go/blob/main/LICENSE +[opentelemetry.io]: https://opentelemetry.io/ +[otel-go-quickstart]: https://opentelemetry.io/docs/instrumentation/go/getting-started/ +[otel-go]: https://github.com/open-telemetry/opentelemetry-go +[otel-rpc-conventions]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/attributes.go b/vendor/github.com/bufbuild/connect-opentelemetry-go/attributes.go new file mode 100644 index 000000000..db3cfe3ee --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/attributes.go @@ -0,0 +1,137 @@ +// Copyright 2022-2023 Buf Technologies, Inc. +// +// 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 otelconnect + +import ( + "fmt" + "net" + "net/http" + "strconv" + "strings" + + "github.com/bufbuild/connect-go" + "go.opentelemetry.io/otel/attribute" + semconv "go.opentelemetry.io/otel/semconv/v1.12.0" +) + +// AttributeFilter is used to filter attributes out based on the [Request] and [attribute.KeyValue]. +// If the filter returns true the attribute will be kept else it will be removed. +// AttributeFilter must be safe to call concurrently. +type AttributeFilter func(*Request, attribute.KeyValue) bool + +func (filter AttributeFilter) filter(request *Request, values ...attribute.KeyValue) []attribute.KeyValue { + if filter == nil { + return values + } + // Assign a new slice of zero length with the same underlying + // array as the values slice. This avoids unnecessary memory allocations. + filteredValues := values[:0] + for _, attr := range values { + if filter(request, attr) { + filteredValues = append(filteredValues, attr) + } + } + for i := len(filteredValues); i < len(values); i++ { + values[i] = attribute.KeyValue{} + } + return filteredValues +} + +func procedureAttributes(procedure string) []attribute.KeyValue { + parts := strings.SplitN(procedure, "/", 2) + var attrs []attribute.KeyValue + switch len(parts) { + case 0: + return attrs // invalid + case 1: + // fall back to treating the whole string as the method + if method := parts[0]; method != "" { + attrs = append(attrs, semconv.RPCMethodKey.String(method)) + } + default: + if svc := parts[0]; svc != "" { + attrs = append(attrs, semconv.RPCServiceKey.String(svc)) + } + if method := parts[1]; method != "" { + attrs = append(attrs, semconv.RPCMethodKey.String(method)) + } + } + return attrs +} + +func requestAttributes(req *Request) []attribute.KeyValue { + var attrs []attribute.KeyValue + if addr := req.Peer.Addr; addr != "" { + attrs = append(attrs, addressAttributes(addr)...) + } + name := strings.TrimLeft(req.Spec.Procedure, "/") + protocol := protocolToSemConv(req.Peer.Protocol) + attrs = append(attrs, semconv.RPCSystemKey.String(protocol)) + attrs = append(attrs, procedureAttributes(name)...) + return attrs +} + +func addressAttributes(address string) []attribute.KeyValue { + if host, port, err := net.SplitHostPort(address); err == nil { + portInt, err := strconv.Atoi(port) + if err == nil { + return []attribute.KeyValue{ + semconv.NetPeerNameKey.String(host), + semconv.NetPeerPortKey.Int(portInt), + } + } + } + return []attribute.KeyValue{semconv.NetPeerNameKey.String(address)} +} + +func statusCodeAttribute(protocol string, serverErr error) (attribute.KeyValue, bool) { + // Following the respective specifications, use integers and "status_code" for + // gRPC codes in contrast to strings and "error_code" for Connect codes. + switch protocol { + case grpcProtocol, grpcwebProtocol: + codeKey := attribute.Key("rpc." + protocol + ".status_code") + if serverErr != nil { + return codeKey.Int64(int64(connect.CodeOf(serverErr))), true + } + return codeKey.Int64(0), true // gRPC uses 0 for success + case connectProtocol: + codeKey := attribute.Key("rpc." + protocol + ".error_code") + if serverErr != nil { + return codeKey.String(connect.CodeOf(serverErr).String()), true + } + } + return attribute.KeyValue{}, false +} + +func headerAttributes(protocol, eventType string, metadata http.Header, allowedKeys []string) []attribute.KeyValue { + attributes := make([]attribute.KeyValue, 0, len(allowedKeys)) + for _, allowedKey := range allowedKeys { + if val, ok := metadata[allowedKey]; ok { + keyValue := attribute.StringSlice( + formatHeaderAttributeKey(protocol, eventType, allowedKey), + val, + ) + attributes = append(attributes, keyValue) + } + } + return attributes +} + +// formatHeaderAttributeKey formats header attributes as suggested by the OpenTelemetry specification: +// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md#grpc-request-and-response-metadata +func formatHeaderAttributeKey(protocol, eventType, key string) string { + key = strings.ReplaceAll(strings.ToLower(key), "-", "_") + return fmt.Sprintf("rpc.%s.%s.metadata.%s", protocol, eventType, key) +} diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/buf.gen.yaml b/vendor/github.com/bufbuild/connect-opentelemetry-go/buf.gen.yaml new file mode 100644 index 000000000..4f7f856d8 --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/buf.gen.yaml @@ -0,0 +1,12 @@ +version: v1 +managed: + enabled: true + go_package_prefix: + default: github.com/bufbuild/connect-opentelemetry-go/internal/gen +plugins: + - name: go + out: internal/gen + opt: paths=source_relative + - name: connect-go + out: internal/gen + opt: paths=source_relative diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/buf.work.yaml b/vendor/github.com/bufbuild/connect-opentelemetry-go/buf.work.yaml new file mode 100644 index 000000000..30f1e1ff0 --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/buf.work.yaml @@ -0,0 +1,3 @@ +version: v1 +directories: + - internal/proto diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/doc.go b/vendor/github.com/bufbuild/connect-opentelemetry-go/doc.go new file mode 100644 index 000000000..5ae5d5939 --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/doc.go @@ -0,0 +1,22 @@ +// Copyright 2022-2023 Buf Technologies, Inc. +// +// 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 otelconnect provides OpenTelemetry tracing and metrics for +// [github.com/bufbuild/connect-go] servers and clients. +// The specification followed was the [OpenTelemetry specification] with both the [rpc metrics specification] and [rpc trace specification] implemented. +// +// [OpenTelemetry specification]: https://github.com/open-telemetry/opentelemetry-specification +// [rpc metrics specification]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc-metrics.md +// [rpc trace specification]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md +package otelconnect diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/instruments.go b/vendor/github.com/bufbuild/connect-opentelemetry-go/instruments.go new file mode 100644 index 000000000..665f95f4e --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/instruments.go @@ -0,0 +1,94 @@ +// Copyright 2022-2023 Buf Technologies, Inc. +// +// 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 otelconnect + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/otel/metric" +) + +const ( + metricKeyFormat = "rpc.%s.%s" + durationKey = "duration" + requestSizeKey = "request.size" + responseSizeKey = "response.size" + requestsPerRPCKey = "requests_per_rpc" + responsesPerRPCKey = "responses_per_rpc" + messageKey = "message" + serverKey = "server" + clientKey = "client" + requestKey = "request" + responseKey = "response" + unitDimensionless = "1" + unitBytes = "By" + unitMilliseconds = "ms" +) + +type instruments struct { + initOnce sync.Once + initErr error + duration metric.Int64Histogram + requestSize metric.Int64Histogram + responseSize metric.Int64Histogram + requestsPerRPC metric.Int64Histogram + responsesPerRPC metric.Int64Histogram +} + +func (i *instruments) init(meter metric.Meter, isClient bool) { + i.initOnce.Do(func() { + interceptorType := serverKey + if isClient { + interceptorType = clientKey + } + i.duration, i.initErr = meter.Int64Histogram( + formatkeys(interceptorType, durationKey), + metric.WithUnit(unitMilliseconds), + ) + if i.initErr != nil { + return + } + i.requestSize, i.initErr = meter.Int64Histogram( + formatkeys(interceptorType, requestSizeKey), + metric.WithUnit(unitBytes), + ) + if i.initErr != nil { + return + } + i.responseSize, i.initErr = meter.Int64Histogram( + formatkeys(interceptorType, responseSizeKey), + metric.WithUnit(unitBytes), + ) + if i.initErr != nil { + return + } + i.requestsPerRPC, i.initErr = meter.Int64Histogram( + formatkeys(interceptorType, requestsPerRPCKey), + metric.WithUnit(unitDimensionless), + ) + if i.initErr != nil { + return + } + i.responsesPerRPC, i.initErr = meter.Int64Histogram( + formatkeys(interceptorType, responsesPerRPCKey), + metric.WithUnit(unitDimensionless), + ) + }) +} + +func formatkeys(interceptorType string, metricName string) string { + return fmt.Sprintf(metricKeyFormat, interceptorType, metricName) +} diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/interceptor.go b/vendor/github.com/bufbuild/connect-opentelemetry-go/interceptor.go new file mode 100644 index 000000000..574e9aa75 --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/interceptor.go @@ -0,0 +1,347 @@ +// Copyright 2022-2023 Buf Technologies, Inc. +// +// 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 otelconnect + +import ( + "context" + "errors" + "strings" + "sync" + "time" + + "github.com/bufbuild/connect-go" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/propagation" + semconv "go.opentelemetry.io/otel/semconv/v1.20.0" + "go.opentelemetry.io/otel/trace" + "google.golang.org/protobuf/proto" +) + +// Interceptor implements [connect.Interceptor] that adds +// OpenTelemetry metrics and tracing to connect handlers and clients. +type Interceptor struct { + config config + clientInstruments instruments + handlerInstruments instruments +} + +var _ connect.Interceptor = &Interceptor{} + +// NewInterceptor constructs and returns an Interceptor which implements [connect.Interceptor] +// that adds OpenTelemetry metrics and tracing to Connect handlers and clients. +func NewInterceptor(options ...Option) *Interceptor { + cfg := config{ + now: time.Now, + tracer: otel.GetTracerProvider().Tracer( + instrumentationName, + trace.WithInstrumentationVersion(semanticVersion), + ), + propagator: otel.GetTextMapPropagator(), + meter: otel.GetMeterProvider().Meter( + instrumentationName, + metric.WithInstrumentationVersion(semanticVersion)), + } + for _, opt := range options { + opt.apply(&cfg) + } + return &Interceptor{ + config: cfg, + } +} + +func (i *Interceptor) getAndInitInstrument(isClient bool) (*instruments, error) { + if isClient { + i.clientInstruments.init(i.config.meter, isClient) + return &i.clientInstruments, i.clientInstruments.initErr + } + i.handlerInstruments.init(i.config.meter, isClient) + return &i.handlerInstruments, i.handlerInstruments.initErr +} + +// WrapUnary implements otel tracing and metrics for unary handlers. +func (i *Interceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc { + return func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) { + requestStartTime := i.config.now() + req := &Request{ + Spec: request.Spec(), + Peer: request.Peer(), + Header: request.Header(), + } + if i.config.filter != nil { + if !i.config.filter(ctx, req) { + return next(ctx, request) + } + } + attributeFilter := i.config.filterAttribute.filter + isClient := request.Spec().IsClient + name := strings.TrimLeft(request.Spec().Procedure, "/") + protocol := protocolToSemConv(request.Peer().Protocol) + attributes := attributeFilter(req, requestAttributes(req)...) + instrumentation, err := i.getAndInitInstrument(isClient) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + carrier := propagation.HeaderCarrier(request.Header()) + spanKind := trace.SpanKindClient + requestSpan, responseSpan := semconv.MessageTypeSent, semconv.MessageTypeReceived + traceOpts := []trace.SpanStartOption{ + trace.WithAttributes(attributes...), + trace.WithAttributes(headerAttributes(protocol, requestKey, req.Header, i.config.requestHeaderKeys)...), + } + if !isClient { + spanKind = trace.SpanKindServer + requestSpan, responseSpan = semconv.MessageTypeReceived, semconv.MessageTypeSent + // if a span already exists in ctx then there must have already been another interceptor + // that set it, so don't extract from carrier. + if !trace.SpanContextFromContext(ctx).IsValid() { + ctx = i.config.propagator.Extract(ctx, carrier) + if !i.config.trustRemote { + traceOpts = append(traceOpts, + trace.WithNewRoot(), + trace.WithLinks(trace.LinkFromContext(ctx)), + ) + } + } + } + traceOpts = append(traceOpts, trace.WithSpanKind(spanKind)) + ctx, span := i.config.tracer.Start( + ctx, + name, + traceOpts..., + ) + defer span.End() + if isClient { + i.config.propagator.Inject(ctx, carrier) + } + var requestSize int + if request != nil { + if msg, ok := request.Any().(proto.Message); ok { + requestSize = proto.Size(msg) + } + } + span.AddEvent(messageKey, + trace.WithAttributes( + requestSpan, + semconv.MessageIDKey.Int(1), + semconv.MessageUncompressedSizeKey.Int(requestSize), + ), + ) + response, err := next(ctx, request) + if statusCode, ok := statusCodeAttribute(protocol, err); ok { + attributes = append(attributes, statusCode) + } + var responseSize int + if err == nil { + if msg, ok := response.Any().(proto.Message); ok { + responseSize = proto.Size(msg) + } + span.SetAttributes(headerAttributes(protocol, responseKey, response.Header(), i.config.responseHeaderKeys)...) + } + span.AddEvent(messageKey, + trace.WithAttributes( + responseSpan, + semconv.MessageIDKey.Int(1), + semconv.MessageUncompressedSizeKey.Int(responseSize), + ), + ) + attributes = attributeFilter(req, attributes...) + span.SetStatus(spanStatus(err)) + span.SetAttributes(attributes...) + instrumentation.duration.Record(ctx, i.config.now().Sub(requestStartTime).Milliseconds(), metric.WithAttributes(attributes...)) + instrumentation.requestSize.Record(ctx, int64(requestSize), metric.WithAttributes(attributes...)) + instrumentation.requestsPerRPC.Record(ctx, 1, metric.WithAttributes(attributes...)) + instrumentation.responseSize.Record(ctx, int64(responseSize), metric.WithAttributes(attributes...)) + instrumentation.responsesPerRPC.Record(ctx, 1, metric.WithAttributes(attributes...)) + return response, err + } +} + +// WrapStreamingClient implements otel tracing and metrics for streaming connect clients. +func (i *Interceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc { + return func(ctx context.Context, spec connect.Spec) connect.StreamingClientConn { + requestStartTime := i.config.now() + conn := next(ctx, spec) + instrumentation, err := i.getAndInitInstrument(spec.IsClient) + if err != nil { + return &errorStreamingClientInterceptor{ + StreamingClientConn: conn, + err: connect.NewError(connect.CodeInternal, err), + } + } + req := &Request{ + Spec: conn.Spec(), + Peer: conn.Peer(), + Header: conn.RequestHeader(), + } + if i.config.filter != nil { + if !i.config.filter(ctx, req) { + return conn + } + } + name := strings.TrimLeft(conn.Spec().Procedure, "/") + protocol := protocolToSemConv(conn.Peer().Protocol) + state := newStreamingState( + req, + i.config.filterAttribute, + requestAttributes(req), + instrumentation.responseSize, + instrumentation.responsesPerRPC, + instrumentation.requestSize, + instrumentation.requestsPerRPC, + ) + var span trace.Span + var createSpanOnce sync.Once + createSpan := func() { + ctx, span = i.config.tracer.Start( + ctx, + name, + trace.WithSpanKind(trace.SpanKindClient), + trace.WithAttributes(state.attributes...), + trace.WithAttributes(headerAttributes( + protocol, + requestKey, + conn.RequestHeader(), + i.config.requestHeaderKeys)...), + ) + // inject the newly created span into the carrier + carrier := propagation.HeaderCarrier(conn.RequestHeader()) + i.config.propagator.Inject(ctx, carrier) + } + return &streamingClientInterceptor{ + StreamingClientConn: conn, + onClose: func() { + createSpanOnce.Do(createSpan) + // state.attributes is updated with the final error that was recorded. + // If error is nil a "success" is recorded on the span and on the final duration + // metric. The "rpc..status_code" is not defined for any other metrics for + // streams because the error only exists when finishing the stream. + if statusCode, ok := statusCodeAttribute(protocol, state.error); ok { + state.addAttributes(statusCode) + } + span.SetAttributes(state.attributes...) + span.SetAttributes(headerAttributes(protocol, responseKey, conn.ResponseHeader(), i.config.responseHeaderKeys)...) + span.SetStatus(spanStatus(state.error)) + span.End() + instrumentation.duration.Record(ctx, i.config.now().Sub(requestStartTime).Milliseconds(), metric.WithAttributes(state.attributes...)) + }, + receive: func(msg any, conn connect.StreamingClientConn) error { + return state.receive(ctx, msg, conn) + }, + send: func(msg any, conn connect.StreamingClientConn) error { + createSpanOnce.Do(createSpan) + return state.send(ctx, msg, conn) + }, + } + } +} + +// WrapStreamingHandler implements otel tracing and metrics for streaming connect handlers. +func (i *Interceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc { + return func(ctx context.Context, conn connect.StreamingHandlerConn) error { + requestStartTime := i.config.now() + isClient := conn.Spec().IsClient + instrumentation, err := i.getAndInitInstrument(isClient) + if err != nil { + return err + } + req := &Request{ + Spec: conn.Spec(), + Peer: conn.Peer(), + Header: conn.RequestHeader(), + } + if i.config.filter != nil { + if !i.config.filter(ctx, req) { + return next(ctx, conn) + } + } + protocol := protocolToSemConv(req.Peer.Protocol) + name := strings.TrimLeft(conn.Spec().Procedure, "/") + state := newStreamingState( + req, + i.config.filterAttribute, + requestAttributes(req), + instrumentation.requestSize, + instrumentation.requestsPerRPC, + instrumentation.responseSize, + instrumentation.responsesPerRPC, + ) + // extract any request headers into the context + carrier := propagation.HeaderCarrier(conn.RequestHeader()) + traceOpts := []trace.SpanStartOption{ + trace.WithSpanKind(trace.SpanKindServer), + trace.WithAttributes(state.attributes...), + trace.WithAttributes(headerAttributes(protocol, requestKey, req.Header, i.config.requestHeaderKeys)...), + } + if !trace.SpanContextFromContext(ctx).IsValid() { + ctx = i.config.propagator.Extract(ctx, carrier) + if !i.config.trustRemote { + traceOpts = append(traceOpts, + trace.WithNewRoot(), + trace.WithLinks(trace.LinkFromContext(ctx)), + ) + } + } + // start a new span with any trace that is in the context + ctx, span := i.config.tracer.Start( + ctx, + name, + traceOpts..., + ) + defer span.End() + streamingHandler := &streamingHandlerInterceptor{ + StreamingHandlerConn: conn, + receive: func(msg any, conn connect.StreamingHandlerConn) error { + return state.receive(ctx, msg, conn) + }, + send: func(msg any, conn connect.StreamingHandlerConn) error { + return state.send(ctx, msg, conn) + }, + } + err = next(ctx, streamingHandler) + if statusCode, ok := statusCodeAttribute(protocol, err); ok { + state.addAttributes(statusCode) + } + span.SetAttributes(state.attributes...) + span.SetAttributes(headerAttributes(protocol, responseKey, conn.ResponseHeader(), i.config.responseHeaderKeys)...) + span.SetStatus(spanStatus(err)) + instrumentation.duration.Record(ctx, i.config.now().Sub(requestStartTime).Milliseconds(), metric.WithAttributes(state.attributes...)) + return err + } +} + +func protocolToSemConv(protocol string) string { + switch protocol { + case grpcwebString: + return grpcwebProtocol + case grpcProtocol: + return grpcProtocol + case connectString: + return connectProtocol + default: + return protocol + } +} + +func spanStatus(err error) (codes.Code, string) { + if err == nil { + return codes.Unset, "" + } + if connectErr := new(connect.Error); errors.As(err, &connectErr) { + return codes.Error, connectErr.Message() + } + return codes.Error, err.Error() +} diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/option.go b/vendor/github.com/bufbuild/connect-opentelemetry-go/option.go new file mode 100644 index 000000000..04bf3917d --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/option.go @@ -0,0 +1,195 @@ +// Copyright 2022-2023 Buf Technologies, Inc. +// +// 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 otelconnect + +import ( + "context" + "net/http" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/noop" + "go.opentelemetry.io/otel/propagation" + semconv "go.opentelemetry.io/otel/semconv/v1.12.0" + "go.opentelemetry.io/otel/trace" +) + +// An Option configures the OpenTelemetry instrumentation. +type Option interface { + apply(*config) +} + +// WithPropagator configures the instrumentation to use the supplied propagator +// when extracting and injecting trace context. By default, the instrumentation +// uses otel.GetTextMapPropagator(). +func WithPropagator(propagator propagation.TextMapPropagator) Option { + return &propagatorOption{propagator} +} + +// WithMeterProvider configures the instrumentation to use the supplied [metric.MeterProvider] +// when extracting and injecting trace context. By default, the instrumentation +// uses global.MeterProvider(). +func WithMeterProvider(provider metric.MeterProvider) Option { + return &meterProviderOption{provider: provider} +} + +// WithTracerProvider configures the instrumentation to use the supplied +// provider when creating a tracer. By default, the instrumentation +// uses otel.GetTracerProvider(). +func WithTracerProvider(provider trace.TracerProvider) Option { + return &tracerProviderOption{provider} +} + +// WithFilter configures the instrumentation to emit traces and metrics only +// when the filter function returns true. Filter functions must be safe to call concurrently. +func WithFilter(filter func(context.Context, *Request) bool) Option { + return &filterOption{filter} +} + +// WithoutTracing disables tracing. +func WithoutTracing() Option { + return WithTracerProvider(trace.NewNoopTracerProvider()) +} + +// WithoutMetrics disables metrics. +func WithoutMetrics() Option { + return WithMeterProvider(noop.NewMeterProvider()) +} + +// WithAttributeFilter sets the attribute filter for all metrics and trace attributes. +func WithAttributeFilter(filter AttributeFilter) Option { + return &attributeFilterOption{filterAttribute: filter} +} + +// WithoutServerPeerAttributes removes net.peer.port and net.peer.name attributes from server trace and span attributes. +// This is recommended to use as net.peer server attributes have high cardinality. +func WithoutServerPeerAttributes() Option { + return WithAttributeFilter(func(request *Request, value attribute.KeyValue) bool { + if request.Spec.IsClient { + return true + } + if value.Key == semconv.NetPeerPortKey { + return false + } + if value.Key == semconv.NetPeerNameKey { + return false + } + return true + }) +} + +// WithTrustRemote sets the Interceptor to trust remote spans. +// By default, all incoming server spans are untrusted and will be linked +// with a [trace.Link] and will not be a child span. +// By default, all client spans are trusted and no change occurs when WithTrustRemote is used. +func WithTrustRemote() Option { + return &trustRemoteOption{} +} + +// WithTraceRequestHeader enables header attributes for the request header keys provided. +// Attributes will be added as Trace attributes only. +func WithTraceRequestHeader(keys ...string) Option { + return &traceRequestHeaderOption{ + keys: keys, + } +} + +// WithTraceResponseHeader enables header attributes for the response header keys provided. +// Attributes will be added as Trace attributes only. +func WithTraceResponseHeader(keys ...string) Option { + return &traceResponseHeaderOption{ + keys: keys, + } +} + +type attributeFilterOption struct { + filterAttribute AttributeFilter +} + +func (o *attributeFilterOption) apply(c *config) { + if o.filterAttribute != nil { + c.filterAttribute = o.filterAttribute + } +} + +type propagatorOption struct { + propagator propagation.TextMapPropagator +} + +func (o *propagatorOption) apply(c *config) { + if o.propagator != nil { + c.propagator = o.propagator + } +} + +type tracerProviderOption struct { + provider trace.TracerProvider +} + +func (o *tracerProviderOption) apply(c *config) { + if o.provider != nil { + c.tracer = o.provider.Tracer( + instrumentationName, + trace.WithInstrumentationVersion(semanticVersion), + ) + } +} + +type filterOption struct { + filter func(context.Context, *Request) bool +} + +func (o *filterOption) apply(c *config) { + if o.filter != nil { + c.filter = o.filter + } +} + +type meterProviderOption struct { + provider metric.MeterProvider +} + +func (m meterProviderOption) apply(c *config) { + c.meter = m.provider.Meter( + instrumentationName, + metric.WithInstrumentationVersion(semanticVersion), + ) +} + +type trustRemoteOption struct{} + +func (o *trustRemoteOption) apply(c *config) { + c.trustRemote = true +} + +type traceRequestHeaderOption struct { + keys []string +} + +func (o *traceRequestHeaderOption) apply(c *config) { + for _, key := range o.keys { + c.requestHeaderKeys = append(c.requestHeaderKeys, http.CanonicalHeaderKey(key)) + } +} + +type traceResponseHeaderOption struct { + keys []string +} + +func (o *traceResponseHeaderOption) apply(c *config) { + for _, key := range o.keys { + c.responseHeaderKeys = append(c.responseHeaderKeys, http.CanonicalHeaderKey(key)) + } +} diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/otelconnect.go b/vendor/github.com/bufbuild/connect-opentelemetry-go/otelconnect.go new file mode 100644 index 000000000..988e440ac --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/otelconnect.go @@ -0,0 +1,58 @@ +// Copyright 2022-2023 Buf Technologies, Inc. +// +// 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 otelconnect + +import ( + "context" + "net/http" + "time" + + "github.com/bufbuild/connect-go" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/propagation" + "go.opentelemetry.io/otel/trace" +) + +const ( + version = "0.0.1-dev" + semanticVersion = "semver:" + version + instrumentationName = "github.com/bufbuild/connect-opentelemetry-go" + grpcProtocol = "grpc" + grpcwebString = "grpcweb" + grpcwebProtocol = "grpc_web" + connectString = "connect" + connectProtocol = "connect_rpc" +) + +// Request is the information about each RPC available to filter functions. It +// contains the common subset of [connect.AnyRequest], +// [connect.StreamingClientConn], and [connect.StreamingHandlerConn]. +type Request struct { + Spec connect.Spec + Peer connect.Peer + Header http.Header +} + +type config struct { + filter func(context.Context, *Request) bool + filterAttribute AttributeFilter + meter metric.Meter + tracer trace.Tracer + propagator propagation.TextMapPropagator + now func() time.Time + trustRemote bool + requestHeaderKeys []string + responseHeaderKeys []string +} diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/payloadinterceptor.go b/vendor/github.com/bufbuild/connect-opentelemetry-go/payloadinterceptor.go new file mode 100644 index 000000000..7e9eb25e4 --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/payloadinterceptor.go @@ -0,0 +1,116 @@ +// Copyright 2022-2023 Buf Technologies, Inc. +// +// 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 otelconnect + +import ( + "fmt" + "sync" + + "github.com/bufbuild/connect-go" +) + +type streamingClientInterceptor struct { + connect.StreamingClientConn + + receive func(any, connect.StreamingClientConn) error + send func(any, connect.StreamingClientConn) error + onClose func() + + mu sync.Mutex + requestClosed bool + responseClosed bool + onCloseCalled bool +} + +func (s *streamingClientInterceptor) Receive(msg any) error { + return s.receive(msg, s.StreamingClientConn) +} + +func (s *streamingClientInterceptor) Send(msg any) error { + return s.send(msg, s.StreamingClientConn) +} + +func (s *streamingClientInterceptor) CloseRequest() error { + err := s.StreamingClientConn.CloseRequest() + s.mu.Lock() + s.requestClosed = true + shouldCall := s.responseClosed && !s.onCloseCalled + if shouldCall { + s.onCloseCalled = true + } + s.mu.Unlock() + if shouldCall { + s.onClose() + } + return err +} + +func (s *streamingClientInterceptor) CloseResponse() error { + err := s.StreamingClientConn.CloseResponse() + s.mu.Lock() + s.responseClosed = true + shouldCall := s.requestClosed && !s.onCloseCalled + if shouldCall { + s.onCloseCalled = true + } + s.mu.Unlock() + if shouldCall { + s.onClose() + } + return err +} + +type errorStreamingClientInterceptor struct { + connect.StreamingClientConn + + err error +} + +func (e *errorStreamingClientInterceptor) Send(any) error { + return e.err +} + +func (e *errorStreamingClientInterceptor) CloseRequest() error { + if err := e.StreamingClientConn.CloseRequest(); err != nil { + return fmt.Errorf("%w %s", err, e.err.Error()) + } + return e.err +} + +func (e *errorStreamingClientInterceptor) Receive(any) error { + return e.err +} + +func (e *errorStreamingClientInterceptor) CloseResponse() error { + if err := e.StreamingClientConn.CloseResponse(); err != nil { + return fmt.Errorf("%w %s", err, e.err.Error()) + } + return e.err +} + +type streamingHandlerInterceptor struct { + connect.StreamingHandlerConn + + receive func(any, connect.StreamingHandlerConn) error + send func(any, connect.StreamingHandlerConn) error +} + +func (p *streamingHandlerInterceptor) Receive(msg any) error { + return p.receive(msg, p.StreamingHandlerConn) +} + +func (p *streamingHandlerInterceptor) Send(msg any) error { + return p.send(msg, p.StreamingHandlerConn) +} diff --git a/vendor/github.com/bufbuild/connect-opentelemetry-go/streaming.go b/vendor/github.com/bufbuild/connect-opentelemetry-go/streaming.go new file mode 100644 index 000000000..9f283d0ee --- /dev/null +++ b/vendor/github.com/bufbuild/connect-opentelemetry-go/streaming.go @@ -0,0 +1,137 @@ +// Copyright 2022-2023 Buf Technologies, Inc. +// +// 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 otelconnect + +import ( + "context" + "errors" + "io" + "sync" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" + semconv "go.opentelemetry.io/otel/semconv/v1.12.0" + "go.opentelemetry.io/otel/trace" + "google.golang.org/protobuf/proto" +) + +type streamingState struct { + mu sync.Mutex + protocol string + req *Request + attributeFilter AttributeFilter + attributes []attribute.KeyValue + error error + sentCounter int + receivedCounter int + receiveSize metric.Int64Histogram + receivesPerRPC metric.Int64Histogram + sendSize metric.Int64Histogram + sendsPerRPC metric.Int64Histogram +} + +func newStreamingState( + req *Request, + attributeFilter AttributeFilter, + attributes []attribute.KeyValue, + receiveSize, receivesPerRPC, sendSize, sendsPerRPC metric.Int64Histogram, +) *streamingState { + attributes = attributeFilter.filter(req, attributes...) + return &streamingState{ + protocol: protocolToSemConv(req.Peer.Protocol), + attributeFilter: attributeFilter, + req: req, + attributes: attributes, + receiveSize: receiveSize, + receivesPerRPC: receivesPerRPC, + sendSize: sendSize, + sendsPerRPC: sendsPerRPC, + } +} + +type sendReceiver interface { + Receive(any) error + Send(any) error +} + +func (s *streamingState) addAttributes(attributes ...attribute.KeyValue) { + s.attributes = append(s.attributes, s.attributeFilter.filter(s.req, attributes...)...) +} + +func (s *streamingState) receive(ctx context.Context, msg any, conn sendReceiver) error { + err := conn.Receive(msg) + s.mu.Lock() + defer s.mu.Unlock() + if errors.Is(err, io.EOF) { + return err + } + if err != nil { + s.error = err + // If error add it to the attributes because the stream is about to terminate. + // If no error don't add anything because status only exists at end of stream. + if statusCode, ok := statusCodeAttribute(s.protocol, err); ok { + s.addAttributes(statusCode) + } + } + protomsg, ok := msg.(proto.Message) + size := proto.Size(protomsg) + s.receivedCounter++ + s.event(ctx, semconv.MessageTypeReceived, s.receivedCounter, ok, size) + s.receiveSize.Record(ctx, int64(size), metric.WithAttributes(s.attributes...)) + s.receivesPerRPC.Record(ctx, 1, metric.WithAttributes(s.attributes...)) + return err +} + +func (s *streamingState) send(ctx context.Context, msg any, conn sendReceiver) error { + err := conn.Send(msg) + s.mu.Lock() + defer s.mu.Unlock() + if errors.Is(err, io.EOF) { + return err + } + if err != nil { + s.error = err + // If error add it to the attributes because the stream is about to terminate. + // If no error don't add anything because status only exists at end of stream. + if statusCode, ok := statusCodeAttribute(s.protocol, err); ok { + s.addAttributes(statusCode) + } + } + protomsg, ok := msg.(proto.Message) + size := proto.Size(protomsg) + s.sentCounter++ + s.event(ctx, semconv.MessageTypeSent, s.sentCounter, ok, size) + s.sendSize.Record(ctx, int64(size), metric.WithAttributes(s.attributes...)) + s.sendsPerRPC.Record(ctx, 1, metric.WithAttributes(s.attributes...)) + return err +} + +func (s *streamingState) event(ctx context.Context, messageType attribute.KeyValue, messageID int, msgOk bool, size int) { + span := trace.SpanFromContext(ctx) + if msgOk { + span.AddEvent("message", trace.WithAttributes(s.attributeFilter.filter( + s.req, + messageType, + semconv.MessageUncompressedSizeKey.Int(size), + semconv.MessageIDKey.Int(messageID), + )...)) + } else { + span.AddEvent("message", trace.WithAttributes(s.attributeFilter.filter( + s.req, + messageType, + semconv.MessageIDKey.Int(messageID), + )...)) + } +} diff --git a/vendor/github.com/containerd/stargz-snapshotter/estargz/LICENSE b/vendor/github.com/containerd/stargz-snapshotter/estargz/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/vendor/github.com/containerd/stargz-snapshotter/estargz/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/containerd/stargz-snapshotter/estargz/build.go b/vendor/github.com/containerd/stargz-snapshotter/estargz/build.go new file mode 100644 index 000000000..b071cea51 --- /dev/null +++ b/vendor/github.com/containerd/stargz-snapshotter/estargz/build.go @@ -0,0 +1,690 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + Copyright 2019 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 estargz + +import ( + "archive/tar" + "bytes" + "compress/gzip" + "context" + "errors" + "fmt" + "io" + "os" + "path" + "runtime" + "strings" + "sync" + + "github.com/containerd/stargz-snapshotter/estargz/errorutil" + "github.com/klauspost/compress/zstd" + digest "github.com/opencontainers/go-digest" + "golang.org/x/sync/errgroup" +) + +type options struct { + chunkSize int + compressionLevel int + prioritizedFiles []string + missedPrioritizedFiles *[]string + compression Compression + ctx context.Context + minChunkSize int +} + +type Option func(o *options) error + +// WithChunkSize option specifies the chunk size of eStargz blob to build. +func WithChunkSize(chunkSize int) Option { + return func(o *options) error { + o.chunkSize = chunkSize + return nil + } +} + +// WithCompressionLevel option specifies the gzip compression level. +// The default is gzip.BestCompression. +// This option will be ignored if WithCompression option is used. +// See also: https://godoc.org/compress/gzip#pkg-constants +func WithCompressionLevel(level int) Option { + return func(o *options) error { + o.compressionLevel = level + return nil + } +} + +// WithPrioritizedFiles option specifies the list of prioritized files. +// These files must be complete paths that are absolute or relative to "/" +// For example, all of "foo/bar", "/foo/bar", "./foo/bar" and "../foo/bar" +// are treated as "/foo/bar". +func WithPrioritizedFiles(files []string) Option { + return func(o *options) error { + o.prioritizedFiles = files + return nil + } +} + +// WithAllowPrioritizeNotFound makes Build continue the execution even if some +// of prioritized files specified by WithPrioritizedFiles option aren't found +// in the input tar. Instead, this records all missed file names to the passed +// slice. +func WithAllowPrioritizeNotFound(missedFiles *[]string) Option { + return func(o *options) error { + if missedFiles == nil { + return fmt.Errorf("WithAllowPrioritizeNotFound: slice must be passed") + } + o.missedPrioritizedFiles = missedFiles + return nil + } +} + +// WithCompression specifies compression algorithm to be used. +// Default is gzip. +func WithCompression(compression Compression) Option { + return func(o *options) error { + o.compression = compression + return nil + } +} + +// WithContext specifies a context that can be used for clean canceleration. +func WithContext(ctx context.Context) Option { + return func(o *options) error { + o.ctx = ctx + return nil + } +} + +// WithMinChunkSize option specifies the minimal number of bytes of data +// must be written in one gzip stream. +// By increasing this number, one gzip stream can contain multiple files +// and it hopefully leads to smaller result blob. +// NOTE: This adds a TOC property that old reader doesn't understand. +func WithMinChunkSize(minChunkSize int) Option { + return func(o *options) error { + o.minChunkSize = minChunkSize + return nil + } +} + +// Blob is an eStargz blob. +type Blob struct { + io.ReadCloser + diffID digest.Digester + tocDigest digest.Digest +} + +// DiffID returns the digest of uncompressed blob. +// It is only valid to call DiffID after Close. +func (b *Blob) DiffID() digest.Digest { + return b.diffID.Digest() +} + +// TOCDigest returns the digest of uncompressed TOC JSON. +func (b *Blob) TOCDigest() digest.Digest { + return b.tocDigest +} + +// Build builds an eStargz blob which is an extended version of stargz, from a blob (gzip, zstd +// or plain tar) passed through the argument. If there are some prioritized files are listed in +// the option, these files are grouped as "prioritized" and can be used for runtime optimization +// (e.g. prefetch). This function builds a blob in parallel, with dividing that blob into several +// (at least the number of runtime.GOMAXPROCS(0)) sub-blobs. +func Build(tarBlob *io.SectionReader, opt ...Option) (_ *Blob, rErr error) { + var opts options + opts.compressionLevel = gzip.BestCompression // BestCompression by default + for _, o := range opt { + if err := o(&opts); err != nil { + return nil, err + } + } + if opts.compression == nil { + opts.compression = newGzipCompressionWithLevel(opts.compressionLevel) + } + layerFiles := newTempFiles() + ctx := opts.ctx + if ctx == nil { + ctx = context.Background() + } + done := make(chan struct{}) + defer close(done) + go func() { + select { + case <-done: + // nop + case <-ctx.Done(): + layerFiles.CleanupAll() + } + }() + defer func() { + if rErr != nil { + if err := layerFiles.CleanupAll(); err != nil { + rErr = fmt.Errorf("failed to cleanup tmp files: %v: %w", err, rErr) + } + } + if cErr := ctx.Err(); cErr != nil { + rErr = fmt.Errorf("error from context %q: %w", cErr, rErr) + } + }() + tarBlob, err := decompressBlob(tarBlob, layerFiles) + if err != nil { + return nil, err + } + entries, err := sortEntries(tarBlob, opts.prioritizedFiles, opts.missedPrioritizedFiles) + if err != nil { + return nil, err + } + var tarParts [][]*entry + if opts.minChunkSize > 0 { + // Each entry needs to know the size of the current gzip stream so they + // cannot be processed in parallel. + tarParts = [][]*entry{entries} + } else { + tarParts = divideEntries(entries, runtime.GOMAXPROCS(0)) + } + writers := make([]*Writer, len(tarParts)) + payloads := make([]*os.File, len(tarParts)) + var mu sync.Mutex + var eg errgroup.Group + for i, parts := range tarParts { + i, parts := i, parts + // builds verifiable stargz sub-blobs + eg.Go(func() error { + esgzFile, err := layerFiles.TempFile("", "esgzdata") + if err != nil { + return err + } + sw := NewWriterWithCompressor(esgzFile, opts.compression) + sw.ChunkSize = opts.chunkSize + sw.MinChunkSize = opts.minChunkSize + if sw.needsOpenGzEntries == nil { + sw.needsOpenGzEntries = make(map[string]struct{}) + } + for _, f := range []string{PrefetchLandmark, NoPrefetchLandmark} { + sw.needsOpenGzEntries[f] = struct{}{} + } + if err := sw.AppendTar(readerFromEntries(parts...)); err != nil { + return err + } + mu.Lock() + writers[i] = sw + payloads[i] = esgzFile + mu.Unlock() + return nil + }) + } + if err := eg.Wait(); err != nil { + rErr = err + return nil, err + } + tocAndFooter, tocDgst, err := closeWithCombine(writers...) + if err != nil { + rErr = err + return nil, err + } + var rs []io.Reader + for _, p := range payloads { + fs, err := fileSectionReader(p) + if err != nil { + return nil, err + } + rs = append(rs, fs) + } + diffID := digest.Canonical.Digester() + pr, pw := io.Pipe() + go func() { + r, err := opts.compression.Reader(io.TeeReader(io.MultiReader(append(rs, tocAndFooter)...), pw)) + if err != nil { + pw.CloseWithError(err) + return + } + defer r.Close() + if _, err := io.Copy(diffID.Hash(), r); err != nil { + pw.CloseWithError(err) + return + } + pw.Close() + }() + return &Blob{ + ReadCloser: readCloser{ + Reader: pr, + closeFunc: layerFiles.CleanupAll, + }, + tocDigest: tocDgst, + diffID: diffID, + }, nil +} + +// closeWithCombine takes unclosed Writers and close them. This also returns the +// toc that combined all Writers into. +// Writers doesn't write TOC and footer to the underlying writers so they can be +// combined into a single eStargz and tocAndFooter returned by this function can +// be appended at the tail of that combined blob. +func closeWithCombine(ws ...*Writer) (tocAndFooterR io.Reader, tocDgst digest.Digest, err error) { + if len(ws) == 0 { + return nil, "", fmt.Errorf("at least one writer must be passed") + } + for _, w := range ws { + if w.closed { + return nil, "", fmt.Errorf("writer must be unclosed") + } + defer func(w *Writer) { w.closed = true }(w) + if err := w.closeGz(); err != nil { + return nil, "", err + } + if err := w.bw.Flush(); err != nil { + return nil, "", err + } + } + var ( + mtoc = new(JTOC) + currentOffset int64 + ) + mtoc.Version = ws[0].toc.Version + for _, w := range ws { + for _, e := range w.toc.Entries { + // Recalculate Offset of non-empty files/chunks + if (e.Type == "reg" && e.Size > 0) || e.Type == "chunk" { + e.Offset += currentOffset + } + mtoc.Entries = append(mtoc.Entries, e) + } + if w.toc.Version > mtoc.Version { + mtoc.Version = w.toc.Version + } + currentOffset += w.cw.n + } + + return tocAndFooter(ws[0].compressor, mtoc, currentOffset) +} + +func tocAndFooter(compressor Compressor, toc *JTOC, offset int64) (io.Reader, digest.Digest, error) { + buf := new(bytes.Buffer) + tocDigest, err := compressor.WriteTOCAndFooter(buf, offset, toc, nil) + if err != nil { + return nil, "", err + } + return buf, tocDigest, nil +} + +// divideEntries divides passed entries to the parts at least the number specified by the +// argument. +func divideEntries(entries []*entry, minPartsNum int) (set [][]*entry) { + var estimatedSize int64 + for _, e := range entries { + estimatedSize += e.header.Size + } + unitSize := estimatedSize / int64(minPartsNum) + var ( + nextEnd = unitSize + offset int64 + ) + set = append(set, []*entry{}) + for _, e := range entries { + set[len(set)-1] = append(set[len(set)-1], e) + offset += e.header.Size + if offset > nextEnd { + set = append(set, []*entry{}) + nextEnd += unitSize + } + } + return +} + +var errNotFound = errors.New("not found") + +// sortEntries reads the specified tar blob and returns a list of tar entries. +// If some of prioritized files are specified, the list starts from these +// files with keeping the order specified by the argument. +func sortEntries(in io.ReaderAt, prioritized []string, missedPrioritized *[]string) ([]*entry, error) { + + // Import tar file. + intar, err := importTar(in) + if err != nil { + return nil, fmt.Errorf("failed to sort: %w", err) + } + + // Sort the tar file respecting to the prioritized files list. + sorted := &tarFile{} + for _, l := range prioritized { + if err := moveRec(l, intar, sorted); err != nil { + if errors.Is(err, errNotFound) && missedPrioritized != nil { + *missedPrioritized = append(*missedPrioritized, l) + continue // allow not found + } + return nil, fmt.Errorf("failed to sort tar entries: %w", err) + } + } + if len(prioritized) == 0 { + sorted.add(&entry{ + header: &tar.Header{ + Name: NoPrefetchLandmark, + Typeflag: tar.TypeReg, + Size: int64(len([]byte{landmarkContents})), + }, + payload: bytes.NewReader([]byte{landmarkContents}), + }) + } else { + sorted.add(&entry{ + header: &tar.Header{ + Name: PrefetchLandmark, + Typeflag: tar.TypeReg, + Size: int64(len([]byte{landmarkContents})), + }, + payload: bytes.NewReader([]byte{landmarkContents}), + }) + } + + // Dump all entry and concatinate them. + return append(sorted.dump(), intar.dump()...), nil +} + +// readerFromEntries returns a reader of tar archive that contains entries passed +// through the arguments. +func readerFromEntries(entries ...*entry) io.Reader { + pr, pw := io.Pipe() + go func() { + tw := tar.NewWriter(pw) + defer tw.Close() + for _, entry := range entries { + if err := tw.WriteHeader(entry.header); err != nil { + pw.CloseWithError(fmt.Errorf("Failed to write tar header: %v", err)) + return + } + if _, err := io.Copy(tw, entry.payload); err != nil { + pw.CloseWithError(fmt.Errorf("Failed to write tar payload: %v", err)) + return + } + } + pw.Close() + }() + return pr +} + +func importTar(in io.ReaderAt) (*tarFile, error) { + tf := &tarFile{} + pw, err := newCountReadSeeker(in) + if err != nil { + return nil, fmt.Errorf("failed to make position watcher: %w", err) + } + tr := tar.NewReader(pw) + + // Walk through all nodes. + for { + // Fetch and parse next header. + h, err := tr.Next() + if err != nil { + if err == io.EOF { + break + } else { + return nil, fmt.Errorf("failed to parse tar file, %w", err) + } + } + switch cleanEntryName(h.Name) { + case PrefetchLandmark, NoPrefetchLandmark: + // Ignore existing landmark + continue + } + + // Add entry. If it already exists, replace it. + if _, ok := tf.get(h.Name); ok { + tf.remove(h.Name) + } + tf.add(&entry{ + header: h, + payload: io.NewSectionReader(in, pw.currentPos(), h.Size), + }) + } + + return tf, nil +} + +func moveRec(name string, in *tarFile, out *tarFile) error { + name = cleanEntryName(name) + if name == "" { // root directory. stop recursion. + if e, ok := in.get(name); ok { + // entry of the root directory exists. we should move it as well. + // this case will occur if tar entries are prefixed with "./", "/", etc. + out.add(e) + in.remove(name) + } + return nil + } + + _, okIn := in.get(name) + _, okOut := out.get(name) + if !okIn && !okOut { + return fmt.Errorf("file: %q: %w", name, errNotFound) + } + + parent, _ := path.Split(strings.TrimSuffix(name, "/")) + if err := moveRec(parent, in, out); err != nil { + return err + } + if e, ok := in.get(name); ok && e.header.Typeflag == tar.TypeLink { + if err := moveRec(e.header.Linkname, in, out); err != nil { + return err + } + } + if e, ok := in.get(name); ok { + out.add(e) + in.remove(name) + } + return nil +} + +type entry struct { + header *tar.Header + payload io.ReadSeeker +} + +type tarFile struct { + index map[string]*entry + stream []*entry +} + +func (f *tarFile) add(e *entry) { + if f.index == nil { + f.index = make(map[string]*entry) + } + f.index[cleanEntryName(e.header.Name)] = e + f.stream = append(f.stream, e) +} + +func (f *tarFile) remove(name string) { + name = cleanEntryName(name) + if f.index != nil { + delete(f.index, name) + } + var filtered []*entry + for _, e := range f.stream { + if cleanEntryName(e.header.Name) == name { + continue + } + filtered = append(filtered, e) + } + f.stream = filtered +} + +func (f *tarFile) get(name string) (e *entry, ok bool) { + if f.index == nil { + return nil, false + } + e, ok = f.index[cleanEntryName(name)] + return +} + +func (f *tarFile) dump() []*entry { + return f.stream +} + +type readCloser struct { + io.Reader + closeFunc func() error +} + +func (rc readCloser) Close() error { + return rc.closeFunc() +} + +func fileSectionReader(file *os.File) (*io.SectionReader, error) { + info, err := file.Stat() + if err != nil { + return nil, err + } + return io.NewSectionReader(file, 0, info.Size()), nil +} + +func newTempFiles() *tempFiles { + return &tempFiles{} +} + +type tempFiles struct { + files []*os.File + filesMu sync.Mutex + cleanupOnce sync.Once +} + +func (tf *tempFiles) TempFile(dir, pattern string) (*os.File, error) { + f, err := os.CreateTemp(dir, pattern) + if err != nil { + return nil, err + } + tf.filesMu.Lock() + tf.files = append(tf.files, f) + tf.filesMu.Unlock() + return f, nil +} + +func (tf *tempFiles) CleanupAll() (err error) { + tf.cleanupOnce.Do(func() { + err = tf.cleanupAll() + }) + return +} + +func (tf *tempFiles) cleanupAll() error { + tf.filesMu.Lock() + defer tf.filesMu.Unlock() + var allErr []error + for _, f := range tf.files { + if err := f.Close(); err != nil { + allErr = append(allErr, err) + } + if err := os.Remove(f.Name()); err != nil { + allErr = append(allErr, err) + } + } + tf.files = nil + return errorutil.Aggregate(allErr) +} + +func newCountReadSeeker(r io.ReaderAt) (*countReadSeeker, error) { + pos := int64(0) + return &countReadSeeker{r: r, cPos: &pos}, nil +} + +type countReadSeeker struct { + r io.ReaderAt + cPos *int64 + + mu sync.Mutex +} + +func (cr *countReadSeeker) Read(p []byte) (int, error) { + cr.mu.Lock() + defer cr.mu.Unlock() + + n, err := cr.r.ReadAt(p, *cr.cPos) + if err == nil { + *cr.cPos += int64(n) + } + return n, err +} + +func (cr *countReadSeeker) Seek(offset int64, whence int) (int64, error) { + cr.mu.Lock() + defer cr.mu.Unlock() + + switch whence { + default: + return 0, fmt.Errorf("Unknown whence: %v", whence) + case io.SeekStart: + case io.SeekCurrent: + offset += *cr.cPos + case io.SeekEnd: + return 0, fmt.Errorf("Unsupported whence: %v", whence) + } + + if offset < 0 { + return 0, fmt.Errorf("invalid offset") + } + *cr.cPos = offset + return offset, nil +} + +func (cr *countReadSeeker) currentPos() int64 { + cr.mu.Lock() + defer cr.mu.Unlock() + + return *cr.cPos +} + +func decompressBlob(org *io.SectionReader, tmp *tempFiles) (*io.SectionReader, error) { + if org.Size() < 4 { + return org, nil + } + src := make([]byte, 4) + if _, err := org.Read(src); err != nil && err != io.EOF { + return nil, err + } + var dR io.Reader + if bytes.Equal([]byte{0x1F, 0x8B, 0x08}, src[:3]) { + // gzip + dgR, err := gzip.NewReader(io.NewSectionReader(org, 0, org.Size())) + if err != nil { + return nil, err + } + defer dgR.Close() + dR = io.Reader(dgR) + } else if bytes.Equal([]byte{0x28, 0xb5, 0x2f, 0xfd}, src[:4]) { + // zstd + dzR, err := zstd.NewReader(io.NewSectionReader(org, 0, org.Size())) + if err != nil { + return nil, err + } + defer dzR.Close() + dR = io.Reader(dzR) + } else { + // uncompressed + return io.NewSectionReader(org, 0, org.Size()), nil + } + b, err := tmp.TempFile("", "uncompresseddata") + if err != nil { + return nil, err + } + if _, err := io.Copy(b, dR); err != nil { + return nil, err + } + return fileSectionReader(b) +} diff --git a/vendor/github.com/containerd/stargz-snapshotter/estargz/errorutil/errors.go b/vendor/github.com/containerd/stargz-snapshotter/estargz/errorutil/errors.go new file mode 100644 index 000000000..6de78b02d --- /dev/null +++ b/vendor/github.com/containerd/stargz-snapshotter/estargz/errorutil/errors.go @@ -0,0 +1,40 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package errorutil + +import ( + "errors" + "fmt" + "strings" +) + +// Aggregate combines a list of errors into a single new error. +func Aggregate(errs []error) error { + switch len(errs) { + case 0: + return nil + case 1: + return errs[0] + default: + points := make([]string, len(errs)+1) + points[0] = fmt.Sprintf("%d error(s) occurred:", len(errs)) + for i, err := range errs { + points[i+1] = fmt.Sprintf("* %s", err) + } + return errors.New(strings.Join(points, "\n\t")) + } +} diff --git a/vendor/github.com/containerd/stargz-snapshotter/estargz/estargz.go b/vendor/github.com/containerd/stargz-snapshotter/estargz/estargz.go new file mode 100644 index 000000000..f4d554655 --- /dev/null +++ b/vendor/github.com/containerd/stargz-snapshotter/estargz/estargz.go @@ -0,0 +1,1223 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + Copyright 2019 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 estargz + +import ( + "bufio" + "bytes" + "compress/gzip" + "crypto/sha256" + "errors" + "fmt" + "hash" + "io" + "os" + "path" + "sort" + "strings" + "sync" + "time" + + "github.com/containerd/stargz-snapshotter/estargz/errorutil" + digest "github.com/opencontainers/go-digest" + "github.com/vbatts/tar-split/archive/tar" +) + +// A Reader permits random access reads from a stargz file. +type Reader struct { + sr *io.SectionReader + toc *JTOC + tocDigest digest.Digest + + // m stores all non-chunk entries, keyed by name. + m map[string]*TOCEntry + + // chunks stores all TOCEntry values for regular files that + // are split up. For a file with a single chunk, it's only + // stored in m. + chunks map[string][]*TOCEntry + + decompressor Decompressor +} + +type openOpts struct { + tocOffset int64 + decompressors []Decompressor + telemetry *Telemetry +} + +// OpenOption is an option used during opening the layer +type OpenOption func(o *openOpts) error + +// WithTOCOffset option specifies the offset of TOC +func WithTOCOffset(tocOffset int64) OpenOption { + return func(o *openOpts) error { + o.tocOffset = tocOffset + return nil + } +} + +// WithDecompressors option specifies decompressors to use. +// Default is gzip-based decompressor. +func WithDecompressors(decompressors ...Decompressor) OpenOption { + return func(o *openOpts) error { + o.decompressors = decompressors + return nil + } +} + +// WithTelemetry option specifies the telemetry hooks +func WithTelemetry(telemetry *Telemetry) OpenOption { + return func(o *openOpts) error { + o.telemetry = telemetry + return nil + } +} + +// MeasureLatencyHook is a func which takes start time and records the diff +type MeasureLatencyHook func(time.Time) + +// Telemetry is a struct which defines telemetry hooks. By implementing these hooks you should be able to record +// the latency metrics of the respective steps of estargz open operation. To be used with estargz.OpenWithTelemetry(...) +type Telemetry struct { + GetFooterLatency MeasureLatencyHook // measure time to get stargz footer (in milliseconds) + GetTocLatency MeasureLatencyHook // measure time to GET TOC JSON (in milliseconds) + DeserializeTocLatency MeasureLatencyHook // measure time to deserialize TOC JSON (in milliseconds) +} + +// Open opens a stargz file for reading. +// The behavior is configurable using options. +// +// Note that each entry name is normalized as the path that is relative to root. +func Open(sr *io.SectionReader, opt ...OpenOption) (*Reader, error) { + var opts openOpts + for _, o := range opt { + if err := o(&opts); err != nil { + return nil, err + } + } + + gzipCompressors := []Decompressor{new(GzipDecompressor), new(LegacyGzipDecompressor)} + decompressors := append(gzipCompressors, opts.decompressors...) + + // Determine the size to fetch. Try to fetch as many bytes as possible. + fetchSize := maxFooterSize(sr.Size(), decompressors...) + if maybeTocOffset := opts.tocOffset; maybeTocOffset > fetchSize { + if maybeTocOffset > sr.Size() { + return nil, fmt.Errorf("blob size %d is smaller than the toc offset", sr.Size()) + } + fetchSize = sr.Size() - maybeTocOffset + } + + start := time.Now() // before getting layer footer + footer := make([]byte, fetchSize) + if _, err := sr.ReadAt(footer, sr.Size()-fetchSize); err != nil { + return nil, fmt.Errorf("error reading footer: %v", err) + } + if opts.telemetry != nil && opts.telemetry.GetFooterLatency != nil { + opts.telemetry.GetFooterLatency(start) + } + + var allErr []error + var found bool + var r *Reader + for _, d := range decompressors { + fSize := d.FooterSize() + fOffset := positive(int64(len(footer)) - fSize) + maybeTocBytes := footer[:fOffset] + _, tocOffset, tocSize, err := d.ParseFooter(footer[fOffset:]) + if err != nil { + allErr = append(allErr, err) + continue + } + if tocOffset >= 0 && tocSize <= 0 { + tocSize = sr.Size() - tocOffset - fSize + } + if tocOffset >= 0 && tocSize < int64(len(maybeTocBytes)) { + maybeTocBytes = maybeTocBytes[:tocSize] + } + r, err = parseTOC(d, sr, tocOffset, tocSize, maybeTocBytes, opts) + if err == nil { + found = true + break + } + allErr = append(allErr, err) + } + if !found { + return nil, errorutil.Aggregate(allErr) + } + if err := r.initFields(); err != nil { + return nil, fmt.Errorf("failed to initialize fields of entries: %v", err) + } + return r, nil +} + +// OpenFooter extracts and parses footer from the given blob. +// only supports gzip-based eStargz. +func OpenFooter(sr *io.SectionReader) (tocOffset int64, footerSize int64, rErr error) { + if sr.Size() < FooterSize && sr.Size() < legacyFooterSize { + return 0, 0, fmt.Errorf("blob size %d is smaller than the footer size", sr.Size()) + } + var footer [FooterSize]byte + if _, err := sr.ReadAt(footer[:], sr.Size()-FooterSize); err != nil { + return 0, 0, fmt.Errorf("error reading footer: %v", err) + } + var allErr []error + for _, d := range []Decompressor{new(GzipDecompressor), new(LegacyGzipDecompressor)} { + fSize := d.FooterSize() + fOffset := positive(int64(len(footer)) - fSize) + _, tocOffset, _, err := d.ParseFooter(footer[fOffset:]) + if err == nil { + return tocOffset, fSize, err + } + allErr = append(allErr, err) + } + return 0, 0, errorutil.Aggregate(allErr) +} + +// initFields populates the Reader from r.toc after decoding it from +// JSON. +// +// Unexported fields are populated and TOCEntry fields that were +// implicit in the JSON are populated. +func (r *Reader) initFields() error { + r.m = make(map[string]*TOCEntry, len(r.toc.Entries)) + r.chunks = make(map[string][]*TOCEntry) + var lastPath string + uname := map[int]string{} + gname := map[int]string{} + var lastRegEnt *TOCEntry + var chunkTopIndex int + for i, ent := range r.toc.Entries { + ent.Name = cleanEntryName(ent.Name) + switch ent.Type { + case "reg", "chunk": + if ent.Offset != r.toc.Entries[chunkTopIndex].Offset { + chunkTopIndex = i + } + ent.chunkTopIndex = chunkTopIndex + } + if ent.Type == "reg" { + lastRegEnt = ent + } + if ent.Type == "chunk" { + ent.Name = lastPath + r.chunks[ent.Name] = append(r.chunks[ent.Name], ent) + if ent.ChunkSize == 0 && lastRegEnt != nil { + ent.ChunkSize = lastRegEnt.Size - ent.ChunkOffset + } + } else { + lastPath = ent.Name + + if ent.Uname != "" { + uname[ent.UID] = ent.Uname + } else { + ent.Uname = uname[ent.UID] + } + if ent.Gname != "" { + gname[ent.GID] = ent.Gname + } else { + ent.Gname = uname[ent.GID] + } + + ent.modTime, _ = time.Parse(time.RFC3339, ent.ModTime3339) + + if ent.Type == "dir" { + ent.NumLink++ // Parent dir links to this directory + } + r.m[ent.Name] = ent + } + if ent.Type == "reg" && ent.ChunkSize > 0 && ent.ChunkSize < ent.Size { + r.chunks[ent.Name] = make([]*TOCEntry, 0, ent.Size/ent.ChunkSize+1) + r.chunks[ent.Name] = append(r.chunks[ent.Name], ent) + } + if ent.ChunkSize == 0 && ent.Size != 0 { + ent.ChunkSize = ent.Size + } + } + + // Populate children, add implicit directories: + for _, ent := range r.toc.Entries { + if ent.Type == "chunk" { + continue + } + // add "foo/": + // add "foo" child to "" (creating "" if necessary) + // + // add "foo/bar/": + // add "bar" child to "foo" (creating "foo" if necessary) + // + // add "foo/bar.txt": + // add "bar.txt" child to "foo" (creating "foo" if necessary) + // + // add "a/b/c/d/e/f.txt": + // create "a/b/c/d/e" node + // add "f.txt" child to "e" + + name := ent.Name + pdirName := parentDir(name) + if name == pdirName { + // This entry and its parent are the same. + // Ignore this for avoiding infinite loop of the reference. + // The example case where this can occur is when tar contains the root + // directory itself (e.g. "./", "/"). + continue + } + pdir := r.getOrCreateDir(pdirName) + ent.NumLink++ // at least one name(ent.Name) references this entry. + if ent.Type == "hardlink" { + org, err := r.getSource(ent) + if err != nil { + return err + } + org.NumLink++ // original entry is referenced by this ent.Name. + ent = org + } + pdir.addChild(path.Base(name), ent) + } + + lastOffset := r.sr.Size() + for i := len(r.toc.Entries) - 1; i >= 0; i-- { + e := r.toc.Entries[i] + if e.isDataType() { + e.nextOffset = lastOffset + } + if e.Offset != 0 && e.InnerOffset == 0 { + lastOffset = e.Offset + } + } + + return nil +} + +func (r *Reader) getSource(ent *TOCEntry) (_ *TOCEntry, err error) { + if ent.Type == "hardlink" { + org, ok := r.m[cleanEntryName(ent.LinkName)] + if !ok { + return nil, fmt.Errorf("%q is a hardlink but the linkname %q isn't found", ent.Name, ent.LinkName) + } + ent, err = r.getSource(org) + if err != nil { + return nil, err + } + } + return ent, nil +} + +func parentDir(p string) string { + dir, _ := path.Split(p) + return strings.TrimSuffix(dir, "/") +} + +func (r *Reader) getOrCreateDir(d string) *TOCEntry { + e, ok := r.m[d] + if !ok { + e = &TOCEntry{ + Name: d, + Type: "dir", + Mode: 0755, + NumLink: 2, // The directory itself(.) and the parent link to this directory. + } + r.m[d] = e + if d != "" { + pdir := r.getOrCreateDir(parentDir(d)) + pdir.addChild(path.Base(d), e) + } + } + return e +} + +func (r *Reader) TOCDigest() digest.Digest { + return r.tocDigest +} + +// VerifyTOC checks that the TOC JSON in the passed blob matches the +// passed digests and that the TOC JSON contains digests for all chunks +// contained in the blob. If the verification succceeds, this function +// returns TOCEntryVerifier which holds all chunk digests in the stargz blob. +func (r *Reader) VerifyTOC(tocDigest digest.Digest) (TOCEntryVerifier, error) { + // Verify the digest of TOC JSON + if r.tocDigest != tocDigest { + return nil, fmt.Errorf("invalid TOC JSON %q; want %q", r.tocDigest, tocDigest) + } + return r.Verifiers() +} + +// Verifiers returns TOCEntryVerifier of this chunk. Use VerifyTOC instead in most cases +// because this doesn't verify TOC. +func (r *Reader) Verifiers() (TOCEntryVerifier, error) { + chunkDigestMap := make(map[int64]digest.Digest) // map from chunk offset to the chunk digest + regDigestMap := make(map[int64]digest.Digest) // map from chunk offset to the reg file digest + var chunkDigestMapIncomplete bool + var regDigestMapIncomplete bool + var containsChunk bool + for _, e := range r.toc.Entries { + if e.Type != "reg" && e.Type != "chunk" { + continue + } + + // offset must be unique in stargz blob + _, dOK := chunkDigestMap[e.Offset] + _, rOK := regDigestMap[e.Offset] + if dOK || rOK { + return nil, fmt.Errorf("offset %d found twice", e.Offset) + } + + if e.Type == "reg" { + if e.Size == 0 { + continue // ignores empty file + } + + // record the digest of regular file payload + if e.Digest != "" { + d, err := digest.Parse(e.Digest) + if err != nil { + return nil, fmt.Errorf("failed to parse regular file digest %q: %w", e.Digest, err) + } + regDigestMap[e.Offset] = d + } else { + regDigestMapIncomplete = true + } + } else { + containsChunk = true // this layer contains "chunk" entries. + } + + // "reg" also can contain ChunkDigest (e.g. when "reg" is the first entry of + // chunked file) + if e.ChunkDigest != "" { + d, err := digest.Parse(e.ChunkDigest) + if err != nil { + return nil, fmt.Errorf("failed to parse chunk digest %q: %w", e.ChunkDigest, err) + } + chunkDigestMap[e.Offset] = d + } else { + chunkDigestMapIncomplete = true + } + } + + if chunkDigestMapIncomplete { + // Though some chunk digests are not found, if this layer doesn't contain + // "chunk"s and all digest of "reg" files are recorded, we can use them instead. + if !containsChunk && !regDigestMapIncomplete { + return &verifier{digestMap: regDigestMap}, nil + } + return nil, fmt.Errorf("some ChunkDigest not found in TOC JSON") + } + + return &verifier{digestMap: chunkDigestMap}, nil +} + +// verifier is an implementation of TOCEntryVerifier which holds verifiers keyed by +// offset of the chunk. +type verifier struct { + digestMap map[int64]digest.Digest + digestMapMu sync.Mutex +} + +// Verifier returns a content verifier specified by TOCEntry. +func (v *verifier) Verifier(ce *TOCEntry) (digest.Verifier, error) { + v.digestMapMu.Lock() + defer v.digestMapMu.Unlock() + d, ok := v.digestMap[ce.Offset] + if !ok { + return nil, fmt.Errorf("verifier for offset=%d,size=%d hasn't been registered", + ce.Offset, ce.ChunkSize) + } + return d.Verifier(), nil +} + +// ChunkEntryForOffset returns the TOCEntry containing the byte of the +// named file at the given offset within the file. +// Name must be absolute path or one that is relative to root. +func (r *Reader) ChunkEntryForOffset(name string, offset int64) (e *TOCEntry, ok bool) { + name = cleanEntryName(name) + e, ok = r.Lookup(name) + if !ok || !e.isDataType() { + return nil, false + } + ents := r.chunks[name] + if len(ents) < 2 { + if offset >= e.ChunkSize { + return nil, false + } + return e, true + } + i := sort.Search(len(ents), func(i int) bool { + e := ents[i] + return e.ChunkOffset >= offset || (offset > e.ChunkOffset && offset < e.ChunkOffset+e.ChunkSize) + }) + if i == len(ents) { + return nil, false + } + return ents[i], true +} + +// Lookup returns the Table of Contents entry for the given path. +// +// To get the root directory, use the empty string. +// Path must be absolute path or one that is relative to root. +func (r *Reader) Lookup(path string) (e *TOCEntry, ok bool) { + path = cleanEntryName(path) + if r == nil { + return + } + e, ok = r.m[path] + if ok && e.Type == "hardlink" { + var err error + e, err = r.getSource(e) + if err != nil { + return nil, false + } + } + return +} + +// OpenFile returns the reader of the specified file payload. +// +// Name must be absolute path or one that is relative to root. +func (r *Reader) OpenFile(name string) (*io.SectionReader, error) { + fr, err := r.newFileReader(name) + if err != nil { + return nil, err + } + return io.NewSectionReader(fr, 0, fr.size), nil +} + +func (r *Reader) newFileReader(name string) (*fileReader, error) { + name = cleanEntryName(name) + ent, ok := r.Lookup(name) + if !ok { + // TODO: come up with some error plan. This is lazy: + return nil, &os.PathError{ + Path: name, + Op: "OpenFile", + Err: os.ErrNotExist, + } + } + if ent.Type != "reg" { + return nil, &os.PathError{ + Path: name, + Op: "OpenFile", + Err: errors.New("not a regular file"), + } + } + return &fileReader{ + r: r, + size: ent.Size, + ents: r.getChunks(ent), + }, nil +} + +func (r *Reader) OpenFileWithPreReader(name string, preRead func(*TOCEntry, io.Reader) error) (*io.SectionReader, error) { + fr, err := r.newFileReader(name) + if err != nil { + return nil, err + } + fr.preRead = preRead + return io.NewSectionReader(fr, 0, fr.size), nil +} + +func (r *Reader) getChunks(ent *TOCEntry) []*TOCEntry { + if ents, ok := r.chunks[ent.Name]; ok { + return ents + } + return []*TOCEntry{ent} +} + +type fileReader struct { + r *Reader + size int64 + ents []*TOCEntry // 1 or more reg/chunk entries + preRead func(*TOCEntry, io.Reader) error +} + +func (fr *fileReader) ReadAt(p []byte, off int64) (n int, err error) { + if off >= fr.size { + return 0, io.EOF + } + if off < 0 { + return 0, errors.New("invalid offset") + } + var i int + if len(fr.ents) > 1 { + i = sort.Search(len(fr.ents), func(i int) bool { + return fr.ents[i].ChunkOffset >= off + }) + if i == len(fr.ents) { + i = len(fr.ents) - 1 + } + } + ent := fr.ents[i] + if ent.ChunkOffset > off { + if i == 0 { + return 0, errors.New("internal error; first chunk offset is non-zero") + } + ent = fr.ents[i-1] + } + + // If ent is a chunk of a large file, adjust the ReadAt + // offset by the chunk's offset. + off -= ent.ChunkOffset + + finalEnt := fr.ents[len(fr.ents)-1] + compressedOff := ent.Offset + // compressedBytesRemain is the number of compressed bytes in this + // file remaining, over 1+ chunks. + compressedBytesRemain := finalEnt.NextOffset() - compressedOff + + sr := io.NewSectionReader(fr.r.sr, compressedOff, compressedBytesRemain) + + const maxRead = 2 << 20 + var bufSize = maxRead + if compressedBytesRemain < maxRead { + bufSize = int(compressedBytesRemain) + } + + br := bufio.NewReaderSize(sr, bufSize) + if _, err := br.Peek(bufSize); err != nil { + return 0, fmt.Errorf("fileReader.ReadAt.peek: %v", err) + } + + dr, err := fr.r.decompressor.Reader(br) + if err != nil { + return 0, fmt.Errorf("fileReader.ReadAt.decompressor.Reader: %v", err) + } + defer dr.Close() + + if fr.preRead == nil { + if n, err := io.CopyN(io.Discard, dr, ent.InnerOffset+off); n != ent.InnerOffset+off || err != nil { + return 0, fmt.Errorf("discard of %d bytes != %v, %v", ent.InnerOffset+off, n, err) + } + return io.ReadFull(dr, p) + } + + var retN int + var retErr error + var found bool + var nr int64 + for _, e := range fr.r.toc.Entries[ent.chunkTopIndex:] { + if !e.isDataType() { + continue + } + if e.Offset != fr.r.toc.Entries[ent.chunkTopIndex].Offset { + break + } + if in, err := io.CopyN(io.Discard, dr, e.InnerOffset-nr); err != nil || in != e.InnerOffset-nr { + return 0, fmt.Errorf("discard of remaining %d bytes != %v, %v", e.InnerOffset-nr, in, err) + } + nr = e.InnerOffset + if e == ent { + found = true + if n, err := io.CopyN(io.Discard, dr, off); n != off || err != nil { + return 0, fmt.Errorf("discard of offset %d bytes != %v, %v", off, n, err) + } + retN, retErr = io.ReadFull(dr, p) + nr += off + int64(retN) + continue + } + cr := &countReader{r: io.LimitReader(dr, e.ChunkSize)} + if err := fr.preRead(e, cr); err != nil { + return 0, fmt.Errorf("failed to pre read: %w", err) + } + nr += cr.n + } + if !found { + return 0, fmt.Errorf("fileReader.ReadAt: target entry not found") + } + return retN, retErr +} + +// A Writer writes stargz files. +// +// Use NewWriter to create a new Writer. +type Writer struct { + bw *bufio.Writer + cw *countWriter + toc *JTOC + diffHash hash.Hash // SHA-256 of uncompressed tar + + closed bool + gz io.WriteCloser + lastUsername map[int]string + lastGroupname map[int]string + compressor Compressor + + uncompressedCounter *countWriteFlusher + + // ChunkSize optionally controls the maximum number of bytes + // of data of a regular file that can be written in one gzip + // stream before a new gzip stream is started. + // Zero means to use a default, currently 4 MiB. + ChunkSize int + + // MinChunkSize optionally controls the minimum number of bytes + // of data must be written in one gzip stream before a new gzip + // NOTE: This adds a TOC property that stargz snapshotter < v0.13.0 doesn't understand. + MinChunkSize int + + needsOpenGzEntries map[string]struct{} +} + +// currentCompressionWriter writes to the current w.gz field, which can +// change throughout writing a tar entry. +// +// Additionally, it updates w's SHA-256 of the uncompressed bytes +// of the tar file. +type currentCompressionWriter struct{ w *Writer } + +func (ccw currentCompressionWriter) Write(p []byte) (int, error) { + ccw.w.diffHash.Write(p) + if ccw.w.gz == nil { + if err := ccw.w.condOpenGz(); err != nil { + return 0, err + } + } + return ccw.w.gz.Write(p) +} + +func (w *Writer) chunkSize() int { + if w.ChunkSize <= 0 { + return 4 << 20 + } + return w.ChunkSize +} + +// Unpack decompresses the given estargz blob and returns a ReadCloser of the tar blob. +// TOC JSON and footer are removed. +func Unpack(sr *io.SectionReader, c Decompressor) (io.ReadCloser, error) { + footerSize := c.FooterSize() + if sr.Size() < footerSize { + return nil, fmt.Errorf("blob is too small; %d < %d", sr.Size(), footerSize) + } + footerOffset := sr.Size() - footerSize + footer := make([]byte, footerSize) + if _, err := sr.ReadAt(footer, footerOffset); err != nil { + return nil, err + } + blobPayloadSize, _, _, err := c.ParseFooter(footer) + if err != nil { + return nil, fmt.Errorf("failed to parse footer: %w", err) + } + if blobPayloadSize < 0 { + blobPayloadSize = sr.Size() + } + return c.Reader(io.LimitReader(sr, blobPayloadSize)) +} + +// NewWriter returns a new stargz writer (gzip-based) writing to w. +// +// The writer must be closed to write its trailing table of contents. +func NewWriter(w io.Writer) *Writer { + return NewWriterLevel(w, gzip.BestCompression) +} + +// NewWriterLevel returns a new stargz writer (gzip-based) writing to w. +// The compression level is configurable. +// +// The writer must be closed to write its trailing table of contents. +func NewWriterLevel(w io.Writer, compressionLevel int) *Writer { + return NewWriterWithCompressor(w, NewGzipCompressorWithLevel(compressionLevel)) +} + +// NewWriterWithCompressor returns a new stargz writer writing to w. +// The compression method is configurable. +// +// The writer must be closed to write its trailing table of contents. +func NewWriterWithCompressor(w io.Writer, c Compressor) *Writer { + bw := bufio.NewWriter(w) + cw := &countWriter{w: bw} + return &Writer{ + bw: bw, + cw: cw, + toc: &JTOC{Version: 1}, + diffHash: sha256.New(), + compressor: c, + uncompressedCounter: &countWriteFlusher{}, + } +} + +// Close writes the stargz's table of contents and flushes all the +// buffers, returning any error. +func (w *Writer) Close() (digest.Digest, error) { + if w.closed { + return "", nil + } + defer func() { w.closed = true }() + + if err := w.closeGz(); err != nil { + return "", err + } + + // Write the TOC index and footer. + tocDigest, err := w.compressor.WriteTOCAndFooter(w.cw, w.cw.n, w.toc, w.diffHash) + if err != nil { + return "", err + } + if err := w.bw.Flush(); err != nil { + return "", err + } + + return tocDigest, nil +} + +func (w *Writer) closeGz() error { + if w.closed { + return errors.New("write on closed Writer") + } + if w.gz != nil { + if err := w.gz.Close(); err != nil { + return err + } + w.gz = nil + } + return nil +} + +func (w *Writer) flushGz() error { + if w.closed { + return errors.New("flush on closed Writer") + } + if w.gz != nil { + if f, ok := w.gz.(interface { + Flush() error + }); ok { + return f.Flush() + } + } + return nil +} + +// nameIfChanged returns name, unless it was the already the value of (*mp)[id], +// in which case it returns the empty string. +func (w *Writer) nameIfChanged(mp *map[int]string, id int, name string) string { + if name == "" { + return "" + } + if *mp == nil { + *mp = make(map[int]string) + } + if (*mp)[id] == name { + return "" + } + (*mp)[id] = name + return name +} + +func (w *Writer) condOpenGz() (err error) { + if w.gz == nil { + w.gz, err = w.compressor.Writer(w.cw) + if w.gz != nil { + w.gz = w.uncompressedCounter.register(w.gz) + } + } + return +} + +// AppendTar reads the tar or tar.gz file from r and appends +// each of its contents to w. +// +// The input r can optionally be gzip compressed but the output will +// always be compressed by the specified compressor. +func (w *Writer) AppendTar(r io.Reader) error { + return w.appendTar(r, false) +} + +// AppendTarLossLess reads the tar or tar.gz file from r and appends +// each of its contents to w. +// +// The input r can optionally be gzip compressed but the output will +// always be compressed by the specified compressor. +// +// The difference of this func with AppendTar is that this writes +// the input tar stream into w without any modification (e.g. to header bytes). +// +// Note that if the input tar stream already contains TOC JSON, this returns +// error because w cannot overwrite the TOC JSON to the one generated by w without +// lossy modification. To avoid this error, if the input stream is known to be stargz/estargz, +// you shoud decompress it and remove TOC JSON in advance. +func (w *Writer) AppendTarLossLess(r io.Reader) error { + return w.appendTar(r, true) +} + +func (w *Writer) appendTar(r io.Reader, lossless bool) error { + var src io.Reader + br := bufio.NewReader(r) + if isGzip(br) { + zr, _ := gzip.NewReader(br) + src = zr + } else { + src = io.Reader(br) + } + dst := currentCompressionWriter{w} + var tw *tar.Writer + if !lossless { + tw = tar.NewWriter(dst) // use tar writer only when this isn't lossless mode. + } + tr := tar.NewReader(src) + if lossless { + tr.RawAccounting = true + } + prevOffset := w.cw.n + var prevOffsetUncompressed int64 + for { + h, err := tr.Next() + if err == io.EOF { + if lossless { + if remain := tr.RawBytes(); len(remain) > 0 { + // Collect the remaining null bytes. + // https://github.com/vbatts/tar-split/blob/80a436fd6164c557b131f7c59ed69bd81af69761/concept/main.go#L49-L53 + if _, err := dst.Write(remain); err != nil { + return err + } + } + } + break + } + if err != nil { + return fmt.Errorf("error reading from source tar: tar.Reader.Next: %v", err) + } + if cleanEntryName(h.Name) == TOCTarName { + // It is possible for a layer to be "stargzified" twice during the + // distribution lifecycle. So we reserve "TOCTarName" here to avoid + // duplicated entries in the resulting layer. + if lossless { + // We cannot handle this in lossless way. + return fmt.Errorf("existing TOC JSON is not allowed; decompress layer before append") + } + continue + } + + xattrs := make(map[string][]byte) + const xattrPAXRecordsPrefix = "SCHILY.xattr." + if h.PAXRecords != nil { + for k, v := range h.PAXRecords { + if strings.HasPrefix(k, xattrPAXRecordsPrefix) { + xattrs[k[len(xattrPAXRecordsPrefix):]] = []byte(v) + } + } + } + ent := &TOCEntry{ + Name: h.Name, + Mode: h.Mode, + UID: h.Uid, + GID: h.Gid, + Uname: w.nameIfChanged(&w.lastUsername, h.Uid, h.Uname), + Gname: w.nameIfChanged(&w.lastGroupname, h.Gid, h.Gname), + ModTime3339: formatModtime(h.ModTime), + Xattrs: xattrs, + } + if err := w.condOpenGz(); err != nil { + return err + } + if tw != nil { + if err := tw.WriteHeader(h); err != nil { + return err + } + } else { + if _, err := dst.Write(tr.RawBytes()); err != nil { + return err + } + } + switch h.Typeflag { + case tar.TypeLink: + ent.Type = "hardlink" + ent.LinkName = h.Linkname + case tar.TypeSymlink: + ent.Type = "symlink" + ent.LinkName = h.Linkname + case tar.TypeDir: + ent.Type = "dir" + case tar.TypeReg: + ent.Type = "reg" + ent.Size = h.Size + case tar.TypeChar: + ent.Type = "char" + ent.DevMajor = int(h.Devmajor) + ent.DevMinor = int(h.Devminor) + case tar.TypeBlock: + ent.Type = "block" + ent.DevMajor = int(h.Devmajor) + ent.DevMinor = int(h.Devminor) + case tar.TypeFifo: + ent.Type = "fifo" + default: + return fmt.Errorf("unsupported input tar entry %q", h.Typeflag) + } + + // We need to keep a reference to the TOC entry for regular files, so that we + // can fill the digest later. + var regFileEntry *TOCEntry + var payloadDigest digest.Digester + if h.Typeflag == tar.TypeReg { + regFileEntry = ent + payloadDigest = digest.Canonical.Digester() + } + + if h.Typeflag == tar.TypeReg && ent.Size > 0 { + var written int64 + totalSize := ent.Size // save it before we destroy ent + tee := io.TeeReader(tr, payloadDigest.Hash()) + for written < totalSize { + chunkSize := int64(w.chunkSize()) + remain := totalSize - written + if remain < chunkSize { + chunkSize = remain + } else { + ent.ChunkSize = chunkSize + } + + // We flush the underlying compression writer here to correctly calculate "w.cw.n". + if err := w.flushGz(); err != nil { + return err + } + if w.needsOpenGz(ent) || w.cw.n-prevOffset >= int64(w.MinChunkSize) { + if err := w.closeGz(); err != nil { + return err + } + ent.Offset = w.cw.n + prevOffset = ent.Offset + prevOffsetUncompressed = w.uncompressedCounter.n + } else { + ent.Offset = prevOffset + ent.InnerOffset = w.uncompressedCounter.n - prevOffsetUncompressed + } + + ent.ChunkOffset = written + chunkDigest := digest.Canonical.Digester() + + if err := w.condOpenGz(); err != nil { + return err + } + + teeChunk := io.TeeReader(tee, chunkDigest.Hash()) + var out io.Writer + if tw != nil { + out = tw + } else { + out = dst + } + if _, err := io.CopyN(out, teeChunk, chunkSize); err != nil { + return fmt.Errorf("error copying %q: %v", h.Name, err) + } + ent.ChunkDigest = chunkDigest.Digest().String() + w.toc.Entries = append(w.toc.Entries, ent) + written += chunkSize + ent = &TOCEntry{ + Name: h.Name, + Type: "chunk", + } + } + } else { + w.toc.Entries = append(w.toc.Entries, ent) + } + if payloadDigest != nil { + regFileEntry.Digest = payloadDigest.Digest().String() + } + if tw != nil { + if err := tw.Flush(); err != nil { + return err + } + } + } + remainDest := io.Discard + if lossless { + remainDest = dst // Preserve the remaining bytes in lossless mode + } + _, err := io.Copy(remainDest, src) + return err +} + +func (w *Writer) needsOpenGz(ent *TOCEntry) bool { + if ent.Type != "reg" { + return false + } + if w.needsOpenGzEntries == nil { + return false + } + _, ok := w.needsOpenGzEntries[ent.Name] + return ok +} + +// DiffID returns the SHA-256 of the uncompressed tar bytes. +// It is only valid to call DiffID after Close. +func (w *Writer) DiffID() string { + return fmt.Sprintf("sha256:%x", w.diffHash.Sum(nil)) +} + +func maxFooterSize(blobSize int64, decompressors ...Decompressor) (res int64) { + for _, d := range decompressors { + if s := d.FooterSize(); res < s && s <= blobSize { + res = s + } + } + return +} + +func parseTOC(d Decompressor, sr *io.SectionReader, tocOff, tocSize int64, tocBytes []byte, opts openOpts) (*Reader, error) { + if tocOff < 0 { + // This means that TOC isn't contained in the blob. + // We pass nil reader to ParseTOC and expect that ParseTOC acquire TOC from + // the external location. + start := time.Now() + toc, tocDgst, err := d.ParseTOC(nil) + if err != nil { + return nil, err + } + if opts.telemetry != nil && opts.telemetry.GetTocLatency != nil { + opts.telemetry.GetTocLatency(start) + } + if opts.telemetry != nil && opts.telemetry.DeserializeTocLatency != nil { + opts.telemetry.DeserializeTocLatency(start) + } + return &Reader{ + sr: sr, + toc: toc, + tocDigest: tocDgst, + decompressor: d, + }, nil + } + if len(tocBytes) > 0 { + start := time.Now() + toc, tocDgst, err := d.ParseTOC(bytes.NewReader(tocBytes)) + if err == nil { + if opts.telemetry != nil && opts.telemetry.DeserializeTocLatency != nil { + opts.telemetry.DeserializeTocLatency(start) + } + return &Reader{ + sr: sr, + toc: toc, + tocDigest: tocDgst, + decompressor: d, + }, nil + } + } + + start := time.Now() + tocBytes = make([]byte, tocSize) + if _, err := sr.ReadAt(tocBytes, tocOff); err != nil { + return nil, fmt.Errorf("error reading %d byte TOC targz: %v", len(tocBytes), err) + } + if opts.telemetry != nil && opts.telemetry.GetTocLatency != nil { + opts.telemetry.GetTocLatency(start) + } + start = time.Now() + toc, tocDgst, err := d.ParseTOC(bytes.NewReader(tocBytes)) + if err != nil { + return nil, err + } + if opts.telemetry != nil && opts.telemetry.DeserializeTocLatency != nil { + opts.telemetry.DeserializeTocLatency(start) + } + return &Reader{ + sr: sr, + toc: toc, + tocDigest: tocDgst, + decompressor: d, + }, nil +} + +func formatModtime(t time.Time) string { + if t.IsZero() || t.Unix() == 0 { + return "" + } + return t.UTC().Round(time.Second).Format(time.RFC3339) +} + +func cleanEntryName(name string) string { + // Use path.Clean to consistently deal with path separators across platforms. + return strings.TrimPrefix(path.Clean("/"+name), "/") +} + +// countWriter counts how many bytes have been written to its wrapped +// io.Writer. +type countWriter struct { + w io.Writer + n int64 +} + +func (cw *countWriter) Write(p []byte) (n int, err error) { + n, err = cw.w.Write(p) + cw.n += int64(n) + return +} + +type countWriteFlusher struct { + io.WriteCloser + n int64 +} + +func (wc *countWriteFlusher) register(w io.WriteCloser) io.WriteCloser { + wc.WriteCloser = w + return wc +} + +func (wc *countWriteFlusher) Write(p []byte) (n int, err error) { + n, err = wc.WriteCloser.Write(p) + wc.n += int64(n) + return +} + +func (wc *countWriteFlusher) Flush() error { + if f, ok := wc.WriteCloser.(interface { + Flush() error + }); ok { + return f.Flush() + } + return nil +} + +func (wc *countWriteFlusher) Close() error { + err := wc.WriteCloser.Close() + wc.WriteCloser = nil + return err +} + +// isGzip reports whether br is positioned right before an upcoming gzip stream. +// It does not consume any bytes from br. +func isGzip(br *bufio.Reader) bool { + const ( + gzipID1 = 0x1f + gzipID2 = 0x8b + gzipDeflate = 8 + ) + peek, _ := br.Peek(3) + return len(peek) >= 3 && peek[0] == gzipID1 && peek[1] == gzipID2 && peek[2] == gzipDeflate +} + +func positive(n int64) int64 { + if n < 0 { + return 0 + } + return n +} + +type countReader struct { + r io.Reader + n int64 +} + +func (cr *countReader) Read(p []byte) (n int, err error) { + n, err = cr.r.Read(p) + cr.n += int64(n) + return +} diff --git a/vendor/github.com/containerd/stargz-snapshotter/estargz/gzip.go b/vendor/github.com/containerd/stargz-snapshotter/estargz/gzip.go new file mode 100644 index 000000000..f24afe32f --- /dev/null +++ b/vendor/github.com/containerd/stargz-snapshotter/estargz/gzip.go @@ -0,0 +1,237 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + Copyright 2019 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 estargz + +import ( + "archive/tar" + "bytes" + "compress/gzip" + "encoding/binary" + "encoding/json" + "fmt" + "hash" + "io" + "strconv" + + digest "github.com/opencontainers/go-digest" +) + +type gzipCompression struct { + *GzipCompressor + *GzipDecompressor +} + +func newGzipCompressionWithLevel(level int) Compression { + return &gzipCompression{ + &GzipCompressor{level}, + &GzipDecompressor{}, + } +} + +func NewGzipCompressor() *GzipCompressor { + return &GzipCompressor{gzip.BestCompression} +} + +func NewGzipCompressorWithLevel(level int) *GzipCompressor { + return &GzipCompressor{level} +} + +type GzipCompressor struct { + compressionLevel int +} + +func (gc *GzipCompressor) Writer(w io.Writer) (WriteFlushCloser, error) { + return gzip.NewWriterLevel(w, gc.compressionLevel) +} + +func (gc *GzipCompressor) WriteTOCAndFooter(w io.Writer, off int64, toc *JTOC, diffHash hash.Hash) (digest.Digest, error) { + tocJSON, err := json.MarshalIndent(toc, "", "\t") + if err != nil { + return "", err + } + gz, _ := gzip.NewWriterLevel(w, gc.compressionLevel) + gw := io.Writer(gz) + if diffHash != nil { + gw = io.MultiWriter(gz, diffHash) + } + tw := tar.NewWriter(gw) + if err := tw.WriteHeader(&tar.Header{ + Typeflag: tar.TypeReg, + Name: TOCTarName, + Size: int64(len(tocJSON)), + }); err != nil { + return "", err + } + if _, err := tw.Write(tocJSON); err != nil { + return "", err + } + + if err := tw.Close(); err != nil { + return "", err + } + if err := gz.Close(); err != nil { + return "", err + } + if _, err := w.Write(gzipFooterBytes(off)); err != nil { + return "", err + } + return digest.FromBytes(tocJSON), nil +} + +// gzipFooterBytes returns the 51 bytes footer. +func gzipFooterBytes(tocOff int64) []byte { + buf := bytes.NewBuffer(make([]byte, 0, FooterSize)) + gz, _ := gzip.NewWriterLevel(buf, gzip.NoCompression) // MUST be NoCompression to keep 51 bytes + + // Extra header indicating the offset of TOCJSON + // https://tools.ietf.org/html/rfc1952#section-2.3.1.1 + header := make([]byte, 4) + header[0], header[1] = 'S', 'G' + subfield := fmt.Sprintf("%016xSTARGZ", tocOff) + binary.LittleEndian.PutUint16(header[2:4], uint16(len(subfield))) // little-endian per RFC1952 + gz.Header.Extra = append(header, []byte(subfield)...) + gz.Close() + if buf.Len() != FooterSize { + panic(fmt.Sprintf("footer buffer = %d, not %d", buf.Len(), FooterSize)) + } + return buf.Bytes() +} + +type GzipDecompressor struct{} + +func (gz *GzipDecompressor) Reader(r io.Reader) (io.ReadCloser, error) { + return gzip.NewReader(r) +} + +func (gz *GzipDecompressor) ParseTOC(r io.Reader) (toc *JTOC, tocDgst digest.Digest, err error) { + return parseTOCEStargz(r) +} + +func (gz *GzipDecompressor) ParseFooter(p []byte) (blobPayloadSize, tocOffset, tocSize int64, err error) { + if len(p) != FooterSize { + return 0, 0, 0, fmt.Errorf("invalid length %d cannot be parsed", len(p)) + } + zr, err := gzip.NewReader(bytes.NewReader(p)) + if err != nil { + return 0, 0, 0, err + } + defer zr.Close() + extra := zr.Header.Extra + si1, si2, subfieldlen, subfield := extra[0], extra[1], extra[2:4], extra[4:] + if si1 != 'S' || si2 != 'G' { + return 0, 0, 0, fmt.Errorf("invalid subfield IDs: %q, %q; want E, S", si1, si2) + } + if slen := binary.LittleEndian.Uint16(subfieldlen); slen != uint16(16+len("STARGZ")) { + return 0, 0, 0, fmt.Errorf("invalid length of subfield %d; want %d", slen, 16+len("STARGZ")) + } + if string(subfield[16:]) != "STARGZ" { + return 0, 0, 0, fmt.Errorf("STARGZ magic string must be included in the footer subfield") + } + tocOffset, err = strconv.ParseInt(string(subfield[:16]), 16, 64) + if err != nil { + return 0, 0, 0, fmt.Errorf("legacy: failed to parse toc offset: %w", err) + } + return tocOffset, tocOffset, 0, nil +} + +func (gz *GzipDecompressor) FooterSize() int64 { + return FooterSize +} + +func (gz *GzipDecompressor) DecompressTOC(r io.Reader) (tocJSON io.ReadCloser, err error) { + return decompressTOCEStargz(r) +} + +type LegacyGzipDecompressor struct{} + +func (gz *LegacyGzipDecompressor) Reader(r io.Reader) (io.ReadCloser, error) { + return gzip.NewReader(r) +} + +func (gz *LegacyGzipDecompressor) ParseTOC(r io.Reader) (toc *JTOC, tocDgst digest.Digest, err error) { + return parseTOCEStargz(r) +} + +func (gz *LegacyGzipDecompressor) ParseFooter(p []byte) (blobPayloadSize, tocOffset, tocSize int64, err error) { + if len(p) != legacyFooterSize { + return 0, 0, 0, fmt.Errorf("legacy: invalid length %d cannot be parsed", len(p)) + } + zr, err := gzip.NewReader(bytes.NewReader(p)) + if err != nil { + return 0, 0, 0, fmt.Errorf("legacy: failed to get footer gzip reader: %w", err) + } + defer zr.Close() + extra := zr.Header.Extra + if len(extra) != 16+len("STARGZ") { + return 0, 0, 0, fmt.Errorf("legacy: invalid stargz's extra field size") + } + if string(extra[16:]) != "STARGZ" { + return 0, 0, 0, fmt.Errorf("legacy: magic string STARGZ not found") + } + tocOffset, err = strconv.ParseInt(string(extra[:16]), 16, 64) + if err != nil { + return 0, 0, 0, fmt.Errorf("legacy: failed to parse toc offset: %w", err) + } + return tocOffset, tocOffset, 0, nil +} + +func (gz *LegacyGzipDecompressor) FooterSize() int64 { + return legacyFooterSize +} + +func (gz *LegacyGzipDecompressor) DecompressTOC(r io.Reader) (tocJSON io.ReadCloser, err error) { + return decompressTOCEStargz(r) +} + +func parseTOCEStargz(r io.Reader) (toc *JTOC, tocDgst digest.Digest, err error) { + tr, err := decompressTOCEStargz(r) + if err != nil { + return nil, "", err + } + dgstr := digest.Canonical.Digester() + toc = new(JTOC) + if err := json.NewDecoder(io.TeeReader(tr, dgstr.Hash())).Decode(&toc); err != nil { + return nil, "", fmt.Errorf("error decoding TOC JSON: %v", err) + } + if err := tr.Close(); err != nil { + return nil, "", err + } + return toc, dgstr.Digest(), nil +} + +func decompressTOCEStargz(r io.Reader) (tocJSON io.ReadCloser, err error) { + zr, err := gzip.NewReader(r) + if err != nil { + return nil, fmt.Errorf("malformed TOC gzip header: %v", err) + } + zr.Multistream(false) + tr := tar.NewReader(zr) + h, err := tr.Next() + if err != nil { + return nil, fmt.Errorf("failed to find tar header in TOC gzip stream: %v", err) + } + if h.Name != TOCTarName { + return nil, fmt.Errorf("TOC tar entry had name %q; expected %q", h.Name, TOCTarName) + } + return readCloser{tr, zr.Close}, nil +} diff --git a/vendor/github.com/containerd/stargz-snapshotter/estargz/testutil.go b/vendor/github.com/containerd/stargz-snapshotter/estargz/testutil.go new file mode 100644 index 000000000..0ca6fd75f --- /dev/null +++ b/vendor/github.com/containerd/stargz-snapshotter/estargz/testutil.go @@ -0,0 +1,2366 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + Copyright 2019 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 estargz + +import ( + "archive/tar" + "bytes" + "compress/gzip" + "crypto/sha256" + "encoding/json" + "errors" + "fmt" + "io" + "math/rand" + "os" + "path/filepath" + "reflect" + "sort" + "strings" + "testing" + "time" + + "github.com/containerd/stargz-snapshotter/estargz/errorutil" + "github.com/klauspost/compress/zstd" + digest "github.com/opencontainers/go-digest" +) + +func init() { + rand.Seed(time.Now().UnixNano()) +} + +// TestingController is Compression with some helper methods necessary for testing. +type TestingController interface { + Compression + TestStreams(t *testing.T, b []byte, streams []int64) + DiffIDOf(*testing.T, []byte) string + String() string +} + +// CompressionTestSuite tests this pkg with controllers can build valid eStargz blobs and parse them. +func CompressionTestSuite(t *testing.T, controllers ...TestingControllerFactory) { + t.Run("testBuild", func(t *testing.T) { t.Parallel(); testBuild(t, controllers...) }) + t.Run("testDigestAndVerify", func(t *testing.T) { t.Parallel(); testDigestAndVerify(t, controllers...) }) + t.Run("testWriteAndOpen", func(t *testing.T) { t.Parallel(); testWriteAndOpen(t, controllers...) }) +} + +type TestingControllerFactory func() TestingController + +const ( + uncompressedType int = iota + gzipType + zstdType +) + +var srcCompressions = []int{ + uncompressedType, + gzipType, + zstdType, +} + +var allowedPrefix = [4]string{"", "./", "/", "../"} + +// testBuild tests the resulting stargz blob built by this pkg has the same +// contents as the normal stargz blob. +func testBuild(t *testing.T, controllers ...TestingControllerFactory) { + tests := []struct { + name string + chunkSize int + minChunkSize []int + in []tarEntry + }{ + { + name: "regfiles and directories", + chunkSize: 4, + in: tarOf( + file("foo", "test1"), + dir("foo2/"), + file("foo2/bar", "test2", xAttr(map[string]string{"test": "sample"})), + ), + }, + { + name: "empty files", + chunkSize: 4, + in: tarOf( + file("foo", "tttttt"), + file("foo_empty", ""), + file("foo2", "tttttt"), + file("foo_empty2", ""), + file("foo3", "tttttt"), + file("foo_empty3", ""), + file("foo4", "tttttt"), + file("foo_empty4", ""), + file("foo5", "tttttt"), + file("foo_empty5", ""), + file("foo6", "tttttt"), + ), + }, + { + name: "various files", + chunkSize: 4, + minChunkSize: []int{0, 64000}, + in: tarOf( + file("baz.txt", "bazbazbazbazbazbazbaz"), + file("foo1.txt", "a"), + file("bar/foo2.txt", "b"), + file("foo3.txt", "c"), + symlink("barlink", "test/bar.txt"), + dir("test/"), + dir("dev/"), + blockdev("dev/testblock", 3, 4), + fifo("dev/testfifo"), + chardev("dev/testchar1", 5, 6), + file("test/bar.txt", "testbartestbar", xAttr(map[string]string{"test2": "sample2"})), + dir("test2/"), + link("test2/bazlink", "baz.txt"), + chardev("dev/testchar2", 1, 2), + ), + }, + { + name: "no contents", + chunkSize: 4, + in: tarOf( + file("baz.txt", ""), + symlink("barlink", "test/bar.txt"), + dir("test/"), + dir("dev/"), + blockdev("dev/testblock", 3, 4), + fifo("dev/testfifo"), + chardev("dev/testchar1", 5, 6), + file("test/bar.txt", "", xAttr(map[string]string{"test2": "sample2"})), + dir("test2/"), + link("test2/bazlink", "baz.txt"), + chardev("dev/testchar2", 1, 2), + ), + }, + } + for _, tt := range tests { + if len(tt.minChunkSize) == 0 { + tt.minChunkSize = []int{0} + } + for _, srcCompression := range srcCompressions { + srcCompression := srcCompression + for _, newCL := range controllers { + newCL := newCL + for _, srcTarFormat := range []tar.Format{tar.FormatUSTAR, tar.FormatPAX, tar.FormatGNU} { + srcTarFormat := srcTarFormat + for _, prefix := range allowedPrefix { + prefix := prefix + for _, minChunkSize := range tt.minChunkSize { + minChunkSize := minChunkSize + t.Run(tt.name+"-"+fmt.Sprintf("compression=%v,prefix=%q,src=%d,format=%s,minChunkSize=%d", newCL(), prefix, srcCompression, srcTarFormat, minChunkSize), func(t *testing.T) { + tarBlob := buildTar(t, tt.in, prefix, srcTarFormat) + // Test divideEntries() + entries, err := sortEntries(tarBlob, nil, nil) // identical order + if err != nil { + t.Fatalf("failed to parse tar: %v", err) + } + var merged []*entry + for _, part := range divideEntries(entries, 4) { + merged = append(merged, part...) + } + if !reflect.DeepEqual(entries, merged) { + for _, e := range entries { + t.Logf("Original: %v", e.header) + } + for _, e := range merged { + t.Logf("Merged: %v", e.header) + } + t.Errorf("divided entries couldn't be merged") + return + } + + // Prepare sample data + cl1 := newCL() + wantBuf := new(bytes.Buffer) + sw := NewWriterWithCompressor(wantBuf, cl1) + sw.MinChunkSize = minChunkSize + sw.ChunkSize = tt.chunkSize + if err := sw.AppendTar(tarBlob); err != nil { + t.Fatalf("failed to append tar to want stargz: %v", err) + } + if _, err := sw.Close(); err != nil { + t.Fatalf("failed to prepare want stargz: %v", err) + } + wantData := wantBuf.Bytes() + want, err := Open(io.NewSectionReader( + bytes.NewReader(wantData), 0, int64(len(wantData))), + WithDecompressors(cl1), + ) + if err != nil { + t.Fatalf("failed to parse the want stargz: %v", err) + } + + // Prepare testing data + var opts []Option + if minChunkSize > 0 { + opts = append(opts, WithMinChunkSize(minChunkSize)) + } + cl2 := newCL() + rc, err := Build(compressBlob(t, tarBlob, srcCompression), + append(opts, WithChunkSize(tt.chunkSize), WithCompression(cl2))...) + if err != nil { + t.Fatalf("failed to build stargz: %v", err) + } + defer rc.Close() + gotBuf := new(bytes.Buffer) + if _, err := io.Copy(gotBuf, rc); err != nil { + t.Fatalf("failed to copy built stargz blob: %v", err) + } + gotData := gotBuf.Bytes() + got, err := Open(io.NewSectionReader( + bytes.NewReader(gotBuf.Bytes()), 0, int64(len(gotData))), + WithDecompressors(cl2), + ) + if err != nil { + t.Fatalf("failed to parse the got stargz: %v", err) + } + + // Check DiffID is properly calculated + rc.Close() + diffID := rc.DiffID() + wantDiffID := cl2.DiffIDOf(t, gotData) + if diffID.String() != wantDiffID { + t.Errorf("DiffID = %q; want %q", diffID, wantDiffID) + } + + // Compare as stargz + if !isSameVersion(t, cl1, wantData, cl2, gotData) { + t.Errorf("built stargz hasn't same json") + return + } + if !isSameEntries(t, want, got) { + t.Errorf("built stargz isn't same as the original") + return + } + + // Compare as tar.gz + if !isSameTarGz(t, cl1, wantData, cl2, gotData) { + t.Errorf("built stargz isn't same tar.gz") + return + } + }) + } + } + } + } + } + } +} + +func isSameTarGz(t *testing.T, cla TestingController, a []byte, clb TestingController, b []byte) bool { + aGz, err := cla.Reader(bytes.NewReader(a)) + if err != nil { + t.Fatalf("failed to read A") + } + defer aGz.Close() + bGz, err := clb.Reader(bytes.NewReader(b)) + if err != nil { + t.Fatalf("failed to read B") + } + defer bGz.Close() + + // Same as tar's Next() method but ignores landmarks and TOCJSON file + next := func(r *tar.Reader) (h *tar.Header, err error) { + for { + if h, err = r.Next(); err != nil { + return + } + if h.Name != PrefetchLandmark && + h.Name != NoPrefetchLandmark && + h.Name != TOCTarName { + return + } + } + } + + aTar := tar.NewReader(aGz) + bTar := tar.NewReader(bGz) + for { + // Fetch and parse next header. + aH, aErr := next(aTar) + bH, bErr := next(bTar) + if aErr != nil || bErr != nil { + if aErr == io.EOF && bErr == io.EOF { + break + } + t.Fatalf("Failed to parse tar file: A: %v, B: %v", aErr, bErr) + } + if !reflect.DeepEqual(aH, bH) { + t.Logf("different header (A = %v; B = %v)", aH, bH) + return false + + } + aFile, err := io.ReadAll(aTar) + if err != nil { + t.Fatal("failed to read tar payload of A") + } + bFile, err := io.ReadAll(bTar) + if err != nil { + t.Fatal("failed to read tar payload of B") + } + if !bytes.Equal(aFile, bFile) { + t.Logf("different tar payload (A = %q; B = %q)", string(a), string(b)) + return false + } + } + + return true +} + +func isSameVersion(t *testing.T, cla TestingController, a []byte, clb TestingController, b []byte) bool { + aJTOC, _, err := parseStargz(io.NewSectionReader(bytes.NewReader(a), 0, int64(len(a))), cla) + if err != nil { + t.Fatalf("failed to parse A: %v", err) + } + bJTOC, _, err := parseStargz(io.NewSectionReader(bytes.NewReader(b), 0, int64(len(b))), clb) + if err != nil { + t.Fatalf("failed to parse B: %v", err) + } + t.Logf("A: TOCJSON: %v", dumpTOCJSON(t, aJTOC)) + t.Logf("B: TOCJSON: %v", dumpTOCJSON(t, bJTOC)) + return aJTOC.Version == bJTOC.Version +} + +func isSameEntries(t *testing.T, a, b *Reader) bool { + aroot, ok := a.Lookup("") + if !ok { + t.Fatalf("failed to get root of A") + } + broot, ok := b.Lookup("") + if !ok { + t.Fatalf("failed to get root of B") + } + aEntry := stargzEntry{aroot, a} + bEntry := stargzEntry{broot, b} + return contains(t, aEntry, bEntry) && contains(t, bEntry, aEntry) +} + +func compressBlob(t *testing.T, src *io.SectionReader, srcCompression int) *io.SectionReader { + buf := new(bytes.Buffer) + var w io.WriteCloser + var err error + if srcCompression == gzipType { + w = gzip.NewWriter(buf) + } else if srcCompression == zstdType { + w, err = zstd.NewWriter(buf) + if err != nil { + t.Fatalf("failed to init zstd writer: %v", err) + } + } else { + return src + } + src.Seek(0, io.SeekStart) + if _, err := io.Copy(w, src); err != nil { + t.Fatalf("failed to compress source") + } + if err := w.Close(); err != nil { + t.Fatalf("failed to finalize compress source") + } + data := buf.Bytes() + return io.NewSectionReader(bytes.NewReader(data), 0, int64(len(data))) + +} + +type stargzEntry struct { + e *TOCEntry + r *Reader +} + +// contains checks if all child entries in "b" are also contained in "a". +// This function also checks if the files/chunks contain the same contents among "a" and "b". +func contains(t *testing.T, a, b stargzEntry) bool { + ae, ar := a.e, a.r + be, br := b.e, b.r + t.Logf("Comparing: %q vs %q", ae.Name, be.Name) + if !equalEntry(ae, be) { + t.Logf("%q != %q: entry: a: %v, b: %v", ae.Name, be.Name, ae, be) + return false + } + if ae.Type == "dir" { + t.Logf("Directory: %q vs %q: %v vs %v", ae.Name, be.Name, + allChildrenName(ae), allChildrenName(be)) + iscontain := true + ae.ForeachChild(func(aBaseName string, aChild *TOCEntry) bool { + // Walk through all files on this stargz file. + + if aChild.Name == PrefetchLandmark || + aChild.Name == NoPrefetchLandmark { + return true // Ignore landmarks + } + + // Ignore a TOCEntry of "./" (formated as "" by stargz lib) on root directory + // because this points to the root directory itself. + if aChild.Name == "" && ae.Name == "" { + return true + } + + bChild, ok := be.LookupChild(aBaseName) + if !ok { + t.Logf("%q (base: %q): not found in b: %v", + ae.Name, aBaseName, allChildrenName(be)) + iscontain = false + return false + } + + childcontain := contains(t, stargzEntry{aChild, a.r}, stargzEntry{bChild, b.r}) + if !childcontain { + t.Logf("%q != %q: non-equal dir", ae.Name, be.Name) + iscontain = false + return false + } + return true + }) + return iscontain + } else if ae.Type == "reg" { + af, err := ar.OpenFile(ae.Name) + if err != nil { + t.Fatalf("failed to open file %q on A: %v", ae.Name, err) + } + bf, err := br.OpenFile(be.Name) + if err != nil { + t.Fatalf("failed to open file %q on B: %v", be.Name, err) + } + + var nr int64 + for nr < ae.Size { + abytes, anext, aok := readOffset(t, af, nr, a) + bbytes, bnext, bok := readOffset(t, bf, nr, b) + if !aok && !bok { + break + } else if !(aok && bok) || anext != bnext { + t.Logf("%q != %q (offset=%d): chunk existence a=%v vs b=%v, anext=%v vs bnext=%v", + ae.Name, be.Name, nr, aok, bok, anext, bnext) + return false + } + nr = anext + if !bytes.Equal(abytes, bbytes) { + t.Logf("%q != %q: different contents %v vs %v", + ae.Name, be.Name, string(abytes), string(bbytes)) + return false + } + } + return true + } + + return true +} + +func allChildrenName(e *TOCEntry) (children []string) { + e.ForeachChild(func(baseName string, _ *TOCEntry) bool { + children = append(children, baseName) + return true + }) + return +} + +func equalEntry(a, b *TOCEntry) bool { + // Here, we selectively compare fileds that we are interested in. + return a.Name == b.Name && + a.Type == b.Type && + a.Size == b.Size && + a.ModTime3339 == b.ModTime3339 && + a.Stat().ModTime().Equal(b.Stat().ModTime()) && // modTime time.Time + a.LinkName == b.LinkName && + a.Mode == b.Mode && + a.UID == b.UID && + a.GID == b.GID && + a.Uname == b.Uname && + a.Gname == b.Gname && + (a.Offset >= 0) == (b.Offset >= 0) && + (a.NextOffset() > 0) == (b.NextOffset() > 0) && + a.DevMajor == b.DevMajor && + a.DevMinor == b.DevMinor && + a.NumLink == b.NumLink && + reflect.DeepEqual(a.Xattrs, b.Xattrs) && + // chunk-related infomations aren't compared in this function. + // ChunkOffset int64 `json:"chunkOffset,omitempty"` + // ChunkSize int64 `json:"chunkSize,omitempty"` + // children map[string]*TOCEntry + a.Digest == b.Digest +} + +func readOffset(t *testing.T, r *io.SectionReader, offset int64, e stargzEntry) ([]byte, int64, bool) { + ce, ok := e.r.ChunkEntryForOffset(e.e.Name, offset) + if !ok { + return nil, 0, false + } + data := make([]byte, ce.ChunkSize) + t.Logf("Offset: %v, NextOffset: %v", ce.Offset, ce.NextOffset()) + n, err := r.ReadAt(data, ce.ChunkOffset) + if err != nil { + t.Fatalf("failed to read file payload of %q (offset:%d,size:%d): %v", + e.e.Name, ce.ChunkOffset, ce.ChunkSize, err) + } + if int64(n) != ce.ChunkSize { + t.Fatalf("unexpected copied data size %d; want %d", + n, ce.ChunkSize) + } + return data[:n], offset + ce.ChunkSize, true +} + +func dumpTOCJSON(t *testing.T, tocJSON *JTOC) string { + jtocData, err := json.Marshal(*tocJSON) + if err != nil { + t.Fatalf("failed to marshal TOC JSON: %v", err) + } + buf := new(bytes.Buffer) + if _, err := io.Copy(buf, bytes.NewReader(jtocData)); err != nil { + t.Fatalf("failed to read toc json blob: %v", err) + } + return buf.String() +} + +const chunkSize = 3 + +// type check func(t *testing.T, sgzData []byte, tocDigest digest.Digest, dgstMap map[string]digest.Digest, compressionLevel int) +type check func(t *testing.T, sgzData []byte, tocDigest digest.Digest, dgstMap map[string]digest.Digest, controller TestingController, newController TestingControllerFactory) + +// testDigestAndVerify runs specified checks against sample stargz blobs. +func testDigestAndVerify(t *testing.T, controllers ...TestingControllerFactory) { + tests := []struct { + name string + tarInit func(t *testing.T, dgstMap map[string]digest.Digest) (blob []tarEntry) + checks []check + minChunkSize []int + }{ + { + name: "no-regfile", + tarInit: func(t *testing.T, dgstMap map[string]digest.Digest) (blob []tarEntry) { + return tarOf( + dir("test/"), + ) + }, + checks: []check{ + checkStargzTOC, + checkVerifyTOC, + checkVerifyInvalidStargzFail(buildTar(t, tarOf( + dir("test2/"), // modified + ), allowedPrefix[0])), + }, + }, + { + name: "small-files", + tarInit: func(t *testing.T, dgstMap map[string]digest.Digest) (blob []tarEntry) { + return tarOf( + regDigest(t, "baz.txt", "", dgstMap), + regDigest(t, "foo.txt", "a", dgstMap), + dir("test/"), + regDigest(t, "test/bar.txt", "bbb", dgstMap), + ) + }, + minChunkSize: []int{0, 64000}, + checks: []check{ + checkStargzTOC, + checkVerifyTOC, + checkVerifyInvalidStargzFail(buildTar(t, tarOf( + file("baz.txt", ""), + file("foo.txt", "M"), // modified + dir("test/"), + file("test/bar.txt", "bbb"), + ), allowedPrefix[0])), + // checkVerifyInvalidTOCEntryFail("foo.txt"), // TODO + checkVerifyBrokenContentFail("foo.txt"), + }, + }, + { + name: "big-files", + tarInit: func(t *testing.T, dgstMap map[string]digest.Digest) (blob []tarEntry) { + return tarOf( + regDigest(t, "baz.txt", "bazbazbazbazbazbazbaz", dgstMap), + regDigest(t, "foo.txt", "a", dgstMap), + dir("test/"), + regDigest(t, "test/bar.txt", "testbartestbar", dgstMap), + ) + }, + checks: []check{ + checkStargzTOC, + checkVerifyTOC, + checkVerifyInvalidStargzFail(buildTar(t, tarOf( + file("baz.txt", "bazbazbazMMMbazbazbaz"), // modified + file("foo.txt", "a"), + dir("test/"), + file("test/bar.txt", "testbartestbar"), + ), allowedPrefix[0])), + checkVerifyInvalidTOCEntryFail("test/bar.txt"), + checkVerifyBrokenContentFail("test/bar.txt"), + }, + }, + { + name: "with-non-regfiles", + minChunkSize: []int{0, 64000}, + tarInit: func(t *testing.T, dgstMap map[string]digest.Digest) (blob []tarEntry) { + return tarOf( + regDigest(t, "baz.txt", "bazbazbazbazbazbazbaz", dgstMap), + regDigest(t, "foo.txt", "a", dgstMap), + regDigest(t, "bar/foo2.txt", "b", dgstMap), + regDigest(t, "foo3.txt", "c", dgstMap), + symlink("barlink", "test/bar.txt"), + dir("test/"), + regDigest(t, "test/bar.txt", "testbartestbar", dgstMap), + dir("test2/"), + link("test2/bazlink", "baz.txt"), + ) + }, + checks: []check{ + checkStargzTOC, + checkVerifyTOC, + checkVerifyInvalidStargzFail(buildTar(t, tarOf( + file("baz.txt", "bazbazbazbazbazbazbaz"), + file("foo.txt", "a"), + file("bar/foo2.txt", "b"), + file("foo3.txt", "c"), + symlink("barlink", "test/bar.txt"), + dir("test/"), + file("test/bar.txt", "testbartestbar"), + dir("test2/"), + link("test2/bazlink", "foo.txt"), // modified + ), allowedPrefix[0])), + checkVerifyInvalidTOCEntryFail("test/bar.txt"), + checkVerifyBrokenContentFail("test/bar.txt"), + }, + }, + } + + for _, tt := range tests { + if len(tt.minChunkSize) == 0 { + tt.minChunkSize = []int{0} + } + for _, srcCompression := range srcCompressions { + srcCompression := srcCompression + for _, newCL := range controllers { + newCL := newCL + for _, prefix := range allowedPrefix { + prefix := prefix + for _, srcTarFormat := range []tar.Format{tar.FormatUSTAR, tar.FormatPAX, tar.FormatGNU} { + srcTarFormat := srcTarFormat + for _, minChunkSize := range tt.minChunkSize { + minChunkSize := minChunkSize + t.Run(tt.name+"-"+fmt.Sprintf("compression=%v,prefix=%q,format=%s,minChunkSize=%d", newCL(), prefix, srcTarFormat, minChunkSize), func(t *testing.T) { + // Get original tar file and chunk digests + dgstMap := make(map[string]digest.Digest) + tarBlob := buildTar(t, tt.tarInit(t, dgstMap), prefix, srcTarFormat) + + cl := newCL() + rc, err := Build(compressBlob(t, tarBlob, srcCompression), + WithChunkSize(chunkSize), WithCompression(cl)) + if err != nil { + t.Fatalf("failed to convert stargz: %v", err) + } + tocDigest := rc.TOCDigest() + defer rc.Close() + buf := new(bytes.Buffer) + if _, err := io.Copy(buf, rc); err != nil { + t.Fatalf("failed to copy built stargz blob: %v", err) + } + newStargz := buf.Bytes() + // NoPrefetchLandmark is added during `Bulid`, which is expected behaviour. + dgstMap[chunkID(NoPrefetchLandmark, 0, int64(len([]byte{landmarkContents})))] = digest.FromBytes([]byte{landmarkContents}) + + for _, check := range tt.checks { + check(t, newStargz, tocDigest, dgstMap, cl, newCL) + } + }) + } + } + } + } + } + } +} + +// checkStargzTOC checks the TOC JSON of the passed stargz has the expected +// digest and contains valid chunks. It walks all entries in the stargz and +// checks all chunk digests stored to the TOC JSON match the actual contents. +func checkStargzTOC(t *testing.T, sgzData []byte, tocDigest digest.Digest, dgstMap map[string]digest.Digest, controller TestingController, newController TestingControllerFactory) { + sgz, err := Open( + io.NewSectionReader(bytes.NewReader(sgzData), 0, int64(len(sgzData))), + WithDecompressors(controller), + ) + if err != nil { + t.Errorf("failed to parse converted stargz: %v", err) + return + } + digestMapTOC, err := listDigests(io.NewSectionReader( + bytes.NewReader(sgzData), 0, int64(len(sgzData))), + controller, + ) + if err != nil { + t.Fatalf("failed to list digest: %v", err) + } + found := make(map[string]bool) + for id := range dgstMap { + found[id] = false + } + zr, err := controller.Reader(bytes.NewReader(sgzData)) + if err != nil { + t.Fatalf("failed to decompress converted stargz: %v", err) + } + defer zr.Close() + tr := tar.NewReader(zr) + for { + h, err := tr.Next() + if err != nil { + if err != io.EOF { + t.Errorf("failed to read tar entry: %v", err) + return + } + break + } + if h.Name == TOCTarName { + // Check the digest of TOC JSON based on the actual contents + // It's sure that TOC JSON exists in this archive because + // Open succeeded. + dgstr := digest.Canonical.Digester() + if _, err := io.Copy(dgstr.Hash(), tr); err != nil { + t.Fatalf("failed to calculate digest of TOC JSON: %v", + err) + } + if dgstr.Digest() != tocDigest { + t.Errorf("invalid TOC JSON %q; want %q", tocDigest, dgstr.Digest()) + } + continue + } + if _, ok := sgz.Lookup(h.Name); !ok { + t.Errorf("lost stargz entry %q in the converted TOC", h.Name) + return + } + var n int64 + for n < h.Size { + ce, ok := sgz.ChunkEntryForOffset(h.Name, n) + if !ok { + t.Errorf("lost chunk %q(offset=%d) in the converted TOC", + h.Name, n) + return + } + + // Get the original digest to make sure the file contents are kept unchanged + // from the original tar, during the whole conversion steps. + id := chunkID(h.Name, n, ce.ChunkSize) + want, ok := dgstMap[id] + if !ok { + t.Errorf("Unexpected chunk %q(offset=%d,size=%d): %v", + h.Name, n, ce.ChunkSize, dgstMap) + return + } + found[id] = true + + // Check the file contents + dgstr := digest.Canonical.Digester() + if _, err := io.CopyN(dgstr.Hash(), tr, ce.ChunkSize); err != nil { + t.Fatalf("failed to calculate digest of %q (offset=%d,size=%d)", + h.Name, n, ce.ChunkSize) + } + if want != dgstr.Digest() { + t.Errorf("Invalid contents in converted stargz %q: %q; want %q", + h.Name, dgstr.Digest(), want) + return + } + + // Check the digest stored in TOC JSON + dgstTOC, ok := digestMapTOC[ce.Offset] + if !ok { + t.Errorf("digest of %q(offset=%d,size=%d,chunkOffset=%d) isn't registered", + h.Name, ce.Offset, ce.ChunkSize, ce.ChunkOffset) + } + if want != dgstTOC { + t.Errorf("Invalid digest in TOCEntry %q: %q; want %q", + h.Name, dgstTOC, want) + return + } + + n += ce.ChunkSize + } + } + + for id, ok := range found { + if !ok { + t.Errorf("required chunk %q not found in the converted stargz: %v", id, found) + } + } +} + +// checkVerifyTOC checks the verification works for the TOC JSON of the passed +// stargz. It walks all entries in the stargz and checks the verifications for +// all chunks work. +func checkVerifyTOC(t *testing.T, sgzData []byte, tocDigest digest.Digest, dgstMap map[string]digest.Digest, controller TestingController, newController TestingControllerFactory) { + sgz, err := Open( + io.NewSectionReader(bytes.NewReader(sgzData), 0, int64(len(sgzData))), + WithDecompressors(controller), + ) + if err != nil { + t.Errorf("failed to parse converted stargz: %v", err) + return + } + ev, err := sgz.VerifyTOC(tocDigest) + if err != nil { + t.Errorf("failed to verify stargz: %v", err) + return + } + + found := make(map[string]bool) + for id := range dgstMap { + found[id] = false + } + zr, err := controller.Reader(bytes.NewReader(sgzData)) + if err != nil { + t.Fatalf("failed to decompress converted stargz: %v", err) + } + defer zr.Close() + tr := tar.NewReader(zr) + for { + h, err := tr.Next() + if err != nil { + if err != io.EOF { + t.Errorf("failed to read tar entry: %v", err) + return + } + break + } + if h.Name == TOCTarName { + continue + } + if _, ok := sgz.Lookup(h.Name); !ok { + t.Errorf("lost stargz entry %q in the converted TOC", h.Name) + return + } + var n int64 + for n < h.Size { + ce, ok := sgz.ChunkEntryForOffset(h.Name, n) + if !ok { + t.Errorf("lost chunk %q(offset=%d) in the converted TOC", + h.Name, n) + return + } + + v, err := ev.Verifier(ce) + if err != nil { + t.Errorf("failed to get verifier for %q(offset=%d)", h.Name, n) + } + + found[chunkID(h.Name, n, ce.ChunkSize)] = true + + // Check the file contents + if _, err := io.CopyN(v, tr, ce.ChunkSize); err != nil { + t.Fatalf("failed to get chunk of %q (offset=%d,size=%d)", + h.Name, n, ce.ChunkSize) + } + if !v.Verified() { + t.Errorf("Invalid contents in converted stargz %q (should be succeeded)", + h.Name) + return + } + n += ce.ChunkSize + } + } + + for id, ok := range found { + if !ok { + t.Errorf("required chunk %q not found in the converted stargz: %v", id, found) + } + } +} + +// checkVerifyInvalidTOCEntryFail checks if misconfigured TOC JSON can be +// detected during the verification and the verification returns an error. +func checkVerifyInvalidTOCEntryFail(filename string) check { + return func(t *testing.T, sgzData []byte, tocDigest digest.Digest, dgstMap map[string]digest.Digest, controller TestingController, newController TestingControllerFactory) { + funcs := map[string]rewriteFunc{ + "lost digest in a entry": func(t *testing.T, toc *JTOC, sgz *io.SectionReader) { + var found bool + for _, e := range toc.Entries { + if cleanEntryName(e.Name) == filename { + if e.Type != "reg" && e.Type != "chunk" { + t.Fatalf("entry %q to break must be regfile or chunk", filename) + } + if e.ChunkDigest == "" { + t.Fatalf("entry %q is already invalid", filename) + } + e.ChunkDigest = "" + found = true + } + } + if !found { + t.Fatalf("rewrite target not found") + } + }, + "duplicated entry offset": func(t *testing.T, toc *JTOC, sgz *io.SectionReader) { + var ( + sampleEntry *TOCEntry + targetEntry *TOCEntry + ) + for _, e := range toc.Entries { + if e.Type == "reg" || e.Type == "chunk" { + if cleanEntryName(e.Name) == filename { + targetEntry = e + } else { + sampleEntry = e + } + } + } + if sampleEntry == nil { + t.Fatalf("TOC must contain at least one regfile or chunk entry other than the rewrite target") + } + if targetEntry == nil { + t.Fatalf("rewrite target not found") + } + targetEntry.Offset = sampleEntry.Offset + }, + } + + for name, rFunc := range funcs { + t.Run(name, func(t *testing.T) { + newSgz, newTocDigest := rewriteTOCJSON(t, io.NewSectionReader(bytes.NewReader(sgzData), 0, int64(len(sgzData))), rFunc, controller) + buf := new(bytes.Buffer) + if _, err := io.Copy(buf, newSgz); err != nil { + t.Fatalf("failed to get converted stargz") + } + isgz := buf.Bytes() + + sgz, err := Open( + io.NewSectionReader(bytes.NewReader(isgz), 0, int64(len(isgz))), + WithDecompressors(controller), + ) + if err != nil { + t.Fatalf("failed to parse converted stargz: %v", err) + return + } + _, err = sgz.VerifyTOC(newTocDigest) + if err == nil { + t.Errorf("must fail for invalid TOC") + return + } + }) + } + } +} + +// checkVerifyInvalidStargzFail checks if the verification detects that the +// given stargz file doesn't match to the expected digest and returns error. +func checkVerifyInvalidStargzFail(invalid *io.SectionReader) check { + return func(t *testing.T, sgzData []byte, tocDigest digest.Digest, dgstMap map[string]digest.Digest, controller TestingController, newController TestingControllerFactory) { + cl := newController() + rc, err := Build(invalid, WithChunkSize(chunkSize), WithCompression(cl)) + if err != nil { + t.Fatalf("failed to convert stargz: %v", err) + } + defer rc.Close() + buf := new(bytes.Buffer) + if _, err := io.Copy(buf, rc); err != nil { + t.Fatalf("failed to copy built stargz blob: %v", err) + } + mStargz := buf.Bytes() + + sgz, err := Open( + io.NewSectionReader(bytes.NewReader(mStargz), 0, int64(len(mStargz))), + WithDecompressors(cl), + ) + if err != nil { + t.Fatalf("failed to parse converted stargz: %v", err) + return + } + _, err = sgz.VerifyTOC(tocDigest) + if err == nil { + t.Errorf("must fail for invalid TOC") + return + } + } +} + +// checkVerifyBrokenContentFail checks if the verifier detects broken contents +// that doesn't match to the expected digest and returns error. +func checkVerifyBrokenContentFail(filename string) check { + return func(t *testing.T, sgzData []byte, tocDigest digest.Digest, dgstMap map[string]digest.Digest, controller TestingController, newController TestingControllerFactory) { + // Parse stargz file + sgz, err := Open( + io.NewSectionReader(bytes.NewReader(sgzData), 0, int64(len(sgzData))), + WithDecompressors(controller), + ) + if err != nil { + t.Fatalf("failed to parse converted stargz: %v", err) + return + } + ev, err := sgz.VerifyTOC(tocDigest) + if err != nil { + t.Fatalf("failed to verify stargz: %v", err) + return + } + + // Open the target file + sr, err := sgz.OpenFile(filename) + if err != nil { + t.Fatalf("failed to open file %q", filename) + } + ce, ok := sgz.ChunkEntryForOffset(filename, 0) + if !ok { + t.Fatalf("lost chunk %q(offset=%d) in the converted TOC", filename, 0) + return + } + if ce.ChunkSize == 0 { + t.Fatalf("file mustn't be empty") + return + } + data := make([]byte, ce.ChunkSize) + if _, err := sr.ReadAt(data, ce.ChunkOffset); err != nil { + t.Errorf("failed to get data of a chunk of %q(offset=%q)", + filename, ce.ChunkOffset) + } + + // Check the broken chunk (must fail) + v, err := ev.Verifier(ce) + if err != nil { + t.Fatalf("failed to get verifier for %q", filename) + } + broken := append([]byte{^data[0]}, data[1:]...) + if _, err := io.CopyN(v, bytes.NewReader(broken), ce.ChunkSize); err != nil { + t.Fatalf("failed to get chunk of %q (offset=%d,size=%d)", + filename, ce.ChunkOffset, ce.ChunkSize) + } + if v.Verified() { + t.Errorf("verification must fail for broken file chunk %q(org:%q,broken:%q)", + filename, data, broken) + } + } +} + +func chunkID(name string, offset, size int64) string { + return fmt.Sprintf("%s-%d-%d", cleanEntryName(name), offset, size) +} + +type rewriteFunc func(t *testing.T, toc *JTOC, sgz *io.SectionReader) + +func rewriteTOCJSON(t *testing.T, sgz *io.SectionReader, rewrite rewriteFunc, controller TestingController) (newSgz io.Reader, tocDigest digest.Digest) { + decodedJTOC, jtocOffset, err := parseStargz(sgz, controller) + if err != nil { + t.Fatalf("failed to extract TOC JSON: %v", err) + } + + rewrite(t, decodedJTOC, sgz) + + tocFooter, tocDigest, err := tocAndFooter(controller, decodedJTOC, jtocOffset) + if err != nil { + t.Fatalf("failed to create toc and footer: %v", err) + } + + // Reconstruct stargz file with the modified TOC JSON + if _, err := sgz.Seek(0, io.SeekStart); err != nil { + t.Fatalf("failed to reset the seek position of stargz: %v", err) + } + return io.MultiReader( + io.LimitReader(sgz, jtocOffset), // Original stargz (before TOC JSON) + tocFooter, // Rewritten TOC and footer + ), tocDigest +} + +func listDigests(sgz *io.SectionReader, controller TestingController) (map[int64]digest.Digest, error) { + decodedJTOC, _, err := parseStargz(sgz, controller) + if err != nil { + return nil, err + } + digestMap := make(map[int64]digest.Digest) + for _, e := range decodedJTOC.Entries { + if e.Type == "reg" || e.Type == "chunk" { + if e.Type == "reg" && e.Size == 0 { + continue // ignores empty file + } + if e.ChunkDigest == "" { + return nil, fmt.Errorf("ChunkDigest of %q(off=%d) not found in TOC JSON", + e.Name, e.Offset) + } + d, err := digest.Parse(e.ChunkDigest) + if err != nil { + return nil, err + } + digestMap[e.Offset] = d + } + } + return digestMap, nil +} + +func parseStargz(sgz *io.SectionReader, controller TestingController) (decodedJTOC *JTOC, jtocOffset int64, err error) { + fSize := controller.FooterSize() + footer := make([]byte, fSize) + if _, err := sgz.ReadAt(footer, sgz.Size()-fSize); err != nil { + return nil, 0, fmt.Errorf("error reading footer: %w", err) + } + _, tocOffset, _, err := controller.ParseFooter(footer[positive(int64(len(footer))-fSize):]) + if err != nil { + return nil, 0, fmt.Errorf("failed to parse footer: %w", err) + } + + // Decode the TOC JSON + var tocReader io.Reader + if tocOffset >= 0 { + tocReader = io.NewSectionReader(sgz, tocOffset, sgz.Size()-tocOffset-fSize) + } + decodedJTOC, _, err = controller.ParseTOC(tocReader) + if err != nil { + return nil, 0, fmt.Errorf("failed to parse TOC: %w", err) + } + return decodedJTOC, tocOffset, nil +} + +func testWriteAndOpen(t *testing.T, controllers ...TestingControllerFactory) { + const content = "Some contents" + invalidUtf8 := "\xff\xfe\xfd" + + xAttrFile := xAttr{"foo": "bar", "invalid-utf8": invalidUtf8} + sampleOwner := owner{uid: 50, gid: 100} + + data64KB := randomContents(64000) + + tests := []struct { + name string + chunkSize int + minChunkSize int + in []tarEntry + want []stargzCheck + wantNumGz int // expected number of streams + + wantNumGzLossLess int // expected number of streams (> 0) in lossless mode if it's different from wantNumGz + wantFailOnLossLess bool + wantTOCVersion int // default = 1 + }{ + { + name: "empty", + in: tarOf(), + wantNumGz: 2, // (empty tar) + TOC + footer + want: checks( + numTOCEntries(0), + ), + }, + { + name: "1dir_1empty_file", + in: tarOf( + dir("foo/"), + file("foo/bar.txt", ""), + ), + wantNumGz: 3, // dir, TOC, footer + want: checks( + numTOCEntries(2), + hasDir("foo/"), + hasFileLen("foo/bar.txt", 0), + entryHasChildren("foo", "bar.txt"), + hasFileDigest("foo/bar.txt", digestFor("")), + ), + }, + { + name: "1dir_1file", + in: tarOf( + dir("foo/"), + file("foo/bar.txt", content, xAttrFile), + ), + wantNumGz: 4, // var dir, foo.txt alone, TOC, footer + want: checks( + numTOCEntries(2), + hasDir("foo/"), + hasFileLen("foo/bar.txt", len(content)), + hasFileDigest("foo/bar.txt", digestFor(content)), + hasFileContentsRange("foo/bar.txt", 0, content), + hasFileContentsRange("foo/bar.txt", 1, content[1:]), + entryHasChildren("", "foo"), + entryHasChildren("foo", "bar.txt"), + hasFileXattrs("foo/bar.txt", "foo", "bar"), + hasFileXattrs("foo/bar.txt", "invalid-utf8", invalidUtf8), + ), + }, + { + name: "2meta_2file", + in: tarOf( + dir("bar/", sampleOwner), + dir("foo/", sampleOwner), + file("foo/bar.txt", content, sampleOwner), + ), + wantNumGz: 4, // both dirs, foo.txt alone, TOC, footer + want: checks( + numTOCEntries(3), + hasDir("bar/"), + hasDir("foo/"), + hasFileLen("foo/bar.txt", len(content)), + entryHasChildren("", "bar", "foo"), + entryHasChildren("foo", "bar.txt"), + hasChunkEntries("foo/bar.txt", 1), + hasEntryOwner("bar/", sampleOwner), + hasEntryOwner("foo/", sampleOwner), + hasEntryOwner("foo/bar.txt", sampleOwner), + ), + }, + { + name: "3dir", + in: tarOf( + dir("bar/"), + dir("foo/"), + dir("foo/bar/"), + ), + wantNumGz: 3, // 3 dirs, TOC, footer + want: checks( + hasDirLinkCount("bar/", 2), + hasDirLinkCount("foo/", 3), + hasDirLinkCount("foo/bar/", 2), + ), + }, + { + name: "symlink", + in: tarOf( + dir("foo/"), + symlink("foo/bar", "../../x"), + ), + wantNumGz: 3, // metas + TOC + footer + want: checks( + numTOCEntries(2), + hasSymlink("foo/bar", "../../x"), + entryHasChildren("", "foo"), + entryHasChildren("foo", "bar"), + ), + }, + { + name: "chunked_file", + chunkSize: 4, + in: tarOf( + dir("foo/"), + file("foo/big.txt", "This "+"is s"+"uch "+"a bi"+"g fi"+"le"), + ), + wantNumGz: 9, // dir + big.txt(6 chunks) + TOC + footer + want: checks( + numTOCEntries(7), // 1 for foo dir, 6 for the foo/big.txt file + hasDir("foo/"), + hasFileLen("foo/big.txt", len("This is such a big file")), + hasFileDigest("foo/big.txt", digestFor("This is such a big file")), + hasFileContentsRange("foo/big.txt", 0, "This is such a big file"), + hasFileContentsRange("foo/big.txt", 1, "his is such a big file"), + hasFileContentsRange("foo/big.txt", 2, "is is such a big file"), + hasFileContentsRange("foo/big.txt", 3, "s is such a big file"), + hasFileContentsRange("foo/big.txt", 4, " is such a big file"), + hasFileContentsRange("foo/big.txt", 5, "is such a big file"), + hasFileContentsRange("foo/big.txt", 6, "s such a big file"), + hasFileContentsRange("foo/big.txt", 7, " such a big file"), + hasFileContentsRange("foo/big.txt", 8, "such a big file"), + hasFileContentsRange("foo/big.txt", 9, "uch a big file"), + hasFileContentsRange("foo/big.txt", 10, "ch a big file"), + hasFileContentsRange("foo/big.txt", 11, "h a big file"), + hasFileContentsRange("foo/big.txt", 12, " a big file"), + hasFileContentsRange("foo/big.txt", len("This is such a big file")-1, ""), + hasChunkEntries("foo/big.txt", 6), + ), + }, + { + name: "recursive", + in: tarOf( + dir("/", sampleOwner), + dir("bar/", sampleOwner), + dir("foo/", sampleOwner), + file("foo/bar.txt", content, sampleOwner), + ), + wantNumGz: 4, // dirs, bar.txt alone, TOC, footer + want: checks( + maxDepth(2), // 0: root directory, 1: "foo/", 2: "bar.txt" + ), + }, + { + name: "block_char_fifo", + in: tarOf( + tarEntryFunc(func(w *tar.Writer, prefix string, format tar.Format) error { + return w.WriteHeader(&tar.Header{ + Name: prefix + "b", + Typeflag: tar.TypeBlock, + Devmajor: 123, + Devminor: 456, + Format: format, + }) + }), + tarEntryFunc(func(w *tar.Writer, prefix string, format tar.Format) error { + return w.WriteHeader(&tar.Header{ + Name: prefix + "c", + Typeflag: tar.TypeChar, + Devmajor: 111, + Devminor: 222, + Format: format, + }) + }), + tarEntryFunc(func(w *tar.Writer, prefix string, format tar.Format) error { + return w.WriteHeader(&tar.Header{ + Name: prefix + "f", + Typeflag: tar.TypeFifo, + Format: format, + }) + }), + ), + wantNumGz: 3, + want: checks( + lookupMatch("b", &TOCEntry{Name: "b", Type: "block", DevMajor: 123, DevMinor: 456, NumLink: 1}), + lookupMatch("c", &TOCEntry{Name: "c", Type: "char", DevMajor: 111, DevMinor: 222, NumLink: 1}), + lookupMatch("f", &TOCEntry{Name: "f", Type: "fifo", NumLink: 1}), + ), + }, + { + name: "modes", + in: tarOf( + dir("foo1/", 0755|os.ModeDir|os.ModeSetgid), + file("foo1/bar1", content, 0700|os.ModeSetuid), + file("foo1/bar2", content, 0755|os.ModeSetgid), + dir("foo2/", 0755|os.ModeDir|os.ModeSticky), + file("foo2/bar3", content, 0755|os.ModeSticky), + dir("foo3/", 0755|os.ModeDir), + file("foo3/bar4", content, os.FileMode(0700)), + file("foo3/bar5", content, os.FileMode(0755)), + ), + wantNumGz: 8, // dir, bar1 alone, bar2 alone + dir, bar3 alone + dir, bar4 alone, bar5 alone, TOC, footer + want: checks( + hasMode("foo1/", 0755|os.ModeDir|os.ModeSetgid), + hasMode("foo1/bar1", 0700|os.ModeSetuid), + hasMode("foo1/bar2", 0755|os.ModeSetgid), + hasMode("foo2/", 0755|os.ModeDir|os.ModeSticky), + hasMode("foo2/bar3", 0755|os.ModeSticky), + hasMode("foo3/", 0755|os.ModeDir), + hasMode("foo3/bar4", os.FileMode(0700)), + hasMode("foo3/bar5", os.FileMode(0755)), + ), + }, + { + name: "lossy", + in: tarOf( + dir("bar/", sampleOwner), + dir("foo/", sampleOwner), + file("foo/bar.txt", content, sampleOwner), + file(TOCTarName, "dummy"), // ignored by the writer. (lossless write returns error) + ), + wantNumGz: 4, // both dirs, foo.txt alone, TOC, footer + want: checks( + numTOCEntries(3), + hasDir("bar/"), + hasDir("foo/"), + hasFileLen("foo/bar.txt", len(content)), + entryHasChildren("", "bar", "foo"), + entryHasChildren("foo", "bar.txt"), + hasChunkEntries("foo/bar.txt", 1), + hasEntryOwner("bar/", sampleOwner), + hasEntryOwner("foo/", sampleOwner), + hasEntryOwner("foo/bar.txt", sampleOwner), + ), + wantFailOnLossLess: true, + }, + { + name: "hardlink should be replaced to the destination entry", + in: tarOf( + dir("foo/"), + file("foo/foo1", "test"), + link("foolink", "foo/foo1"), + ), + wantNumGz: 4, // dir, foo1 + link, TOC, footer + want: checks( + mustSameEntry("foo/foo1", "foolink"), + ), + }, + { + name: "several_files_in_chunk", + minChunkSize: 8000, + in: tarOf( + dir("foo/"), + file("foo/foo1", data64KB), + file("foo2", "bb"), + file("foo22", "ccc"), + dir("bar/"), + file("bar/bar.txt", "aaa"), + file("foo3", data64KB), + ), + // NOTE: we assume that the compressed "data64KB" is still larger than 8KB + wantNumGz: 4, // dir+foo1, foo2+foo22+dir+bar.txt+foo3, TOC, footer + want: checks( + numTOCEntries(7), // dir, foo1, foo2, foo22, dir, bar.txt, foo3 + hasDir("foo/"), + hasDir("bar/"), + hasFileLen("foo/foo1", len(data64KB)), + hasFileLen("foo2", len("bb")), + hasFileLen("foo22", len("ccc")), + hasFileLen("bar/bar.txt", len("aaa")), + hasFileLen("foo3", len(data64KB)), + hasFileDigest("foo/foo1", digestFor(data64KB)), + hasFileDigest("foo2", digestFor("bb")), + hasFileDigest("foo22", digestFor("ccc")), + hasFileDigest("bar/bar.txt", digestFor("aaa")), + hasFileDigest("foo3", digestFor(data64KB)), + hasFileContentsWithPreRead("foo22", 0, "ccc", chunkInfo{"foo2", "bb"}, chunkInfo{"bar/bar.txt", "aaa"}, chunkInfo{"foo3", data64KB}), + hasFileContentsRange("foo/foo1", 0, data64KB), + hasFileContentsRange("foo2", 0, "bb"), + hasFileContentsRange("foo2", 1, "b"), + hasFileContentsRange("foo22", 0, "ccc"), + hasFileContentsRange("foo22", 1, "cc"), + hasFileContentsRange("foo22", 2, "c"), + hasFileContentsRange("bar/bar.txt", 0, "aaa"), + hasFileContentsRange("bar/bar.txt", 1, "aa"), + hasFileContentsRange("bar/bar.txt", 2, "a"), + hasFileContentsRange("foo3", 0, data64KB), + hasFileContentsRange("foo3", 1, data64KB[1:]), + hasFileContentsRange("foo3", 2, data64KB[2:]), + hasFileContentsRange("foo3", len(data64KB)/2, data64KB[len(data64KB)/2:]), + hasFileContentsRange("foo3", len(data64KB)-1, data64KB[len(data64KB)-1:]), + ), + }, + { + name: "several_files_in_chunk_chunked", + minChunkSize: 8000, + chunkSize: 32000, + in: tarOf( + dir("foo/"), + file("foo/foo1", data64KB), + file("foo2", "bb"), + dir("bar/"), + file("foo3", data64KB), + ), + // NOTE: we assume that the compressed chunk of "data64KB" is still larger than 8KB + wantNumGz: 6, // dir+foo1(1), foo1(2), foo2+dir+foo3(1), foo3(2), TOC, footer + want: checks( + numTOCEntries(7), // dir, foo1(2 chunks), foo2, dir, foo3(2 chunks) + hasDir("foo/"), + hasDir("bar/"), + hasFileLen("foo/foo1", len(data64KB)), + hasFileLen("foo2", len("bb")), + hasFileLen("foo3", len(data64KB)), + hasFileDigest("foo/foo1", digestFor(data64KB)), + hasFileDigest("foo2", digestFor("bb")), + hasFileDigest("foo3", digestFor(data64KB)), + hasFileContentsWithPreRead("foo2", 0, "bb", chunkInfo{"foo3", data64KB[:32000]}), + hasFileContentsRange("foo/foo1", 0, data64KB), + hasFileContentsRange("foo/foo1", 1, data64KB[1:]), + hasFileContentsRange("foo/foo1", 2, data64KB[2:]), + hasFileContentsRange("foo/foo1", len(data64KB)/2, data64KB[len(data64KB)/2:]), + hasFileContentsRange("foo/foo1", len(data64KB)-1, data64KB[len(data64KB)-1:]), + hasFileContentsRange("foo2", 0, "bb"), + hasFileContentsRange("foo2", 1, "b"), + hasFileContentsRange("foo3", 0, data64KB), + hasFileContentsRange("foo3", 1, data64KB[1:]), + hasFileContentsRange("foo3", 2, data64KB[2:]), + hasFileContentsRange("foo3", len(data64KB)/2, data64KB[len(data64KB)/2:]), + hasFileContentsRange("foo3", len(data64KB)-1, data64KB[len(data64KB)-1:]), + ), + }, + } + + for _, tt := range tests { + for _, newCL := range controllers { + newCL := newCL + for _, prefix := range allowedPrefix { + prefix := prefix + for _, srcTarFormat := range []tar.Format{tar.FormatUSTAR, tar.FormatPAX, tar.FormatGNU} { + srcTarFormat := srcTarFormat + for _, lossless := range []bool{true, false} { + t.Run(tt.name+"-"+fmt.Sprintf("compression=%v,prefix=%q,lossless=%v,format=%s", newCL(), prefix, lossless, srcTarFormat), func(t *testing.T) { + var tr io.Reader = buildTar(t, tt.in, prefix, srcTarFormat) + origTarDgstr := digest.Canonical.Digester() + tr = io.TeeReader(tr, origTarDgstr.Hash()) + var stargzBuf bytes.Buffer + cl1 := newCL() + w := NewWriterWithCompressor(&stargzBuf, cl1) + w.ChunkSize = tt.chunkSize + w.MinChunkSize = tt.minChunkSize + if lossless { + err := w.AppendTarLossLess(tr) + if tt.wantFailOnLossLess { + if err != nil { + return // expected to fail + } + t.Fatalf("Append wanted to fail on lossless") + } + if err != nil { + t.Fatalf("Append(lossless): %v", err) + } + } else { + if err := w.AppendTar(tr); err != nil { + t.Fatalf("Append: %v", err) + } + } + if _, err := w.Close(); err != nil { + t.Fatalf("Writer.Close: %v", err) + } + b := stargzBuf.Bytes() + + if lossless { + // Check if the result blob reserves original tar metadata + rc, err := Unpack(io.NewSectionReader(bytes.NewReader(b), 0, int64(len(b))), cl1) + if err != nil { + t.Errorf("failed to decompress blob: %v", err) + return + } + defer rc.Close() + resultDgstr := digest.Canonical.Digester() + if _, err := io.Copy(resultDgstr.Hash(), rc); err != nil { + t.Errorf("failed to read result decompressed blob: %v", err) + return + } + if resultDgstr.Digest() != origTarDgstr.Digest() { + t.Errorf("lossy compression occurred: digest=%v; want %v", + resultDgstr.Digest(), origTarDgstr.Digest()) + return + } + } + + diffID := w.DiffID() + wantDiffID := cl1.DiffIDOf(t, b) + if diffID != wantDiffID { + t.Errorf("DiffID = %q; want %q", diffID, wantDiffID) + } + + telemetry, checkCalled := newCalledTelemetry() + sr := io.NewSectionReader(bytes.NewReader(b), 0, int64(len(b))) + r, err := Open( + sr, + WithDecompressors(cl1), + WithTelemetry(telemetry), + ) + if err != nil { + t.Fatalf("stargz.Open: %v", err) + } + wantTOCVersion := 1 + if tt.wantTOCVersion > 0 { + wantTOCVersion = tt.wantTOCVersion + } + if r.toc.Version != wantTOCVersion { + t.Fatalf("invalid TOC Version %d; wanted %d", r.toc.Version, wantTOCVersion) + } + + footerSize := cl1.FooterSize() + footerOffset := sr.Size() - footerSize + footer := make([]byte, footerSize) + if _, err := sr.ReadAt(footer, footerOffset); err != nil { + t.Errorf("failed to read footer: %v", err) + } + _, tocOffset, _, err := cl1.ParseFooter(footer) + if err != nil { + t.Errorf("failed to parse footer: %v", err) + } + if err := checkCalled(tocOffset >= 0); err != nil { + t.Errorf("telemetry failure: %v", err) + } + + wantNumGz := tt.wantNumGz + if lossless && tt.wantNumGzLossLess > 0 { + wantNumGz = tt.wantNumGzLossLess + } + streamOffsets := []int64{0} + prevOffset := int64(-1) + streams := 0 + for _, e := range r.toc.Entries { + if e.Offset > prevOffset { + streamOffsets = append(streamOffsets, e.Offset) + prevOffset = e.Offset + streams++ + } + } + streams++ // TOC + if tocOffset >= 0 { + // toc is in the blob + streamOffsets = append(streamOffsets, tocOffset) + } + streams++ // footer + streamOffsets = append(streamOffsets, footerOffset) + if streams != wantNumGz { + t.Errorf("number of streams in TOC = %d; want %d", streams, wantNumGz) + } + + t.Logf("testing streams: %+v", streamOffsets) + cl1.TestStreams(t, b, streamOffsets) + + for _, want := range tt.want { + want.check(t, r) + } + }) + } + } + } + } + } +} + +type chunkInfo struct { + name string + data string +} + +func newCalledTelemetry() (telemetry *Telemetry, check func(needsGetTOC bool) error) { + var getFooterLatencyCalled bool + var getTocLatencyCalled bool + var deserializeTocLatencyCalled bool + return &Telemetry{ + func(time.Time) { getFooterLatencyCalled = true }, + func(time.Time) { getTocLatencyCalled = true }, + func(time.Time) { deserializeTocLatencyCalled = true }, + }, func(needsGetTOC bool) error { + var allErr []error + if !getFooterLatencyCalled { + allErr = append(allErr, fmt.Errorf("metrics GetFooterLatency isn't called")) + } + if needsGetTOC { + if !getTocLatencyCalled { + allErr = append(allErr, fmt.Errorf("metrics GetTocLatency isn't called")) + } + } + if !deserializeTocLatencyCalled { + allErr = append(allErr, fmt.Errorf("metrics DeserializeTocLatency isn't called")) + } + return errorutil.Aggregate(allErr) + } +} + +func digestFor(content string) string { + sum := sha256.Sum256([]byte(content)) + return fmt.Sprintf("sha256:%x", sum) +} + +type numTOCEntries int + +func (n numTOCEntries) check(t *testing.T, r *Reader) { + if r.toc == nil { + t.Fatal("nil TOC") + } + if got, want := len(r.toc.Entries), int(n); got != want { + t.Errorf("got %d TOC entries; want %d", got, want) + } + t.Logf("got TOC entries:") + for i, ent := range r.toc.Entries { + entj, _ := json.Marshal(ent) + t.Logf(" [%d]: %s\n", i, entj) + } + if t.Failed() { + t.FailNow() + } +} + +func checks(s ...stargzCheck) []stargzCheck { return s } + +type stargzCheck interface { + check(t *testing.T, r *Reader) +} + +type stargzCheckFn func(*testing.T, *Reader) + +func (f stargzCheckFn) check(t *testing.T, r *Reader) { f(t, r) } + +func maxDepth(max int) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + e, ok := r.Lookup("") + if !ok { + t.Fatal("root directory not found") + } + d, err := getMaxDepth(t, e, 0, 10*max) + if err != nil { + t.Errorf("failed to get max depth (wanted %d): %v", max, err) + return + } + if d != max { + t.Errorf("invalid depth %d; want %d", d, max) + return + } + }) +} + +func getMaxDepth(t *testing.T, e *TOCEntry, current, limit int) (max int, rErr error) { + if current > limit { + return -1, fmt.Errorf("walkMaxDepth: exceeds limit: current:%d > limit:%d", + current, limit) + } + max = current + e.ForeachChild(func(baseName string, ent *TOCEntry) bool { + t.Logf("%q(basename:%q) is child of %q\n", ent.Name, baseName, e.Name) + d, err := getMaxDepth(t, ent, current+1, limit) + if err != nil { + rErr = err + return false + } + if d > max { + max = d + } + return true + }) + return +} + +func hasFileLen(file string, wantLen int) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + for _, ent := range r.toc.Entries { + if ent.Name == file { + if ent.Type != "reg" { + t.Errorf("file type of %q is %q; want \"reg\"", file, ent.Type) + } else if ent.Size != int64(wantLen) { + t.Errorf("file size of %q = %d; want %d", file, ent.Size, wantLen) + } + return + } + } + t.Errorf("file %q not found", file) + }) +} + +func hasFileXattrs(file, name, value string) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + for _, ent := range r.toc.Entries { + if ent.Name == file { + if ent.Type != "reg" { + t.Errorf("file type of %q is %q; want \"reg\"", file, ent.Type) + } + if ent.Xattrs == nil { + t.Errorf("file %q has no xattrs", file) + return + } + valueFound, found := ent.Xattrs[name] + if !found { + t.Errorf("file %q has no xattr %q", file, name) + return + } + if string(valueFound) != value { + t.Errorf("file %q has xattr %q with value %q instead of %q", file, name, valueFound, value) + } + + return + } + } + t.Errorf("file %q not found", file) + }) +} + +func hasFileDigest(file string, digest string) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + ent, ok := r.Lookup(file) + if !ok { + t.Fatalf("didn't find TOCEntry for file %q", file) + } + if ent.Digest != digest { + t.Fatalf("Digest(%q) = %q, want %q", file, ent.Digest, digest) + } + }) +} + +func hasFileContentsWithPreRead(file string, offset int, want string, extra ...chunkInfo) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + extraMap := make(map[string]chunkInfo) + for _, e := range extra { + extraMap[e.name] = e + } + var extraNames []string + for n := range extraMap { + extraNames = append(extraNames, n) + } + f, err := r.OpenFileWithPreReader(file, func(e *TOCEntry, cr io.Reader) error { + t.Logf("On %q: got preread of %q", file, e.Name) + ex, ok := extraMap[e.Name] + if !ok { + t.Fatalf("fail on %q: unexpected entry %q: %+v, %+v", file, e.Name, e, extraNames) + } + got, err := io.ReadAll(cr) + if err != nil { + t.Fatalf("fail on %q: failed to read %q: %v", file, e.Name, err) + } + if ex.data != string(got) { + t.Fatalf("fail on %q: unexpected contents of %q: len=%d; want=%d", file, e.Name, len(got), len(ex.data)) + } + delete(extraMap, e.Name) + return nil + }) + if err != nil { + t.Fatal(err) + } + got := make([]byte, len(want)) + n, err := f.ReadAt(got, int64(offset)) + if err != nil { + t.Fatalf("ReadAt(len %d, offset %d, size %d) = %v, %v", len(got), offset, f.Size(), n, err) + } + if string(got) != want { + t.Fatalf("ReadAt(len %d, offset %d) = %q, want %q", len(got), offset, viewContent(got), viewContent([]byte(want))) + } + if len(extraMap) != 0 { + var exNames []string + for _, ex := range extraMap { + exNames = append(exNames, ex.name) + } + t.Fatalf("fail on %q: some entries aren't read: %+v", file, exNames) + } + }) +} + +func hasFileContentsRange(file string, offset int, want string) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + f, err := r.OpenFile(file) + if err != nil { + t.Fatal(err) + } + got := make([]byte, len(want)) + n, err := f.ReadAt(got, int64(offset)) + if err != nil { + t.Fatalf("ReadAt(len %d, offset %d) = %v, %v", len(got), offset, n, err) + } + if string(got) != want { + t.Fatalf("ReadAt(len %d, offset %d) = %q, want %q", len(got), offset, viewContent(got), viewContent([]byte(want))) + } + }) +} + +func hasChunkEntries(file string, wantChunks int) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + ent, ok := r.Lookup(file) + if !ok { + t.Fatalf("no file for %q", file) + } + if ent.Type != "reg" { + t.Fatalf("file %q has unexpected type %q; want reg", file, ent.Type) + } + chunks := r.getChunks(ent) + if len(chunks) != wantChunks { + t.Errorf("len(r.getChunks(%q)) = %d; want %d", file, len(chunks), wantChunks) + return + } + f := chunks[0] + + var gotChunks []*TOCEntry + var last *TOCEntry + for off := int64(0); off < f.Size; off++ { + e, ok := r.ChunkEntryForOffset(file, off) + if !ok { + t.Errorf("no ChunkEntryForOffset at %d", off) + return + } + if last != e { + gotChunks = append(gotChunks, e) + last = e + } + } + if !reflect.DeepEqual(chunks, gotChunks) { + t.Errorf("gotChunks=%d, want=%d; contents mismatch", len(gotChunks), wantChunks) + } + + // And verify the NextOffset + for i := 0; i < len(gotChunks)-1; i++ { + ci := gotChunks[i] + cnext := gotChunks[i+1] + if ci.NextOffset() != cnext.Offset { + t.Errorf("chunk %d NextOffset %d != next chunk's Offset of %d", i, ci.NextOffset(), cnext.Offset) + } + } + }) +} + +func entryHasChildren(dir string, want ...string) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + want := append([]string(nil), want...) + var got []string + ent, ok := r.Lookup(dir) + if !ok { + t.Fatalf("didn't find TOCEntry for dir node %q", dir) + } + for baseName := range ent.children { + got = append(got, baseName) + } + sort.Strings(got) + sort.Strings(want) + if !reflect.DeepEqual(got, want) { + t.Errorf("children of %q = %q; want %q", dir, got, want) + } + }) +} + +func hasDir(file string) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + for _, ent := range r.toc.Entries { + if ent.Name == cleanEntryName(file) { + if ent.Type != "dir" { + t.Errorf("file type of %q is %q; want \"dir\"", file, ent.Type) + } + return + } + } + t.Errorf("directory %q not found", file) + }) +} + +func hasDirLinkCount(file string, count int) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + for _, ent := range r.toc.Entries { + if ent.Name == cleanEntryName(file) { + if ent.Type != "dir" { + t.Errorf("file type of %q is %q; want \"dir\"", file, ent.Type) + return + } + if ent.NumLink != count { + t.Errorf("link count of %q = %d; want %d", file, ent.NumLink, count) + } + return + } + } + t.Errorf("directory %q not found", file) + }) +} + +func hasMode(file string, mode os.FileMode) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + for _, ent := range r.toc.Entries { + if ent.Name == cleanEntryName(file) { + if ent.Stat().Mode() != mode { + t.Errorf("invalid mode: got %v; want %v", ent.Stat().Mode(), mode) + return + } + return + } + } + t.Errorf("file %q not found", file) + }) +} + +func hasSymlink(file, target string) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + for _, ent := range r.toc.Entries { + if ent.Name == file { + if ent.Type != "symlink" { + t.Errorf("file type of %q is %q; want \"symlink\"", file, ent.Type) + } else if ent.LinkName != target { + t.Errorf("link target of symlink %q is %q; want %q", file, ent.LinkName, target) + } + return + } + } + t.Errorf("symlink %q not found", file) + }) +} + +func lookupMatch(name string, want *TOCEntry) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + e, ok := r.Lookup(name) + if !ok { + t.Fatalf("failed to Lookup entry %q", name) + } + if !reflect.DeepEqual(e, want) { + t.Errorf("entry %q mismatch.\n got: %+v\nwant: %+v\n", name, e, want) + } + + }) +} + +func hasEntryOwner(entry string, owner owner) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + ent, ok := r.Lookup(strings.TrimSuffix(entry, "/")) + if !ok { + t.Errorf("entry %q not found", entry) + return + } + if ent.UID != owner.uid || ent.GID != owner.gid { + t.Errorf("entry %q has invalid owner (uid:%d, gid:%d) instead of (uid:%d, gid:%d)", entry, ent.UID, ent.GID, owner.uid, owner.gid) + return + } + }) +} + +func mustSameEntry(files ...string) stargzCheck { + return stargzCheckFn(func(t *testing.T, r *Reader) { + var first *TOCEntry + for _, f := range files { + if first == nil { + var ok bool + first, ok = r.Lookup(f) + if !ok { + t.Errorf("unknown first file on Lookup: %q", f) + return + } + } + + // Test Lookup + e, ok := r.Lookup(f) + if !ok { + t.Errorf("unknown file on Lookup: %q", f) + return + } + if e != first { + t.Errorf("Lookup: %+v(%p) != %+v(%p)", e, e, first, first) + return + } + + // Test LookupChild + pe, ok := r.Lookup(filepath.Dir(filepath.Clean(f))) + if !ok { + t.Errorf("failed to get parent of %q", f) + return + } + e, ok = pe.LookupChild(filepath.Base(filepath.Clean(f))) + if !ok { + t.Errorf("failed to get %q as the child of %+v", f, pe) + return + } + if e != first { + t.Errorf("LookupChild: %+v(%p) != %+v(%p)", e, e, first, first) + return + } + + // Test ForeachChild + pe.ForeachChild(func(baseName string, e *TOCEntry) bool { + if baseName == filepath.Base(filepath.Clean(f)) { + if e != first { + t.Errorf("ForeachChild: %+v(%p) != %+v(%p)", e, e, first, first) + return false + } + } + return true + }) + } + }) +} + +func viewContent(c []byte) string { + if len(c) < 100 { + return string(c) + } + return string(c[:50]) + "...(omit)..." + string(c[50:100]) +} + +func tarOf(s ...tarEntry) []tarEntry { return s } + +type tarEntry interface { + appendTar(tw *tar.Writer, prefix string, format tar.Format) error +} + +type tarEntryFunc func(*tar.Writer, string, tar.Format) error + +func (f tarEntryFunc) appendTar(tw *tar.Writer, prefix string, format tar.Format) error { + return f(tw, prefix, format) +} + +func buildTar(t *testing.T, ents []tarEntry, prefix string, opts ...interface{}) *io.SectionReader { + format := tar.FormatUnknown + for _, opt := range opts { + switch v := opt.(type) { + case tar.Format: + format = v + default: + panic(fmt.Errorf("unsupported opt for buildTar: %v", opt)) + } + } + buf := new(bytes.Buffer) + tw := tar.NewWriter(buf) + for _, ent := range ents { + if err := ent.appendTar(tw, prefix, format); err != nil { + t.Fatalf("building input tar: %v", err) + } + } + if err := tw.Close(); err != nil { + t.Errorf("closing write of input tar: %v", err) + } + data := append(buf.Bytes(), make([]byte, 100)...) // append empty bytes at the tail to see lossless works + return io.NewSectionReader(bytes.NewReader(data), 0, int64(len(data))) +} + +func dir(name string, opts ...interface{}) tarEntry { + return tarEntryFunc(func(tw *tar.Writer, prefix string, format tar.Format) error { + var o owner + mode := os.FileMode(0755) + for _, opt := range opts { + switch v := opt.(type) { + case owner: + o = v + case os.FileMode: + mode = v + default: + return errors.New("unsupported opt") + } + } + if !strings.HasSuffix(name, "/") { + panic(fmt.Sprintf("missing trailing slash in dir %q ", name)) + } + tm, err := fileModeToTarMode(mode) + if err != nil { + return err + } + return tw.WriteHeader(&tar.Header{ + Typeflag: tar.TypeDir, + Name: prefix + name, + Mode: tm, + Uid: o.uid, + Gid: o.gid, + Format: format, + }) + }) +} + +// xAttr are extended attributes to set on test files created with the file func. +type xAttr map[string]string + +// owner is owner ot set on test files and directories with the file and dir functions. +type owner struct { + uid int + gid int +} + +func file(name, contents string, opts ...interface{}) tarEntry { + return tarEntryFunc(func(tw *tar.Writer, prefix string, format tar.Format) error { + var xattrs xAttr + var o owner + mode := os.FileMode(0644) + for _, opt := range opts { + switch v := opt.(type) { + case xAttr: + xattrs = v + case owner: + o = v + case os.FileMode: + mode = v + default: + return errors.New("unsupported opt") + } + } + if strings.HasSuffix(name, "/") { + return fmt.Errorf("bogus trailing slash in file %q", name) + } + tm, err := fileModeToTarMode(mode) + if err != nil { + return err + } + if len(xattrs) > 0 { + format = tar.FormatPAX // only PAX supports xattrs + } + if err := tw.WriteHeader(&tar.Header{ + Typeflag: tar.TypeReg, + Name: prefix + name, + Mode: tm, + Xattrs: xattrs, + Size: int64(len(contents)), + Uid: o.uid, + Gid: o.gid, + Format: format, + }); err != nil { + return err + } + _, err = io.WriteString(tw, contents) + return err + }) +} + +func symlink(name, target string) tarEntry { + return tarEntryFunc(func(tw *tar.Writer, prefix string, format tar.Format) error { + return tw.WriteHeader(&tar.Header{ + Typeflag: tar.TypeSymlink, + Name: prefix + name, + Linkname: target, + Mode: 0644, + Format: format, + }) + }) +} + +func link(name string, linkname string) tarEntry { + now := time.Now() + return tarEntryFunc(func(w *tar.Writer, prefix string, format tar.Format) error { + return w.WriteHeader(&tar.Header{ + Typeflag: tar.TypeLink, + Name: prefix + name, + Linkname: linkname, + ModTime: now, + Format: format, + }) + }) +} + +func chardev(name string, major, minor int64) tarEntry { + now := time.Now() + return tarEntryFunc(func(w *tar.Writer, prefix string, format tar.Format) error { + return w.WriteHeader(&tar.Header{ + Typeflag: tar.TypeChar, + Name: prefix + name, + Devmajor: major, + Devminor: minor, + ModTime: now, + Format: format, + }) + }) +} + +func blockdev(name string, major, minor int64) tarEntry { + now := time.Now() + return tarEntryFunc(func(w *tar.Writer, prefix string, format tar.Format) error { + return w.WriteHeader(&tar.Header{ + Typeflag: tar.TypeBlock, + Name: prefix + name, + Devmajor: major, + Devminor: minor, + ModTime: now, + Format: format, + }) + }) +} +func fifo(name string) tarEntry { + now := time.Now() + return tarEntryFunc(func(w *tar.Writer, prefix string, format tar.Format) error { + return w.WriteHeader(&tar.Header{ + Typeflag: tar.TypeFifo, + Name: prefix + name, + ModTime: now, + Format: format, + }) + }) +} + +func prefetchLandmark() tarEntry { + return tarEntryFunc(func(w *tar.Writer, prefix string, format tar.Format) error { + if err := w.WriteHeader(&tar.Header{ + Name: PrefetchLandmark, + Typeflag: tar.TypeReg, + Size: int64(len([]byte{landmarkContents})), + Format: format, + }); err != nil { + return err + } + contents := []byte{landmarkContents} + if _, err := io.CopyN(w, bytes.NewReader(contents), int64(len(contents))); err != nil { + return err + } + return nil + }) +} + +func noPrefetchLandmark() tarEntry { + return tarEntryFunc(func(w *tar.Writer, prefix string, format tar.Format) error { + if err := w.WriteHeader(&tar.Header{ + Name: NoPrefetchLandmark, + Typeflag: tar.TypeReg, + Size: int64(len([]byte{landmarkContents})), + Format: format, + }); err != nil { + return err + } + contents := []byte{landmarkContents} + if _, err := io.CopyN(w, bytes.NewReader(contents), int64(len(contents))); err != nil { + return err + } + return nil + }) +} + +func regDigest(t *testing.T, name string, contentStr string, digestMap map[string]digest.Digest) tarEntry { + if digestMap == nil { + t.Fatalf("digest map mustn't be nil") + } + content := []byte(contentStr) + + var n int64 + for n < int64(len(content)) { + size := int64(chunkSize) + remain := int64(len(content)) - n + if remain < size { + size = remain + } + dgstr := digest.Canonical.Digester() + if _, err := io.CopyN(dgstr.Hash(), bytes.NewReader(content[n:n+size]), size); err != nil { + t.Fatalf("failed to calculate digest of %q (name=%q,offset=%d,size=%d)", + string(content[n:n+size]), name, n, size) + } + digestMap[chunkID(name, n, size)] = dgstr.Digest() + n += size + } + + return tarEntryFunc(func(w *tar.Writer, prefix string, format tar.Format) error { + if err := w.WriteHeader(&tar.Header{ + Typeflag: tar.TypeReg, + Name: prefix + name, + Size: int64(len(content)), + Format: format, + }); err != nil { + return err + } + if _, err := io.CopyN(w, bytes.NewReader(content), int64(len(content))); err != nil { + return err + } + return nil + }) +} + +var runes = []rune("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + +func randomContents(n int) string { + b := make([]rune, n) + for i := range b { + b[i] = runes[rand.Intn(len(runes))] + } + return string(b) +} + +func fileModeToTarMode(mode os.FileMode) (int64, error) { + h, err := tar.FileInfoHeader(fileInfoOnlyMode(mode), "") + if err != nil { + return 0, err + } + return h.Mode, nil +} + +// fileInfoOnlyMode is os.FileMode that populates only file mode. +type fileInfoOnlyMode os.FileMode + +func (f fileInfoOnlyMode) Name() string { return "" } +func (f fileInfoOnlyMode) Size() int64 { return 0 } +func (f fileInfoOnlyMode) Mode() os.FileMode { return os.FileMode(f) } +func (f fileInfoOnlyMode) ModTime() time.Time { return time.Now() } +func (f fileInfoOnlyMode) IsDir() bool { return os.FileMode(f).IsDir() } +func (f fileInfoOnlyMode) Sys() interface{} { return nil } + +func CheckGzipHasStreams(t *testing.T, b []byte, streams []int64) { + if len(streams) == 0 { + return // nop + } + + wants := map[int64]struct{}{} + for _, s := range streams { + wants[s] = struct{}{} + } + + len0 := len(b) + br := bytes.NewReader(b) + zr := new(gzip.Reader) + t.Logf("got gzip streams:") + numStreams := 0 + for { + zoff := len0 - br.Len() + if err := zr.Reset(br); err != nil { + if err == io.EOF { + return + } + t.Fatalf("countStreams(gzip), Reset: %v", err) + } + zr.Multistream(false) + n, err := io.Copy(io.Discard, zr) + if err != nil { + t.Fatalf("countStreams(gzip), Copy: %v", err) + } + var extra string + if len(zr.Header.Extra) > 0 { + extra = fmt.Sprintf("; extra=%q", zr.Header.Extra) + } + t.Logf(" [%d] at %d in stargz, uncompressed length %d%s", numStreams, zoff, n, extra) + delete(wants, int64(zoff)) + numStreams++ + } +} + +func GzipDiffIDOf(t *testing.T, b []byte) string { + h := sha256.New() + zr, err := gzip.NewReader(bytes.NewReader(b)) + if err != nil { + t.Fatalf("diffIDOf(gzip): %v", err) + } + defer zr.Close() + if _, err := io.Copy(h, zr); err != nil { + t.Fatalf("diffIDOf(gzip).Copy: %v", err) + } + return fmt.Sprintf("sha256:%x", h.Sum(nil)) +} diff --git a/vendor/github.com/containerd/stargz-snapshotter/estargz/types.go b/vendor/github.com/containerd/stargz-snapshotter/estargz/types.go new file mode 100644 index 000000000..57e0aa614 --- /dev/null +++ b/vendor/github.com/containerd/stargz-snapshotter/estargz/types.go @@ -0,0 +1,342 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + Copyright 2019 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 estargz + +import ( + "archive/tar" + "hash" + "io" + "os" + "path" + "time" + + digest "github.com/opencontainers/go-digest" +) + +const ( + // TOCTarName is the name of the JSON file in the tar archive in the + // table of contents gzip stream. + TOCTarName = "stargz.index.json" + + // FooterSize is the number of bytes in the footer + // + // The footer is an empty gzip stream with no compression and an Extra + // header of the form "%016xSTARGZ", where the 64 bit hex-encoded + // number is the offset to the gzip stream of JSON TOC. + // + // 51 comes from: + // + // 10 bytes gzip header + // 2 bytes XLEN (length of Extra field) = 26 (4 bytes header + 16 hex digits + len("STARGZ")) + // 2 bytes Extra: SI1 = 'S', SI2 = 'G' + // 2 bytes Extra: LEN = 22 (16 hex digits + len("STARGZ")) + // 22 bytes Extra: subfield = fmt.Sprintf("%016xSTARGZ", offsetOfTOC) + // 5 bytes flate header + // 8 bytes gzip footer + // (End of the eStargz blob) + // + // NOTE: For Extra fields, subfield IDs SI1='S' SI2='G' is used for eStargz. + FooterSize = 51 + + // legacyFooterSize is the number of bytes in the legacy stargz footer. + // + // 47 comes from: + // + // 10 byte gzip header + + // 2 byte (LE16) length of extra, encoding 22 (16 hex digits + len("STARGZ")) == "\x16\x00" + + // 22 bytes of extra (fmt.Sprintf("%016xSTARGZ", tocGzipOffset)) + // 5 byte flate header + // 8 byte gzip footer (two little endian uint32s: digest, size) + legacyFooterSize = 47 + + // TOCJSONDigestAnnotation is an annotation for an image layer. This stores the + // digest of the TOC JSON. + // This annotation is valid only when it is specified in `.[]layers.annotations` + // of an image manifest. + TOCJSONDigestAnnotation = "containerd.io/snapshot/stargz/toc.digest" + + // StoreUncompressedSizeAnnotation is an additional annotation key for eStargz to enable lazy + // pulling on containers/storage. Stargz Store is required to expose the layer's uncompressed size + // to the runtime but current OCI image doesn't ship this information by default. So we store this + // to the special annotation. + StoreUncompressedSizeAnnotation = "io.containers.estargz.uncompressed-size" + + // PrefetchLandmark is a file entry which indicates the end position of + // prefetch in the stargz file. + PrefetchLandmark = ".prefetch.landmark" + + // NoPrefetchLandmark is a file entry which indicates that no prefetch should + // occur in the stargz file. + NoPrefetchLandmark = ".no.prefetch.landmark" + + landmarkContents = 0xf +) + +// JTOC is the JSON-serialized table of contents index of the files in the stargz file. +type JTOC struct { + Version int `json:"version"` + Entries []*TOCEntry `json:"entries"` +} + +// TOCEntry is an entry in the stargz file's TOC (Table of Contents). +type TOCEntry struct { + // Name is the tar entry's name. It is the complete path + // stored in the tar file, not just the base name. + Name string `json:"name"` + + // Type is one of "dir", "reg", "symlink", "hardlink", "char", + // "block", "fifo", or "chunk". + // The "chunk" type is used for regular file data chunks past the first + // TOCEntry; the 2nd chunk and on have only Type ("chunk"), Offset, + // ChunkOffset, and ChunkSize populated. + Type string `json:"type"` + + // Size, for regular files, is the logical size of the file. + Size int64 `json:"size,omitempty"` + + // ModTime3339 is the modification time of the tar entry. Empty + // means zero or unknown. Otherwise it's in UTC RFC3339 + // format. Use the ModTime method to access the time.Time value. + ModTime3339 string `json:"modtime,omitempty"` + modTime time.Time + + // LinkName, for symlinks and hardlinks, is the link target. + LinkName string `json:"linkName,omitempty"` + + // Mode is the permission and mode bits. + Mode int64 `json:"mode,omitempty"` + + // UID is the user ID of the owner. + UID int `json:"uid,omitempty"` + + // GID is the group ID of the owner. + GID int `json:"gid,omitempty"` + + // Uname is the username of the owner. + // + // In the serialized JSON, this field may only be present for + // the first entry with the same UID. + Uname string `json:"userName,omitempty"` + + // Gname is the group name of the owner. + // + // In the serialized JSON, this field may only be present for + // the first entry with the same GID. + Gname string `json:"groupName,omitempty"` + + // Offset, for regular files, provides the offset in the + // stargz file to the file's data bytes. See ChunkOffset and + // ChunkSize. + Offset int64 `json:"offset,omitempty"` + + // InnerOffset is an optional field indicates uncompressed offset + // of this "reg" or "chunk" payload in a stream starts from Offset. + // This field enables to put multiple "reg" or "chunk" payloads + // in one chunk with having the same Offset but different InnerOffset. + InnerOffset int64 `json:"innerOffset,omitempty"` + + nextOffset int64 // the Offset of the next entry with a non-zero Offset + + // DevMajor is the major device number for "char" and "block" types. + DevMajor int `json:"devMajor,omitempty"` + + // DevMinor is the major device number for "char" and "block" types. + DevMinor int `json:"devMinor,omitempty"` + + // NumLink is the number of entry names pointing to this entry. + // Zero means one name references this entry. + // This field is calculated during runtime and not recorded in TOC JSON. + NumLink int `json:"-"` + + // Xattrs are the extended attribute for the entry. + Xattrs map[string][]byte `json:"xattrs,omitempty"` + + // Digest stores the OCI checksum for regular files payload. + // It has the form "sha256:abcdef01234....". + Digest string `json:"digest,omitempty"` + + // ChunkOffset is non-zero if this is a chunk of a large, + // regular file. If so, the Offset is where the gzip header of + // ChunkSize bytes at ChunkOffset in Name begin. + // + // In serialized form, a "chunkSize" JSON field of zero means + // that the chunk goes to the end of the file. After reading + // from the stargz TOC, though, the ChunkSize is initialized + // to a non-zero file for when Type is either "reg" or + // "chunk". + ChunkOffset int64 `json:"chunkOffset,omitempty"` + ChunkSize int64 `json:"chunkSize,omitempty"` + + // ChunkDigest stores an OCI digest of the chunk. This must be formed + // as "sha256:0123abcd...". + ChunkDigest string `json:"chunkDigest,omitempty"` + + children map[string]*TOCEntry + + // chunkTopIndex is index of the entry where Offset starts in the blob. + chunkTopIndex int +} + +// ModTime returns the entry's modification time. +func (e *TOCEntry) ModTime() time.Time { return e.modTime } + +// NextOffset returns the position (relative to the start of the +// stargz file) of the next gzip boundary after e.Offset. +func (e *TOCEntry) NextOffset() int64 { return e.nextOffset } + +func (e *TOCEntry) addChild(baseName string, child *TOCEntry) { + if e.children == nil { + e.children = make(map[string]*TOCEntry) + } + if child.Type == "dir" { + e.NumLink++ // Entry ".." in the subdirectory links to this directory + } + e.children[baseName] = child +} + +// isDataType reports whether TOCEntry is a regular file or chunk (something that +// contains regular file data). +func (e *TOCEntry) isDataType() bool { return e.Type == "reg" || e.Type == "chunk" } + +// Stat returns a FileInfo value representing e. +func (e *TOCEntry) Stat() os.FileInfo { return fileInfo{e} } + +// ForeachChild calls f for each child item. If f returns false, iteration ends. +// If e is not a directory, f is not called. +func (e *TOCEntry) ForeachChild(f func(baseName string, ent *TOCEntry) bool) { + for name, ent := range e.children { + if !f(name, ent) { + return + } + } +} + +// LookupChild returns the directory e's child by its base name. +func (e *TOCEntry) LookupChild(baseName string) (child *TOCEntry, ok bool) { + child, ok = e.children[baseName] + return +} + +// fileInfo implements os.FileInfo using the wrapped *TOCEntry. +type fileInfo struct{ e *TOCEntry } + +var _ os.FileInfo = fileInfo{} + +func (fi fileInfo) Name() string { return path.Base(fi.e.Name) } +func (fi fileInfo) IsDir() bool { return fi.e.Type == "dir" } +func (fi fileInfo) Size() int64 { return fi.e.Size } +func (fi fileInfo) ModTime() time.Time { return fi.e.ModTime() } +func (fi fileInfo) Sys() interface{} { return fi.e } +func (fi fileInfo) Mode() (m os.FileMode) { + // TOCEntry.Mode is tar.Header.Mode so we can understand the these bits using `tar` pkg. + m = (&tar.Header{Mode: fi.e.Mode}).FileInfo().Mode() & + (os.ModePerm | os.ModeSetuid | os.ModeSetgid | os.ModeSticky) + switch fi.e.Type { + case "dir": + m |= os.ModeDir + case "symlink": + m |= os.ModeSymlink + case "char": + m |= os.ModeDevice | os.ModeCharDevice + case "block": + m |= os.ModeDevice + case "fifo": + m |= os.ModeNamedPipe + } + return m +} + +// TOCEntryVerifier holds verifiers that are usable for verifying chunks contained +// in a eStargz blob. +type TOCEntryVerifier interface { + + // Verifier provides a content verifier that can be used for verifying the + // contents of the specified TOCEntry. + Verifier(ce *TOCEntry) (digest.Verifier, error) +} + +// Compression provides the compression helper to be used creating and parsing eStargz. +// This package provides gzip-based Compression by default, but any compression +// algorithm (e.g. zstd) can be used as long as it implements Compression. +type Compression interface { + Compressor + Decompressor +} + +// Compressor represents the helper mothods to be used for creating eStargz. +type Compressor interface { + // Writer returns WriteCloser to be used for writing a chunk to eStargz. + // Everytime a chunk is written, the WriteCloser is closed and Writer is + // called again for writing the next chunk. + // + // The returned writer should implement "Flush() error" function that flushes + // any pending compressed data to the underlying writer. + Writer(w io.Writer) (WriteFlushCloser, error) + + // WriteTOCAndFooter is called to write JTOC to the passed Writer. + // diffHash calculates the DiffID (uncompressed sha256 hash) of the blob + // WriteTOCAndFooter can optionally write anything that affects DiffID calculation + // (e.g. uncompressed TOC JSON). + // + // This function returns tocDgst that represents the digest of TOC that will be used + // to verify this blob when it's parsed. + WriteTOCAndFooter(w io.Writer, off int64, toc *JTOC, diffHash hash.Hash) (tocDgst digest.Digest, err error) +} + +// Decompressor represents the helper mothods to be used for parsing eStargz. +type Decompressor interface { + // Reader returns ReadCloser to be used for decompressing file payload. + Reader(r io.Reader) (io.ReadCloser, error) + + // FooterSize returns the size of the footer of this blob. + FooterSize() int64 + + // ParseFooter parses the footer and returns the offset and (compressed) size of TOC. + // payloadBlobSize is the (compressed) size of the blob payload (i.e. the size between + // the top until the TOC JSON). + // + // If tocOffset < 0, we assume that TOC isn't contained in the blob and pass nil reader + // to ParseTOC. We expect that ParseTOC acquire TOC from the external location and return it. + // + // tocSize is optional. If tocSize <= 0, it's by default the size of the range from tocOffset until the beginning of the + // footer (blob size - tocOff - FooterSize). + // If blobPayloadSize < 0, blobPayloadSize become the blob size. + ParseFooter(p []byte) (blobPayloadSize, tocOffset, tocSize int64, err error) + + // ParseTOC parses TOC from the passed reader. The reader provides the partial contents + // of the underlying blob that has the range specified by ParseFooter method. + // + // This function returns tocDgst that represents the digest of TOC that will be used + // to verify this blob. This must match to the value returned from + // Compressor.WriteTOCAndFooter that is used when creating this blob. + // + // If tocOffset returned by ParseFooter is < 0, we assume that TOC isn't contained in the blob. + // Pass nil reader to ParseTOC then we expect that ParseTOC acquire TOC from the external location + // and return it. + ParseTOC(r io.Reader) (toc *JTOC, tocDgst digest.Digest, err error) +} + +type WriteFlushCloser interface { + io.WriteCloser + Flush() error +} diff --git a/vendor/github.com/docker/cli/cli/config/configfile/file.go b/vendor/github.com/docker/cli/cli/config/configfile/file.go index 609a88c27..5db7f8b82 100644 --- a/vendor/github.com/docker/cli/cli/config/configfile/file.go +++ b/vendor/github.com/docker/cli/cli/config/configfile/file.go @@ -37,7 +37,6 @@ type ConfigFile struct { PruneFilters []string `json:"pruneFilters,omitempty"` Proxies map[string]ProxyConfig `json:"proxies,omitempty"` Experimental string `json:"experimental,omitempty"` - StackOrchestrator string `json:"stackOrchestrator,omitempty"` // Deprecated: swarm is now the default orchestrator, and this option is ignored. CurrentContext string `json:"currentContext,omitempty"` CLIPluginsExtraDirs []string `json:"cliPluginsExtraDirs,omitempty"` Plugins map[string]map[string]string `json:"plugins,omitempty"` diff --git a/vendor/github.com/docker/docker/AUTHORS b/vendor/github.com/docker/docker/AUTHORS index 0728bfe18..b31418192 100644 --- a/vendor/github.com/docker/docker/AUTHORS +++ b/vendor/github.com/docker/docker/AUTHORS @@ -29,6 +29,7 @@ Adam Pointer Adam Singer Adam Walz Adam Williams +AdamKorcz Addam Hardy Aditi Rajagopal Aditya @@ -81,6 +82,7 @@ Alex Goodman Alex Nordlund Alex Olshansky Alex Samorukov +Alex Stockinger Alex Warhawk Alexander Artemenko Alexander Boyd @@ -198,6 +200,7 @@ Anusha Ragunathan Anyu Wang apocas Arash Deshmeh +arcosx ArikaChen Arko Dasgupta Arnaud Lefebvre @@ -241,6 +244,7 @@ Benjamin Atkin Benjamin Baker Benjamin Boudreau Benjamin Böhmke +Benjamin Wang Benjamin Yolken Benny Ng Benoit Chesneau @@ -634,6 +638,7 @@ Eng Zer Jun Enguerran Eohyung Lee epeterso +er0k Eric Barch Eric Curtin Eric G. Noriega @@ -754,6 +759,7 @@ Félix Baylac-Jacqué Félix Cantournet Gabe Rosenhouse Gabor Nagy +Gabriel Adrian Samfira Gabriel Goller Gabriel L. Somlo Gabriel Linder @@ -855,6 +861,7 @@ Hongbin Lu Hongxu Jia Honza Pokorny Hsing-Hui Hsu +Hsing-Yu (David) Chen hsinko <21551195@zju.edu.cn> Hu Keping Hu Tao @@ -887,6 +894,7 @@ Igor Dolzhikov Igor Karpovich Iliana Weller Ilkka Laukkanen +Illia Antypenko Illo Abdulrahim Ilya Dmitrichenko Ilya Gusev @@ -938,6 +946,7 @@ Jamie Hannaford Jamshid Afshar Jan Breig Jan Chren +Jan Garcia Jan Götte Jan Keromnes Jan Koprowski @@ -1206,6 +1215,7 @@ Kimbro Staken Kir Kolyshkin Kiran Gangadharan Kirill SIbirev +Kirk Easterson knappe Kohei Tsuruta Koichi Shiraishi @@ -1240,10 +1250,12 @@ Lars Kellogg-Stedman Lars R. Damerow Lars-Magnus Skog Laszlo Meszaros +Laura Brehm Laura Frank Laurent Bernaille Laurent Erignoux Laurie Voss +Leandro Motta Barros Leandro Siqueira Lee Calcote Lee Chao <932819864@qq.com> @@ -1563,6 +1575,7 @@ Nick Neisen Nick Parker Nick Payne Nick Russo +Nick Santos Nick Stenning Nick Stinemates Nick Wood @@ -1584,6 +1597,7 @@ NikolaMandic Nikolas Garofil Nikolay Edigaryev Nikolay Milovanov +ningmingxiao Nirmal Mehta Nishant Totla NIWA Hideyuki @@ -1615,6 +1629,7 @@ Omri Shiv Onur Filiz Oriol Francès Oscar Bonilla <6f6231@gmail.com> +oscar.chen <2972789494@qq.com> Oskar Niburski Otto Kekäläinen Ouyang Liduo @@ -1822,6 +1837,7 @@ Rory Hunter Rory McCune Ross Boucher Rovanion Luckey +Roy Reznik Royce Remer Rozhnov Alexandr Rudolph Gottesheim @@ -2271,6 +2287,7 @@ Xiaoyu Zhang xichengliudui <1693291525@qq.com> xiekeyang Ximo Guanter Gonzálbez +xin.li Xinbo Weng Xinfeng Liu Xinzi Zhou @@ -2282,6 +2299,7 @@ Yahya yalpul YAMADA Tsuyoshi Yamasaki Masahide +Yamazaki Masashi Yan Feng Yan Zhu Yang Bai diff --git a/vendor/github.com/docker/docker/api/common.go b/vendor/github.com/docker/docker/api/common.go index bee9b875a..cba66bc46 100644 --- a/vendor/github.com/docker/docker/api/common.go +++ b/vendor/github.com/docker/docker/api/common.go @@ -3,7 +3,7 @@ package api // import "github.com/docker/docker/api" // Common constants for daemon and client. const ( // DefaultVersion of Current REST API - DefaultVersion = "1.42" + DefaultVersion = "1.43" // NoBaseImageSpecifier is the symbol used by the FROM // command to specify that no base image is to be used. diff --git a/vendor/github.com/docker/docker/api/swagger.yaml b/vendor/github.com/docker/docker/api/swagger.yaml index afe7a8c37..c2943888d 100644 --- a/vendor/github.com/docker/docker/api/swagger.yaml +++ b/vendor/github.com/docker/docker/api/swagger.yaml @@ -19,10 +19,10 @@ produces: consumes: - "application/json" - "text/plain" -basePath: "/v1.42" +basePath: "/v1.43" info: title: "Docker Engine API" - version: "1.42" + version: "1.43" x-logo: url: "https://docs.docker.com/assets/images/logo-docker-main.png" description: | @@ -55,8 +55,8 @@ info: the URL is not supported by the daemon, a HTTP `400 Bad Request` error message is returned. - If you omit the version-prefix, the current version of the API (v1.42) is used. - For example, calling `/info` is the same as calling `/v1.42/info`. Using the + If you omit the version-prefix, the current version of the API (v1.43) is used. + For example, calling `/info` is the same as calling `/v1.43/info`. Using the API without a version-prefix is deprecated and will be removed in a future release. Engine releases in the near future should support this version of the API, @@ -976,6 +976,13 @@ definitions: items: type: "integer" minimum: 0 + Annotations: + type: "object" + description: | + Arbitrary non-identifying metadata attached to container and + provided to the runtime when the container is started. + additionalProperties: + type: "string" # Applicable to UNIX platforms CapAdd: @@ -1122,6 +1129,7 @@ definitions: remapping option is enabled. ShmSize: type: "integer" + format: "int64" description: | Size of `/dev/shm` in bytes. If omitted, the system uses 64MB. minimum: 0 @@ -1610,6 +1618,34 @@ definitions: "WorkDir": "/var/lib/docker/overlay2/ef749362d13333e65fc95c572eb525abbe0052e16e086cb64bc3b98ae9aa6d74/work" } + FilesystemChange: + description: | + Change in the container's filesystem. + type: "object" + required: [Path, Kind] + properties: + Path: + description: | + Path to file or directory that has changed. + type: "string" + x-nullable: false + Kind: + $ref: "#/definitions/ChangeType" + + ChangeType: + description: | + Kind of change + + Can be one of: + + - `0`: Modified ("C") + - `1`: Added ("A") + - `2`: Deleted ("D") + type: "integer" + format: "uint8" + enum: [0, 1, 2] + x-nullable: false + ImageInspect: description: | Information about an image in the local image cache. @@ -1746,15 +1782,14 @@ definitions: Total size of the image including all layers it is composed of. In versions of Docker before v1.10, this field was calculated from - the image itself and all of its parent images. Docker v1.10 and up - store images self-contained, and no longer use a parent-chain, making - this field an equivalent of the Size field. + the image itself and all of its parent images. Images are now stored + self-contained, and no longer use a parent-chain, making this field + an equivalent of the Size field. - This field is kept for backward compatibility, but may be removed in - a future version of the API. + > **Deprecated**: this field is kept for backward compatibility, but + > will be removed in API v1.44. type: "integer" format: "int64" - x-nullable: false example: 1239828 GraphDriver: $ref: "#/definitions/GraphDriverData" @@ -1802,7 +1837,6 @@ definitions: - Created - Size - SharedSize - - VirtualSize - Labels - Containers properties: @@ -1888,19 +1922,17 @@ definitions: x-nullable: false example: 1239828 VirtualSize: - description: | + description: |- Total size of the image including all layers it is composed of. In versions of Docker before v1.10, this field was calculated from - the image itself and all of its parent images. Docker v1.10 and up - store images self-contained, and no longer use a parent-chain, making - this field an equivalent of the Size field. + the image itself and all of its parent images. Images are now stored + self-contained, and no longer use a parent-chain, making this field + an equivalent of the Size field. - This field is kept for backward compatibility, but may be removed in - a future version of the API. + Deprecated: this field is kept for backward compatibility, and will be removed in API v1.44. type: "integer" format: "int64" - x-nullable: false example: 172064416 Labels: description: "User-defined key/value metadata." @@ -4652,7 +4684,8 @@ definitions: example: false OOMKilled: description: | - Whether this container has been killed because it ran out of memory. + Whether a process within this container has been killed because it ran + out of memory since the container was last started. type: "boolean" example: false Dead: @@ -5242,7 +5275,8 @@ definitions: SecurityOptions: description: | List of security features that are enabled on the daemon, such as - apparmor, seccomp, SELinux, user-namespaces (userns), and rootless. + apparmor, seccomp, SELinux, user-namespaces (userns), rootless and + no-new-privileges. Additional configuration options for each security feature may be present, and are included as a comma-separated list of key/value @@ -6875,9 +6909,9 @@ paths: Returns which files in a container's filesystem have been added, deleted, or modified. The `Kind` of modification can be one of: - - `0`: Modified - - `1`: Added - - `2`: Deleted + - `0`: Modified ("C") + - `1`: Added ("A") + - `2`: Deleted ("D") operationId: "ContainerChanges" produces: ["application/json"] responses: @@ -6886,22 +6920,7 @@ paths: schema: type: "array" items: - type: "object" - x-go-name: "ContainerChangeResponseItem" - title: "ContainerChangeResponseItem" - description: "change item in response to ContainerChanges operation" - required: [Path, Kind] - properties: - Path: - description: "Path to file that has changed" - type: "string" - x-nullable: false - Kind: - description: "Kind of change" - type: "integer" - format: "uint8" - enum: [0, 1, 2] - x-nullable: false + $ref: "#/definitions/FilesystemChange" examples: application/json: - Path: "/dev" @@ -8228,7 +8247,7 @@ paths: Available filters: - - `until=`: duration relative to daemon's time, during which build cache was not used, in Go's duration format (e.g., '24h') + - `until=` remove cache older than ``. The `` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon's local time. - `id=` - `parent=` - `type=` diff --git a/vendor/github.com/docker/docker/api/types/auth.go b/vendor/github.com/docker/docker/api/types/auth.go index ddf15bb18..9ee329a2f 100644 --- a/vendor/github.com/docker/docker/api/types/auth.go +++ b/vendor/github.com/docker/docker/api/types/auth.go @@ -1,22 +1,7 @@ package types // import "github.com/docker/docker/api/types" +import "github.com/docker/docker/api/types/registry" -// AuthConfig contains authorization information for connecting to a Registry -type AuthConfig struct { - Username string `json:"username,omitempty"` - Password string `json:"password,omitempty"` - Auth string `json:"auth,omitempty"` - - // Email is an optional value associated with the username. - // This field is deprecated and will be removed in a later - // version of docker. - Email string `json:"email,omitempty"` - - ServerAddress string `json:"serveraddress,omitempty"` - - // IdentityToken is used to authenticate the user and get - // an access token for the registry. - IdentityToken string `json:"identitytoken,omitempty"` - - // RegistryToken is a bearer token to be sent to a registry - RegistryToken string `json:"registrytoken,omitempty"` -} +// AuthConfig contains authorization information for connecting to a Registry. +// +// Deprecated: use github.com/docker/docker/api/types/registry.AuthConfig +type AuthConfig = registry.AuthConfig diff --git a/vendor/github.com/docker/docker/api/types/client.go b/vendor/github.com/docker/docker/api/types/client.go index 97aca0230..d8cd30613 100644 --- a/vendor/github.com/docker/docker/api/types/client.go +++ b/vendor/github.com/docker/docker/api/types/client.go @@ -7,6 +7,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/registry" units "github.com/docker/go-units" ) @@ -180,7 +181,7 @@ type ImageBuildOptions struct { // at all (nil). See the parsing of buildArgs in // api/server/router/build/build_routes.go for even more info. BuildArgs map[string]*string - AuthConfigs map[string]AuthConfig + AuthConfigs map[string]registry.AuthConfig Context io.Reader Labels map[string]string // squash the resulting image's layers to the parent diff --git a/vendor/github.com/docker/docker/api/types/container/change_response_deprecated.go b/vendor/github.com/docker/docker/api/types/container/change_response_deprecated.go new file mode 100644 index 000000000..6b4b47390 --- /dev/null +++ b/vendor/github.com/docker/docker/api/types/container/change_response_deprecated.go @@ -0,0 +1,6 @@ +package container + +// ContainerChangeResponseItem change item in response to ContainerChanges operation +// +// Deprecated: use [FilesystemChange]. +type ContainerChangeResponseItem = FilesystemChange diff --git a/vendor/github.com/docker/docker/api/types/container/change_type.go b/vendor/github.com/docker/docker/api/types/container/change_type.go new file mode 100644 index 000000000..fe8d6d369 --- /dev/null +++ b/vendor/github.com/docker/docker/api/types/container/change_type.go @@ -0,0 +1,15 @@ +package container + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// ChangeType Kind of change +// +// Can be one of: +// +// - `0`: Modified ("C") +// - `1`: Added ("A") +// - `2`: Deleted ("D") +// +// swagger:model ChangeType +type ChangeType uint8 diff --git a/vendor/github.com/docker/docker/api/types/container/change_types.go b/vendor/github.com/docker/docker/api/types/container/change_types.go new file mode 100644 index 000000000..3a3a83866 --- /dev/null +++ b/vendor/github.com/docker/docker/api/types/container/change_types.go @@ -0,0 +1,23 @@ +package container + +const ( + // ChangeModify represents the modify operation. + ChangeModify ChangeType = 0 + // ChangeAdd represents the add operation. + ChangeAdd ChangeType = 1 + // ChangeDelete represents the delete operation. + ChangeDelete ChangeType = 2 +) + +func (ct ChangeType) String() string { + switch ct { + case ChangeModify: + return "C" + case ChangeAdd: + return "A" + case ChangeDelete: + return "D" + default: + return "" + } +} diff --git a/vendor/github.com/docker/docker/api/types/container/container_changes.go b/vendor/github.com/docker/docker/api/types/container/container_changes.go deleted file mode 100644 index 16dd5019e..000000000 --- a/vendor/github.com/docker/docker/api/types/container/container_changes.go +++ /dev/null @@ -1,20 +0,0 @@ -package container // import "github.com/docker/docker/api/types/container" - -// ---------------------------------------------------------------------------- -// Code generated by `swagger generate operation`. DO NOT EDIT. -// -// See hack/generate-swagger-api.sh -// ---------------------------------------------------------------------------- - -// ContainerChangeResponseItem change item in response to ContainerChanges operation -// swagger:model ContainerChangeResponseItem -type ContainerChangeResponseItem struct { - - // Kind of change - // Required: true - Kind uint8 `json:"Kind"` - - // Path to file that has changed - // Required: true - Path string `json:"Path"` -} diff --git a/vendor/github.com/docker/docker/api/types/container/deprecated.go b/vendor/github.com/docker/docker/api/types/container/deprecated.go deleted file mode 100644 index 0cb70e363..000000000 --- a/vendor/github.com/docker/docker/api/types/container/deprecated.go +++ /dev/null @@ -1,16 +0,0 @@ -package container // import "github.com/docker/docker/api/types/container" - -// ContainerCreateCreatedBody OK response to ContainerCreate operation -// -// Deprecated: use CreateResponse -type ContainerCreateCreatedBody = CreateResponse - -// ContainerWaitOKBody OK response to ContainerWait operation -// -// Deprecated: use WaitResponse -type ContainerWaitOKBody = WaitResponse - -// ContainerWaitOKBodyError container waiting error, if any -// -// Deprecated: use WaitExitError -type ContainerWaitOKBodyError = WaitExitError diff --git a/vendor/github.com/docker/docker/api/types/container/filesystem_change.go b/vendor/github.com/docker/docker/api/types/container/filesystem_change.go new file mode 100644 index 000000000..9e9c2ad1d --- /dev/null +++ b/vendor/github.com/docker/docker/api/types/container/filesystem_change.go @@ -0,0 +1,19 @@ +package container + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// FilesystemChange Change in the container's filesystem. +// +// swagger:model FilesystemChange +type FilesystemChange struct { + + // kind + // Required: true + Kind ChangeType `json:"Kind"` + + // Path to file or directory that has changed. + // + // Required: true + Path string `json:"Path"` +} diff --git a/vendor/github.com/docker/docker/api/types/container/host_config.go b/vendor/github.com/docker/docker/api/types/container/hostconfig.go similarity index 84% rename from vendor/github.com/docker/docker/api/types/container/host_config.go rename to vendor/github.com/docker/docker/api/types/container/hostconfig.go index 100f434ce..d4e6f5537 100644 --- a/vendor/github.com/docker/docker/api/types/container/host_config.go +++ b/vendor/github.com/docker/docker/api/types/container/hostconfig.go @@ -101,7 +101,8 @@ func (n IpcMode) IsShareable() bool { // IsContainer indicates whether the container uses another container's ipc namespace. func (n IpcMode) IsContainer() bool { - return strings.HasPrefix(string(n), string(IPCModeContainer)+":") + _, ok := containerID(string(n)) + return ok } // IsNone indicates whether container IpcMode is set to "none". @@ -116,15 +117,14 @@ func (n IpcMode) IsEmpty() bool { // Valid indicates whether the ipc mode is valid. func (n IpcMode) Valid() bool { + // TODO(thaJeztah): align with PidMode, and consider container-mode without a container name/ID to be invalid. 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 { - if n.IsContainer() { - return strings.TrimPrefix(string(n), string(IPCModeContainer)+":") - } - return "" +func (n IpcMode) Container() (idOrName string) { + idOrName, _ = containerID(string(n)) + return idOrName } // NetworkMode represents the container network stack. @@ -147,17 +147,14 @@ func (n NetworkMode) IsPrivate() bool { // IsContainer indicates whether container uses a container network stack. func (n NetworkMode) IsContainer() bool { - parts := strings.SplitN(string(n), ":", 2) - return len(parts) > 1 && parts[0] == "container" + _, ok := containerID(string(n)) + return ok } // ConnectedContainer is the id of the container which network this container is connected to. -func (n NetworkMode) ConnectedContainer() string { - parts := strings.SplitN(string(n), ":", 2) - if len(parts) > 1 { - return parts[1] - } - return "" +func (n NetworkMode) ConnectedContainer() (idOrName string) { + idOrName, _ = containerID(string(n)) + return idOrName } // UserDefined indicates user-created network @@ -178,18 +175,12 @@ func (n UsernsMode) IsHost() bool { // IsPrivate indicates whether the container uses the a private userns. func (n UsernsMode) IsPrivate() bool { - return !(n.IsHost()) + return !n.IsHost() } // Valid indicates whether the userns is valid. func (n UsernsMode) Valid() bool { - parts := strings.Split(string(n), ":") - switch mode := parts[0]; mode { - case "", "host": - default: - return false - } - return true + return n == "" || n.IsHost() } // CgroupSpec represents the cgroup to use for the container. @@ -197,22 +188,20 @@ type CgroupSpec string // IsContainer indicates whether the container is using another container cgroup func (c CgroupSpec) IsContainer() bool { - parts := strings.SplitN(string(c), ":", 2) - return len(parts) > 1 && parts[0] == "container" + _, ok := containerID(string(c)) + return ok } // Valid indicates whether the cgroup spec is valid. func (c CgroupSpec) Valid() bool { - return c.IsContainer() || c == "" + // TODO(thaJeztah): align with PidMode, and consider container-mode without a container name/ID to be invalid. + return c == "" || c.IsContainer() } -// Container returns the name of the container whose cgroup will be used. -func (c CgroupSpec) Container() string { - parts := strings.SplitN(string(c), ":", 2) - if len(parts) > 1 { - return parts[1] - } - return "" +// Container returns the ID or name of the container whose cgroup will be used. +func (c CgroupSpec) Container() (idOrName string) { + idOrName, _ = containerID(string(c)) + return idOrName } // UTSMode represents the UTS namespace of the container. @@ -220,7 +209,7 @@ type UTSMode string // IsPrivate indicates whether the container uses its private UTS namespace. func (n UTSMode) IsPrivate() bool { - return !(n.IsHost()) + return !n.IsHost() } // IsHost indicates whether the container uses the host's UTS namespace. @@ -230,13 +219,7 @@ func (n UTSMode) IsHost() bool { // Valid indicates whether the UTS namespace is valid. func (n UTSMode) Valid() bool { - parts := strings.Split(string(n), ":") - switch mode := parts[0]; mode { - case "", "host": - default: - return false - } - return true + return n == "" || n.IsHost() } // PidMode represents the pid namespace of the container. @@ -254,32 +237,19 @@ func (n PidMode) IsHost() bool { // IsContainer indicates whether the container uses a container's pid namespace. func (n PidMode) IsContainer() bool { - parts := strings.SplitN(string(n), ":", 2) - return len(parts) > 1 && parts[0] == "container" + _, ok := containerID(string(n)) + return ok } // Valid indicates whether the pid namespace is valid. func (n PidMode) 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 == "" || n.IsHost() || validContainer(string(n)) } // Container returns the name of the container whose pid namespace is going to be used. -func (n PidMode) Container() string { - parts := strings.SplitN(string(n), ":", 2) - if len(parts) > 1 { - return parts[1] - } - return "" +func (n PidMode) Container() (idOrName string) { + idOrName, _ = containerID(string(n)) + return idOrName } // DeviceRequest represents a request for devices from a device driver. @@ -408,16 +378,17 @@ type UpdateConfig struct { // Portable information *should* appear in Config. type HostConfig struct { // Applicable to all platforms - Binds []string // List of volume bindings for this container - ContainerIDFile string // File (path) where the containerId is written - LogConfig LogConfig // Configuration of the logs for this container - NetworkMode NetworkMode // Network mode to use for the container - PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host - RestartPolicy RestartPolicy // Restart policy to be used for the container - AutoRemove bool // Automatically remove container when it exits - VolumeDriver string // Name of the volume driver used to mount volumes - VolumesFrom []string // List of volumes to take from other container - ConsoleSize [2]uint // Initial console size (height,width) + Binds []string // List of volume bindings for this container + ContainerIDFile string // File (path) where the containerId is written + LogConfig LogConfig // Configuration of the logs for this container + NetworkMode NetworkMode // Network mode to use for the container + PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host + RestartPolicy RestartPolicy // Restart policy to be used for the container + AutoRemove bool // Automatically remove container when it exits + VolumeDriver string // Name of the volume driver used to mount volumes + VolumesFrom []string // List of volumes to take from other container + ConsoleSize [2]uint // Initial console size (height,width) + Annotations map[string]string `json:",omitempty"` // Arbitrary non-identifying metadata attached to container and provided to the runtime // Applicable to UNIX platforms CapAdd strslice.StrSlice // List of kernel capabilities to add to the container @@ -463,3 +434,23 @@ type HostConfig struct { // Run a custom init inside the container, if null, use the daemon's configured settings Init *bool `json:",omitempty"` } + +// containerID splits "container:" values. It returns the container +// ID or name, and whether an ID/name was found. It returns an empty string and +// a "false" if the value does not have a "container:" prefix. Further validation +// of the returned, including checking if the value is empty, should be handled +// by the caller. +func containerID(val string) (idOrName string, ok bool) { + k, v, hasSep := strings.Cut(val, ":") + if !hasSep || k != "container" { + return "", false + } + return v, true +} + +// validContainer checks if the given value is a "container:" mode with +// a non-empty name/ID. +func validContainer(val string) bool { + id, ok := containerID(val) + return ok && id != "" +} diff --git a/vendor/github.com/docker/docker/api/types/deprecated.go b/vendor/github.com/docker/docker/api/types/deprecated.go deleted file mode 100644 index 216d1df0f..000000000 --- a/vendor/github.com/docker/docker/api/types/deprecated.go +++ /dev/null @@ -1,14 +0,0 @@ -package types // import "github.com/docker/docker/api/types" - -import "github.com/docker/docker/api/types/volume" - -// Volume volume -// -// Deprecated: use github.com/docker/docker/api/types/volume.Volume -type Volume = volume.Volume - -// VolumeUsageData Usage details about the volume. This information is used by the -// `GET /system/df` endpoint, and omitted in other endpoints. -// -// Deprecated: use github.com/docker/docker/api/types/volume.UsageData -type VolumeUsageData = volume.UsageData diff --git a/vendor/github.com/docker/docker/api/types/filters/errors.go b/vendor/github.com/docker/docker/api/types/filters/errors.go new file mode 100644 index 000000000..f52f69440 --- /dev/null +++ b/vendor/github.com/docker/docker/api/types/filters/errors.go @@ -0,0 +1,37 @@ +package filters + +import "fmt" + +// invalidFilter indicates that the provided filter or its value is invalid +type invalidFilter struct { + Filter string + Value []string +} + +func (e invalidFilter) Error() string { + msg := "invalid filter" + if e.Filter != "" { + msg += " '" + e.Filter + if e.Value != nil { + msg = fmt.Sprintf("%s=%s", msg, e.Value) + } + msg += "'" + } + return msg +} + +// InvalidParameter marks this error as ErrInvalidParameter +func (e invalidFilter) InvalidParameter() {} + +// unreachableCode is an error indicating that the code path was not expected to be reached. +type unreachableCode struct { + Filter string + Value []string +} + +// System marks this error as ErrSystem +func (e unreachableCode) System() {} + +func (e unreachableCode) Error() string { + return fmt.Sprintf("unreachable code reached for filter: %q with values: %s", e.Filter, e.Value) +} 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 f8fe79407..887648cf3 100644 --- a/vendor/github.com/docker/docker/api/types/filters/parse.go +++ b/vendor/github.com/docker/docker/api/types/filters/parse.go @@ -10,7 +10,6 @@ import ( "strings" "github.com/docker/docker/api/types/versions" - "github.com/pkg/errors" ) // Args stores a mapping of keys to a set of multiple values. @@ -99,7 +98,7 @@ func FromJSON(p string) (Args, error) { // Fallback to parsing arguments in the legacy slice format deprecated := map[string][]string{} if legacyErr := json.Unmarshal(raw, &deprecated); legacyErr != nil { - return args, invalidFilter{errors.Wrap(err, "invalid filter")} + return args, invalidFilter{} } args.fields = deprecatedArgs(deprecated) @@ -163,13 +162,13 @@ func (args Args) MatchKVList(key string, sources map[string]string) bool { } for value := range fieldValues { - testKV := strings.SplitN(value, "=", 2) + testK, testV, hasValue := strings.Cut(value, "=") - v, ok := sources[testKV[0]] + v, ok := sources[testK] if !ok { return false } - if len(testKV) == 2 && testKV[1] != v { + if hasValue && testV != v { return false } } @@ -196,6 +195,38 @@ func (args Args) Match(field, source string) bool { return false } +// GetBoolOrDefault returns a boolean value of the key if the key is present +// and is intepretable as a boolean value. Otherwise the default value is returned. +// Error is not nil only if the filter values are not valid boolean or are conflicting. +func (args Args) GetBoolOrDefault(key string, defaultValue bool) (bool, error) { + fieldValues, ok := args.fields[key] + + if !ok { + return defaultValue, nil + } + + if len(fieldValues) == 0 { + return defaultValue, invalidFilter{key, nil} + } + + isFalse := fieldValues["0"] || fieldValues["false"] + isTrue := fieldValues["1"] || fieldValues["true"] + + conflicting := isFalse && isTrue + invalid := !isFalse && !isTrue + + if conflicting || invalid { + return defaultValue, invalidFilter{key, args.Get(key)} + } else if isFalse { + return false, nil + } else if isTrue { + return true, nil + } + + // This code shouldn't be reached. + return defaultValue, unreachableCode{Filter: key, Value: args.Get(key)} +} + // 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] @@ -246,20 +277,12 @@ func (args Args) Contains(field string) bool { return ok } -type invalidFilter struct{ error } - -func (e invalidFilter) Error() string { - return e.error.Error() -} - -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 invalidFilter{errors.New("invalid filter '" + name + "'")} + return invalidFilter{name, nil} } } return nil diff --git a/vendor/github.com/docker/docker/api/types/image/opts.go b/vendor/github.com/docker/docker/api/types/image/opts.go new file mode 100644 index 000000000..a24f9059a --- /dev/null +++ b/vendor/github.com/docker/docker/api/types/image/opts.go @@ -0,0 +1,9 @@ +package image + +import specs "github.com/opencontainers/image-spec/specs-go/v1" + +// GetImageOpts holds parameters to inspect an image. +type GetImageOpts struct { + Platform *specs.Platform + Details bool +} diff --git a/vendor/github.com/docker/docker/api/types/image_summary.go b/vendor/github.com/docker/docker/api/types/image_summary.go index 90b983a25..0f6f14484 100644 --- a/vendor/github.com/docker/docker/api/types/image_summary.go +++ b/vendor/github.com/docker/docker/api/types/image_summary.go @@ -85,13 +85,10 @@ type ImageSummary struct { // Total size of the image including all layers it is composed of. // // In versions of Docker before v1.10, this field was calculated from - // the image itself and all of its parent images. Docker v1.10 and up - // store images self-contained, and no longer use a parent-chain, making - // this field an equivalent of the Size field. + // the image itself and all of its parent images. Images are now stored + // self-contained, and no longer use a parent-chain, making this field + // an equivalent of the Size field. // - // This field is kept for backward compatibility, but may be removed in - // a future version of the API. - // - // Required: true - VirtualSize int64 `json:"VirtualSize"` + // Deprecated: this field is kept for backward compatibility, and will be removed in API v1.44. + VirtualSize int64 `json:"VirtualSize,omitempty"` } diff --git a/vendor/github.com/docker/docker/api/types/registry/authconfig.go b/vendor/github.com/docker/docker/api/types/registry/authconfig.go new file mode 100644 index 000000000..97a924e37 --- /dev/null +++ b/vendor/github.com/docker/docker/api/types/registry/authconfig.go @@ -0,0 +1,99 @@ +package registry // import "github.com/docker/docker/api/types/registry" +import ( + "encoding/base64" + "encoding/json" + "io" + "strings" + + "github.com/pkg/errors" +) + +// AuthHeader is the name of the header used to send encoded registry +// authorization credentials for registry operations (push/pull). +const AuthHeader = "X-Registry-Auth" + +// AuthConfig contains authorization information for connecting to a Registry. +type AuthConfig struct { + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Auth string `json:"auth,omitempty"` + + // Email is an optional value associated with the username. + // This field is deprecated and will be removed in a later + // version of docker. + Email string `json:"email,omitempty"` + + ServerAddress string `json:"serveraddress,omitempty"` + + // IdentityToken is used to authenticate the user and get + // an access token for the registry. + IdentityToken string `json:"identitytoken,omitempty"` + + // RegistryToken is a bearer token to be sent to a registry + RegistryToken string `json:"registrytoken,omitempty"` +} + +// EncodeAuthConfig serializes the auth configuration as a base64url encoded +// RFC4648, section 5) JSON string for sending through the X-Registry-Auth header. +// +// For details on base64url encoding, see: +// - RFC4648, section 5: https://tools.ietf.org/html/rfc4648#section-5 +func EncodeAuthConfig(authConfig AuthConfig) (string, error) { + buf, err := json.Marshal(authConfig) + if err != nil { + return "", errInvalidParameter{err} + } + return base64.URLEncoding.EncodeToString(buf), nil +} + +// DecodeAuthConfig decodes base64url encoded (RFC4648, section 5) JSON +// authentication information as sent through the X-Registry-Auth header. +// +// This function always returns an AuthConfig, even if an error occurs. It is up +// to the caller to decide if authentication is required, and if the error can +// be ignored. +// +// For details on base64url encoding, see: +// - RFC4648, section 5: https://tools.ietf.org/html/rfc4648#section-5 +func DecodeAuthConfig(authEncoded string) (*AuthConfig, error) { + if authEncoded == "" { + return &AuthConfig{}, nil + } + + authJSON := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authEncoded)) + return decodeAuthConfigFromReader(authJSON) +} + +// DecodeAuthConfigBody decodes authentication information as sent as JSON in the +// body of a request. This function is to provide backward compatibility with old +// clients and API versions. Current clients and API versions expect authentication +// to be provided through the X-Registry-Auth header. +// +// Like DecodeAuthConfig, this function always returns an AuthConfig, even if an +// error occurs. It is up to the caller to decide if authentication is required, +// and if the error can be ignored. +func DecodeAuthConfigBody(rdr io.ReadCloser) (*AuthConfig, error) { + return decodeAuthConfigFromReader(rdr) +} + +func decodeAuthConfigFromReader(rdr io.Reader) (*AuthConfig, error) { + authConfig := &AuthConfig{} + if err := json.NewDecoder(rdr).Decode(authConfig); err != nil { + // always return an (empty) AuthConfig to increase compatibility with + // the existing API. + return &AuthConfig{}, invalid(err) + } + return authConfig, nil +} + +func invalid(err error) error { + return errInvalidParameter{errors.Wrap(err, "invalid X-Registry-Auth header")} +} + +type errInvalidParameter struct{ error } + +func (errInvalidParameter) InvalidParameter() {} + +func (e errInvalidParameter) Cause() error { return e.error } + +func (e errInvalidParameter) Unwrap() error { return e.error } 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 2a74b7a59..cab5c32e3 100644 --- a/vendor/github.com/docker/docker/api/types/time/timestamp.go +++ b/vendor/github.com/docker/docker/api/types/time/timestamp.go @@ -95,37 +95,37 @@ func GetTimestamp(value string, reference time.Time) (string, error) { return fmt.Sprintf("%d.%09d", t.Unix(), int64(t.Nanosecond())), nil } -// ParseTimestamps returns seconds and nanoseconds from a timestamp that has the -// format "%d.%09d", time.Unix(), int64(time.Nanosecond())) -// if the incoming nanosecond portion is longer or shorter than 9 digits it is -// converted to nanoseconds. The expectation is that the seconds and -// seconds will be used to create a time variable. For example: +// ParseTimestamps returns seconds and nanoseconds from a timestamp that has +// the format ("%d.%09d", time.Unix(), int64(time.Nanosecond())). +// If the incoming nanosecond portion is longer than 9 digits it is truncated. +// The expectation is that the seconds and nanoseconds will be used to create a +// time variable. For example: // -// seconds, nanoseconds, err := ParseTimestamp("1136073600.000000001",0) -// if err == nil since := time.Unix(seconds, nanoseconds) +// seconds, nanoseconds, _ := ParseTimestamp("1136073600.000000001",0) +// since := time.Unix(seconds, nanoseconds) // -// returns seconds as def(aultSeconds) if value == "" -func ParseTimestamps(value string, def int64) (int64, int64, error) { +// returns seconds as defaultSeconds if value == "" +func ParseTimestamps(value string, defaultSeconds int64) (seconds int64, nanoseconds int64, err error) { if value == "" { - return def, 0, nil + return defaultSeconds, 0, nil } return parseTimestamp(value) } -func parseTimestamp(value string) (int64, int64, error) { - sa := strings.SplitN(value, ".", 2) - s, err := strconv.ParseInt(sa[0], 10, 64) +func parseTimestamp(value string) (sec int64, nsec int64, err error) { + s, n, ok := strings.Cut(value, ".") + sec, err = strconv.ParseInt(s, 10, 64) if err != nil { - return s, 0, err + return sec, 0, err } - if len(sa) != 2 { - return s, 0, nil + if !ok { + return sec, 0, nil } - n, err := strconv.ParseInt(sa[1], 10, 64) + nsec, err = strconv.ParseInt(n, 10, 64) if err != nil { - return s, n, err + return sec, nsec, err } // should already be in nanoseconds but just in case convert n to nanoseconds - n = int64(float64(n) * math.Pow(float64(10), float64(9-len(sa[1])))) - return s, n, nil + nsec = int64(float64(nsec) * math.Pow(float64(10), float64(9-len(n)))) + return sec, nsec, nil } diff --git a/vendor/github.com/docker/docker/api/types/types.go b/vendor/github.com/docker/docker/api/types/types.go index 036405299..b413e0200 100644 --- a/vendor/github.com/docker/docker/api/types/types.go +++ b/vendor/github.com/docker/docker/api/types/types.go @@ -123,9 +123,8 @@ type ImageInspect struct { // store images self-contained, and no longer use a parent-chain, making // this field an equivalent of the Size field. // - // This field is kept for backward compatibility, but may be removed in - // a future version of the API. - VirtualSize int64 // TODO(thaJeztah): deprecate this field + // Deprecated: Unused in API 1.43 and up, but kept for backward compatibility with older API versions. + VirtualSize int64 `json:"VirtualSize,omitempty"` // GraphDriver holds information about the storage driver used to store the // container's and image's filesystem. @@ -297,8 +296,6 @@ type Info struct { Labels []string ExperimentalBuild bool ServerVersion string - ClusterStore string `json:",omitempty"` // Deprecated: host-discovery and overlay networks with external k/v stores are deprecated - ClusterAdvertise string `json:",omitempty"` // Deprecated: host-discovery and overlay networks with external k/v stores are deprecated Runtimes map[string]Runtime DefaultRuntime string Swarm swarm.Info @@ -350,20 +347,19 @@ func DecodeSecurityOptions(opts []string) ([]SecurityOpt, error) { continue } secopt := SecurityOpt{} - split := strings.Split(opt, ",") - for _, s := range split { - kv := strings.SplitN(s, "=", 2) - if len(kv) != 2 { + for _, s := range strings.Split(opt, ",") { + k, v, ok := strings.Cut(s, "=") + if !ok { return nil, fmt.Errorf("invalid security option %q", s) } - if kv[0] == "" || kv[1] == "" { + if k == "" || v == "" { return nil, errors.New("invalid empty security option") } - if kv[0] == "name" { - secopt.Name = kv[1] + if k == "name" { + secopt.Name = v continue } - secopt.Options = append(secopt.Options, KeyValue{Key: kv[0], Value: kv[1]}) + secopt.Options = append(secopt.Options, KeyValue{Key: k, Value: v}) } so = append(so, secopt) } @@ -656,12 +652,18 @@ type Checkpoint struct { // Runtime describes an OCI runtime type Runtime struct { - Path string `json:"path"` + // "Legacy" runtime configuration for runc-compatible runtimes. + + Path string `json:"path,omitempty"` Args []string `json:"runtimeArgs,omitempty"` + // Shimv2 runtime configuration. Mutually exclusive with the legacy config above. + + Type string `json:"runtimeType,omitempty"` + Options map[string]interface{} `json:"options,omitempty"` + // This is exposed here only for internal use - // It is not currently supported to specify custom shim configs - Shim *ShimConfig `json:"-"` + ShimConfig *ShimConfig `json:"-"` } // ShimConfig is used by runtime to configure containerd shims diff --git a/vendor/github.com/docker/docker/api/types/volume/deprecated.go b/vendor/github.com/docker/docker/api/types/volume/deprecated.go deleted file mode 100644 index ab622d8cc..000000000 --- a/vendor/github.com/docker/docker/api/types/volume/deprecated.go +++ /dev/null @@ -1,11 +0,0 @@ -package volume // import "github.com/docker/docker/api/types/volume" - -// VolumeCreateBody Volume configuration -// -// Deprecated: use CreateOptions -type VolumeCreateBody = CreateOptions - -// VolumeListOKBody Volume list response -// -// Deprecated: use ListResponse -type VolumeListOKBody = ListResponse diff --git a/vendor/github.com/docker/docker/client/build_prune.go b/vendor/github.com/docker/docker/client/build_prune.go index 397d67cdc..2b6606236 100644 --- a/vendor/github.com/docker/docker/client/build_prune.go +++ b/vendor/github.com/docker/docker/client/build_prune.go @@ -3,8 +3,8 @@ package client // import "github.com/docker/docker/client" import ( "context" "encoding/json" - "fmt" "net/url" + "strconv" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" @@ -23,12 +23,12 @@ func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePru if opts.All { query.Set("all", "1") } - query.Set("keep-storage", fmt.Sprintf("%d", opts.KeepStorage)) - filters, err := filters.ToJSON(opts.Filters) + query.Set("keep-storage", strconv.Itoa(int(opts.KeepStorage))) + f, err := filters.ToJSON(opts.Filters) if err != nil { return nil, errors.Wrap(err, "prune could not marshal filters option") } - query.Set("filters", filters) + query.Set("filters", f) serverResp, err := cli.post(ctx, "/build/prune", query, nil, nil) defer ensureReaderClosed(serverResp) @@ -38,7 +38,7 @@ func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePru } if err := json.NewDecoder(serverResp.body).Decode(&report); err != nil { - return nil, fmt.Errorf("Error retrieving disk usage: %v", err) + return nil, errors.Wrap(err, "error retrieving disk usage") } return &report, nil diff --git a/vendor/github.com/docker/docker/client/client.go b/vendor/github.com/docker/docker/client/client.go index 09ea4851f..1c081a51a 100644 --- a/vendor/github.com/docker/docker/client/client.go +++ b/vendor/github.com/docker/docker/client/client.go @@ -126,7 +126,12 @@ func CheckRedirect(req *http.Request, via []*http.Request) error { // client.WithAPIVersionNegotiation(), // ) func NewClientWithOpts(ops ...Opt) (*Client, error) { - client, err := defaultHTTPClient(DefaultDockerHost) + hostURL, err := ParseHostURL(DefaultDockerHost) + if err != nil { + return nil, err + } + + client, err := defaultHTTPClient(hostURL) if err != nil { return nil, err } @@ -134,8 +139,8 @@ func NewClientWithOpts(ops ...Opt) (*Client, error) { host: DefaultDockerHost, version: api.DefaultVersion, client: client, - proto: defaultProto, - addr: defaultAddr, + proto: hostURL.Scheme, + addr: hostURL.Host, } for _, op := range ops { @@ -161,13 +166,12 @@ func NewClientWithOpts(ops ...Opt) (*Client, error) { return c, nil } -func defaultHTTPClient(host string) (*http.Client, error) { - hostURL, err := ParseHostURL(host) +func defaultHTTPClient(hostURL *url.URL) (*http.Client, error) { + transport := &http.Transport{} + err := sockets.ConfigureTransport(transport, hostURL.Scheme, hostURL.Host) if err != nil { return nil, err } - transport := &http.Transport{} - _ = sockets.ConfigureTransport(transport, hostURL.Scheme, hostURL.Host) return &http.Client{ Transport: transport, CheckRedirect: CheckRedirect, @@ -283,13 +287,12 @@ func (cli *Client) HTTPClient() *http.Client { // 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 { + proto, addr, ok := strings.Cut(host, "://") + if !ok || addr == "" { return nil, errors.Errorf("unable to parse docker host `%s`", host) } var basePath string - proto, addr := protoAddrParts[0], protoAddrParts[1] if proto == "tcp" { parsed, err := url.Parse("tcp://" + addr) if err != nil { diff --git a/vendor/github.com/docker/docker/client/client_unix.go b/vendor/github.com/docker/docker/client/client_unix.go index f0783f708..319b738d3 100644 --- a/vendor/github.com/docker/docker/client/client_unix.go +++ b/vendor/github.com/docker/docker/client/client_unix.go @@ -1,11 +1,8 @@ -//go:build linux || freebsd || openbsd || netbsd || darwin || solaris || illumos || dragonfly -// +build linux freebsd openbsd netbsd darwin solaris illumos dragonfly +//go:build !windows +// +build !windows package client // import "github.com/docker/docker/client" // DefaultDockerHost defines OS-specific default host if the DOCKER_HOST // (EnvOverrideHost) environment variable is unset or empty. const DefaultDockerHost = "unix:///var/run/docker.sock" - -const defaultProto = "unix" -const defaultAddr = "/var/run/docker.sock" diff --git a/vendor/github.com/docker/docker/client/client_windows.go b/vendor/github.com/docker/docker/client/client_windows.go index 5abe60457..56572d1a2 100644 --- a/vendor/github.com/docker/docker/client/client_windows.go +++ b/vendor/github.com/docker/docker/client/client_windows.go @@ -3,6 +3,3 @@ package client // import "github.com/docker/docker/client" // DefaultDockerHost defines OS-specific default host if the DOCKER_HOST // (EnvOverrideHost) environment variable is unset or empty. const DefaultDockerHost = "npipe:////./pipe/docker_engine" - -const defaultProto = "npipe" -const defaultAddr = "//./pipe/docker_engine" diff --git a/vendor/github.com/docker/docker/client/container_diff.go b/vendor/github.com/docker/docker/client/container_diff.go index 29dac8491..c22c819a7 100644 --- a/vendor/github.com/docker/docker/client/container_diff.go +++ b/vendor/github.com/docker/docker/client/container_diff.go @@ -9,8 +9,8 @@ import ( ) // ContainerDiff shows differences in a container filesystem since it was started. -func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]container.ContainerChangeResponseItem, error) { - var changes []container.ContainerChangeResponseItem +func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]container.FilesystemChange, error) { + var changes []container.FilesystemChange serverResp, err := cli.get(ctx, "/containers/"+containerID+"/changes", url.Values{}, nil) defer ensureReaderClosed(serverResp) diff --git a/vendor/github.com/docker/docker/client/distribution_inspect.go b/vendor/github.com/docker/docker/client/distribution_inspect.go index 7f36c99a0..efab066d3 100644 --- a/vendor/github.com/docker/docker/client/distribution_inspect.go +++ b/vendor/github.com/docker/docker/client/distribution_inspect.go @@ -5,13 +5,13 @@ import ( "encoding/json" "net/url" - registrytypes "github.com/docker/docker/api/types/registry" + "github.com/docker/docker/api/types/registry" ) // DistributionInspect returns the image digest with the full manifest. -func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registrytypes.DistributionInspect, error) { +func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error) { // Contact the registry to retrieve digest and platform information - var distributionInspect registrytypes.DistributionInspect + var distributionInspect registry.DistributionInspect if image == "" { return distributionInspect, objectNotFoundError{object: "distribution", id: image} } @@ -23,7 +23,7 @@ func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegist if encodedRegistryAuth != "" { headers = map[string][]string{ - "X-Registry-Auth": {encodedRegistryAuth}, + registry.AuthHeader: {encodedRegistryAuth}, } } diff --git a/vendor/github.com/docker/docker/client/errors.go b/vendor/github.com/docker/docker/client/errors.go index e5a8a865f..6878144c4 100644 --- a/vendor/github.com/docker/docker/client/errors.go +++ b/vendor/github.com/docker/docker/client/errors.go @@ -58,31 +58,6 @@ func (e objectNotFoundError) Error() string { return fmt.Sprintf("Error: No such %s: %s", e.object, e.id) } -// IsErrUnauthorized returns true if the error is caused -// when a remote registry authentication fails -// -// Deprecated: use errdefs.IsUnauthorized -func IsErrUnauthorized(err error) bool { - return errdefs.IsUnauthorized(err) -} - -type pluginPermissionDenied struct { - name string -} - -func (e pluginPermissionDenied) Error() string { - return "Permission denied while installing plugin " + e.name -} - -// IsErrNotImplemented returns true if the error is a NotImplemented error. -// This is returned by the API when a requested feature has not been -// implemented. -// -// Deprecated: use errdefs.IsNotImplemented -func IsErrNotImplemented(err error) bool { - return errdefs.IsNotImplemented(err) -} - // NewVersionError returns an error if the APIVersion required // if less than the current supported version func (cli *Client) NewVersionError(APIrequired, feature string) error { diff --git a/vendor/github.com/docker/docker/client/image_create.go b/vendor/github.com/docker/docker/client/image_create.go index b1c022777..6a9b708f7 100644 --- a/vendor/github.com/docker/docker/client/image_create.go +++ b/vendor/github.com/docker/docker/client/image_create.go @@ -8,6 +8,7 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" ) // ImageCreate creates a new image based on the parent options. @@ -32,6 +33,6 @@ func (cli *Client) ImageCreate(ctx context.Context, parentReference string, opti } func (cli *Client) tryImageCreate(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) { - headers := map[string][]string{"X-Registry-Auth": {registryAuth}} + headers := map[string][]string{registry.AuthHeader: {registryAuth}} return cli.post(ctx, "/images/create", query, nil, headers) } diff --git a/vendor/github.com/docker/docker/client/image_push.go b/vendor/github.com/docker/docker/client/image_push.go index 845580d4a..dd1b8f347 100644 --- a/vendor/github.com/docker/docker/client/image_push.go +++ b/vendor/github.com/docker/docker/client/image_push.go @@ -8,6 +8,7 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" ) @@ -49,6 +50,6 @@ func (cli *Client) ImagePush(ctx context.Context, image string, options types.Im } func (cli *Client) tryImagePush(ctx context.Context, imageID string, query url.Values, registryAuth string) (serverResponse, error) { - headers := map[string][]string{"X-Registry-Auth": {registryAuth}} + headers := map[string][]string{registry.AuthHeader: {registryAuth}} return cli.post(ctx, "/images/"+imageID+"/push", query, nil, headers) } diff --git a/vendor/github.com/docker/docker/client/image_search.go b/vendor/github.com/docker/docker/client/image_search.go index e69fa3722..5f0c49ed3 100644 --- a/vendor/github.com/docker/docker/client/image_search.go +++ b/vendor/github.com/docker/docker/client/image_search.go @@ -48,6 +48,6 @@ func (cli *Client) ImageSearch(ctx context.Context, term string, options types.I } func (cli *Client) tryImageSearch(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) { - headers := map[string][]string{"X-Registry-Auth": {registryAuth}} + headers := map[string][]string{registry.AuthHeader: {registryAuth}} return cli.get(ctx, "/images/search", query, headers) } diff --git a/vendor/github.com/docker/docker/client/interface.go b/vendor/github.com/docker/docker/client/interface.go index e9c1ed722..64877d164 100644 --- a/vendor/github.com/docker/docker/client/interface.go +++ b/vendor/github.com/docker/docker/client/interface.go @@ -48,7 +48,7 @@ type ContainerAPIClient interface { ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error) - ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error) + ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, error) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) @@ -166,7 +166,7 @@ type SwarmAPIClient interface { type SystemAPIClient interface { Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) Info(ctx context.Context) (types.Info, error) - RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) + RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) Ping(ctx context.Context) (types.Ping, error) } @@ -176,7 +176,7 @@ type VolumeAPIClient interface { VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) - VolumeList(ctx context.Context, filter filters.Args) (volume.ListResponse, error) + VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) VolumeRemove(ctx context.Context, volumeID string, force bool) error VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error) VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error diff --git a/vendor/github.com/docker/docker/client/login.go b/vendor/github.com/docker/docker/client/login.go index f05852063..19e985e0b 100644 --- a/vendor/github.com/docker/docker/client/login.go +++ b/vendor/github.com/docker/docker/client/login.go @@ -5,13 +5,12 @@ import ( "encoding/json" "net/url" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" ) // RegistryLogin authenticates the docker server with a given docker registry. // It returns unauthorizedError when the authentication fails. -func (cli *Client) RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) { +func (cli *Client) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) { resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil) defer ensureReaderClosed(resp) diff --git a/vendor/github.com/docker/docker/client/ping.go b/vendor/github.com/docker/docker/client/ping.go index 27e8695cb..347ae71e0 100644 --- a/vendor/github.com/docker/docker/client/ping.go +++ b/vendor/github.com/docker/docker/client/ping.go @@ -64,10 +64,10 @@ func parsePingResponse(cli *Client, resp serverResponse) (types.Ping, error) { ping.BuilderVersion = types.BuilderVersion(bv) } if si := resp.header.Get("Swarm"); si != "" { - parts := strings.SplitN(si, "/", 2) + state, role, _ := strings.Cut(si, "/") ping.SwarmStatus = &swarm.Status{ - NodeState: swarm.LocalNodeState(parts[0]), - ControlAvailable: len(parts) == 2 && parts[1] == "manager", + NodeState: swarm.LocalNodeState(state), + ControlAvailable: role == "manager", } } err := cli.checkResponseErr(resp) diff --git a/vendor/github.com/docker/docker/client/plugin_install.go b/vendor/github.com/docker/docker/client/plugin_install.go index 012afe61c..3a740ec4f 100644 --- a/vendor/github.com/docker/docker/client/plugin_install.go +++ b/vendor/github.com/docker/docker/client/plugin_install.go @@ -8,6 +8,7 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" "github.com/pkg/errors" ) @@ -67,12 +68,12 @@ func (cli *Client) PluginInstall(ctx context.Context, name string, options types } func (cli *Client) tryPluginPrivileges(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) { - headers := map[string][]string{"X-Registry-Auth": {registryAuth}} + headers := map[string][]string{registry.AuthHeader: {registryAuth}} return cli.get(ctx, "/plugins/privileges", query, headers) } func (cli *Client) tryPluginPull(ctx context.Context, query url.Values, privileges types.PluginPrivileges, registryAuth string) (serverResponse, error) { - headers := map[string][]string{"X-Registry-Auth": {registryAuth}} + headers := map[string][]string{registry.AuthHeader: {registryAuth}} return cli.post(ctx, "/plugins/pull", query, privileges, headers) } @@ -106,7 +107,7 @@ func (cli *Client) checkPluginPermissions(ctx context.Context, query url.Values, return nil, err } if !accept { - return nil, pluginPermissionDenied{options.RemoteRef} + return nil, errors.Errorf("permission denied while installing plugin %s", options.RemoteRef) } } return privileges, nil diff --git a/vendor/github.com/docker/docker/client/plugin_push.go b/vendor/github.com/docker/docker/client/plugin_push.go index d20bfe844..18f9754c4 100644 --- a/vendor/github.com/docker/docker/client/plugin_push.go +++ b/vendor/github.com/docker/docker/client/plugin_push.go @@ -3,11 +3,13 @@ package client // import "github.com/docker/docker/client" import ( "context" "io" + + "github.com/docker/docker/api/types/registry" ) // PluginPush pushes a plugin to a registry func (cli *Client) PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error) { - headers := map[string][]string{"X-Registry-Auth": {registryAuth}} + headers := map[string][]string{registry.AuthHeader: {registryAuth}} resp, err := cli.post(ctx, "/plugins/"+name+"/push", nil, nil, headers) if err != nil { return nil, err diff --git a/vendor/github.com/docker/docker/client/plugin_upgrade.go b/vendor/github.com/docker/docker/client/plugin_upgrade.go index 115cea945..995d1fd2c 100644 --- a/vendor/github.com/docker/docker/client/plugin_upgrade.go +++ b/vendor/github.com/docker/docker/client/plugin_upgrade.go @@ -7,6 +7,7 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/pkg/errors" ) @@ -34,6 +35,6 @@ func (cli *Client) PluginUpgrade(ctx context.Context, name string, options types } func (cli *Client) tryPluginUpgrade(ctx context.Context, query url.Values, privileges types.PluginPrivileges, name, registryAuth string) (serverResponse, error) { - headers := map[string][]string{"X-Registry-Auth": {registryAuth}} + headers := map[string][]string{registry.AuthHeader: {registryAuth}} return cli.post(ctx, "/plugins/"+name+"/upgrade", query, privileges, headers) } diff --git a/vendor/github.com/docker/docker/client/service_create.go b/vendor/github.com/docker/docker/client/service_create.go index 23024d0f8..b6065b8ee 100644 --- a/vendor/github.com/docker/docker/client/service_create.go +++ b/vendor/github.com/docker/docker/client/service_create.go @@ -8,6 +8,7 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" "github.com/opencontainers/go-digest" "github.com/pkg/errors" @@ -21,7 +22,7 @@ func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, } if options.EncodedRegistryAuth != "" { - headers["X-Registry-Auth"] = []string{options.EncodedRegistryAuth} + headers[registry.AuthHeader] = []string{options.EncodedRegistryAuth} } // Make sure containerSpec is not nil when no runtime is set or the runtime is set to container diff --git a/vendor/github.com/docker/docker/client/service_update.go b/vendor/github.com/docker/docker/client/service_update.go index 8014b8625..ff8cded8b 100644 --- a/vendor/github.com/docker/docker/client/service_update.go +++ b/vendor/github.com/docker/docker/client/service_update.go @@ -6,6 +6,7 @@ import ( "net/url" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" ) @@ -23,7 +24,7 @@ func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version } if options.EncodedRegistryAuth != "" { - headers["X-Registry-Auth"] = []string{options.EncodedRegistryAuth} + headers[registry.AuthHeader] = []string{options.EncodedRegistryAuth} } if options.RegistryAuthFrom != "" { diff --git a/vendor/github.com/docker/docker/client/volume_list.go b/vendor/github.com/docker/docker/client/volume_list.go index d8204f8db..d5ea9827c 100644 --- a/vendor/github.com/docker/docker/client/volume_list.go +++ b/vendor/github.com/docker/docker/client/volume_list.go @@ -10,13 +10,13 @@ import ( ) // VolumeList returns the volumes configured in the docker host. -func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volume.ListResponse, error) { +func (cli *Client) VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) { var volumes volume.ListResponse query := url.Values{} - if filter.Len() > 0 { + if options.Filters.Len() > 0 { //nolint:staticcheck // ignore SA1019 for old code - filterJSON, err := filters.ToParamWithVersion(cli.version, filter) + filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters) if err != nil { return volumes, err } diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go index 7df039b4c..ded1c7c8c 100644 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go +++ b/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go @@ -64,13 +64,14 @@ func stick(f string) error { // GetDataHome returns XDG_DATA_HOME. // GetDataHome returns $HOME/.local/share and nil error if XDG_DATA_HOME is not set. +// If HOME and XDG_DATA_HOME are not set, getpwent(3) is consulted to determine the users home directory. // // See also https://standards.freedesktop.org/basedir-spec/latest/ar01s03.html func GetDataHome() (string, error) { if xdgDataHome := os.Getenv("XDG_DATA_HOME"); xdgDataHome != "" { return xdgDataHome, nil } - home := os.Getenv("HOME") + home := Get() if home == "" { return "", errors.New("could not get either XDG_DATA_HOME or HOME") } @@ -79,13 +80,14 @@ func GetDataHome() (string, error) { // GetConfigHome returns XDG_CONFIG_HOME. // GetConfigHome returns $HOME/.config and nil error if XDG_CONFIG_HOME is not set. +// If HOME and XDG_CONFIG_HOME are not set, getpwent(3) is consulted to determine the users home directory. // // See also https://standards.freedesktop.org/basedir-spec/latest/ar01s03.html func GetConfigHome() (string, error) { if xdgConfigHome := os.Getenv("XDG_CONFIG_HOME"); xdgConfigHome != "" { return xdgConfigHome, nil } - home := os.Getenv("HOME") + home := Get() if home == "" { return "", errors.New("could not get either XDG_CONFIG_HOME or HOME") } @@ -93,8 +95,9 @@ func GetConfigHome() (string, error) { } // GetLibHome returns $HOME/.local/lib +// If HOME is not set, getpwent(3) is consulted to determine the users home directory. func GetLibHome() (string, error) { - home := os.Getenv("HOME") + home := Get() if home == "" { return "", errors.New("could not get HOME") } diff --git a/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage.go b/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage.go index cf8d04b1b..035160c83 100644 --- a/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage.go +++ b/vendor/github.com/docker/docker/pkg/jsonmessage/jsonmessage.go @@ -16,8 +16,8 @@ import ( // ensure the formatted time isalways the same number of characters. const RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00" -// JSONError wraps a concrete Code and Message, `Code` is -// is an integer error code, `Message` is the error message. +// JSONError wraps a concrete Code and Message, Code is +// an integer error code, Message is the error message. type JSONError struct { Code int `json:"code,omitempty"` Message string `json:"message,omitempty"` @@ -27,20 +27,28 @@ func (e *JSONError) Error() string { return e.Message } -// JSONProgress describes a Progress. terminalFd is the fd of the current terminal, -// Start is the initial value for the operation. Current is the current status and -// value of the progress made towards Total. Total is the end value describing when -// we made 100% progress for an operation. +// JSONProgress describes a progress message in a JSON stream. type JSONProgress struct { + // Current is the current status and value of the progress made towards Total. + Current int64 `json:"current,omitempty"` + // Total is the end value describing when we made 100% progress for an operation. + Total int64 `json:"total,omitempty"` + // Start is the initial value for the operation. + Start int64 `json:"start,omitempty"` + // HideCounts. if true, hides the progress count indicator (xB/yB). + HideCounts bool `json:"hidecounts,omitempty"` + // Units is the unit to print for progress. It defaults to "bytes" if empty. + Units string `json:"units,omitempty"` + + // terminalFd is the fd of the current terminal, if any. It is used + // to get the terminal width. terminalFd uintptr - Current int64 `json:"current,omitempty"` - Total int64 `json:"total,omitempty"` - Start int64 `json:"start,omitempty"` - // If true, don't show xB/yB - HideCounts bool `json:"hidecounts,omitempty"` - Units string `json:"units,omitempty"` - nowFunc func() time.Time - winSize int + + // nowFunc is used to override the current time in tests. + nowFunc func() time.Time + + // winSize is used to override the terminal width in tests. + winSize int } func (p *JSONProgress) String() string { @@ -56,8 +64,7 @@ func (p *JSONProgress) String() string { if p.Total <= 0 { switch p.Units { case "": - current := units.HumanSize(float64(p.Current)) - return fmt.Sprintf("%8v", current) + return fmt.Sprintf("%8v", units.HumanSize(float64(p.Current))) default: return fmt.Sprintf("%d %s", p.Current, p.Units) } @@ -110,17 +117,17 @@ func (p *JSONProgress) String() string { return pbBox + numbersBox + timeLeftBox } -// shim for testing +// now returns the current time in UTC, but can be overridden in tests +// by setting JSONProgress.nowFunc to a custom function. func (p *JSONProgress) now() time.Time { - if p.nowFunc == nil { - p.nowFunc = func() time.Time { - return time.Now().UTC() - } + if p.nowFunc != nil { + return p.nowFunc() } - return p.nowFunc() + return time.Now().UTC() } -// shim for testing +// width returns the current terminal's width, but can be overridden +// in tests by setting JSONProgress.winSize to a non-zero value. func (p *JSONProgress) width() int { if p.winSize != 0 { return p.winSize @@ -164,13 +171,11 @@ func cursorDown(out io.Writer, l uint) { fmt.Fprint(out, aec.Down(l)) } -// Display displays the JSONMessage to `out`. If `isTerminal` is true, it will erase the -// entire current line when displaying the progressbar. +// Display prints the JSONMessage to out. If isTerminal is true, it erases +// the entire current line when displaying the progressbar. It returns an +// error if the [JSONMessage.Error] field is non-nil. func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error { if jm.Error != nil { - if jm.Error.Code == 401 { - return fmt.Errorf("authentication is required") - } return jm.Error } var endl string @@ -204,9 +209,22 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error { return nil } -// DisplayJSONMessagesStream displays a json message stream from `in` to `out`, `isTerminal` -// describes if `out` is a terminal. If this is the case, it will print `\n` at the end of -// each line and move the cursor while displaying. +// DisplayJSONMessagesStream reads a JSON message stream from in, and writes +// each [JSONMessage] to out. It returns an error if an invalid JSONMessage +// is received, or if a JSONMessage containers a non-zero [JSONMessage.Error]. +// +// Presentation of the JSONMessage depends on whether a terminal is attached, +// and on the terminal width. Progress bars ([JSONProgress]) are suppressed +// on narrower terminals (< 110 characters). +// +// - isTerminal describes if out is a terminal, in which case it prints +// a newline ("\n") at the end of each line and moves the cursor while +// displaying. +// - terminalFd is the fd of the current terminal (if any), and used +// to get the terminal width. +// - auxCallback allows handling the [JSONMessage.Aux] field. It is +// called if a JSONMessage contains an Aux field, in which case +// DisplayJSONMessagesStream does not present the JSONMessage. func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool, auxCallback func(JSONMessage)) error { var ( dec = json.NewDecoder(in) @@ -271,13 +289,19 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, return nil } -type stream interface { +// Stream is an io.Writer for output with utilities to get the output's file +// descriptor and to detect wether it's a terminal. +// +// it is subset of the streams.Out type in +// https://pkg.go.dev/github.com/docker/cli@v20.10.17+incompatible/cli/streams#Out +type Stream interface { io.Writer FD() uintptr IsTerminal() bool } -// DisplayJSONMessagesToStream prints json messages to the output stream -func DisplayJSONMessagesToStream(in io.Reader, stream stream, auxCallback func(JSONMessage)) error { +// DisplayJSONMessagesToStream prints json messages to the output Stream. It is +// used by the Docker CLI to print JSONMessage streams. +func DisplayJSONMessagesToStream(in io.Reader, stream Stream, auxCallback func(JSONMessage)) error { return DisplayJSONMessagesStream(in, stream, stream.FD(), stream.IsTerminal(), auxCallback) } diff --git a/vendor/github.com/docker/docker/pkg/stringid/README.md b/vendor/github.com/docker/docker/pkg/stringid/README.md deleted file mode 100644 index 37a5098fd..000000000 --- a/vendor/github.com/docker/docker/pkg/stringid/README.md +++ /dev/null @@ -1 +0,0 @@ -This package provides helper functions for dealing with string identifiers diff --git a/vendor/github.com/docker/docker/pkg/stringid/stringid.go b/vendor/github.com/docker/docker/pkg/stringid/stringid.go index 5fe071d62..d3d1014ac 100644 --- a/vendor/github.com/docker/docker/pkg/stringid/stringid.go +++ b/vendor/github.com/docker/docker/pkg/stringid/stringid.go @@ -4,21 +4,28 @@ package stringid // import "github.com/docker/docker/pkg/stringid" import ( "crypto/rand" "encoding/hex" - "fmt" + "errors" "regexp" "strconv" "strings" ) -const shortLen = 12 +const ( + shortLen = 12 + fullLen = 64 +) var ( validShortID = regexp.MustCompile("^[a-f0-9]{12}$") validHex = regexp.MustCompile(`^[a-f0-9]{64}$`) ) -// IsShortID determines if an arbitrary string *looks like* a short ID. +// IsShortID determines if id has the correct format and length for a short ID. +// It checks the IDs length and if it consists of valid characters for IDs (a-f0-9). func IsShortID(id string) bool { + if len(id) != shortLen { + return false + } return validShortID.MatchString(id) } @@ -54,10 +61,13 @@ func GenerateRandomID() string { } } -// ValidateID checks whether an ID string is a valid image ID. +// ValidateID checks whether an ID string is a valid, full-length image ID. func ValidateID(id string) error { - if ok := validHex.MatchString(id); !ok { - return fmt.Errorf("image ID %q is invalid", id) + if len(id) != fullLen { + return errors.New("image ID '" + id + "' is invalid") + } + if !validHex.MatchString(id) { + return errors.New("image ID '" + id + "' is invalid") } return nil } diff --git a/vendor/github.com/evilmartians/lefthook/.golangci.yml b/vendor/github.com/evilmartians/lefthook/.golangci.yml index ce406f262..6b6f1b0f8 100644 --- a/vendor/github.com/evilmartians/lefthook/.golangci.yml +++ b/vendor/github.com/evilmartians/lefthook/.golangci.yml @@ -45,7 +45,6 @@ linters: - govet - ineffassign - misspell - - nakedret - nestif - noctx - nolintlint diff --git a/vendor/github.com/evilmartians/lefthook/.goreleaser.yml b/vendor/github.com/evilmartians/lefthook/.goreleaser.yml index 5d58df252..f8e5c7ca8 100644 --- a/vendor/github.com/evilmartians/lefthook/.goreleaser.yml +++ b/vendor/github.com/evilmartians/lefthook/.goreleaser.yml @@ -13,6 +13,14 @@ builds: goarch: - amd64 - arm64 + - 386 + ignore: + - goos: darwin + goarch: 386 + - goos: linux + goarch: 386 + - goos: freebsd + goarch: 386 ldflags: - -s -w -X github.com/evilmartians/lefthook/internal/version.commit={{.Commit}} archives: @@ -26,6 +34,7 @@ archives: {{- if eq .Os "darwin" }}MacOS {{- else }}{{ title .Os }}{{ end }}_ {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }} - id: lefthook-gz format: gz @@ -52,6 +61,7 @@ changelog: - '^spec:' - '^tmp:' - '^context:' + - '^\d\.\d\.\d:' snapcrafts: - diff --git a/vendor/github.com/evilmartians/lefthook/CHANGELOG.md b/vendor/github.com/evilmartians/lefthook/CHANGELOG.md index 08f89fc38..d5d96c605 100644 --- a/vendor/github.com/evilmartians/lefthook/CHANGELOG.md +++ b/vendor/github.com/evilmartians/lefthook/CHANGELOG.md @@ -2,6 +2,34 @@ ## master (unreleased) +## 1.4.4 (2023-07-10) + +- fix: don't render bold ANSI sequence when colors are disabled ([#515](https://github.com/evilmartians/lefthook/pull/515)) by @adam12 +- deps: July 2023 ([#514](https://github.com/evilmartians/lefthook/pull/514)) by @mrexox + +## 1.4.3 (2023-06-19) + +- fix: auto stage non-standard files ([#506](https://github.com/evilmartians/lefthook/pull/506)) by @mrexox + +## 1.4.2 (2023-06-13) + +- deps: June 2023 ([#499](https://github.com/evilmartians/lefthook/pull/499)) +- feat: support toml dumpint ([#490](https://github.com/evilmartians/lefthook/pull/490)) by @mrexox +- feat: support json configs ([#489](https://github.com/evilmartians/lefthook/pull/489)) by @mrexox + +## 1.4.1 (2023-05-22) + +- fix: add win32 binary to artifacts (by @mrexox) +- feat: allow dumping with JSON ([#485](https://github.com/evilmartians/lefthook/pull/485) by @mrexox +- feat: add skip execution_info option ([#484](https://github.com/evilmartians/lefthook/pull/484)) by @mrexox +- deps: from 05.2023 ([#487](https://github.com/evilmartians/lefthook/pull/487)) by @mrexox + +## 1.4.0 (2023-05-18) + +- feat: add adaptive colors ([#482](https://github.com/evilmartians/lefthook/pull/482)) by @mrexox +- fix: skip output for interactive commands if configured ([#483](https://github.com/evilmartians/lefthook/pull/483)) by @mrexox +- feat: add dump command ([#481](https://github.com/evilmartians/lefthook/pull/481)) by @mrexox + ## 1.3.13 (2023-05-11) - feat: add only option ([#478](https://github.com/evilmartians/lefthook/pull/478)) by @mrexox @@ -110,7 +138,7 @@ ## 1.2.1 (2022-11-17) - fix: Remove quoting for scripts ([PR #371](https://github.com/evilmartians/lefthook/pull/371) by @stonesbg + @mrexox) -- fix: remove lefthook.checksum on uninstall ([PR #370](https://github.com/evilmartians/lefthook/pull370) by @JuliusHenke) +- fix: remove lefthook.checksum on uninstall ([PR #370](https://github.com/evilmartians/lefthook/pull/370) by @JuliusHenke) - fix: Print prepare-commit-msg hook if it exists in config ([PR #368](https://github.com/evilmartians/lefthook/pull/368) by @mrexox) - fix: Allow changing refs for remote ([PR #363](https://github.com/evilmartians/lefthook/pull/363) by @mrexox) diff --git a/vendor/github.com/evilmartians/lefthook/CONTRIBUTING.md b/vendor/github.com/evilmartians/lefthook/CONTRIBUTING.md index e6574232d..29c8cf085 100644 --- a/vendor/github.com/evilmartians/lefthook/CONTRIBUTING.md +++ b/vendor/github.com/evilmartians/lefthook/CONTRIBUTING.md @@ -4,7 +4,7 @@ First off, thanks for taking the time to contribute! Feel free to make Pull Requ # Requirements -Go >= 1.19.0 +Go >= 1.20.0 # Process diff --git a/vendor/github.com/evilmartians/lefthook/Makefile b/vendor/github.com/evilmartians/lefthook/Makefile index e246c64e2..85075b3d0 100644 --- a/vendor/github.com/evilmartians/lefthook/Makefile +++ b/vendor/github.com/evilmartians/lefthook/Makefile @@ -3,9 +3,18 @@ COMMIT_HASH = $(shell git rev-parse HEAD) build: go build -ldflags "-s -w -X github.com/evilmartians/lefthook/internal/version.commit=$(COMMIT_HASH)" -o lefthook +build-with-coverage: + go build -cover -ldflags "-s -w -X github.com/evilmartians/lefthook/internal/version.commit=$(COMMIT_HASH)" -o lefthook + +install: build + cp lefthook $(GOPATH)/bin/ + test: go test -cpu 24 -race -count=1 -timeout=30s ./... +test-integrity: install + go test -cpu 24 -race -count=1 -timeout=30s -tags=integrity integrity_test.go + bench: go test -cpu 24 -race -run=Bench -bench=. ./... diff --git a/vendor/github.com/evilmartians/lefthook/README.md b/vendor/github.com/evilmartians/lefthook/README.md index 2c7cc0b8d..c68dfdc38 100644 --- a/vendor/github.com/evilmartians/lefthook/README.md +++ b/vendor/github.com/evilmartians/lefthook/README.md @@ -21,7 +21,7 @@ Fast and powerful Git hooks manager for Node.js, Ruby or any other type of proje ## Install -With **Go** (>= 1.19): +With **Go** (>= 1.20): ```bash go install github.com/evilmartians/lefthook@latest diff --git a/vendor/github.com/evilmartians/lefthook/cmd/dump.go b/vendor/github.com/evilmartians/lefthook/cmd/dump.go new file mode 100644 index 000000000..1dfbc02ea --- /dev/null +++ b/vendor/github.com/evilmartians/lefthook/cmd/dump.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "github.com/spf13/cobra" + + "github.com/evilmartians/lefthook/internal/lefthook" +) + +func newDumpCmd(opts *lefthook.Options) *cobra.Command { + dumpArgs := lefthook.DumpArgs{} + dumpCmd := cobra.Command{ + Use: "dump", + Short: "Prints config merged from all extensions (in YAML format by default)", + Example: "lefthook dump", + Run: func(cmd *cobra.Command, args []string) { + lefthook.Dump(opts, dumpArgs) + }, + } + + dumpCmd.Flags().BoolVarP( + &dumpArgs.JSON, "json", "j", false, + "dump in JSON format", + ) + + dumpCmd.Flags().BoolVarP( + &dumpArgs.TOML, "toml", "t", false, + "dump in TOML format", + ) + + return &dumpCmd +} diff --git a/vendor/github.com/evilmartians/lefthook/cmd/lefthook.go b/vendor/github.com/evilmartians/lefthook/cmd/lefthook.go index 0b469d72c..b31b67446 100644 --- a/vendor/github.com/evilmartians/lefthook/cmd/lefthook.go +++ b/vendor/github.com/evilmartians/lefthook/cmd/lefthook.go @@ -1,18 +1,16 @@ package cmd -import ( - "os" +import "github.com/evilmartians/lefthook/internal/log" - "github.com/evilmartians/lefthook/internal/log" -) - -func Lefthook() { +func Lefthook() int { rootCmd := newRootCmd() if err := rootCmd.Execute(); err != nil { if err.Error() != "" { log.Errorf("Error: %s", err) } - os.Exit(1) + return 1 } + + return 0 } diff --git a/vendor/github.com/evilmartians/lefthook/cmd/root.go b/vendor/github.com/evilmartians/lefthook/cmd/root.go index 8c52baa1f..12949eb1d 100644 --- a/vendor/github.com/evilmartians/lefthook/cmd/root.go +++ b/vendor/github.com/evilmartians/lefthook/cmd/root.go @@ -14,6 +14,7 @@ var commands = [...]func(*lefthook.Options) *cobra.Command{ newInstallCmd, newUninstallCmd, newRunCmd, + newDumpCmd, } func newRootCmd() *cobra.Command { diff --git a/vendor/github.com/evilmartians/lefthook/internal/config/command.go b/vendor/github.com/evilmartians/lefthook/internal/config/command.go index 49d9c4b45..c671589c4 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/config/command.go +++ b/vendor/github.com/evilmartians/lefthook/internal/config/command.go @@ -12,21 +12,21 @@ import ( var errFilesIncompatible = errors.New("One of your runners contains incompatible file types") type Command struct { - Run string `mapstructure:"run"` + Run string `mapstructure:"run" yaml:"run" json:"run" toml:"run"` - Skip interface{} `mapstructure:"skip"` - Only interface{} `mapstructure:"only"` - Tags []string `mapstructure:"tags"` - Glob string `mapstructure:"glob"` - Files string `mapstructure:"files"` - Env map[string]string `mapstructure:"env"` + Skip interface{} `mapstructure:"skip" yaml:",omitempty" json:"skip,omitempty" toml:"skip,omitempty,inline"` + Only interface{} `mapstructure:"only" yaml:",omitempty" json:"only,omitempty" toml:"only,omitempty,inline"` + Tags []string `mapstructure:"tags" yaml:",omitempty" json:"tags,omitempty" toml:"tags,omitempty"` + Glob string `mapstructure:"glob" yaml:",omitempty" json:"glob,omitempty" toml:"glob,omitempty"` + Files string `mapstructure:"files" yaml:",omitempty" json:"files,omitempty" toml:"files,omitempty"` + Env map[string]string `mapstructure:"env" yaml:",omitempty" json:"env,omitempty" toml:"env,omitempty"` - Root string `mapstructure:"root"` - Exclude string `mapstructure:"exclude"` + Root string `mapstructure:"root" yaml:",omitempty" json:"root,omitempty" toml:"root,omitempty"` + Exclude string `mapstructure:"exclude" yaml:",omitempty" json:"exclude,omitempty" toml:"exclude,omitempty"` - FailText string `mapstructure:"fail_text"` - Interactive bool `mapstructure:"interactive"` - StageFixed bool `mapstructure:"stage_fixed"` + FailText string `mapstructure:"fail_text" yaml:"fail_text,omitempty" json:"fail_text,omitempty" toml:"fail_text,omitempty"` + Interactive bool `mapstructure:"interactive" yaml:",omitempty" json:"interactive,omitempty" toml:"interactive,omitempty"` + StageFixed bool `mapstructure:"stage_fixed" yaml:"stage_fixed,omitempty" json:"stage_fixed,omitempty" toml:"stage_fixed,omitempty"` } func (c Command) Validate() error { diff --git a/vendor/github.com/evilmartians/lefthook/internal/config/config.go b/vendor/github.com/evilmartians/lefthook/internal/config/config.go index 9839ffc3c..52fc5c8b3 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/config/config.go +++ b/vendor/github.com/evilmartians/lefthook/internal/config/config.go @@ -1,23 +1,95 @@ package config import ( + "encoding/json" + "os" + + "github.com/mitchellh/mapstructure" + toml "github.com/pelletier/go-toml/v2" + "gopkg.in/yaml.v3" + + "github.com/evilmartians/lefthook/internal/log" "github.com/evilmartians/lefthook/internal/version" ) +const dumpIndent = 2 + type Config struct { - Colors bool `mapstructure:"colors"` - Extends []string `mapstructure:"extends"` - Remote Remote `mapstructure:"remote"` - MinVersion string `mapstructure:"min_version"` - SkipOutput []string `mapstructure:"skip_output"` - SourceDir string `mapstructure:"source_dir"` - SourceDirLocal string `mapstructure:"source_dir_local"` - Rc string `mapstructure:"rc"` - NoTTY bool `mapstructure:"no_tty"` - - Hooks map[string]*Hook + MinVersion string `mapstructure:"min_version,omitempty"` + SourceDir string `mapstructure:"source_dir"` + SourceDirLocal string `mapstructure:"source_dir_local"` + Rc string `mapstructure:"rc,omitempty"` + SkipOutput []string `mapstructure:"skip_output,omitempty"` + Extends []string `mapstructure:"extends,omitempty"` + NoTTY bool `mapstructure:"no_tty,omitempty"` + Colors interface{} `mapstructure:"colors,omitempty"` + Remote *Remote `mapstructure:"remote,omitempty" ` + + Hooks map[string]*Hook `mapstructure:"-"` } func (c *Config) Validate() error { return version.CheckCovered(c.MinVersion) } + +func (c *Config) Dump(asJSON bool, asTOML bool) error { + res := make(map[string]interface{}) + if err := mapstructure.Decode(c, &res); err != nil { + return err + } + + if c.SourceDir == DefaultSourceDir { + delete(res, "source_dir") + } + if c.SourceDirLocal == DefaultSourceDirLocal { + delete(res, "source_dir_local") + } + + for hookName, hook := range c.Hooks { + res[hookName] = hook + } + + if asJSON { + return dumpJSON(res) + } + + if asTOML { + return dumpTOML(res) + } + + return dumpYAML(res) +} + +func dumpYAML(input map[string]interface{}) error { + encoder := yaml.NewEncoder(os.Stdout) + encoder.SetIndent(dumpIndent) + defer encoder.Close() + + err := encoder.Encode(input) + if err != nil { + return err + } + + return nil +} + +func dumpJSON(input map[string]interface{}) error { + res, err := json.MarshalIndent(input, "", " ") + if err != nil { + return err + } + + log.Info(string(res)) + + return nil +} + +func dumpTOML(input map[string]interface{}) error { + encoder := toml.NewEncoder(os.Stdout) + err := encoder.Encode(input) + if err != nil { + return err + } + + return nil +} diff --git a/vendor/github.com/evilmartians/lefthook/internal/config/hook.go b/vendor/github.com/evilmartians/lefthook/internal/config/hook.go index 2b538c149..fcb092a45 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/config/hook.go +++ b/vendor/github.com/evilmartians/lefthook/internal/config/hook.go @@ -18,20 +18,20 @@ type Hook struct { // Should be unmarshalled with `mapstructure:"commands"` // But replacing '{cmd}' is still an issue // Unmarshaling it manually, so omit auto unmarshaling - Commands map[string]*Command `mapstructure:"?"` + Commands map[string]*Command `mapstructure:"-" yaml:",omitempty" json:"commands,omitempty" toml:"commands,omitempty"` // Should be unmarshalled with `mapstructure:"scripts"` // But parsing keys with dots in it is still an issue: https://github.com/spf13/viper/issues/324 // Unmarshaling it manually, so omit auto unmarshaling - Scripts map[string]*Script `mapstructure:"?"` - - Files string `mapstructure:"files"` - Parallel bool `mapstructure:"parallel"` - Piped bool `mapstructure:"piped"` - ExcludeTags []string `mapstructure:"exclude_tags"` - Skip interface{} `mapstructure:"skip"` - Only interface{} `mapstructure:"only"` - Follow bool `mapstructure:"follow"` + Scripts map[string]*Script `mapstructure:"-" yaml:",omitempty" json:"scripts,omitempty" toml:"scripts,omitempty"` + + Files string `mapstructure:"files" yaml:",omitempty" json:"files,omitempty" toml:"files,omitempty"` + Parallel bool `mapstructure:"parallel" yaml:",omitempty" json:"parallel,omitempty" toml:"parallel,omitempty"` + Piped bool `mapstructure:"piped" yaml:",omitempty" json:"piped,omitempty" toml:"piped,omitempty"` + Follow bool `mapstructure:"follow" yaml:",omitempty" json:"follow,omitempty" toml:"follow,omitempty"` + ExcludeTags []string `mapstructure:"exclude_tags" yaml:"exclude_tags,omitempty" json:"exclude_tags,omitempty" toml:"exclude_tags,omitempty"` + Skip interface{} `mapstructure:"skip" yaml:",omitempty" json:"skip,omitempty" toml:"skip,omitempty,inline"` + Only interface{} `mapstructure:"only" yaml:",omitempty" json:"only,omitempty" toml:"only,omitempty,inline"` } func (h *Hook) Validate() error { diff --git a/vendor/github.com/evilmartians/lefthook/internal/config/load.go b/vendor/github.com/evilmartians/lefthook/internal/config/load.go index 45d000514..ae9ea4aa4 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/config/load.go +++ b/vendor/github.com/evilmartians/lefthook/internal/config/load.go @@ -18,7 +18,6 @@ const ( DefaultConfigName = "lefthook.yml" DefaultSourceDir = ".lefthook" DefaultSourceDirLocal = ".lefthook-local" - DefaultColorsEnabled = true ) var hookKeyRegexp = regexp.MustCompile(`^(?P[^.]+)\.(scripts|commands)`) @@ -52,7 +51,6 @@ func Load(fs afero.Fs, repo *git.Repository) (*Config, error) { var config Config - config.Colors = DefaultColorsEnabled config.SourceDir = DefaultSourceDir config.SourceDirLocal = DefaultSourceDirLocal @@ -61,6 +59,7 @@ func Load(fs afero.Fs, repo *git.Repository) (*Config, error) { return nil, err } + log.SetColors(config.Colors) return &config, nil } diff --git a/vendor/github.com/evilmartians/lefthook/internal/config/remote.go b/vendor/github.com/evilmartians/lefthook/internal/config/remote.go index 525c59e3d..b81555294 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/config/remote.go +++ b/vendor/github.com/evilmartians/lefthook/internal/config/remote.go @@ -1,11 +1,15 @@ package config type Remote struct { - GitURL string `mapstructure:"git_url"` - Ref string `mapstructure:"ref"` - Config string `mapstructure:"config"` + GitURL string `mapstructure:"git_url" yaml:"git_url" json:"git_url,omitempty" toml:"git_url"` + Ref string `mapstructure:"ref,omitempty" yaml:",omitempty" json:"ref,omitempty" toml:"ref,omitempty"` + Config string `mapstructure:"config,omitempty" yaml:",omitempty" json:"config,omitempty" toml:"config,omitempty"` } -func (r Remote) Configured() bool { +func (r *Remote) Configured() bool { + if r == nil { + return false + } + return len(r.GitURL) > 0 } diff --git a/vendor/github.com/evilmartians/lefthook/internal/config/script.go b/vendor/github.com/evilmartians/lefthook/internal/config/script.go index 41c0bc522..3cad3604b 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/config/script.go +++ b/vendor/github.com/evilmartians/lefthook/internal/config/script.go @@ -10,16 +10,16 @@ import ( ) type Script struct { - Runner string `mapstructure:"runner"` + Runner string `mapstructure:"runner" yaml:"runner" json:"runner" toml:"runner"` - Skip interface{} `mapstructure:"skip"` - Only interface{} `mapstructure:"only"` - Tags []string `mapstructure:"tags"` - Env map[string]string `mapstructure:"env"` + Skip interface{} `mapstructure:"skip" yaml:",omitempty" json:"skip,omitempty" toml:"skip,omitempty,inline"` + Only interface{} `mapstructure:"only" yaml:",omitempty" json:"only,omitempty" toml:"only,omitempty,inline"` + Tags []string `mapstructure:"tags" yaml:",omitempty" json:"tags,omitempty" toml:"tags,omitempty"` + Env map[string]string `mapstructure:"env" yaml:",omitempty" json:"env,omitempty" toml:"env,omitempty"` - FailText string `mapstructure:"fail_text"` - Interactive bool `mapstructure:"interactive"` - StageFixed bool `mapstructure:"stage_fixed"` + FailText string `mapstructure:"fail_text" yaml:"fail_text,omitempty" json:"fail_text,omitempty" toml:"fail_text,omitempty"` + Interactive bool `mapstructure:"interactive" yaml:",omitempty" json:"interactive,omitempty" toml:"interactive,omitempty"` + StageFixed bool `mapstructure:"stage_fixed" yaml:"stage_fixed,omitempty" json:"stage_fixed,omitempty" toml:"stage_fixed,omitempty"` } func (s Script) DoSkip(gitState git.State) bool { diff --git a/vendor/github.com/evilmartians/lefthook/internal/lefthook/dump.go b/vendor/github.com/evilmartians/lefthook/internal/lefthook/dump.go new file mode 100644 index 000000000..be96fda74 --- /dev/null +++ b/vendor/github.com/evilmartians/lefthook/internal/lefthook/dump.go @@ -0,0 +1,30 @@ +package lefthook + +import ( + "github.com/evilmartians/lefthook/internal/config" + "github.com/evilmartians/lefthook/internal/log" +) + +type DumpArgs struct { + JSON bool + TOML bool +} + +func Dump(opts *Options, args DumpArgs) { + lefthook, err := initialize(opts) + if err != nil { + log.Errorf("couldn't initialize lefthook: %s\n", err) + return + } + + cfg, err := config.Load(lefthook.Fs, lefthook.repo) + if err != nil { + log.Errorf("couldn't load config: %s\n", err) + return + } + + if err := cfg.Dump(args.JSON, args.TOML); err != nil { + log.Errorf("couldn't dump config: %s\n", err) + return + } +} diff --git a/vendor/github.com/evilmartians/lefthook/internal/lefthook/install.go b/vendor/github.com/evilmartians/lefthook/internal/lefthook/install.go index 88d828c05..32504ab24 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/lefthook/install.go +++ b/vendor/github.com/evilmartians/lefthook/internal/lefthook/install.go @@ -4,12 +4,15 @@ import ( "bufio" "crypto/md5" "encoding/hex" + "fmt" "io" + "os" "path/filepath" "regexp" "strconv" "strings" + "github.com/gobwas/glob" "github.com/spf13/afero" "github.com/evilmartians/lefthook/internal/config" @@ -21,12 +24,15 @@ const ( configFileMode = 0o666 checksumFileMode = 0o644 hooksDirMode = 0o755 - configGlob = "lefthook.y*ml" timestampBase = 10 timestampBitsize = 64 ) -var lefthookChecksumRegexp = regexp.MustCompile(`(\w+)\s+(\d+)`) +var ( + lefthookChecksumRegexp = regexp.MustCompile(`(\w+)\s+(\d+)`) + configGlob = glob.MustCompile("lefthook.{yml,yaml,json,toml}") + errNoConfig = fmt.Errorf("no lefthook config found") +) type InstallArgs struct { Force, Aggressive bool @@ -69,7 +75,6 @@ func (l *Lefthook) readOrCreateConfig() (*config.Config, error) { if !l.configExists(l.repo.RootPath) { log.Info("Config not found, creating...") - if err := l.createConfig(l.repo.RootPath); err != nil { return nil, err } @@ -79,13 +84,13 @@ func (l *Lefthook) readOrCreateConfig() (*config.Config, error) { } func (l *Lefthook) configExists(path string) bool { - paths, err := afero.Glob(l.Fs, filepath.Join(path, configGlob)) + paths, err := afero.ReadDir(l.Fs, path) if err != nil { return false } - for _, config := range paths { - if ok, _ := afero.Exists(l.Fs, config); ok { + for _, file := range paths { + if ok := configGlob.Match(file.Name()); ok { return true } } @@ -199,27 +204,46 @@ func (l *Lefthook) hooksSynchronized() bool { } func (l *Lefthook) configLastUpdateTimestamp() (timestamp int64, err error) { - m, err := afero.Glob(l.Fs, filepath.Join(l.repo.RootPath, configGlob)) + paths, err := afero.ReadDir(l.Fs, l.repo.RootPath) if err != nil { return } + var config os.FileInfo + for _, file := range paths { + if ok := configGlob.Match(file.Name()); ok { + config = file + break + } + } - info, err := l.Fs.Stat(m[0]) - if err != nil { + if config == nil { + err = errNoConfig return } - timestamp = info.ModTime().Unix() + timestamp = config.ModTime().Unix() return } func (l *Lefthook) configChecksum() (checksum string, err error) { - m, err := afero.Glob(l.Fs, filepath.Join(l.repo.RootPath, configGlob)) + paths, err := afero.ReadDir(l.Fs, l.repo.RootPath) if err != nil { return } - file, err := l.Fs.Open(m[0]) + var config string + for _, file := range paths { + if ok := configGlob.Match(file.Name()); ok { + config = file.Name() + break + } + } + if len(config) == 0 { + err = errNoConfig + return + } + + file, err := l.Fs.Open(filepath.Join(l.repo.RootPath, config)) if err != nil { return } diff --git a/vendor/github.com/evilmartians/lefthook/internal/lefthook/run.go b/vendor/github.com/evilmartians/lefthook/internal/lefthook/run.go index 6f0db2414..e1844c958 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/lefthook/run.go +++ b/vendor/github.com/evilmartians/lefthook/internal/lefthook/run.go @@ -16,7 +16,7 @@ import ( const ( envEnabled = "LEFTHOOK" // "0", "false" - envSkipOutput = "LEFTHOOK_QUIET" // "meta,success,failure,summary,execution,execution_out,skips" + envSkipOutput = "LEFTHOOK_QUIET" // "meta,success,failure,summary,skips,execution,execution_out,execution_info" envVerbose = "LEFTHOOK_VERBOSE" // keep all output ) @@ -76,10 +76,6 @@ func (l *Lefthook) Run(hookName string, args RunArgs, gitArgs []string) error { (&logSettings).ApplySetting(skipOption) } - if cfg.Colors != config.DefaultColorsEnabled { - log.SetColors(cfg.Colors) - } - if !logSettings.SkipMeta() { log.Info(log.Cyan("Lefthook v" + version.Version(false))) } diff --git a/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/execute_unix.go b/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/execute_unix.go index 328f965e2..e74594e31 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/execute_unix.go +++ b/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/execute_unix.go @@ -47,7 +47,7 @@ func (e CommandExecutor) Execute(opts ExecuteOptions, out io.Writer) error { command.Env = append(os.Environ(), envList...) if opts.interactive { - command.Stdout = os.Stdout + command.Stdout = out command.Stdin = stdin command.Stderr = os.Stderr err := command.Start() diff --git a/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/prepare_command.go b/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/prepare_command.go index aab1c2312..67dbfe104 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/prepare_command.go +++ b/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/prepare_command.go @@ -62,7 +62,7 @@ func (r *Runner) buildCommandArgs(command *config.Command) (*commandArgs, error, }, } - filteredFiles := []string{} + filesFiltered := make([]string, 0) runString := command.Run for filesType, filesFn := range filesTypeToFn { // Checking substitutions and skipping execution if it is empty. @@ -79,28 +79,31 @@ func (r *Runner) buildCommandArgs(command *config.Command) (*commandArgs, error, return nil, nil, errors.New("no files for inspection") } - filesPrepared := prepareFiles(command, files) - if len(filesPrepared) == 0 { + filtered := filterFiles(command, files) + filesFiltered = append(filesFiltered, filtered...) + + prepared := escapeFiles(filtered) + if len(prepared) == 0 { return nil, nil, errors.New("no files for inspection") } - filteredFiles = append(filteredFiles, filesPrepared...) - runString = replaceQuoted(runString, filesType, filesPrepared) + + runString = replaceQuoted(runString, filesType, prepared) } } - if len(filteredFiles) == 0 && config.HookUsesStagedFiles(r.HookName) { + if len(filesFiltered) == 0 && config.HookUsesStagedFiles(r.HookName) { files, err := r.Repo.StagedFiles() if err == nil { - if len(prepareFiles(command, files)) == 0 { + if len(filterFiles(command, files)) == 0 { return nil, nil, errors.New("no matching staged files") } } } - if len(filteredFiles) == 0 && config.HookUsesPushFiles(r.HookName) { + if len(filesFiltered) == 0 && config.HookUsesPushFiles(r.HookName) { files, err := r.Repo.PushFiles() if err == nil { - if len(prepareFiles(command, files)) == 0 { + if len(filterFiles(command, files)) == 0 { return nil, nil, errors.New("no matching push files") } } @@ -111,7 +114,7 @@ func (r *Runner) buildCommandArgs(command *config.Command) (*commandArgs, error, log.Debug("[lefthook] executing: ", runString) return &commandArgs{ - files: filteredFiles, + files: filesFiltered, all: strings.Split(runString, " "), }, nil, nil } @@ -124,7 +127,7 @@ func (r *Runner) replacePositionalArguments(runString string) string { return runString } -func prepareFiles(command *config.Command, files []string) []string { +func filterFiles(command *config.Command, files []string) []string { if files == nil { return []string{} } @@ -137,7 +140,11 @@ func prepareFiles(command *config.Command, files []string) []string { log.Debug("[lefthook] files after filters:\n", files) - // Escape file names to prevent unexpected bugs + return files +} + +// Escape file names to prevent unexpected bugs. +func escapeFiles(files []string) []string { var filesEsc []string for _, fileName := range files { if len(fileName) > 0 { diff --git a/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/runner.go b/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/runner.go index 689f65b2b..81d423880 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/runner.go +++ b/vendor/github.com/evilmartians/lefthook/internal/lefthook/runner/runner.go @@ -372,13 +372,16 @@ func (r *Runner) runCommand(name string, command *config.Command) { if finished && config.HookUsesStagedFiles(r.HookName) && command.StageFixed { files := args.files + if len(files) == 0 { - stagedFiles, err := r.Repo.StagedFiles() + var err error + files, err = r.Repo.StagedFiles() if err != nil { log.Warn("Couldn't stage fixed files:", err) return } - files = prepareFiles(command, stagedFiles) + + files = filterFiles(command, files) } if len(command.Root) > 0 { @@ -402,7 +405,7 @@ func (r *Runner) run(opts ExecuteOptions, follow bool) bool { defer log.UnsetName(opts.name) if (follow || opts.interactive) && !r.SkipSettings.SkipExecution() { - log.Info(log.Cyan("\n EXECUTE > "), log.Bold(opts.name)) + r.logExecute(opts.name, nil, nil) var out io.Writer if r.SkipSettings.SkipExecutionOutput() { @@ -424,29 +427,13 @@ func (r *Runner) run(opts ExecuteOptions, follow bool) bool { out := bytes.NewBuffer(make([]byte, 0)) err := r.executor.Execute(opts, out) - var execName string if err != nil { r.fail(opts.name, opts.failText) - execName = fmt.Sprint(log.Red("\n EXECUTE > "), log.Bold(opts.name)) } else { r.success(opts.name) - execName = fmt.Sprint(log.Cyan("\n EXECUTE > "), log.Bold(opts.name)) - } - - if err == nil && r.SkipSettings.SkipExecution() { - return false - } - - if r.SkipSettings.SkipExecutionOutput() { - log.Infof("%s\n", execName) - } else { - log.Infof("%s\n%s", execName, out) } - if err != nil { - log.Infof("%s", err) - } - log.Infof("\n") + r.logExecute(opts.name, err, out) return err == nil } @@ -482,3 +469,33 @@ func (r *Runner) logSkip(name, reason string) { ), ) } + +func (r *Runner) logExecute(name string, err error, out io.Reader) { + if err == nil && r.SkipSettings.SkipExecution() { + return + } + + var execLog string + switch { + case r.SkipSettings.SkipExecutionInfo(): + execLog = "\n" + case err != nil: + execLog = fmt.Sprint(log.Red("\n EXECUTE > "), log.Bold(name)) + default: + execLog = fmt.Sprint(log.Cyan("\n EXECUTE > "), log.Bold(name)) + } + + if err == nil && r.SkipSettings.SkipExecutionOutput() { + log.Info(execLog) + return + } + + log.Info(execLog) + if out != nil { + log.Info(out) + } + + if err != nil { + log.Infof("%s", err) + } +} diff --git a/vendor/github.com/evilmartians/lefthook/internal/log/log.go b/vendor/github.com/evilmartians/lefthook/internal/log/log.go index 6c82ef918..f3e4d383b 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/log/log.go +++ b/vendor/github.com/evilmartians/lefthook/internal/log/log.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "strconv" "strings" "sync" "time" @@ -12,15 +13,34 @@ import ( "github.com/charmbracelet/lipgloss" ) -const ( - colorCyan = "#70C0BA" - colorYellow = "#fada5e" - colorRed = "#ff6347" - colorGreen = "#76ff7a" - colorGray = "#808080" -) +var ( + colorRed lipgloss.TerminalColor = lipgloss.CompleteAdaptiveColor{ + Dark: lipgloss.CompleteColor{TrueColor: "#ff6347", ANSI256: "196", ANSI: "9"}, + Light: lipgloss.CompleteColor{TrueColor: "#d70000", ANSI256: "160", ANSI: "1"}, + } + + colorGreen lipgloss.TerminalColor = lipgloss.CompleteAdaptiveColor{ + Dark: lipgloss.CompleteColor{TrueColor: "#76ff7a", ANSI256: "155", ANSI: "10"}, + Light: lipgloss.CompleteColor{TrueColor: "#afd700", ANSI256: "148", ANSI: "2"}, + } + + colorYellow lipgloss.TerminalColor = lipgloss.CompleteAdaptiveColor{ + Dark: lipgloss.CompleteColor{TrueColor: "#fada5e", ANSI256: "191", ANSI: "11"}, + Light: lipgloss.CompleteColor{TrueColor: "#ffaf00", ANSI256: "214", ANSI: "3"}, + } + + colorCyan lipgloss.TerminalColor = lipgloss.CompleteAdaptiveColor{ + Dark: lipgloss.CompleteColor{TrueColor: "#70C0BA", ANSI256: "37", ANSI: "14"}, + Light: lipgloss.CompleteColor{TrueColor: "#00af87", ANSI256: "36", ANSI: "6"}, + } -var std = New() + colorGray lipgloss.TerminalColor = lipgloss.CompleteAdaptiveColor{ + Dark: lipgloss.CompleteColor{TrueColor: "#808080", ANSI256: "244", ANSI: "7"}, + Light: lipgloss.CompleteColor{TrueColor: "#4e4e4e", ANSI256: "239", ANSI: "8"}, + } + + std = New() +) type Level uint32 @@ -112,8 +132,44 @@ func SetLevel(level Level) { std.SetLevel(level) } -func SetColors(enable bool) { - std.colors = enable +func SetColors(colors interface{}) { + switch typedColors := colors.(type) { + case bool: + std.colors = typedColors + return + case map[string]interface{}: + std.colors = true + setColor(typedColors["red"], &colorRed) + setColor(typedColors["green"], &colorGreen) + setColor(typedColors["yellow"], &colorYellow) + setColor(typedColors["cyan"], &colorCyan) + setColor(typedColors["gray"], &colorGray) + return + default: + std.colors = true + } +} + +func setColor(colorCode interface{}, adaptiveColor *lipgloss.TerminalColor) { + if colorCode == nil { + return + } + + var code string + switch typedCode := colorCode.(type) { + case int: + code = strconv.Itoa(typedCode) + case string: + code = typedCode + default: + return + } + + if len(code) == 0 { + return + } + + *adaptiveColor = lipgloss.Color(code) } func Cyan(s string) string { @@ -137,15 +193,19 @@ func Gray(s string) string { } func Bold(s string) string { + if !std.colors { + return lipgloss.NewStyle().Render(s) + } + return lipgloss.NewStyle().Bold(true).Render(s) } -func color(colorCode string) lipgloss.Style { +func color(clr lipgloss.TerminalColor) lipgloss.Style { if !std.colors { return lipgloss.NewStyle() } - return lipgloss.NewStyle().Foreground(lipgloss.Color(colorCode)) + return lipgloss.NewStyle().Foreground(clr) } func SetOutput(out io.Writer) { diff --git a/vendor/github.com/evilmartians/lefthook/internal/log/skip_settings.go b/vendor/github.com/evilmartians/lefthook/internal/log/skip_settings.go index 0593a713d..fe736659d 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/log/skip_settings.go +++ b/vendor/github.com/evilmartians/lefthook/internal/log/skip_settings.go @@ -5,9 +5,10 @@ const ( skipSuccess skipFailure skipSummary + skipSkips skipExecution skipExecutionOutput - skipSkips + skipExecutionInfo ) type SkipSettings int16 @@ -28,6 +29,8 @@ func (s *SkipSettings) ApplySetting(setting string) { *s |= skipExecution case "execution_out": *s |= skipExecutionOutput + case "execution_info": + *s |= skipExecutionInfo } } @@ -55,6 +58,10 @@ func (s SkipSettings) SkipExecutionOutput() bool { return s.doSkip(skipExecutionOutput) } +func (s SkipSettings) SkipExecutionInfo() bool { + return s.doSkip(skipExecutionInfo) +} + func (s SkipSettings) SkipSkips() bool { return s.doSkip(skipSkips) } diff --git a/vendor/github.com/evilmartians/lefthook/internal/version/version.go b/vendor/github.com/evilmartians/lefthook/internal/version/version.go index 6b051989c..2fb416988 100644 --- a/vendor/github.com/evilmartians/lefthook/internal/version/version.go +++ b/vendor/github.com/evilmartians/lefthook/internal/version/version.go @@ -6,7 +6,7 @@ import ( "strconv" ) -const version = "1.3.13" +const version = "1.4.4" var ( // Is set via -X github.com/evilmartians/lefthook/internal/version.commit={commit}. diff --git a/vendor/github.com/evilmartians/lefthook/main.go b/vendor/github.com/evilmartians/lefthook/main.go index 64accc086..25b3d8e3b 100644 --- a/vendor/github.com/evilmartians/lefthook/main.go +++ b/vendor/github.com/evilmartians/lefthook/main.go @@ -1,7 +1,11 @@ package main -import "github.com/evilmartians/lefthook/cmd" +import ( + "os" + + "github.com/evilmartians/lefthook/cmd" +) func main() { - cmd.Lefthook() + os.Exit(cmd.Lefthook()) } diff --git a/vendor/github.com/google/go-containerregistry/internal/estargz/estargz.go b/vendor/github.com/google/go-containerregistry/internal/estargz/estargz.go new file mode 100644 index 000000000..69021bcee --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/internal/estargz/estargz.go @@ -0,0 +1,54 @@ +// Copyright 2020 Google LLC 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 estargz adapts the containerd estargz package to our abstractions. +package estargz + +import ( + "bytes" + "io" + + "github.com/containerd/stargz-snapshotter/estargz" + v1 "github.com/google/go-containerregistry/pkg/v1" +) + +// Assert that what we're returning is an io.ReadCloser +var _ io.ReadCloser = (*estargz.Blob)(nil) + +// ReadCloser reads uncompressed tarball input from the io.ReadCloser and +// returns: +// - An io.ReadCloser from which compressed data may be read, and +// - A v1.Hash with the hash of the estargz table of contents, or +// - An error if the estargz processing encountered a problem. +// +// Refer to estargz for the options: +// https://pkg.go.dev/github.com/containerd/stargz-snapshotter/estargz@v0.4.1#Option +func ReadCloser(r io.ReadCloser, opts ...estargz.Option) (*estargz.Blob, v1.Hash, error) { + defer r.Close() + + // TODO(#876): Avoid buffering into memory. + bs, err := io.ReadAll(r) + if err != nil { + return nil, v1.Hash{}, err + } + br := bytes.NewReader(bs) + + rc, err := estargz.Build(io.NewSectionReader(br, 0, int64(len(bs))), opts...) + if err != nil { + return nil, v1.Hash{}, err + } + + h, err := v1.NewHash(rc.TOCDigest().String()) + return rc, h, err +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/authn/keychain.go b/vendor/github.com/google/go-containerregistry/pkg/authn/keychain.go index a4a88b3d5..4e32500cd 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/authn/keychain.go +++ b/vendor/github.com/google/go-containerregistry/pkg/authn/keychain.go @@ -18,6 +18,7 @@ import ( "os" "path/filepath" "sync" + "time" "github.com/docker/cli/cli/config" "github.com/docker/cli/cli/config/configfile" @@ -52,7 +53,7 @@ type defaultKeychain struct { var ( // DefaultKeychain implements Keychain by interpreting the docker config file. - DefaultKeychain Keychain = &defaultKeychain{} + DefaultKeychain = RefreshingKeychain(&defaultKeychain{}, 5*time.Minute) ) const ( @@ -178,3 +179,71 @@ func (w wrapper) Resolve(r Resource) (Authenticator, error) { } return FromConfig(AuthConfig{Username: u, Password: p}), nil } + +func RefreshingKeychain(inner Keychain, duration time.Duration) Keychain { + return &refreshingKeychain{ + keychain: inner, + duration: duration, + } +} + +type refreshingKeychain struct { + keychain Keychain + duration time.Duration + clock func() time.Time +} + +func (r *refreshingKeychain) Resolve(target Resource) (Authenticator, error) { + last := time.Now() + auth, err := r.keychain.Resolve(target) + if err != nil || auth == Anonymous { + return auth, err + } + return &refreshing{ + target: target, + keychain: r.keychain, + last: last, + cached: auth, + duration: r.duration, + clock: r.clock, + }, nil +} + +type refreshing struct { + sync.Mutex + target Resource + keychain Keychain + + duration time.Duration + + last time.Time + cached Authenticator + + // for testing + clock func() time.Time +} + +func (r *refreshing) Authorization() (*AuthConfig, error) { + r.Lock() + defer r.Unlock() + if r.cached == nil || r.expired() { + r.last = r.now() + auth, err := r.keychain.Resolve(r.target) + if err != nil { + return nil, err + } + r.cached = auth + } + return r.cached.Authorization() +} + +func (r *refreshing) now() time.Time { + if r.clock == nil { + return time.Now() + } + return r.clock() +} + +func (r *refreshing) expired() bool { + return r.now().Sub(r.last) > r.duration +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/registry.go b/vendor/github.com/google/go-containerregistry/pkg/name/registry.go index 2a26b66d0..5b0d01769 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/registry.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/registry.go @@ -17,6 +17,7 @@ package name import ( "net" "net/url" + "path" "regexp" "strings" ) @@ -50,6 +51,11 @@ func (r Registry) String() string { return r.Name() } +// Repo returns a Repository in the Registry with the given name. +func (r Registry) Repo(repo ...string) Repository { + return Repository{Registry: r, repository: path.Join(repo...)} +} + // Scope returns the scope required to access the registry. func (r Registry) Scope(string) string { // The only resource under 'registry' is 'catalog'. http://goo.gl/N9cN9Z diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/empty/README.md b/vendor/github.com/google/go-containerregistry/pkg/v1/empty/README.md new file mode 100644 index 000000000..8663a830f --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/empty/README.md @@ -0,0 +1,8 @@ +# `empty` + +[![GoDoc](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/empty?status.svg)](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/empty) + +The empty packages provides an empty base for constructing a `v1.Image` or `v1.ImageIndex`. +This is especially useful when paired with the [`mutate`](/pkg/v1/mutate) package, +see [`mutate.Append`](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/mutate#Append) +and [`mutate.AppendManifests`](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/mutate#AppendManifests). diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatecreate/usage.gen.go b/vendor/github.com/google/go-containerregistry/pkg/v1/empty/doc.go similarity index 71% rename from vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatecreate/usage.gen.go rename to vendor/github.com/google/go-containerregistry/pkg/v1/empty/doc.go index b9f9de4f1..1a521e9a7 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatecreate/usage.gen.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/empty/doc.go @@ -1,10 +1,10 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2018 Google LLC 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 +// 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, @@ -12,8 +12,5 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Generated. DO NOT EDIT. - -package templatecreate - -import _ "github.com/bufbuild/buf/private/usage" +// Package empty provides an implementation of v1.Image equivalent to "FROM scratch". +package empty diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/empty/image.go b/vendor/github.com/google/go-containerregistry/pkg/v1/empty/image.go new file mode 100644 index 000000000..c58a06ce0 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/empty/image.go @@ -0,0 +1,52 @@ +// Copyright 2018 Google LLC 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 empty + +import ( + "fmt" + + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/partial" + "github.com/google/go-containerregistry/pkg/v1/types" +) + +// Image is a singleton empty image, think: FROM scratch. +var Image, _ = partial.UncompressedToImage(emptyImage{}) + +type emptyImage struct{} + +// MediaType implements partial.UncompressedImageCore. +func (i emptyImage) MediaType() (types.MediaType, error) { + return types.DockerManifestSchema2, nil +} + +// RawConfigFile implements partial.UncompressedImageCore. +func (i emptyImage) RawConfigFile() ([]byte, error) { + return partial.RawConfigFile(i) +} + +// ConfigFile implements v1.Image. +func (i emptyImage) ConfigFile() (*v1.ConfigFile, error) { + return &v1.ConfigFile{ + RootFS: v1.RootFS{ + // Some clients check this. + Type: "layers", + }, + }, nil +} + +func (i emptyImage) LayerByDiffID(h v1.Hash) (partial.UncompressedLayer, error) { + return nil, fmt.Errorf("LayerByDiffID(%s): empty image", h) +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/empty/index.go b/vendor/github.com/google/go-containerregistry/pkg/v1/empty/index.go new file mode 100644 index 000000000..18b414891 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/empty/index.go @@ -0,0 +1,65 @@ +// Copyright 2018 Google LLC 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 empty + +import ( + "encoding/json" + "errors" + + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/partial" + "github.com/google/go-containerregistry/pkg/v1/types" +) + +// Index is a singleton empty index, think: FROM scratch. +var Index = emptyIndex{} + +type emptyIndex struct{} + +func (i emptyIndex) MediaType() (types.MediaType, error) { + return types.OCIImageIndex, nil +} + +func (i emptyIndex) Digest() (v1.Hash, error) { + return partial.Digest(i) +} + +func (i emptyIndex) Size() (int64, error) { + return partial.Size(i) +} + +func (i emptyIndex) IndexManifest() (*v1.IndexManifest, error) { + return base(), nil +} + +func (i emptyIndex) RawManifest() ([]byte, error) { + return json.Marshal(base()) +} + +func (i emptyIndex) Image(v1.Hash) (v1.Image, error) { + return nil, errors.New("empty index") +} + +func (i emptyIndex) ImageIndex(v1.Hash) (v1.ImageIndex, error) { + return nil, errors.New("empty index") +} + +func base() *v1.IndexManifest { + return &v1.IndexManifest{ + SchemaVersion: 2, + MediaType: types.OCIImageIndex, + Manifests: []v1.Descriptor{}, + } +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/README.md b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/README.md new file mode 100644 index 000000000..19e161243 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/README.md @@ -0,0 +1,56 @@ +# `mutate` + +[![GoDoc](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/mutate?status.svg)](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/mutate) + +The `v1.Image`, `v1.ImageIndex`, and `v1.Layer` interfaces provide only +accessor methods, so they are essentially immutable. If you want to change +something about them, you need to produce a new instance of that interface. + +A common use case for this library is to read an image from somewhere (a source), +change something about it, and write the image somewhere else (a sink). + +Graphically, this looks something like: + +

+ +

+ +## Mutations + +This is obviously not a comprehensive set of useful transformations (PRs welcome!), +but a rough summary of what the `mutate` package currently does: + +### `Config` and `ConfigFile` + +These allow you to change the [image configuration](https://github.com/opencontainers/image-spec/blob/master/config.md#properties), +e.g. to change the entrypoint, environment, author, etc. + +### `Time`, `Canonical`, and `CreatedAt` + +These are useful in the context of [reproducible builds](https://reproducible-builds.org/), +where you may want to strip timestamps and other non-reproducible information. + +### `Append`, `AppendLayers`, and `AppendManifests` + +These functions allow the extension of a `v1.Image` or `v1.ImageIndex` with +new layers or manifests. + +For constructing an image `FROM scratch`, see the [`empty`](/pkg/v1/empty) package. + +### `MediaType` and `IndexMediaType` + +Sometimes, it is necessary to change the media type of an image or index, +e.g. to appease a registry with strict validation of images (_looking at you, GCR_). + +### `Rebase` + +Rebase has [its own README](/cmd/crane/rebase.md). + +This is the underlying implementation of [`crane rebase`](https://github.com/google/go-containerregistry/blob/main/cmd/crane/doc/crane_rebase.md). + +### `Extract` + +Extract will flatten an image filesystem into a single tar stream, +respecting whiteout files. + +This is the underlying implementation of [`crane export`](https://github.com/google/go-containerregistry/blob/main/cmd/crane/doc/crane_export.md). diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/doc.go b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/doc.go new file mode 100644 index 000000000..dfbd9951e --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/doc.go @@ -0,0 +1,16 @@ +// Copyright 2018 Google LLC 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 mutate provides facilities for mutating v1.Images of any kind. +package mutate diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/image.go b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/image.go new file mode 100644 index 000000000..3ea27fe47 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/image.go @@ -0,0 +1,293 @@ +// Copyright 2019 Google LLC 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 mutate + +import ( + "bytes" + "encoding/json" + "errors" + "sync" + + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/partial" + "github.com/google/go-containerregistry/pkg/v1/stream" + "github.com/google/go-containerregistry/pkg/v1/types" +) + +type image struct { + base v1.Image + adds []Addendum + + computed bool + configFile *v1.ConfigFile + manifest *v1.Manifest + annotations map[string]string + mediaType *types.MediaType + configMediaType *types.MediaType + diffIDMap map[v1.Hash]v1.Layer + digestMap map[v1.Hash]v1.Layer + subject *v1.Descriptor + + sync.Mutex +} + +var _ v1.Image = (*image)(nil) + +func (i *image) MediaType() (types.MediaType, error) { + if i.mediaType != nil { + return *i.mediaType, nil + } + return i.base.MediaType() +} + +func (i *image) compute() error { + i.Lock() + defer i.Unlock() + + // Don't re-compute if already computed. + if i.computed { + return nil + } + var configFile *v1.ConfigFile + if i.configFile != nil { + configFile = i.configFile + } else { + cf, err := i.base.ConfigFile() + if err != nil { + return err + } + configFile = cf.DeepCopy() + } + diffIDs := configFile.RootFS.DiffIDs + history := configFile.History + + diffIDMap := make(map[v1.Hash]v1.Layer) + digestMap := make(map[v1.Hash]v1.Layer) + + for _, add := range i.adds { + history = append(history, add.History) + if add.Layer != nil { + diffID, err := add.Layer.DiffID() + if err != nil { + return err + } + diffIDs = append(diffIDs, diffID) + diffIDMap[diffID] = add.Layer + } + } + + m, err := i.base.Manifest() + if err != nil { + return err + } + manifest := m.DeepCopy() + manifestLayers := manifest.Layers + for _, add := range i.adds { + if add.Layer == nil { + // Empty layers include only history in manifest. + continue + } + + desc, err := partial.Descriptor(add.Layer) + if err != nil { + return err + } + + // Fields in the addendum override the original descriptor. + if len(add.Annotations) != 0 { + desc.Annotations = add.Annotations + } + if len(add.URLs) != 0 { + desc.URLs = add.URLs + } + + if add.MediaType != "" { + desc.MediaType = add.MediaType + } + + manifestLayers = append(manifestLayers, *desc) + digestMap[desc.Digest] = add.Layer + } + + configFile.RootFS.DiffIDs = diffIDs + configFile.History = history + + manifest.Layers = manifestLayers + + rcfg, err := json.Marshal(configFile) + if err != nil { + return err + } + d, sz, err := v1.SHA256(bytes.NewBuffer(rcfg)) + if err != nil { + return err + } + manifest.Config.Digest = d + manifest.Config.Size = sz + + // If Data was set in the base image, we need to update it in the mutated image. + if m.Config.Data != nil { + manifest.Config.Data = rcfg + } + + // If the user wants to mutate the media type of the config + if i.configMediaType != nil { + manifest.Config.MediaType = *i.configMediaType + } + + if i.mediaType != nil { + manifest.MediaType = *i.mediaType + } + + if i.annotations != nil { + if manifest.Annotations == nil { + manifest.Annotations = map[string]string{} + } + + for k, v := range i.annotations { + manifest.Annotations[k] = v + } + } + manifest.Subject = i.subject + + i.configFile = configFile + i.manifest = manifest + i.diffIDMap = diffIDMap + i.digestMap = digestMap + i.computed = true + return nil +} + +// Layers returns the ordered collection of filesystem layers that comprise this image. +// The order of the list is oldest/base layer first, and most-recent/top layer last. +func (i *image) Layers() ([]v1.Layer, error) { + if err := i.compute(); errors.Is(err, stream.ErrNotComputed) { + // Image contains a streamable layer which has not yet been + // consumed. Just return the layers we have in case the caller + // is going to consume the layers. + layers, err := i.base.Layers() + if err != nil { + return nil, err + } + for _, add := range i.adds { + layers = append(layers, add.Layer) + } + return layers, nil + } else if err != nil { + return nil, err + } + + diffIDs, err := partial.DiffIDs(i) + if err != nil { + return nil, err + } + ls := make([]v1.Layer, 0, len(diffIDs)) + for _, h := range diffIDs { + l, err := i.LayerByDiffID(h) + if err != nil { + return nil, err + } + ls = append(ls, l) + } + return ls, nil +} + +// ConfigName returns the hash of the image's config file. +func (i *image) ConfigName() (v1.Hash, error) { + if err := i.compute(); err != nil { + return v1.Hash{}, err + } + return partial.ConfigName(i) +} + +// ConfigFile returns this image's config file. +func (i *image) ConfigFile() (*v1.ConfigFile, error) { + if err := i.compute(); err != nil { + return nil, err + } + return i.configFile.DeepCopy(), nil +} + +// RawConfigFile returns the serialized bytes of ConfigFile() +func (i *image) RawConfigFile() ([]byte, error) { + if err := i.compute(); err != nil { + return nil, err + } + return json.Marshal(i.configFile) +} + +// Digest returns the sha256 of this image's manifest. +func (i *image) Digest() (v1.Hash, error) { + if err := i.compute(); err != nil { + return v1.Hash{}, err + } + return partial.Digest(i) +} + +// Size implements v1.Image. +func (i *image) Size() (int64, error) { + if err := i.compute(); err != nil { + return -1, err + } + return partial.Size(i) +} + +// Manifest returns this image's Manifest object. +func (i *image) Manifest() (*v1.Manifest, error) { + if err := i.compute(); err != nil { + return nil, err + } + return i.manifest.DeepCopy(), nil +} + +// RawManifest returns the serialized bytes of Manifest() +func (i *image) RawManifest() ([]byte, error) { + if err := i.compute(); err != nil { + return nil, err + } + return json.Marshal(i.manifest) +} + +// LayerByDigest returns a Layer for interacting with a particular layer of +// the image, looking it up by "digest" (the compressed hash). +func (i *image) LayerByDigest(h v1.Hash) (v1.Layer, error) { + if cn, err := i.ConfigName(); err != nil { + return nil, err + } else if h == cn { + return partial.ConfigLayer(i) + } + if layer, ok := i.digestMap[h]; ok { + return layer, nil + } + return i.base.LayerByDigest(h) +} + +// LayerByDiffID is an analog to LayerByDigest, looking up by "diff id" +// (the uncompressed hash). +func (i *image) LayerByDiffID(h v1.Hash) (v1.Layer, error) { + if layer, ok := i.diffIDMap[h]; ok { + return layer, nil + } + return i.base.LayerByDiffID(h) +} + +func validate(adds []Addendum) error { + for _, add := range adds { + if add.Layer == nil && !add.History.EmptyLayer { + return errors.New("unable to add a nil layer to the image") + } + } + return nil +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/index.go b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/index.go new file mode 100644 index 000000000..512effef6 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/index.go @@ -0,0 +1,232 @@ +// Copyright 2019 Google LLC 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 mutate + +import ( + "encoding/json" + "errors" + "fmt" + "sync" + + "github.com/google/go-containerregistry/pkg/logs" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/match" + "github.com/google/go-containerregistry/pkg/v1/partial" + "github.com/google/go-containerregistry/pkg/v1/stream" + "github.com/google/go-containerregistry/pkg/v1/types" +) + +func computeDescriptor(ia IndexAddendum) (*v1.Descriptor, error) { + desc, err := partial.Descriptor(ia.Add) + if err != nil { + return nil, err + } + + // The IndexAddendum allows overriding Descriptor values. + if ia.Descriptor.Size != 0 { + desc.Size = ia.Descriptor.Size + } + if string(ia.Descriptor.MediaType) != "" { + desc.MediaType = ia.Descriptor.MediaType + } + if ia.Descriptor.Digest != (v1.Hash{}) { + desc.Digest = ia.Descriptor.Digest + } + if ia.Descriptor.Platform != nil { + desc.Platform = ia.Descriptor.Platform + } + if len(ia.Descriptor.URLs) != 0 { + desc.URLs = ia.Descriptor.URLs + } + if len(ia.Descriptor.Annotations) != 0 { + desc.Annotations = ia.Descriptor.Annotations + } + if ia.Descriptor.Data != nil { + desc.Data = ia.Descriptor.Data + } + + return desc, nil +} + +type index struct { + base v1.ImageIndex + adds []IndexAddendum + // remove is removed before adds + remove match.Matcher + + computed bool + manifest *v1.IndexManifest + annotations map[string]string + mediaType *types.MediaType + imageMap map[v1.Hash]v1.Image + indexMap map[v1.Hash]v1.ImageIndex + layerMap map[v1.Hash]v1.Layer + subject *v1.Descriptor + + sync.Mutex +} + +var _ v1.ImageIndex = (*index)(nil) + +func (i *index) MediaType() (types.MediaType, error) { + if i.mediaType != nil { + return *i.mediaType, nil + } + return i.base.MediaType() +} + +func (i *index) Size() (int64, error) { return partial.Size(i) } + +func (i *index) compute() error { + i.Lock() + defer i.Unlock() + + // Don't re-compute if already computed. + if i.computed { + return nil + } + + i.imageMap = make(map[v1.Hash]v1.Image) + i.indexMap = make(map[v1.Hash]v1.ImageIndex) + i.layerMap = make(map[v1.Hash]v1.Layer) + + m, err := i.base.IndexManifest() + if err != nil { + return err + } + manifest := m.DeepCopy() + manifests := manifest.Manifests + + if i.remove != nil { + var cleanedManifests []v1.Descriptor + for _, m := range manifests { + if !i.remove(m) { + cleanedManifests = append(cleanedManifests, m) + } + } + manifests = cleanedManifests + } + + for _, add := range i.adds { + desc, err := computeDescriptor(add) + if err != nil { + return err + } + + manifests = append(manifests, *desc) + if idx, ok := add.Add.(v1.ImageIndex); ok { + i.indexMap[desc.Digest] = idx + } else if img, ok := add.Add.(v1.Image); ok { + i.imageMap[desc.Digest] = img + } else if l, ok := add.Add.(v1.Layer); ok { + i.layerMap[desc.Digest] = l + } else { + logs.Warn.Printf("Unexpected index addendum: %T", add.Add) + } + } + + manifest.Manifests = manifests + + if i.mediaType != nil { + manifest.MediaType = *i.mediaType + } + + if i.annotations != nil { + if manifest.Annotations == nil { + manifest.Annotations = map[string]string{} + } + for k, v := range i.annotations { + manifest.Annotations[k] = v + } + } + manifest.Subject = i.subject + + i.manifest = manifest + i.computed = true + return nil +} + +func (i *index) Image(h v1.Hash) (v1.Image, error) { + if img, ok := i.imageMap[h]; ok { + return img, nil + } + return i.base.Image(h) +} + +func (i *index) ImageIndex(h v1.Hash) (v1.ImageIndex, error) { + if idx, ok := i.indexMap[h]; ok { + return idx, nil + } + return i.base.ImageIndex(h) +} + +type withLayer interface { + Layer(v1.Hash) (v1.Layer, error) +} + +// Workaround for #819. +func (i *index) Layer(h v1.Hash) (v1.Layer, error) { + if layer, ok := i.layerMap[h]; ok { + return layer, nil + } + if wl, ok := i.base.(withLayer); ok { + return wl.Layer(h) + } + return nil, fmt.Errorf("layer not found: %s", h) +} + +// Digest returns the sha256 of this image's manifest. +func (i *index) Digest() (v1.Hash, error) { + if err := i.compute(); err != nil { + return v1.Hash{}, err + } + return partial.Digest(i) +} + +// Manifest returns this image's Manifest object. +func (i *index) IndexManifest() (*v1.IndexManifest, error) { + if err := i.compute(); err != nil { + return nil, err + } + return i.manifest.DeepCopy(), nil +} + +// RawManifest returns the serialized bytes of Manifest() +func (i *index) RawManifest() ([]byte, error) { + if err := i.compute(); err != nil { + return nil, err + } + return json.Marshal(i.manifest) +} + +func (i *index) Manifests() ([]partial.Describable, error) { + if err := i.compute(); errors.Is(err, stream.ErrNotComputed) { + // Index contains a streamable layer which has not yet been + // consumed. Just return the manifests we have in case the caller + // is going to consume the streamable layers. + manifests, err := partial.Manifests(i.base) + if err != nil { + return nil, err + } + for _, add := range i.adds { + manifests = append(manifests, add.Add) + } + return manifests, nil + } else if err != nil { + return nil, err + } + + return partial.ComputeManifests(i) +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/mutate.go b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/mutate.go new file mode 100644 index 000000000..e4a0e5273 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/mutate.go @@ -0,0 +1,553 @@ +// Copyright 2018 Google LLC 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 mutate + +import ( + "archive/tar" + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "path/filepath" + "strings" + "time" + + "github.com/google/go-containerregistry/internal/gzip" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/empty" + "github.com/google/go-containerregistry/pkg/v1/match" + "github.com/google/go-containerregistry/pkg/v1/partial" + "github.com/google/go-containerregistry/pkg/v1/tarball" + "github.com/google/go-containerregistry/pkg/v1/types" +) + +const whiteoutPrefix = ".wh." + +// Addendum contains layers and history to be appended +// to a base image +type Addendum struct { + Layer v1.Layer + History v1.History + URLs []string + Annotations map[string]string + MediaType types.MediaType +} + +// AppendLayers applies layers to a base image. +func AppendLayers(base v1.Image, layers ...v1.Layer) (v1.Image, error) { + additions := make([]Addendum, 0, len(layers)) + for _, layer := range layers { + additions = append(additions, Addendum{Layer: layer}) + } + + return Append(base, additions...) +} + +// Append will apply the list of addendums to the base image +func Append(base v1.Image, adds ...Addendum) (v1.Image, error) { + if len(adds) == 0 { + return base, nil + } + if err := validate(adds); err != nil { + return nil, err + } + + return &image{ + base: base, + adds: adds, + }, nil +} + +// Appendable is an interface that represents something that can be appended +// to an ImageIndex. We need to be able to construct a v1.Descriptor in order +// to append something, and this is the minimum required information for that. +type Appendable interface { + MediaType() (types.MediaType, error) + Digest() (v1.Hash, error) + Size() (int64, error) +} + +// IndexAddendum represents an appendable thing and all the properties that +// we may want to override in the resulting v1.Descriptor. +type IndexAddendum struct { + Add Appendable + v1.Descriptor +} + +// AppendManifests appends a manifest to the ImageIndex. +func AppendManifests(base v1.ImageIndex, adds ...IndexAddendum) v1.ImageIndex { + return &index{ + base: base, + adds: adds, + } +} + +// RemoveManifests removes any descriptors that match the match.Matcher. +func RemoveManifests(base v1.ImageIndex, matcher match.Matcher) v1.ImageIndex { + return &index{ + base: base, + remove: matcher, + } +} + +// Config mutates the provided v1.Image to have the provided v1.Config +func Config(base v1.Image, cfg v1.Config) (v1.Image, error) { + cf, err := base.ConfigFile() + if err != nil { + return nil, err + } + + cf.Config = cfg + + return ConfigFile(base, cf) +} + +// Subject mutates the subject on an image or index manifest. +// +// The input is expected to be a v1.Image or v1.ImageIndex, and +// returns the same type. You can type-assert the result like so: +// +// img := Subject(empty.Image, subj).(v1.Image) +// +// Or for an index: +// +// idx := Subject(empty.Index, subj).(v1.ImageIndex) +// +// If the input is not an Image or ImageIndex, the result will +// attempt to lazily annotate the raw manifest. +func Subject(f partial.WithRawManifest, subject v1.Descriptor) partial.WithRawManifest { + if img, ok := f.(v1.Image); ok { + return &image{ + base: img, + subject: &subject, + } + } + if idx, ok := f.(v1.ImageIndex); ok { + return &index{ + base: idx, + subject: &subject, + } + } + return arbitraryRawManifest{a: f, subject: &subject} +} + +// Annotations mutates the annotations on an annotatable image or index manifest. +// +// The annotatable input is expected to be a v1.Image or v1.ImageIndex, and +// returns the same type. You can type-assert the result like so: +// +// img := Annotations(empty.Image, map[string]string{ +// "foo": "bar", +// }).(v1.Image) +// +// Or for an index: +// +// idx := Annotations(empty.Index, map[string]string{ +// "foo": "bar", +// }).(v1.ImageIndex) +// +// If the input Annotatable is not an Image or ImageIndex, the result will +// attempt to lazily annotate the raw manifest. +func Annotations(f partial.WithRawManifest, anns map[string]string) partial.WithRawManifest { + if img, ok := f.(v1.Image); ok { + return &image{ + base: img, + annotations: anns, + } + } + if idx, ok := f.(v1.ImageIndex); ok { + return &index{ + base: idx, + annotations: anns, + } + } + return arbitraryRawManifest{a: f, anns: anns} +} + +type arbitraryRawManifest struct { + a partial.WithRawManifest + anns map[string]string + subject *v1.Descriptor +} + +func (a arbitraryRawManifest) RawManifest() ([]byte, error) { + b, err := a.a.RawManifest() + if err != nil { + return nil, err + } + var m map[string]any + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + if ann, ok := m["annotations"]; ok { + if annm, ok := ann.(map[string]string); ok { + for k, v := range a.anns { + annm[k] = v + } + } else { + return nil, fmt.Errorf(".annotations is not a map: %T", ann) + } + } else { + m["annotations"] = a.anns + } + if a.subject != nil { + m["subject"] = a.subject + } + return json.Marshal(m) +} + +// ConfigFile mutates the provided v1.Image to have the provided v1.ConfigFile +func ConfigFile(base v1.Image, cfg *v1.ConfigFile) (v1.Image, error) { + m, err := base.Manifest() + if err != nil { + return nil, err + } + + image := &image{ + base: base, + manifest: m.DeepCopy(), + configFile: cfg, + } + + return image, nil +} + +// CreatedAt mutates the provided v1.Image to have the provided v1.Time +func CreatedAt(base v1.Image, created v1.Time) (v1.Image, error) { + cf, err := base.ConfigFile() + if err != nil { + return nil, err + } + + cfg := cf.DeepCopy() + cfg.Created = created + + return ConfigFile(base, cfg) +} + +// Extract takes an image and returns an io.ReadCloser containing the image's +// flattened filesystem. +// +// Callers can read the filesystem contents by passing the reader to +// tar.NewReader, or io.Copy it directly to some output. +// +// If a caller doesn't read the full contents, they should Close it to free up +// resources used during extraction. +func Extract(img v1.Image) io.ReadCloser { + pr, pw := io.Pipe() + + go func() { + // Close the writer with any errors encountered during + // extraction. These errors will be returned by the reader end + // on subsequent reads. If err == nil, the reader will return + // EOF. + pw.CloseWithError(extract(img, pw)) + }() + + return pr +} + +// Adapted from https://github.com/google/containerregistry/blob/da03b395ccdc4e149e34fbb540483efce962dc64/client/v2_2/docker_image_.py#L816 +func extract(img v1.Image, w io.Writer) error { + tarWriter := tar.NewWriter(w) + defer tarWriter.Close() + + fileMap := map[string]bool{} + + layers, err := img.Layers() + if err != nil { + return fmt.Errorf("retrieving image layers: %w", err) + } + + // we iterate through the layers in reverse order because it makes handling + // whiteout layers more efficient, since we can just keep track of the removed + // files as we see .wh. layers and ignore those in previous layers. + for i := len(layers) - 1; i >= 0; i-- { + layer := layers[i] + layerReader, err := layer.Uncompressed() + if err != nil { + return fmt.Errorf("reading layer contents: %w", err) + } + defer layerReader.Close() + tarReader := tar.NewReader(layerReader) + for { + header, err := tarReader.Next() + if errors.Is(err, io.EOF) { + break + } + if err != nil { + return fmt.Errorf("reading tar: %w", err) + } + + // Some tools prepend everything with "./", so if we don't Clean the + // name, we may have duplicate entries, which angers tar-split. + header.Name = filepath.Clean(header.Name) + // force PAX format to remove Name/Linkname length limit of 100 characters + // required by USTAR and to not depend on internal tar package guess which + // prefers USTAR over PAX + header.Format = tar.FormatPAX + + basename := filepath.Base(header.Name) + dirname := filepath.Dir(header.Name) + tombstone := strings.HasPrefix(basename, whiteoutPrefix) + if tombstone { + basename = basename[len(whiteoutPrefix):] + } + + // check if we have seen value before + // if we're checking a directory, don't filepath.Join names + var name string + if header.Typeflag == tar.TypeDir { + name = header.Name + } else { + name = filepath.Join(dirname, basename) + } + + if _, ok := fileMap[name]; ok { + continue + } + + // check for a whited out parent directory + if inWhiteoutDir(fileMap, name) { + continue + } + + // mark file as handled. non-directory implicitly tombstones + // any entries with a matching (or child) name + fileMap[name] = tombstone || !(header.Typeflag == tar.TypeDir) + if !tombstone { + if err := tarWriter.WriteHeader(header); err != nil { + return err + } + if header.Size > 0 { + if _, err := io.CopyN(tarWriter, tarReader, header.Size); err != nil { + return err + } + } + } + } + } + return nil +} + +func inWhiteoutDir(fileMap map[string]bool, file string) bool { + for { + if file == "" { + break + } + dirname := filepath.Dir(file) + if file == dirname { + break + } + if val, ok := fileMap[dirname]; ok && val { + return true + } + file = dirname + } + return false +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +// Time sets all timestamps in an image to the given timestamp. +func Time(img v1.Image, t time.Time) (v1.Image, error) { + newImage := empty.Image + + layers, err := img.Layers() + if err != nil { + return nil, fmt.Errorf("getting image layers: %w", err) + } + + ocf, err := img.ConfigFile() + if err != nil { + return nil, fmt.Errorf("getting original config file: %w", err) + } + + addendums := make([]Addendum, max(len(ocf.History), len(layers))) + var historyIdx, addendumIdx int + for layerIdx := 0; layerIdx < len(layers); addendumIdx, layerIdx = addendumIdx+1, layerIdx+1 { + newLayer, err := layerTime(layers[layerIdx], t) + if err != nil { + return nil, fmt.Errorf("setting layer times: %w", err) + } + + // try to search for the history entry that corresponds to this layer + for ; historyIdx < len(ocf.History); historyIdx++ { + addendums[addendumIdx].History = ocf.History[historyIdx] + // if it's an EmptyLayer, do not set the Layer and have the Addendum with just the History + // and move on to the next History entry + if ocf.History[historyIdx].EmptyLayer { + addendumIdx++ + continue + } + // otherwise, we can exit from the cycle + historyIdx++ + break + } + addendums[addendumIdx].Layer = newLayer + } + + // add all leftover History entries + for ; historyIdx < len(ocf.History); historyIdx, addendumIdx = historyIdx+1, addendumIdx+1 { + addendums[addendumIdx].History = ocf.History[historyIdx] + } + + newImage, err = Append(newImage, addendums...) + if err != nil { + return nil, fmt.Errorf("appending layers: %w", err) + } + + cf, err := newImage.ConfigFile() + if err != nil { + return nil, fmt.Errorf("setting config file: %w", err) + } + + cfg := cf.DeepCopy() + + // Copy basic config over + cfg.Architecture = ocf.Architecture + cfg.OS = ocf.OS + cfg.OSVersion = ocf.OSVersion + cfg.Config = ocf.Config + + // Strip away timestamps from the config file + cfg.Created = v1.Time{Time: t} + + for i, h := range cfg.History { + h.Created = v1.Time{Time: t} + h.CreatedBy = ocf.History[i].CreatedBy + h.Comment = ocf.History[i].Comment + h.EmptyLayer = ocf.History[i].EmptyLayer + // Explicitly ignore Author field; which hinders reproducibility + h.Author = "" + cfg.History[i] = h + } + + return ConfigFile(newImage, cfg) +} + +func layerTime(layer v1.Layer, t time.Time) (v1.Layer, error) { + layerReader, err := layer.Uncompressed() + if err != nil { + return nil, fmt.Errorf("getting layer: %w", err) + } + defer layerReader.Close() + w := new(bytes.Buffer) + tarWriter := tar.NewWriter(w) + defer tarWriter.Close() + + tarReader := tar.NewReader(layerReader) + for { + header, err := tarReader.Next() + if errors.Is(err, io.EOF) { + break + } + if err != nil { + return nil, fmt.Errorf("reading layer: %w", err) + } + + header.ModTime = t + + //PAX and GNU Format support additional timestamps in the header + if header.Format == tar.FormatPAX || header.Format == tar.FormatGNU { + header.AccessTime = t + header.ChangeTime = t + } + + if err := tarWriter.WriteHeader(header); err != nil { + return nil, fmt.Errorf("writing tar header: %w", err) + } + + if header.Typeflag == tar.TypeReg { + // TODO(#1168): This should be lazy, and not buffer the entire layer contents. + if _, err = io.CopyN(tarWriter, tarReader, header.Size); err != nil { + return nil, fmt.Errorf("writing layer file: %w", err) + } + } + } + + if err := tarWriter.Close(); err != nil { + return nil, err + } + + b := w.Bytes() + // gzip the contents, then create the layer + opener := func() (io.ReadCloser, error) { + return gzip.ReadCloser(io.NopCloser(bytes.NewReader(b))), nil + } + layer, err = tarball.LayerFromOpener(opener) + if err != nil { + return nil, fmt.Errorf("creating layer: %w", err) + } + + return layer, nil +} + +// Canonical is a helper function to combine Time and configFile +// to remove any randomness during a docker build. +func Canonical(img v1.Image) (v1.Image, error) { + // Set all timestamps to 0 + created := time.Time{} + img, err := Time(img, created) + if err != nil { + return nil, err + } + + cf, err := img.ConfigFile() + if err != nil { + return nil, err + } + + // Get rid of host-dependent random config + cfg := cf.DeepCopy() + + cfg.Container = "" + cfg.Config.Hostname = "" + cfg.DockerVersion = "" + + return ConfigFile(img, cfg) +} + +// MediaType modifies the MediaType() of the given image. +func MediaType(img v1.Image, mt types.MediaType) v1.Image { + return &image{ + base: img, + mediaType: &mt, + } +} + +// ConfigMediaType modifies the MediaType() of the given image's Config. +// +// If !mt.IsConfig(), this will be the image's artifactType in any indexes it's a part of. +func ConfigMediaType(img v1.Image, mt types.MediaType) v1.Image { + return &image{ + base: img, + configMediaType: &mt, + } +} + +// IndexMediaType modifies the MediaType() of the given index. +func IndexMediaType(idx v1.ImageIndex, mt types.MediaType) v1.ImageIndex { + return &index{ + base: idx, + mediaType: &mt, + } +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go new file mode 100644 index 000000000..c606e0b76 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go @@ -0,0 +1,144 @@ +// Copyright 2018 Google LLC 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 mutate + +import ( + "fmt" + + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/empty" +) + +// Rebase returns a new v1.Image where the oldBase in orig is replaced by newBase. +func Rebase(orig, oldBase, newBase v1.Image) (v1.Image, error) { + // Verify that oldBase's layers are present in orig, otherwise orig is + // not based on oldBase at all. + origLayers, err := orig.Layers() + if err != nil { + return nil, fmt.Errorf("failed to get layers for original: %w", err) + } + oldBaseLayers, err := oldBase.Layers() + if err != nil { + return nil, err + } + if len(oldBaseLayers) > len(origLayers) { + return nil, fmt.Errorf("image %q is not based on %q (too few layers)", orig, oldBase) + } + for i, l := range oldBaseLayers { + oldLayerDigest, err := l.Digest() + if err != nil { + return nil, fmt.Errorf("failed to get digest of layer %d of %q: %w", i, oldBase, err) + } + origLayerDigest, err := origLayers[i].Digest() + if err != nil { + return nil, fmt.Errorf("failed to get digest of layer %d of %q: %w", i, orig, err) + } + if oldLayerDigest != origLayerDigest { + return nil, fmt.Errorf("image %q is not based on %q (layer %d mismatch)", orig, oldBase, i) + } + } + + oldConfig, err := oldBase.ConfigFile() + if err != nil { + return nil, fmt.Errorf("failed to get config for old base: %w", err) + } + + origConfig, err := orig.ConfigFile() + if err != nil { + return nil, fmt.Errorf("failed to get config for original: %w", err) + } + + newConfig, err := newBase.ConfigFile() + if err != nil { + return nil, fmt.Errorf("could not get config for new base: %w", err) + } + + // Stitch together an image that contains: + // - original image's config + // - new base image's os/arch properties + // - new base image's layers + top of original image's layers + // - new base image's history + top of original image's history + rebasedImage, err := Config(empty.Image, *origConfig.Config.DeepCopy()) + if err != nil { + return nil, fmt.Errorf("failed to create empty image with original config: %w", err) + } + + // Add new config properties from existing images. + rebasedConfig, err := rebasedImage.ConfigFile() + if err != nil { + return nil, fmt.Errorf("could not get config for rebased image: %w", err) + } + // OS/Arch properties from new base + rebasedConfig.Architecture = newConfig.Architecture + rebasedConfig.OS = newConfig.OS + rebasedConfig.OSVersion = newConfig.OSVersion + + // Apply config properties to rebased. + rebasedImage, err = ConfigFile(rebasedImage, rebasedConfig) + if err != nil { + return nil, fmt.Errorf("failed to replace config for rebased image: %w", err) + } + + // Get new base layers and config for history. + newBaseLayers, err := newBase.Layers() + if err != nil { + return nil, fmt.Errorf("could not get new base layers for new base: %w", err) + } + // Add new base layers. + rebasedImage, err = Append(rebasedImage, createAddendums(0, 0, newConfig.History, newBaseLayers)...) + if err != nil { + return nil, fmt.Errorf("failed to append new base image: %w", err) + } + + // Add original layers above the old base. + rebasedImage, err = Append(rebasedImage, createAddendums(len(oldConfig.History), len(oldBaseLayers)+1, origConfig.History, origLayers)...) + if err != nil { + return nil, fmt.Errorf("failed to append original image: %w", err) + } + + return rebasedImage, nil +} + +// createAddendums makes a list of addendums from a history and layers starting from a specific history and layer +// indexes. +func createAddendums(startHistory, startLayer int, history []v1.History, layers []v1.Layer) []Addendum { + var adds []Addendum + // History should be a superset of layers; empty layers (e.g. ENV statements) only exist in history. + // They cannot be iterated identically but must be walked independently, only advancing the iterator for layers + // when a history entry for a non-empty layer is seen. + layerIndex := 0 + for historyIndex := range history { + var layer v1.Layer + emptyLayer := history[historyIndex].EmptyLayer + if !emptyLayer { + layer = layers[layerIndex] + layerIndex++ + } + if historyIndex >= startHistory || layerIndex >= startLayer { + adds = append(adds, Addendum{ + Layer: layer, + History: history[historyIndex], + }) + } + } + // In the event history was malformed or non-existent, append the remaining layers. + for i := layerIndex; i < len(layers); i++ { + if i >= startLayer { + adds = append(adds, Addendum{Layer: layers[layerIndex]}) + } + } + + return adds +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/partial/index.go b/vendor/github.com/google/go-containerregistry/pkg/v1/partial/index.go index f17f27446..10cfb2b2f 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/partial/index.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/partial/index.go @@ -19,6 +19,7 @@ import ( v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/match" + "github.com/google/go-containerregistry/pkg/v1/types" ) // FindManifests given a v1.ImageIndex, find the manifests that fit the matcher. @@ -83,3 +84,82 @@ func FindIndexes(index v1.ImageIndex, matcher match.Matcher) ([]v1.ImageIndex, e } return matches, nil } + +type withManifests interface { + Manifests() ([]Describable, error) +} + +type withLayer interface { + Layer(v1.Hash) (v1.Layer, error) +} + +type describable struct { + desc v1.Descriptor +} + +func (d describable) Digest() (v1.Hash, error) { + return d.desc.Digest, nil +} + +func (d describable) Size() (int64, error) { + return d.desc.Size, nil +} + +func (d describable) MediaType() (types.MediaType, error) { + return d.desc.MediaType, nil +} + +func (d describable) Descriptor() (*v1.Descriptor, error) { + return &d.desc, nil +} + +// Manifests is analogous to v1.Image.Layers in that it allows values in the +// returned list to be lazily evaluated, which enables an index to contain +// an image that contains a streaming layer. +// +// This should have been part of the v1.ImageIndex interface, but wasn't. +// It is instead usable through this extension interface. +func Manifests(idx v1.ImageIndex) ([]Describable, error) { + if wm, ok := idx.(withManifests); ok { + return wm.Manifests() + } + + return ComputeManifests(idx) +} + +// ComputeManifests provides a fallback implementation for Manifests. +func ComputeManifests(idx v1.ImageIndex) ([]Describable, error) { + m, err := idx.IndexManifest() + if err != nil { + return nil, err + } + manifests := []Describable{} + for _, desc := range m.Manifests { + switch { + case desc.MediaType.IsImage(): + img, err := idx.Image(desc.Digest) + if err != nil { + return nil, err + } + manifests = append(manifests, img) + case desc.MediaType.IsIndex(): + idx, err := idx.ImageIndex(desc.Digest) + if err != nil { + return nil, err + } + manifests = append(manifests, idx) + default: + if wl, ok := idx.(withLayer); ok { + layer, err := wl.Layer(desc.Digest) + if err != nil { + return nil, err + } + manifests = append(manifests, layer) + } else { + manifests = append(manifests, describable{desc}) + } + } + } + + return manifests, nil +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/catalog.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/catalog.go index eb4306f28..a0281b9fd 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/catalog.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/catalog.go @@ -25,38 +25,35 @@ import ( "github.com/google/go-containerregistry/pkg/v1/remote/transport" ) -type catalog struct { +type Catalogs struct { Repos []string `json:"repositories"` + Next string `json:"next,omitempty"` } // CatalogPage calls /_catalog, returning the list of repositories on the registry. func CatalogPage(target name.Registry, last string, n int, options ...Option) ([]string, error) { - o, err := makeOptions(target, options...) + o, err := makeOptions(options...) if err != nil { return nil, err } - scopes := []string{target.Scope(transport.PullScope)} - tr, err := transport.NewWithContext(o.context, target, o.auth, o.transport, scopes) + f, err := newPuller(o).fetcher(o.context, target) if err != nil { return nil, err } - query := fmt.Sprintf("last=%s&n=%d", url.QueryEscape(last), n) - uri := url.URL{ Scheme: target.Scheme(), Host: target.RegistryStr(), Path: "/v2/_catalog", - RawQuery: query, + RawQuery: fmt.Sprintf("last=%s&n=%d", url.QueryEscape(last), n), } - client := http.Client{Transport: tr} req, err := http.NewRequest(http.MethodGet, uri.String(), nil) if err != nil { return nil, err } - resp, err := client.Do(req.WithContext(o.context)) + resp, err := f.client.Do(req.WithContext(o.context)) if err != nil { return nil, err } @@ -66,7 +63,7 @@ func CatalogPage(target name.Registry, last string, n int, options ...Option) ([ return nil, err } - var parsed catalog + var parsed Catalogs if err := json.NewDecoder(resp.Body).Decode(&parsed); err != nil { return nil, err } @@ -76,79 +73,87 @@ func CatalogPage(target name.Registry, last string, n int, options ...Option) ([ // Catalog calls /_catalog, returning the list of repositories on the registry. func Catalog(ctx context.Context, target name.Registry, options ...Option) ([]string, error) { - o, err := makeOptions(target, options...) + o, err := makeOptions(options...) if err != nil { return nil, err } - scopes := []string{target.Scope(transport.PullScope)} - tr, err := transport.NewWithContext(o.context, target, o.auth, o.transport, scopes) + // WithContext overrides the ctx passed directly. + if o.context != context.Background() { + ctx = o.context + } + + return newPuller(o).catalog(ctx, target, o.pageSize) +} + +func (f *fetcher) catalogPage(ctx context.Context, reg name.Registry, next string, pageSize int) (*Catalogs, error) { + if next == "" { + uri := &url.URL{ + Scheme: reg.Scheme(), + Host: reg.RegistryStr(), + Path: "/v2/_catalog", + } + if pageSize > 0 { + uri.RawQuery = fmt.Sprintf("n=%d", pageSize) + } + next = uri.String() + } + + req, err := http.NewRequestWithContext(ctx, "GET", next, nil) if err != nil { return nil, err } - uri := &url.URL{ - Scheme: target.Scheme(), - Host: target.RegistryStr(), - Path: "/v2/_catalog", + resp, err := f.client.Do(req) + if err != nil { + return nil, err } - if o.pageSize > 0 { - uri.RawQuery = fmt.Sprintf("n=%d", o.pageSize) + if err := transport.CheckError(resp, http.StatusOK); err != nil { + return nil, err } - client := http.Client{Transport: tr} - - // WithContext overrides the ctx passed directly. - if o.context != context.Background() { - ctx = o.context + parsed := Catalogs{} + if err := json.NewDecoder(resp.Body).Decode(&parsed); err != nil { + return nil, err } - var ( - parsed catalog - repoList []string - ) + if err := resp.Body.Close(); err != nil { + return nil, err + } - // get responses until there is no next page - for { - select { - case <-ctx.Done(): - return nil, ctx.Err() - default: - } + uri, err := getNextPageURL(resp) + if err != nil { + return nil, err + } - req, err := http.NewRequest("GET", uri.String(), nil) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) + if uri != nil { + parsed.Next = uri.String() + } - resp, err := client.Do(req) - if err != nil { - return nil, err - } + return &parsed, nil +} - if err := transport.CheckError(resp, http.StatusOK); err != nil { - return nil, err - } +type Catalogger struct { + f *fetcher + reg name.Registry + pageSize int - if err := json.NewDecoder(resp.Body).Decode(&parsed); err != nil { - return nil, err - } - if err := resp.Body.Close(); err != nil { - return nil, err - } + page *Catalogs + err error - repoList = append(repoList, parsed.Repos...) + needMore bool +} - uri, err = getNextPageURL(resp) - if err != nil { - return nil, err - } - // no next page - if uri == nil { - break - } +func (l *Catalogger) Next(ctx context.Context) (*Catalogs, error) { + if l.needMore { + l.page, l.err = l.f.catalogPage(ctx, l.reg, l.page.Next, l.pageSize) + } else { + l.needMore = true } - return repoList, nil + return l.page, l.err +} + +func (l *Catalogger) HasNext() bool { + return l.page != nil && (!l.needMore || l.page.Next != "") } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/delete.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/delete.go index 74a06fd22..36e1d0816 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/delete.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/delete.go @@ -15,47 +15,14 @@ package remote import ( - "fmt" - "net/http" - "net/url" - "github.com/google/go-containerregistry/pkg/name" - "github.com/google/go-containerregistry/pkg/v1/remote/transport" ) // Delete removes the specified image reference from the remote registry. func Delete(ref name.Reference, options ...Option) error { - o, err := makeOptions(ref.Context(), options...) - if err != nil { - return err - } - scopes := []string{ref.Scope(transport.DeleteScope)} - tr, err := transport.NewWithContext(o.context, ref.Context().Registry, o.auth, o.transport, scopes) - if err != nil { - return err - } - c := &http.Client{Transport: tr} - - u := url.URL{ - Scheme: ref.Context().Registry.Scheme(), - Host: ref.Context().RegistryStr(), - Path: fmt.Sprintf("/v2/%s/manifests/%s", ref.Context().RepositoryStr(), ref.Identifier()), - } - - req, err := http.NewRequest(http.MethodDelete, u.String(), nil) - if err != nil { - return err - } - - resp, err := c.Do(req.WithContext(o.context)) + o, err := makeOptions(options...) if err != nil { return err } - defer resp.Body.Close() - - return transport.CheckError(resp, http.StatusOK, http.StatusAccepted) - - // TODO(jason): If the manifest had a `subject`, and if the registry - // doesn't support Referrers, update the index pointed to by the - // subject's fallback tag to remove the descriptor for this manifest. + return newPusher(o).Delete(o.context, ref) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/descriptor.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/descriptor.go index 78919d7a8..61f28f4c0 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/descriptor.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/descriptor.go @@ -15,26 +15,21 @@ package remote import ( - "bytes" "context" - "encoding/json" - "errors" "fmt" - "io" - "net/http" - "net/url" - "strings" - "github.com/google/go-containerregistry/internal/redact" - "github.com/google/go-containerregistry/internal/verify" "github.com/google/go-containerregistry/pkg/logs" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/partial" - "github.com/google/go-containerregistry/pkg/v1/remote/transport" "github.com/google/go-containerregistry/pkg/v1/types" ) +var allManifestMediaTypes = append(append([]types.MediaType{ + types.DockerManifestSchema1, + types.DockerManifestSchema1Signed, +}, acceptableImageMediaTypes...), acceptableIndexMediaTypes...) + // ErrSchema1 indicates that we received a schema1 manifest from the registry. // This library doesn't have plans to support this legacy image format: // https://github.com/google/go-containerregistry/issues/377 @@ -57,14 +52,21 @@ func (e *ErrSchema1) Error() string { // Descriptor provides access to metadata about remote artifact and accessors // for efficiently converting it into a v1.Image or v1.ImageIndex. type Descriptor struct { - fetcher + fetcher fetcher v1.Descriptor + + ref name.Reference Manifest []byte + ctx context.Context // So we can share this implementation with Image. platform v1.Platform } +func (d *Descriptor) toDesc() v1.Descriptor { + return d.Descriptor +} + // RawManifest exists to satisfy the Taggable interface. func (d *Descriptor) RawManifest() ([]byte, error) { return d.Manifest, nil @@ -76,14 +78,7 @@ func (d *Descriptor) RawManifest() ([]byte, error) { // // See Head if you don't need the response body. func Get(ref name.Reference, options ...Option) (*Descriptor, error) { - acceptable := []types.MediaType{ - // Just to look at them. - types.DockerManifestSchema1, - types.DockerManifestSchema1Signed, - } - acceptable = append(acceptable, acceptableImageMediaTypes...) - acceptable = append(acceptable, acceptableIndexMediaTypes...) - return get(ref, acceptable, options...) + return get(ref, allManifestMediaTypes, options...) } // Head returns a v1.Descriptor for the given reference by issuing a HEAD @@ -92,48 +87,22 @@ func Get(ref name.Reference, options ...Option) (*Descriptor, error) { // Note that the server response will not have a body, so any errors encountered // should be retried with Get to get more details. func Head(ref name.Reference, options ...Option) (*v1.Descriptor, error) { - acceptable := []types.MediaType{ - // Just to look at them. - types.DockerManifestSchema1, - types.DockerManifestSchema1Signed, - } - acceptable = append(acceptable, acceptableImageMediaTypes...) - acceptable = append(acceptable, acceptableIndexMediaTypes...) - - o, err := makeOptions(ref.Context(), options...) - if err != nil { - return nil, err - } - - f, err := makeFetcher(ref, o) + o, err := makeOptions(options...) if err != nil { return nil, err } - return f.headManifest(ref, acceptable) + return newPuller(o).Head(o.context, ref) } // Handle options and fetch the manifest with the acceptable MediaTypes in the // Accept header. func get(ref name.Reference, acceptable []types.MediaType, options ...Option) (*Descriptor, error) { - o, err := makeOptions(ref.Context(), options...) - if err != nil { - return nil, err - } - f, err := makeFetcher(ref, o) - if err != nil { - return nil, err - } - b, desc, err := f.fetchManifest(ref, acceptable) + o, err := makeOptions(options...) if err != nil { return nil, err } - return &Descriptor{ - fetcher: *f, - Manifest: b, - Descriptor: *desc, - platform: o.platform, - }, nil + return newPuller(o).get(o.context, ref, acceptable, o.platform) } // Image converts the Descriptor into a v1.Image. @@ -169,7 +138,28 @@ func (d *Descriptor) Image() (v1.Image, error) { } return &mountableImage{ Image: imgCore, - Reference: d.Ref, + Reference: d.ref, + }, nil +} + +// Schema1 converts the Descriptor into a v1.Image for v2 schema 1 media types. +// +// The v1.Image returned by this method does not implement the entire interface because it would be inefficient. +// This exists mostly to make it easier to copy schema 1 images around or look at their filesystems. +// This is separate from Image() to avoid a backward incompatible change for callers expecting ErrSchema1. +func (d *Descriptor) Schema1() (v1.Image, error) { + i := &schema1{ + ref: d.ref, + fetcher: d.fetcher, + ctx: d.ctx, + manifest: d.Manifest, + mediaType: d.MediaType, + descriptor: &d.Descriptor, + } + + return &mountableImage{ + Image: i, + Reference: d.ref, }, nil } @@ -195,6 +185,8 @@ func (d *Descriptor) ImageIndex() (v1.ImageIndex, error) { func (d *Descriptor) remoteImage() *remoteImage { return &remoteImage{ + ref: d.ref, + ctx: d.ctx, fetcher: d.fetcher, manifest: d.Manifest, mediaType: d.MediaType, @@ -204,308 +196,11 @@ func (d *Descriptor) remoteImage() *remoteImage { func (d *Descriptor) remoteIndex() *remoteIndex { return &remoteIndex{ + ref: d.ref, + ctx: d.ctx, fetcher: d.fetcher, manifest: d.Manifest, mediaType: d.MediaType, descriptor: &d.Descriptor, } } - -// fetcher implements methods for reading from a registry. -type fetcher struct { - Ref name.Reference - Client *http.Client - context context.Context -} - -func makeFetcher(ref name.Reference, o *options) (*fetcher, error) { - tr, err := transport.NewWithContext(o.context, ref.Context().Registry, o.auth, o.transport, []string{ref.Scope(transport.PullScope)}) - if err != nil { - return nil, err - } - return &fetcher{ - Ref: ref, - Client: &http.Client{Transport: tr}, - context: o.context, - }, nil -} - -// url returns a url.Url for the specified path in the context of this remote image reference. -func (f *fetcher) url(resource, identifier string) url.URL { - return url.URL{ - Scheme: f.Ref.Context().Registry.Scheme(), - Host: f.Ref.Context().RegistryStr(), - Path: fmt.Sprintf("/v2/%s/%s/%s", f.Ref.Context().RepositoryStr(), resource, identifier), - } -} - -// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#referrers-tag-schema -func fallbackTag(d name.Digest) name.Tag { - return d.Context().Tag(strings.Replace(d.DigestStr(), ":", "-", 1)) -} - -func (f *fetcher) fetchReferrers(ctx context.Context, filter map[string]string, d name.Digest) (*v1.IndexManifest, error) { - // Check the Referrers API endpoint first. - u := f.url("referrers", d.DigestStr()) - req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil) - if err != nil { - return nil, err - } - req.Header.Set("Accept", string(types.OCIImageIndex)) - - resp, err := f.Client.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - if err := transport.CheckError(resp, http.StatusOK, http.StatusNotFound, http.StatusBadRequest); err != nil { - return nil, err - } - if resp.StatusCode == http.StatusOK { - var im v1.IndexManifest - if err := json.NewDecoder(resp.Body).Decode(&im); err != nil { - return nil, err - } - return filterReferrersResponse(filter, &im), nil - } - - // The registry doesn't support the Referrers API endpoint, so we'll use the fallback tag scheme. - b, _, err := f.fetchManifest(fallbackTag(d), []types.MediaType{types.OCIImageIndex}) - if err != nil { - return nil, err - } - var terr *transport.Error - if ok := errors.As(err, &terr); ok && terr.StatusCode == http.StatusNotFound { - // Not found just means there are no attachments yet. Start with an empty manifest. - return &v1.IndexManifest{MediaType: types.OCIImageIndex}, nil - } - - var im v1.IndexManifest - if err := json.Unmarshal(b, &im); err != nil { - return nil, err - } - - return filterReferrersResponse(filter, &im), nil -} - -func (f *fetcher) fetchManifest(ref name.Reference, acceptable []types.MediaType) ([]byte, *v1.Descriptor, error) { - u := f.url("manifests", ref.Identifier()) - req, err := http.NewRequest(http.MethodGet, u.String(), nil) - if err != nil { - return nil, nil, err - } - accept := []string{} - for _, mt := range acceptable { - accept = append(accept, string(mt)) - } - req.Header.Set("Accept", strings.Join(accept, ",")) - - resp, err := f.Client.Do(req.WithContext(f.context)) - if err != nil { - return nil, nil, err - } - defer resp.Body.Close() - - if err := transport.CheckError(resp, http.StatusOK); err != nil { - return nil, nil, err - } - - manifest, err := io.ReadAll(resp.Body) - if err != nil { - return nil, nil, err - } - - digest, size, err := v1.SHA256(bytes.NewReader(manifest)) - if err != nil { - return nil, nil, err - } - - mediaType := types.MediaType(resp.Header.Get("Content-Type")) - contentDigest, err := v1.NewHash(resp.Header.Get("Docker-Content-Digest")) - if err == nil && mediaType == types.DockerManifestSchema1Signed { - // If we can parse the digest from the header, and it's a signed schema 1 - // manifest, let's use that for the digest to appease older registries. - digest = contentDigest - } - - // Validate the digest matches what we asked for, if pulling by digest. - if dgst, ok := ref.(name.Digest); ok { - if digest.String() != dgst.DigestStr() { - return nil, nil, fmt.Errorf("manifest digest: %q does not match requested digest: %q for %q", digest, dgst.DigestStr(), f.Ref) - } - } - - var artifactType string - mf, _ := v1.ParseManifest(bytes.NewReader(manifest)) - // Failing to parse as a manifest should just be ignored. - // The manifest might not be valid, and that's okay. - if mf != nil && !mf.Config.MediaType.IsConfig() { - artifactType = string(mf.Config.MediaType) - } - - // Do nothing for tags; I give up. - // - // We'd like to validate that the "Docker-Content-Digest" header matches what is returned by the registry, - // but so many registries implement this incorrectly that it's not worth checking. - // - // For reference: - // https://github.com/GoogleContainerTools/kaniko/issues/298 - - // Return all this info since we have to calculate it anyway. - desc := v1.Descriptor{ - Digest: digest, - Size: size, - MediaType: mediaType, - ArtifactType: artifactType, - } - - return manifest, &desc, nil -} - -func (f *fetcher) headManifest(ref name.Reference, acceptable []types.MediaType) (*v1.Descriptor, error) { - u := f.url("manifests", ref.Identifier()) - req, err := http.NewRequest(http.MethodHead, u.String(), nil) - if err != nil { - return nil, err - } - accept := []string{} - for _, mt := range acceptable { - accept = append(accept, string(mt)) - } - req.Header.Set("Accept", strings.Join(accept, ",")) - - resp, err := f.Client.Do(req.WithContext(f.context)) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - if err := transport.CheckError(resp, http.StatusOK); err != nil { - return nil, err - } - - mth := resp.Header.Get("Content-Type") - if mth == "" { - return nil, fmt.Errorf("HEAD %s: response did not include Content-Type header", u.String()) - } - mediaType := types.MediaType(mth) - - size := resp.ContentLength - if size == -1 { - return nil, fmt.Errorf("GET %s: response did not include Content-Length header", u.String()) - } - - dh := resp.Header.Get("Docker-Content-Digest") - if dh == "" { - return nil, fmt.Errorf("HEAD %s: response did not include Docker-Content-Digest header", u.String()) - } - digest, err := v1.NewHash(dh) - if err != nil { - return nil, err - } - - // Validate the digest matches what we asked for, if pulling by digest. - if dgst, ok := ref.(name.Digest); ok { - if digest.String() != dgst.DigestStr() { - return nil, fmt.Errorf("manifest digest: %q does not match requested digest: %q for %q", digest, dgst.DigestStr(), f.Ref) - } - } - - // Return all this info since we have to calculate it anyway. - return &v1.Descriptor{ - Digest: digest, - Size: size, - MediaType: mediaType, - }, nil -} - -func (f *fetcher) fetchBlob(ctx context.Context, size int64, h v1.Hash) (io.ReadCloser, error) { - u := f.url("blobs", h.String()) - req, err := http.NewRequest(http.MethodGet, u.String(), nil) - if err != nil { - return nil, err - } - - resp, err := f.Client.Do(req.WithContext(ctx)) - if err != nil { - return nil, redact.Error(err) - } - - if err := transport.CheckError(resp, http.StatusOK); err != nil { - resp.Body.Close() - return nil, err - } - - // Do whatever we can. - // If we have an expected size and Content-Length doesn't match, return an error. - // If we don't have an expected size and we do have a Content-Length, use Content-Length. - if hsize := resp.ContentLength; hsize != -1 { - if size == verify.SizeUnknown { - size = hsize - } else if hsize != size { - return nil, fmt.Errorf("GET %s: Content-Length header %d does not match expected size %d", u.String(), hsize, size) - } - } - - return verify.ReadCloser(resp.Body, size, h) -} - -func (f *fetcher) headBlob(h v1.Hash) (*http.Response, error) { - u := f.url("blobs", h.String()) - req, err := http.NewRequest(http.MethodHead, u.String(), nil) - if err != nil { - return nil, err - } - - resp, err := f.Client.Do(req.WithContext(f.context)) - if err != nil { - return nil, redact.Error(err) - } - - if err := transport.CheckError(resp, http.StatusOK); err != nil { - resp.Body.Close() - return nil, err - } - - return resp, nil -} - -func (f *fetcher) blobExists(h v1.Hash) (bool, error) { - u := f.url("blobs", h.String()) - req, err := http.NewRequest(http.MethodHead, u.String(), nil) - if err != nil { - return false, err - } - - resp, err := f.Client.Do(req.WithContext(f.context)) - if err != nil { - return false, redact.Error(err) - } - defer resp.Body.Close() - - if err := transport.CheckError(resp, http.StatusOK, http.StatusNotFound); err != nil { - return false, err - } - - return resp.StatusCode == http.StatusOK, nil -} - -// If filter applied, filter out by artifactType. -// See https://github.com/opencontainers/distribution-spec/blob/main/spec.md#listing-referrers -func filterReferrersResponse(filter map[string]string, origIndex *v1.IndexManifest) *v1.IndexManifest { - newIndex := origIndex - if filter == nil { - return newIndex - } - if v, ok := filter["artifactType"]; ok { - tmp := []v1.Descriptor{} - for _, desc := range newIndex.Manifests { - if desc.ArtifactType == v { - tmp = append(tmp, desc) - } - } - newIndex.Manifests = tmp - } - return newIndex -} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/fetcher.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/fetcher.go new file mode 100644 index 000000000..b671f836c --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/fetcher.go @@ -0,0 +1,311 @@ +// Copyright 2023 Google LLC 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 remote + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "net/url" + "strings" + + "github.com/google/go-containerregistry/internal/redact" + "github.com/google/go-containerregistry/internal/verify" + "github.com/google/go-containerregistry/pkg/authn" + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/remote/transport" + "github.com/google/go-containerregistry/pkg/v1/types" +) + +// fetcher implements methods for reading from a registry. +type fetcher struct { + target resource + client *http.Client +} + +func makeFetcher(ctx context.Context, target resource, o *options) (*fetcher, error) { + auth := o.auth + if o.keychain != nil { + kauth, err := o.keychain.Resolve(target) + if err != nil { + return nil, err + } + auth = kauth + } + + reg, ok := target.(name.Registry) + if !ok { + repo, ok := target.(name.Repository) + if !ok { + return nil, fmt.Errorf("unexpected resource: %T", target) + } + reg = repo.Registry + } + + tr, err := transport.NewWithContext(ctx, reg, auth, o.transport, []string{target.Scope(transport.PullScope)}) + if err != nil { + return nil, err + } + return &fetcher{ + target: target, + client: &http.Client{Transport: tr}, + }, nil +} + +func (f *fetcher) Do(req *http.Request) (*http.Response, error) { + return f.client.Do(req) +} + +type resource interface { + Scheme() string + RegistryStr() string + Scope(string) string + + authn.Resource +} + +// url returns a url.Url for the specified path in the context of this remote image reference. +func (f *fetcher) url(resource, identifier string) url.URL { + u := url.URL{ + Scheme: f.target.Scheme(), + Host: f.target.RegistryStr(), + // Default path if this is not a repository. + Path: "/v2/_catalog", + } + if repo, ok := f.target.(name.Repository); ok { + u.Path = fmt.Sprintf("/v2/%s/%s/%s", repo.RepositoryStr(), resource, identifier) + } + return u +} + +func (f *fetcher) get(ctx context.Context, ref name.Reference, acceptable []types.MediaType, platform v1.Platform) (*Descriptor, error) { + b, desc, err := f.fetchManifest(ctx, ref, acceptable) + if err != nil { + return nil, err + } + return &Descriptor{ + ref: ref, + ctx: ctx, + fetcher: *f, + Manifest: b, + Descriptor: *desc, + platform: platform, + }, nil +} + +func (f *fetcher) fetchManifest(ctx context.Context, ref name.Reference, acceptable []types.MediaType) ([]byte, *v1.Descriptor, error) { + u := f.url("manifests", ref.Identifier()) + req, err := http.NewRequest(http.MethodGet, u.String(), nil) + if err != nil { + return nil, nil, err + } + accept := []string{} + for _, mt := range acceptable { + accept = append(accept, string(mt)) + } + req.Header.Set("Accept", strings.Join(accept, ",")) + + resp, err := f.client.Do(req.WithContext(ctx)) + if err != nil { + return nil, nil, err + } + defer resp.Body.Close() + + if err := transport.CheckError(resp, http.StatusOK); err != nil { + return nil, nil, err + } + + manifest, err := io.ReadAll(resp.Body) + if err != nil { + return nil, nil, err + } + + digest, size, err := v1.SHA256(bytes.NewReader(manifest)) + if err != nil { + return nil, nil, err + } + + mediaType := types.MediaType(resp.Header.Get("Content-Type")) + contentDigest, err := v1.NewHash(resp.Header.Get("Docker-Content-Digest")) + if err == nil && mediaType == types.DockerManifestSchema1Signed { + // If we can parse the digest from the header, and it's a signed schema 1 + // manifest, let's use that for the digest to appease older registries. + digest = contentDigest + } + + // Validate the digest matches what we asked for, if pulling by digest. + if dgst, ok := ref.(name.Digest); ok { + if digest.String() != dgst.DigestStr() { + return nil, nil, fmt.Errorf("manifest digest: %q does not match requested digest: %q for %q", digest, dgst.DigestStr(), ref) + } + } + + var artifactType string + mf, _ := v1.ParseManifest(bytes.NewReader(manifest)) + // Failing to parse as a manifest should just be ignored. + // The manifest might not be valid, and that's okay. + if mf != nil && !mf.Config.MediaType.IsConfig() { + artifactType = string(mf.Config.MediaType) + } + + // Do nothing for tags; I give up. + // + // We'd like to validate that the "Docker-Content-Digest" header matches what is returned by the registry, + // but so many registries implement this incorrectly that it's not worth checking. + // + // For reference: + // https://github.com/GoogleContainerTools/kaniko/issues/298 + + // Return all this info since we have to calculate it anyway. + desc := v1.Descriptor{ + Digest: digest, + Size: size, + MediaType: mediaType, + ArtifactType: artifactType, + } + + return manifest, &desc, nil +} + +func (f *fetcher) headManifest(ctx context.Context, ref name.Reference, acceptable []types.MediaType) (*v1.Descriptor, error) { + u := f.url("manifests", ref.Identifier()) + req, err := http.NewRequest(http.MethodHead, u.String(), nil) + if err != nil { + return nil, err + } + accept := []string{} + for _, mt := range acceptable { + accept = append(accept, string(mt)) + } + req.Header.Set("Accept", strings.Join(accept, ",")) + + resp, err := f.client.Do(req.WithContext(ctx)) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + if err := transport.CheckError(resp, http.StatusOK); err != nil { + return nil, err + } + + mth := resp.Header.Get("Content-Type") + if mth == "" { + return nil, fmt.Errorf("HEAD %s: response did not include Content-Type header", u.String()) + } + mediaType := types.MediaType(mth) + + size := resp.ContentLength + if size == -1 { + return nil, fmt.Errorf("GET %s: response did not include Content-Length header", u.String()) + } + + dh := resp.Header.Get("Docker-Content-Digest") + if dh == "" { + return nil, fmt.Errorf("HEAD %s: response did not include Docker-Content-Digest header", u.String()) + } + digest, err := v1.NewHash(dh) + if err != nil { + return nil, err + } + + // Validate the digest matches what we asked for, if pulling by digest. + if dgst, ok := ref.(name.Digest); ok { + if digest.String() != dgst.DigestStr() { + return nil, fmt.Errorf("manifest digest: %q does not match requested digest: %q for %q", digest, dgst.DigestStr(), ref) + } + } + + // Return all this info since we have to calculate it anyway. + return &v1.Descriptor{ + Digest: digest, + Size: size, + MediaType: mediaType, + }, nil +} + +func (f *fetcher) fetchBlob(ctx context.Context, size int64, h v1.Hash) (io.ReadCloser, error) { + u := f.url("blobs", h.String()) + req, err := http.NewRequest(http.MethodGet, u.String(), nil) + if err != nil { + return nil, err + } + + resp, err := f.client.Do(req.WithContext(ctx)) + if err != nil { + return nil, redact.Error(err) + } + + if err := transport.CheckError(resp, http.StatusOK); err != nil { + resp.Body.Close() + return nil, err + } + + // Do whatever we can. + // If we have an expected size and Content-Length doesn't match, return an error. + // If we don't have an expected size and we do have a Content-Length, use Content-Length. + if hsize := resp.ContentLength; hsize != -1 { + if size == verify.SizeUnknown { + size = hsize + } else if hsize != size { + return nil, fmt.Errorf("GET %s: Content-Length header %d does not match expected size %d", u.String(), hsize, size) + } + } + + return verify.ReadCloser(resp.Body, size, h) +} + +func (f *fetcher) headBlob(ctx context.Context, h v1.Hash) (*http.Response, error) { + u := f.url("blobs", h.String()) + req, err := http.NewRequest(http.MethodHead, u.String(), nil) + if err != nil { + return nil, err + } + + resp, err := f.client.Do(req.WithContext(ctx)) + if err != nil { + return nil, redact.Error(err) + } + + if err := transport.CheckError(resp, http.StatusOK); err != nil { + resp.Body.Close() + return nil, err + } + + return resp, nil +} + +func (f *fetcher) blobExists(ctx context.Context, h v1.Hash) (bool, error) { + u := f.url("blobs", h.String()) + req, err := http.NewRequest(http.MethodHead, u.String(), nil) + if err != nil { + return false, err + } + + resp, err := f.client.Do(req.WithContext(ctx)) + if err != nil { + return false, redact.Error(err) + } + defer resp.Body.Close() + + if err := transport.CheckError(resp, http.StatusOK, http.StatusNotFound); err != nil { + return false, err + } + + return resp.StatusCode == http.StatusOK, nil +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/image.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/image.go index fde614274..f085967ed 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/image.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/image.go @@ -16,6 +16,7 @@ package remote import ( "bytes" + "context" "io" "net/http" "net/url" @@ -37,7 +38,9 @@ var acceptableImageMediaTypes = []types.MediaType{ // remoteImage accesses an image from a remote registry type remoteImage struct { - fetcher + fetcher fetcher + ref name.Reference + ctx context.Context manifestLock sync.Mutex // Protects manifest manifest []byte configLock sync.Mutex // Protects config @@ -84,7 +87,7 @@ func (r *remoteImage) RawManifest() ([]byte, error) { // NOTE(jonjohnsonjr): We should never get here because the public entrypoints // do type-checking via remote.Descriptor. I've left this here for tests that // directly instantiate a remoteImage. - manifest, desc, err := r.fetchManifest(r.Ref, acceptableImageMediaTypes) + manifest, desc, err := r.fetcher.fetchManifest(r.ctx, r.ref, acceptableImageMediaTypes) if err != nil { return nil, err } @@ -117,7 +120,7 @@ func (r *remoteImage) RawConfigFile() ([]byte, error) { return r.config, nil } - body, err := r.fetchBlob(r.context, m.Config.Size, m.Config.Digest) + body, err := r.fetcher.fetchBlob(r.ctx, m.Config.Size, m.Config.Digest) if err != nil { return nil, err } @@ -139,9 +142,26 @@ func (r *remoteImage) Descriptor() (*v1.Descriptor, error) { return r.descriptor, err } +func (r *remoteImage) ConfigLayer() (v1.Layer, error) { + if _, err := r.RawManifest(); err != nil { + return nil, err + } + m, err := partial.Manifest(r) + if err != nil { + return nil, err + } + + return partial.CompressedToLayer(&remoteImageLayer{ + ri: r, + ctx: r.ctx, + digest: m.Config.Digest, + }) +} + // remoteImageLayer implements partial.CompressedLayer type remoteImageLayer struct { ri *remoteImage + ctx context.Context digest v1.Hash } @@ -152,7 +172,7 @@ func (rl *remoteImageLayer) Digest() (v1.Hash, error) { // Compressed implements partial.CompressedLayer func (rl *remoteImageLayer) Compressed() (io.ReadCloser, error) { - urls := []url.URL{rl.ri.url("blobs", rl.digest.String())} + urls := []url.URL{rl.ri.fetcher.url("blobs", rl.digest.String())} // Add alternative layer sources from URLs (usually none). d, err := partial.BlobDescriptor(rl, rl.digest) @@ -165,7 +185,7 @@ func (rl *remoteImageLayer) Compressed() (io.ReadCloser, error) { } // We don't want to log binary layers -- this can break terminals. - ctx := redact.NewContext(rl.ri.context, "omitting binary blobs from logs") + ctx := redact.NewContext(rl.ctx, "omitting binary blobs from logs") for _, s := range d.URLs { u, err := url.Parse(s) @@ -186,7 +206,7 @@ func (rl *remoteImageLayer) Compressed() (io.ReadCloser, error) { return nil, err } - resp, err := rl.ri.Client.Do(req.WithContext(ctx)) + resp, err := rl.ri.fetcher.Do(req.WithContext(ctx)) if err != nil { lastErr = err continue @@ -244,13 +264,14 @@ func (rl *remoteImageLayer) Descriptor() (*v1.Descriptor, error) { // See partial.Exists. func (rl *remoteImageLayer) Exists() (bool, error) { - return rl.ri.blobExists(rl.digest) + return rl.ri.fetcher.blobExists(rl.ri.ctx, rl.digest) } // LayerByDigest implements partial.CompressedLayer func (r *remoteImage) LayerByDigest(h v1.Hash) (partial.CompressedLayer, error) { return &remoteImageLayer{ ri: r, + ctx: r.ctx, digest: h, }, nil } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/index.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/index.go index 0939947e3..b80972c80 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/index.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/index.go @@ -16,6 +16,7 @@ package remote import ( "bytes" + "context" "fmt" "sync" @@ -33,7 +34,9 @@ var acceptableIndexMediaTypes = []types.MediaType{ // remoteIndex accesses an index from a remote registry type remoteIndex struct { - fetcher + fetcher fetcher + ref name.Reference + ctx context.Context manifestLock sync.Mutex // Protects manifest manifest []byte mediaType types.MediaType @@ -75,7 +78,7 @@ func (r *remoteIndex) RawManifest() ([]byte, error) { // NOTE(jonjohnsonjr): We should never get here because the public entrypoints // do type-checking via remote.Descriptor. I've left this here for tests that // directly instantiate a remoteIndex. - manifest, desc, err := r.fetchManifest(r.Ref, acceptableIndexMediaTypes) + manifest, desc, err := r.fetcher.fetchManifest(r.ctx, r.ref, acceptableIndexMediaTypes) if err != nil { return nil, err } @@ -133,6 +136,7 @@ func (r *remoteIndex) Layer(h v1.Hash) (v1.Layer, error) { if h == childDesc.Digest { l, err := partial.CompressedToLayer(&remoteLayer{ fetcher: r.fetcher, + ctx: r.ctx, digest: h, }) if err != nil { @@ -140,47 +144,13 @@ func (r *remoteIndex) Layer(h v1.Hash) (v1.Layer, error) { } return &MountableLayer{ Layer: l, - Reference: r.Ref.Context().Digest(h.String()), + Reference: r.ref.Context().Digest(h.String()), }, nil } } return nil, fmt.Errorf("layer not found: %s", h) } -// Experiment with a better API for v1.ImageIndex. We might want to move this -// to partial? -func (r *remoteIndex) Manifests() ([]partial.Describable, error) { - m, err := r.IndexManifest() - if err != nil { - return nil, err - } - manifests := []partial.Describable{} - for _, desc := range m.Manifests { - switch { - case desc.MediaType.IsImage(): - img, err := r.Image(desc.Digest) - if err != nil { - return nil, err - } - manifests = append(manifests, img) - case desc.MediaType.IsIndex(): - idx, err := r.ImageIndex(desc.Digest) - if err != nil { - return nil, err - } - manifests = append(manifests, idx) - default: - layer, err := r.Layer(desc.Digest) - if err != nil { - return nil, err - } - manifests = append(manifests, layer) - } - } - - return manifests, nil -} - func (r *remoteIndex) imageByPlatform(platform v1.Platform) (v1.Image, error) { desc, err := r.childByPlatform(platform) if err != nil { @@ -216,7 +186,7 @@ func (r *remoteIndex) childByPlatform(platform v1.Platform) (*Descriptor, error) return r.childDescriptor(childDesc, platform) } } - return nil, fmt.Errorf("no child with platform %+v in index %s", platform, r.Ref) + return nil, fmt.Errorf("no child with platform %+v in index %s", platform, r.ref) } func (r *remoteIndex) childByHash(h v1.Hash) (*Descriptor, error) { @@ -229,12 +199,12 @@ func (r *remoteIndex) childByHash(h v1.Hash) (*Descriptor, error) { return r.childDescriptor(childDesc, defaultPlatform) } } - return nil, fmt.Errorf("no child with digest %s in index %s", h, r.Ref) + return nil, fmt.Errorf("no child with digest %s in index %s", h, r.ref) } // Convert one of this index's child's v1.Descriptor into a remote.Descriptor, with the given platform option. func (r *remoteIndex) childDescriptor(child v1.Descriptor, platform v1.Platform) (*Descriptor, error) { - ref := r.Ref.Context().Digest(child.Digest.String()) + ref := r.ref.Context().Digest(child.Digest.String()) var ( manifest []byte err error @@ -245,7 +215,7 @@ func (r *remoteIndex) childDescriptor(child v1.Descriptor, platform v1.Platform) } manifest = child.Data } else { - manifest, _, err = r.fetchManifest(ref, []types.MediaType{child.MediaType}) + manifest, _, err = r.fetcher.fetchManifest(r.ctx, ref, []types.MediaType{child.MediaType}) if err != nil { return nil, err } @@ -261,11 +231,9 @@ func (r *remoteIndex) childDescriptor(child v1.Descriptor, platform v1.Platform) } return &Descriptor{ - fetcher: fetcher{ - Ref: ref, - Client: r.Client, - context: r.context, - }, + ref: ref, + ctx: r.ctx, + fetcher: r.fetcher, Manifest: manifest, Descriptor: child, platform: platform, diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/layer.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/layer.go index b2126f599..39c205950 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/layer.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/layer.go @@ -15,32 +15,33 @@ package remote import ( + "context" "io" "github.com/google/go-containerregistry/internal/redact" "github.com/google/go-containerregistry/internal/verify" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" - "github.com/google/go-containerregistry/pkg/v1/partial" "github.com/google/go-containerregistry/pkg/v1/types" ) // remoteImagelayer implements partial.CompressedLayer type remoteLayer struct { - fetcher - digest v1.Hash + ctx context.Context + fetcher fetcher + digest v1.Hash } // Compressed implements partial.CompressedLayer func (rl *remoteLayer) Compressed() (io.ReadCloser, error) { // We don't want to log binary layers -- this can break terminals. - ctx := redact.NewContext(rl.context, "omitting binary blobs from logs") - return rl.fetchBlob(ctx, verify.SizeUnknown, rl.digest) + ctx := redact.NewContext(rl.ctx, "omitting binary blobs from logs") + return rl.fetcher.fetchBlob(ctx, verify.SizeUnknown, rl.digest) } // Compressed implements partial.CompressedLayer func (rl *remoteLayer) Size() (int64, error) { - resp, err := rl.headBlob(rl.digest) + resp, err := rl.fetcher.headBlob(rl.ctx, rl.digest) if err != nil { return -1, err } @@ -60,7 +61,7 @@ func (rl *remoteLayer) MediaType() (types.MediaType, error) { // See partial.Exists. func (rl *remoteLayer) Exists() (bool, error) { - return rl.blobExists(rl.digest) + return rl.fetcher.blobExists(rl.ctx, rl.digest) } // Layer reads the given blob reference from a registry as a Layer. A blob @@ -68,27 +69,9 @@ func (rl *remoteLayer) Exists() (bool, error) { // digest of the blob to be read and the repository portion is the repo where // that blob lives. func Layer(ref name.Digest, options ...Option) (v1.Layer, error) { - o, err := makeOptions(ref.Context(), options...) + o, err := makeOptions(options...) if err != nil { return nil, err } - f, err := makeFetcher(ref, o) - if err != nil { - return nil, err - } - h, err := v1.NewHash(ref.Identifier()) - if err != nil { - return nil, err - } - l, err := partial.CompressedToLayer(&remoteLayer{ - fetcher: *f, - digest: h, - }) - if err != nil { - return nil, err - } - return &MountableLayer{ - Layer: l, - Reference: ref, - }, nil + return newPuller(o).Layer(o.context, ref) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/list.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/list.go index e643c49aa..910d2a94c 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/list.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/list.go @@ -26,11 +26,6 @@ import ( "github.com/google/go-containerregistry/pkg/v1/remote/transport" ) -type tags struct { - Name string `json:"name"` - Tags []string `json:"tags"` -} - // ListWithContext calls List with the given context. // // Deprecated: Use List and WithContext. This will be removed in a future release. @@ -41,73 +36,65 @@ func ListWithContext(ctx context.Context, repo name.Repository, options ...Optio // List calls /tags/list for the given repository, returning the list of tags // in the "tags" property. func List(repo name.Repository, options ...Option) ([]string, error) { - o, err := makeOptions(repo, options...) + o, err := makeOptions(options...) if err != nil { return nil, err } - scopes := []string{repo.Scope(transport.PullScope)} - tr, err := transport.NewWithContext(o.context, repo.Registry, o.auth, o.transport, scopes) + return newPuller(o).List(o.context, repo) +} + +type Tags struct { + Name string `json:"name"` + Tags []string `json:"tags"` + Next string `json:"next,omitempty"` +} + +func (f *fetcher) listPage(ctx context.Context, repo name.Repository, next string, pageSize int) (*Tags, error) { + if next == "" { + uri := &url.URL{ + Scheme: repo.Scheme(), + Host: repo.RegistryStr(), + Path: fmt.Sprintf("/v2/%s/tags/list", repo.RepositoryStr()), + } + if pageSize > 0 { + uri.RawQuery = fmt.Sprintf("n=%d", pageSize) + } + next = uri.String() + } + + req, err := http.NewRequestWithContext(ctx, "GET", next, nil) if err != nil { return nil, err } - uri := &url.URL{ - Scheme: repo.Registry.Scheme(), - Host: repo.Registry.RegistryStr(), - Path: fmt.Sprintf("/v2/%s/tags/list", repo.RepositoryStr()), + resp, err := f.client.Do(req) + if err != nil { + return nil, err } - if o.pageSize > 0 { - uri.RawQuery = fmt.Sprintf("n=%d", o.pageSize) + if err := transport.CheckError(resp, http.StatusOK); err != nil { + return nil, err } - client := http.Client{Transport: tr} - tagList := []string{} - parsed := tags{} - - // get responses until there is no next page - for { - select { - case <-o.context.Done(): - return nil, o.context.Err() - default: - } - - req, err := http.NewRequestWithContext(o.context, "GET", uri.String(), nil) - if err != nil { - return nil, err - } - - resp, err := client.Do(req) - if err != nil { - return nil, err - } - - if err := transport.CheckError(resp, http.StatusOK); err != nil { - return nil, err - } - - if err := json.NewDecoder(resp.Body).Decode(&parsed); err != nil { - return nil, err - } + parsed := Tags{} + if err := json.NewDecoder(resp.Body).Decode(&parsed); err != nil { + return nil, err + } - if err := resp.Body.Close(); err != nil { - return nil, err - } + if err := resp.Body.Close(); err != nil { + return nil, err + } - tagList = append(tagList, parsed.Tags...) + uri, err := getNextPageURL(resp) + if err != nil { + return nil, err + } - uri, err = getNextPageURL(resp) - if err != nil { - return nil, err - } - // no next page - if uri == nil { - break - } + if uri != nil { + parsed.Next = uri.String() } - return tagList, nil + return &parsed, nil } // getNextPageURL checks if there is a Link header in a http.Response which @@ -139,3 +126,27 @@ func getNextPageURL(resp *http.Response) (*url.URL, error) { linkURL = resp.Request.URL.ResolveReference(linkURL) return linkURL, nil } + +type Lister struct { + f *fetcher + repo name.Repository + pageSize int + + page *Tags + err error + + needMore bool +} + +func (l *Lister) Next(ctx context.Context) (*Tags, error) { + if l.needMore { + l.page, l.err = l.f.listPage(ctx, l.repo, l.page.Next, l.pageSize) + } else { + l.needMore = true + } + return l.page, l.err +} + +func (l *Lister) HasNext() bool { + return l.page != nil && (!l.needMore || l.page.Next != "") +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/multi_write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/multi_write.go index 7f32413ce..a6705de89 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/multi_write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/multi_write.go @@ -15,288 +15,32 @@ package remote import ( - "context" - "fmt" - "net/http" - "github.com/google/go-containerregistry/pkg/name" - v1 "github.com/google/go-containerregistry/pkg/v1" - "github.com/google/go-containerregistry/pkg/v1/partial" - "github.com/google/go-containerregistry/pkg/v1/remote/transport" - "github.com/google/go-containerregistry/pkg/v1/types" "golang.org/x/sync/errgroup" ) // MultiWrite writes the given Images or ImageIndexes to the given refs, as -// efficiently as possible, by deduping shared layer blobs and uploading layers -// in parallel, then uploading all manifests in parallel. -// -// Current limitations: -// - All refs must share the same repository. -// - Images cannot consist of stream.Layers. -func MultiWrite(m map[name.Reference]Taggable, options ...Option) (rerr error) { - // Determine the repository being pushed to; if asked to push to - // multiple repositories, give up. - var repo, zero name.Repository - for ref := range m { - if repo == zero { - repo = ref.Context() - } else if ref.Context() != repo { - return fmt.Errorf("MultiWrite can only push to the same repository (saw %q and %q)", repo, ref.Context()) - } - } - - o, err := makeOptions(repo, options...) - if err != nil { - return err - } - - // Collect unique blobs (layers and config blobs). - blobs := map[v1.Hash]v1.Layer{} - newManifests := []map[name.Reference]Taggable{} - // Separate originally requested images and indexes, so we can push images first. - images, indexes := map[name.Reference]Taggable{}, map[name.Reference]Taggable{} - for ref, i := range m { - if img, ok := i.(v1.Image); ok { - images[ref] = i - if err := addImageBlobs(img, blobs, o.allowNondistributableArtifacts); err != nil { - return err - } - continue - } - if idx, ok := i.(v1.ImageIndex); ok { - indexes[ref] = i - newManifests, err = addIndexBlobs(idx, blobs, repo, newManifests, 0, o.allowNondistributableArtifacts) - if err != nil { - return err - } - continue - } - return fmt.Errorf("pushable resource was not Image or ImageIndex: %T", i) - } - - // Determine if any of the layers are Mountable, because if so we need - // to request Pull scope too. - ls := []v1.Layer{} - for _, l := range blobs { - ls = append(ls, l) - } - scopes := scopesForUploadingImage(repo, ls) - tr, err := transport.NewWithContext(o.context, repo.Registry, o.auth, o.transport, scopes) +// efficiently as possible, by deduping shared layer blobs while uploading them +// in parallel. +func MultiWrite(todo map[name.Reference]Taggable, options ...Option) (rerr error) { + o, err := makeOptions(options...) if err != nil { return err } - w := writer{ - repo: repo, - client: &http.Client{Transport: tr}, - backoff: o.retryBackoff, - predicate: o.retryPredicate, + if o.progress != nil { + defer func() { o.progress.Close(rerr) }() } + p := newPusher(o) - // Collect the total size of blobs and manifests we're about to write. - if o.updates != nil { - w.progress = &progress{updates: o.updates} - w.progress.lastUpdate = &v1.Update{} - defer close(o.updates) - defer func() { _ = w.progress.err(rerr) }() - for _, b := range blobs { - size, err := b.Size() - if err != nil { - return err - } - w.progress.total(size) - } - countManifest := func(t Taggable) error { - b, err := t.RawManifest() - if err != nil { - return err - } - w.progress.total(int64(len(b))) - return nil - } - for _, i := range images { - if err := countManifest(i); err != nil { - return err - } - } - for _, nm := range newManifests { - for _, i := range nm { - if err := countManifest(i); err != nil { - return err - } - } - } - for _, i := range indexes { - if err := countManifest(i); err != nil { - return err - } - } - } + g, ctx := errgroup.WithContext(o.context) + g.SetLimit(o.jobs) - // Upload individual blobs and collect any errors. - blobChan := make(chan v1.Layer, 2*o.jobs) - ctx := o.context - g, gctx := errgroup.WithContext(o.context) - for i := 0; i < o.jobs; i++ { - // Start N workers consuming blobs to upload. + for ref, t := range todo { + ref, t := ref, t g.Go(func() error { - for b := range blobChan { - if err := w.uploadOne(gctx, b); err != nil { - return err - } - } - return nil + return p.Push(ctx, ref, t) }) } - g.Go(func() error { - defer close(blobChan) - for _, b := range blobs { - select { - case blobChan <- b: - case <-gctx.Done(): - return gctx.Err() - } - } - return nil - }) - if err := g.Wait(); err != nil { - return err - } - - commitMany := func(ctx context.Context, m map[name.Reference]Taggable) error { - g, ctx := errgroup.WithContext(ctx) - // With all of the constituent elements uploaded, upload the manifests - // to commit the images and indexes, and collect any errors. - type task struct { - i Taggable - ref name.Reference - } - taskChan := make(chan task, 2*o.jobs) - for i := 0; i < o.jobs; i++ { - // Start N workers consuming tasks to upload manifests. - g.Go(func() error { - for t := range taskChan { - if err := w.commitManifest(ctx, t.i, t.ref); err != nil { - return err - } - } - return nil - }) - } - go func() { - for ref, i := range m { - taskChan <- task{i, ref} - } - close(taskChan) - }() - return g.Wait() - } - // Push originally requested image manifests. These have no - // dependencies. - if err := commitMany(ctx, images); err != nil { - return err - } - // Push new manifests from lowest levels up. - for i := len(newManifests) - 1; i >= 0; i-- { - if err := commitMany(ctx, newManifests[i]); err != nil { - return err - } - } - // Push originally requested index manifests, which might depend on - // newly discovered manifests. - - return commitMany(ctx, indexes) -} -// addIndexBlobs adds blobs to the set of blobs we intend to upload, and -// returns the latest copy of the ordered collection of manifests to upload. -func addIndexBlobs(idx v1.ImageIndex, blobs map[v1.Hash]v1.Layer, repo name.Repository, newManifests []map[name.Reference]Taggable, lvl int, allowNondistributableArtifacts bool) ([]map[name.Reference]Taggable, error) { - if lvl > len(newManifests)-1 { - newManifests = append(newManifests, map[name.Reference]Taggable{}) - } - - im, err := idx.IndexManifest() - if err != nil { - return nil, err - } - for _, desc := range im.Manifests { - switch desc.MediaType { - case types.OCIImageIndex, types.DockerManifestList: - idx, err := idx.ImageIndex(desc.Digest) - if err != nil { - return nil, err - } - newManifests, err = addIndexBlobs(idx, blobs, repo, newManifests, lvl+1, allowNondistributableArtifacts) - if err != nil { - return nil, err - } - - // Also track the sub-index manifest to upload later by digest. - newManifests[lvl][repo.Digest(desc.Digest.String())] = idx - case types.OCIManifestSchema1, types.DockerManifestSchema2: - img, err := idx.Image(desc.Digest) - if err != nil { - return nil, err - } - if err := addImageBlobs(img, blobs, allowNondistributableArtifacts); err != nil { - return nil, err - } - - // Also track the sub-image manifest to upload later by digest. - newManifests[lvl][repo.Digest(desc.Digest.String())] = img - default: - // Workaround for #819. - if wl, ok := idx.(withLayer); ok { - layer, err := wl.Layer(desc.Digest) - if err != nil { - return nil, err - } - if err := addLayerBlob(layer, blobs, allowNondistributableArtifacts); err != nil { - return nil, err - } - } else { - return nil, fmt.Errorf("unknown media type: %v", desc.MediaType) - } - } - } - return newManifests, nil -} - -func addLayerBlob(l v1.Layer, blobs map[v1.Hash]v1.Layer, allowNondistributableArtifacts bool) error { - // Ignore foreign layers. - mt, err := l.MediaType() - if err != nil { - return err - } - - if mt.IsDistributable() || allowNondistributableArtifacts { - d, err := l.Digest() - if err != nil { - return err - } - - blobs[d] = l - } - - return nil -} - -func addImageBlobs(img v1.Image, blobs map[v1.Hash]v1.Layer, allowNondistributableArtifacts bool) error { - ls, err := img.Layers() - if err != nil { - return err - } - // Collect all layers. - for _, l := range ls { - if err := addLayerBlob(l, blobs, allowNondistributableArtifacts); err != nil { - return err - } - } - - // Collect config blob. - cl, err := partial.ConfigLayer(img) - if err != nil { - return err - } - return addLayerBlob(cl, blobs, allowNondistributableArtifacts) + return g.Wait() } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/options.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/options.go index 54a0af227..a722c2ca6 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/options.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/options.go @@ -37,16 +37,23 @@ type options struct { auth authn.Authenticator keychain authn.Keychain transport http.RoundTripper - platform v1.Platform context context.Context jobs int userAgent string allowNondistributableArtifacts bool - updates chan<- v1.Update - pageSize int + progress *progress retryBackoff Backoff retryPredicate retry.Predicate - filter map[string]string + retryStatusCodes []int + + // Only these options can overwrite Reuse()d options. + platform v1.Platform + pageSize int + filter map[string]string + + // Set by Reuse, we currently store one or the other. + puller *Puller + pusher *Pusher } var defaultPlatform = v1.Platform{ @@ -60,7 +67,7 @@ type Backoff = retry.Backoff var defaultRetryPredicate retry.Predicate = func(err error) bool { // Various failure modes here, as we're often reading from and writing to // the network. - if retry.IsTemporary(err) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, io.EOF) || errors.Is(err, syscall.EPIPE) || errors.Is(err, syscall.ECONNRESET) { + if retry.IsTemporary(err) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, io.EOF) || errors.Is(err, syscall.EPIPE) || errors.Is(err, syscall.ECONNRESET) || errors.Is(err, net.ErrClosed) { logs.Warn.Printf("retrying %v", err) return true } @@ -83,12 +90,13 @@ var fastBackoff = Backoff{ Steps: 3, } -var retryableStatusCodes = []int{ +var defaultRetryStatusCodes = []int{ http.StatusRequestTimeout, http.StatusInternalServerError, http.StatusBadGateway, http.StatusServiceUnavailable, http.StatusGatewayTimeout, + 499, } const ( @@ -112,17 +120,20 @@ var DefaultTransport http.RoundTripper = &http.Transport{ IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, + // We usually are dealing with 2 hosts (at most), split MaxIdleConns between them. + MaxIdleConnsPerHost: 50, } -func makeOptions(target authn.Resource, opts ...Option) (*options, error) { +func makeOptions(opts ...Option) (*options, error) { o := &options{ - transport: DefaultTransport, - platform: defaultPlatform, - context: context.Background(), - jobs: defaultJobs, - pageSize: defaultPageSize, - retryPredicate: defaultRetryPredicate, - retryBackoff: defaultRetryBackoff, + transport: DefaultTransport, + platform: defaultPlatform, + context: context.Background(), + jobs: defaultJobs, + pageSize: defaultPageSize, + retryPredicate: defaultRetryPredicate, + retryBackoff: defaultRetryBackoff, + retryStatusCodes: defaultRetryStatusCodes, } for _, option := range opts { @@ -136,12 +147,6 @@ func makeOptions(target authn.Resource, opts ...Option) (*options, error) { // It is a better experience to explicitly tell a caller their auth is misconfigured // than potentially fail silently when the correct auth is overridden by option misuse. return nil, errors.New("provide an option for either authn.Authenticator or authn.Keychain, not both") - case o.keychain != nil: - auth, err := o.keychain.Resolve(target) - if err != nil { - return nil, err - } - o.auth = auth case o.auth == nil: o.auth = authn.Anonymous } @@ -157,7 +162,7 @@ func makeOptions(target authn.Resource, opts ...Option) (*options, error) { } // Wrap the transport in something that can retry network flakes. - o.transport = transport.NewRetry(o.transport, transport.WithRetryPredicate(defaultRetryPredicate), transport.WithRetryStatusCodes(retryableStatusCodes...)) + o.transport = transport.NewRetry(o.transport, transport.WithRetryPredicate(defaultRetryPredicate), transport.WithRetryStatusCodes(o.retryStatusCodes...)) // Wrap this last to prevent transport.New from double-wrapping. if o.userAgent != "" { @@ -273,7 +278,8 @@ func WithNondistributable(o *options) error { // should provide a buffered channel to avoid potential deadlocks. func WithProgress(updates chan<- v1.Update) Option { return func(o *options) error { - o.updates = updates + o.progress = &progress{updates: updates} + o.progress.lastUpdate = &v1.Update{} return nil } } @@ -305,6 +311,14 @@ func WithRetryPredicate(predicate retry.Predicate) Option { } } +// WithRetryStatusCodes sets which http response codes will be retried. +func WithRetryStatusCodes(codes ...int) Option { + return func(o *options) error { + o.retryStatusCodes = codes + return nil + } +} + // WithFilter sets the filter querystring for HTTP operations. func WithFilter(key string, value string) Option { return func(o *options) error { @@ -315,3 +329,20 @@ func WithFilter(key string, value string) Option { return nil } } + +// Reuse takes a Puller or Pusher and reuses it for remote interactions +// rather than starting from a clean slate. For example, it will reuse token exchanges +// when possible and avoid sending redundant HEAD requests. +// +// Reuse will take precedence over other options passed to most remote functions because +// most options deal with setting up auth and transports, which Reuse intetionally skips. +func Reuse[I *Puller | *Pusher](i I) Option { + return func(o *options) error { + if puller, ok := any(i).(*Puller); ok { + o.puller = puller + } else if pusher, ok := any(i).(*Pusher); ok { + o.pusher = pusher + } + return nil + } +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/progress.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/progress.go index 1f4396350..fe60c8c35 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/progress.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/progress.go @@ -29,6 +29,8 @@ type progress struct { } func (p *progress) total(delta int64) { + p.Lock() + defer p.Unlock() atomic.AddInt64(&p.lastUpdate.Total, delta) } @@ -48,6 +50,11 @@ func (p *progress) err(err error) error { return err } +func (p *progress) Close(err error) { + _ = p.err(err) + close(p.updates) +} + type progressReader struct { rc io.ReadCloser diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/puller.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/puller.go new file mode 100644 index 000000000..7da8017ee --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/puller.go @@ -0,0 +1,222 @@ +// Copyright 2023 Google LLC 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 remote + +import ( + "context" + "sync" + + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/partial" + "github.com/google/go-containerregistry/pkg/v1/types" +) + +type Puller struct { + o *options + + // map[resource]*reader + readers sync.Map +} + +func NewPuller(options ...Option) (*Puller, error) { + o, err := makeOptions(options...) + if err != nil { + return nil, err + } + + return newPuller(o), nil +} + +func newPuller(o *options) *Puller { + if o.puller != nil { + return o.puller + } + return &Puller{ + o: o, + } +} + +type reader struct { + // in + target resource + o *options + + // f() + once sync.Once + + // out + f *fetcher + err error +} + +// this will run once per reader instance +func (r *reader) init(ctx context.Context) error { + r.once.Do(func() { + r.f, r.err = makeFetcher(ctx, r.target, r.o) + }) + return r.err +} + +func (p *Puller) fetcher(ctx context.Context, target resource) (*fetcher, error) { + v, _ := p.readers.LoadOrStore(target, &reader{ + target: target, + o: p.o, + }) + rr := v.(*reader) + return rr.f, rr.init(ctx) +} + +// Head is like remote.Head, but avoids re-authenticating when possible. +func (p *Puller) Head(ctx context.Context, ref name.Reference) (*v1.Descriptor, error) { + f, err := p.fetcher(ctx, ref.Context()) + if err != nil { + return nil, err + } + + return f.headManifest(ctx, ref, allManifestMediaTypes) +} + +// Get is like remote.Get, but avoids re-authenticating when possible. +func (p *Puller) Get(ctx context.Context, ref name.Reference) (*Descriptor, error) { + return p.get(ctx, ref, allManifestMediaTypes, p.o.platform) +} + +func (p *Puller) get(ctx context.Context, ref name.Reference, acceptable []types.MediaType, platform v1.Platform) (*Descriptor, error) { + f, err := p.fetcher(ctx, ref.Context()) + if err != nil { + return nil, err + } + return f.get(ctx, ref, acceptable, platform) +} + +// Layer is like remote.Layer, but avoids re-authenticating when possible. +func (p *Puller) Layer(ctx context.Context, ref name.Digest) (v1.Layer, error) { + f, err := p.fetcher(ctx, ref.Context()) + if err != nil { + return nil, err + } + + h, err := v1.NewHash(ref.Identifier()) + if err != nil { + return nil, err + } + l, err := partial.CompressedToLayer(&remoteLayer{ + fetcher: *f, + ctx: ctx, + digest: h, + }) + if err != nil { + return nil, err + } + return &MountableLayer{ + Layer: l, + Reference: ref, + }, nil +} + +// List lists tags in a repo and handles pagination, returning the full list of tags. +func (p *Puller) List(ctx context.Context, repo name.Repository) ([]string, error) { + lister, err := p.Lister(ctx, repo) + if err != nil { + return nil, err + } + + tagList := []string{} + for lister.HasNext() { + tags, err := lister.Next(ctx) + if err != nil { + return nil, err + } + tagList = append(tagList, tags.Tags...) + } + + return tagList, nil +} + +// Lister lists tags in a repo and returns a Lister for paginating through the results. +func (p *Puller) Lister(ctx context.Context, repo name.Repository) (*Lister, error) { + return p.lister(ctx, repo, p.o.pageSize) +} + +func (p *Puller) lister(ctx context.Context, repo name.Repository, pageSize int) (*Lister, error) { + f, err := p.fetcher(ctx, repo) + if err != nil { + return nil, err + } + page, err := f.listPage(ctx, repo, "", pageSize) + if err != nil { + return nil, err + } + return &Lister{ + f: f, + repo: repo, + pageSize: pageSize, + page: page, + err: err, + }, nil +} + +// Catalog lists repos in a registry and handles pagination, returning the full list of repos. +func (p *Puller) Catalog(ctx context.Context, reg name.Registry) ([]string, error) { + return p.catalog(ctx, reg, p.o.pageSize) +} + +func (p *Puller) catalog(ctx context.Context, reg name.Registry, pageSize int) ([]string, error) { + catalogger, err := p.catalogger(ctx, reg, pageSize) + if err != nil { + return nil, err + } + repoList := []string{} + for catalogger.HasNext() { + repos, err := catalogger.Next(ctx) + if err != nil { + return nil, err + } + repoList = append(repoList, repos.Repos...) + } + return repoList, nil +} + +// Catalogger lists repos in a registry and returns a Catalogger for paginating through the results. +func (p *Puller) Catalogger(ctx context.Context, reg name.Registry) (*Catalogger, error) { + return p.catalogger(ctx, reg, p.o.pageSize) +} + +func (p *Puller) catalogger(ctx context.Context, reg name.Registry, pageSize int) (*Catalogger, error) { + f, err := p.fetcher(ctx, reg) + if err != nil { + return nil, err + } + page, err := f.catalogPage(ctx, reg, "", pageSize) + if err != nil { + return nil, err + } + return &Catalogger{ + f: f, + reg: reg, + pageSize: pageSize, + page: page, + err: err, + }, nil +} + +func (p *Puller) referrers(ctx context.Context, d name.Digest, filter map[string]string) (v1.ImageIndex, error) { + f, err := p.fetcher(ctx, d.Context()) + if err != nil { + return nil, err + } + return f.fetchReferrers(ctx, filter, d) +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/pusher.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/pusher.go new file mode 100644 index 000000000..1c07bd475 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/pusher.go @@ -0,0 +1,559 @@ +// Copyright 2023 Google LLC 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 remote + +import ( + "bytes" + "context" + "errors" + "fmt" + "net/http" + "net/url" + "sync" + + "github.com/google/go-containerregistry/pkg/logs" + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/partial" + "github.com/google/go-containerregistry/pkg/v1/remote/transport" + "github.com/google/go-containerregistry/pkg/v1/stream" + "github.com/google/go-containerregistry/pkg/v1/types" + "golang.org/x/sync/errgroup" +) + +type manifest interface { + Taggable + partial.Describable +} + +// key is either v1.Hash or v1.Layer (for stream.Layer) +type workers struct { + // map[v1.Hash|v1.Layer]*sync.Once + onces sync.Map + + // map[v1.Hash|v1.Layer]error + errors sync.Map +} + +func nop() error { + return nil +} + +func (w *workers) err(digest v1.Hash) error { + v, ok := w.errors.Load(digest) + if !ok || v == nil { + return nil + } + return v.(error) +} + +func (w *workers) Do(digest v1.Hash, f func() error) error { + // We don't care if it was loaded or not because the sync.Once will do it for us. + once, _ := w.onces.LoadOrStore(digest, &sync.Once{}) + + once.(*sync.Once).Do(func() { + w.errors.Store(digest, f()) + }) + + err := w.err(digest) + if err != nil { + // Allow this to be retried by another caller. + w.onces.Delete(digest) + } + return err +} + +func (w *workers) Stream(layer v1.Layer, f func() error) error { + // We don't care if it was loaded or not because the sync.Once will do it for us. + once, _ := w.onces.LoadOrStore(layer, &sync.Once{}) + + once.(*sync.Once).Do(func() { + w.errors.Store(layer, f()) + }) + + v, ok := w.errors.Load(layer) + if !ok || v == nil { + return nil + } + + return v.(error) +} + +type Pusher struct { + o *options + + // map[name.Repository]*repoWriter + writers sync.Map +} + +func NewPusher(options ...Option) (*Pusher, error) { + o, err := makeOptions(options...) + if err != nil { + return nil, err + } + + return newPusher(o), nil +} + +func newPusher(o *options) *Pusher { + if o.pusher != nil { + return o.pusher + } + return &Pusher{ + o: o, + } +} + +func (p *Pusher) writer(ctx context.Context, repo name.Repository, o *options) (*repoWriter, error) { + v, _ := p.writers.LoadOrStore(repo, &repoWriter{ + repo: repo, + o: o, + }) + rw := v.(*repoWriter) + return rw, rw.init(ctx) +} + +func (p *Pusher) Push(ctx context.Context, ref name.Reference, t Taggable) error { + w, err := p.writer(ctx, ref.Context(), p.o) + if err != nil { + return err + } + return w.writeManifest(ctx, ref, t) +} + +func (p *Pusher) Upload(ctx context.Context, repo name.Repository, l v1.Layer) error { + w, err := p.writer(ctx, repo, p.o) + if err != nil { + return err + } + return w.writeLayer(ctx, l) +} + +func (p *Pusher) Delete(ctx context.Context, ref name.Reference) error { + w, err := p.writer(ctx, ref.Context(), p.o) + if err != nil { + return err + } + + u := url.URL{ + Scheme: ref.Context().Registry.Scheme(), + Host: ref.Context().RegistryStr(), + Path: fmt.Sprintf("/v2/%s/manifests/%s", ref.Context().RepositoryStr(), ref.Identifier()), + } + + req, err := http.NewRequest(http.MethodDelete, u.String(), nil) + if err != nil { + return err + } + + resp, err := w.w.client.Do(req.WithContext(ctx)) + if err != nil { + return err + } + defer resp.Body.Close() + + return transport.CheckError(resp, http.StatusOK, http.StatusAccepted) + + // TODO(jason): If the manifest had a `subject`, and if the registry + // doesn't support Referrers, update the index pointed to by the + // subject's fallback tag to remove the descriptor for this manifest. +} + +type repoWriter struct { + repo name.Repository + o *options + once sync.Once + + w *writer + err error + + work *workers +} + +// this will run once per repoWriter instance +func (rw *repoWriter) init(ctx context.Context) error { + rw.once.Do(func() { + rw.work = &workers{} + rw.w, rw.err = makeWriter(ctx, rw.repo, nil, rw.o) + }) + return rw.err +} + +func (rw *repoWriter) writeDeps(ctx context.Context, m manifest) error { + if img, ok := m.(v1.Image); ok { + return rw.writeLayers(ctx, img) + } + + if idx, ok := m.(v1.ImageIndex); ok { + return rw.writeChildren(ctx, idx) + } + + // This has no deps, not an error (e.g. something you want to just PUT). + return nil +} + +type describable struct { + desc v1.Descriptor +} + +func (d describable) Digest() (v1.Hash, error) { + return d.desc.Digest, nil +} + +func (d describable) Size() (int64, error) { + return d.desc.Size, nil +} + +func (d describable) MediaType() (types.MediaType, error) { + return d.desc.MediaType, nil +} + +type tagManifest struct { + Taggable + partial.Describable +} + +func taggableToManifest(t Taggable) (manifest, error) { + if m, ok := t.(manifest); ok { + return m, nil + } + + if d, ok := t.(*Descriptor); ok { + if d.MediaType.IsIndex() { + return d.ImageIndex() + } + + if d.MediaType.IsImage() { + return d.Image() + } + + if d.MediaType.IsSchema1() { + return d.Schema1() + } + + return tagManifest{t, describable{d.toDesc()}}, nil + } + + desc := v1.Descriptor{ + // A reasonable default if Taggable doesn't implement MediaType. + MediaType: types.DockerManifestSchema2, + } + + b, err := t.RawManifest() + if err != nil { + return nil, err + } + + if wmt, ok := t.(withMediaType); ok { + desc.MediaType, err = wmt.MediaType() + if err != nil { + return nil, err + } + } + + desc.Digest, desc.Size, err = v1.SHA256(bytes.NewReader(b)) + if err != nil { + return nil, err + } + + return tagManifest{t, describable{desc}}, nil +} + +func (rw *repoWriter) writeManifest(ctx context.Context, ref name.Reference, t Taggable) error { + m, err := taggableToManifest(t) + if err != nil { + return err + } + + needDeps := true + + digest, err := m.Digest() + if errors.Is(err, stream.ErrNotComputed) { + if err := rw.writeDeps(ctx, m); err != nil { + return err + } + + needDeps = false + + digest, err = m.Digest() + if err != nil { + return err + } + } else if err != nil { + return err + } + + // This may be a lazy child where we have no ref until digest is computed. + if ref == nil { + ref = rw.repo.Digest(digest.String()) + } + + // For tags, we want to do this check outside of our Work.Do closure because + // we don't want to dedupe based on the manifest digest. + _, byTag := ref.(name.Tag) + if byTag { + if exists, err := rw.manifestExists(ctx, ref, t); err != nil { + return err + } else if exists { + return nil + } + } + + // The following work.Do will get deduped by digest, so it won't happen unless + // this tag happens to be the first commitManifest to run for that digest. + needPut := byTag + + if err := rw.work.Do(digest, func() error { + if !byTag { + if exists, err := rw.manifestExists(ctx, ref, t); err != nil { + return err + } else if exists { + return nil + } + } + + if needDeps { + if err := rw.writeDeps(ctx, m); err != nil { + return err + } + } + + needPut = false + return rw.commitManifest(ctx, ref, m) + }); err != nil { + return err + } + + if !needPut { + return nil + } + + // Only runs for tags that got deduped by digest. + return rw.commitManifest(ctx, ref, m) +} + +func (rw *repoWriter) writeChildren(ctx context.Context, idx v1.ImageIndex) error { + children, err := partial.Manifests(idx) + if err != nil { + return err + } + + g, ctx := errgroup.WithContext(ctx) + g.SetLimit(rw.o.jobs) + + for _, child := range children { + child := child + if err := rw.writeChild(ctx, child, g); err != nil { + return err + } + } + + return g.Wait() +} + +func (rw *repoWriter) writeChild(ctx context.Context, child partial.Describable, g *errgroup.Group) error { + switch child := child.(type) { + case v1.ImageIndex: + // For recursive index, we want to do a depth-first launching of goroutines + // to avoid deadlocking. + // + // Note that this is rare, so the impact of this should be really small. + return rw.writeManifest(ctx, nil, child) + case v1.Image: + g.Go(func() error { + return rw.writeManifest(ctx, nil, child) + }) + case v1.Layer: + g.Go(func() error { + return rw.writeLayer(ctx, child) + }) + default: + // This can't happen. + return fmt.Errorf("encountered unknown child: %T", child) + } + return nil +} + +// TODO: Consider caching some representation of the tags/digests in the destination +// repository as a hint to avoid this optimistic check in cases where we will most +// likely have to do a PUT anyway, e.g. if we are overwriting a tag we just wrote. +func (rw *repoWriter) manifestExists(ctx context.Context, ref name.Reference, t Taggable) (bool, error) { + f := &fetcher{ + target: ref.Context(), + client: rw.w.client, + } + + m, err := taggableToManifest(t) + if err != nil { + return false, err + } + + digest, err := m.Digest() + if err != nil { + // Possibly due to streaming layers. + return false, nil + } + got, err := f.headManifest(ctx, ref, allManifestMediaTypes) + if err != nil { + var terr *transport.Error + if errors.As(err, &terr) { + if terr.StatusCode == http.StatusNotFound { + return false, nil + } + + // We treat a 403 here as non-fatal because this existence check is an optimization and + // some registries will return a 403 instead of a 404 in certain situations. + // E.g. https://jfrog.atlassian.net/browse/RTFACT-13797 + if terr.StatusCode == http.StatusForbidden { + logs.Debug.Printf("manifestExists unexpected 403: %v", err) + return false, nil + } + } + + return false, err + } + + if digest != got.Digest { + // Mark that we saw this digest in the registry so we don't have to check it again. + rw.work.Do(got.Digest, nop) + + return false, nil + } + + if tag, ok := ref.(name.Tag); ok { + logs.Progress.Printf("existing manifest: %s@%s", tag.Identifier(), got.Digest) + } else { + logs.Progress.Print("existing manifest: ", got.Digest) + } + + return true, nil +} + +func (rw *repoWriter) commitManifest(ctx context.Context, ref name.Reference, m manifest) error { + if rw.o.progress != nil { + size, err := m.Size() + if err != nil { + return err + } + rw.o.progress.total(size) + } + + return rw.w.commitManifest(ctx, m, ref) +} + +func (rw *repoWriter) writeLayers(pctx context.Context, img v1.Image) error { + ls, err := img.Layers() + if err != nil { + return err + } + + g, ctx := errgroup.WithContext(pctx) + g.SetLimit(rw.o.jobs) + + for _, l := range ls { + l := l + + g.Go(func() error { + return rw.writeLayer(ctx, l) + }) + } + + mt, err := img.MediaType() + if err != nil { + return err + } + + if mt.IsSchema1() { + return g.Wait() + } + + cl, err := partial.ConfigLayer(img) + if errors.Is(err, stream.ErrNotComputed) { + if err := g.Wait(); err != nil { + return err + } + + cl, err := partial.ConfigLayer(img) + if err != nil { + return err + } + + return rw.writeLayer(pctx, cl) + } else if err != nil { + return err + } + + g.Go(func() error { + return rw.writeLayer(ctx, cl) + }) + + return g.Wait() +} + +func (rw *repoWriter) writeLayer(ctx context.Context, l v1.Layer) error { + // Skip any non-distributable things. + mt, err := l.MediaType() + if err != nil { + return err + } + if !mt.IsDistributable() && !rw.o.allowNondistributableArtifacts { + return nil + } + + digest, err := l.Digest() + if err != nil { + if errors.Is(err, stream.ErrNotComputed) { + return rw.lazyWriteLayer(ctx, l) + } + return err + } + + return rw.work.Do(digest, func() error { + if rw.o.progress != nil { + size, err := l.Size() + if err != nil { + return err + } + rw.o.progress.total(size) + } + return rw.w.uploadOne(ctx, l) + }) +} + +func (rw *repoWriter) lazyWriteLayer(ctx context.Context, l v1.Layer) error { + return rw.work.Stream(l, func() error { + if err := rw.w.uploadOne(ctx, l); err != nil { + return err + } + + // Mark this upload completed. + digest, err := l.Digest() + if err != nil { + return err + } + + rw.work.Do(digest, nop) + + if rw.o.progress != nil { + size, err := l.Size() + if err != nil { + return err + } + rw.o.progress.total(size) + } + + return nil + }) +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/referrers.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/referrers.go index b3db863d1..e30ca57ed 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/referrers.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/referrers.go @@ -15,21 +15,103 @@ package remote import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "strings" + "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/empty" + "github.com/google/go-containerregistry/pkg/v1/mutate" + "github.com/google/go-containerregistry/pkg/v1/remote/transport" + "github.com/google/go-containerregistry/pkg/v1/types" ) // Referrers returns a list of descriptors that refer to the given manifest digest. // // The subject manifest doesn't have to exist in the registry for there to be descriptors that refer to it. -func Referrers(d name.Digest, options ...Option) (*v1.IndexManifest, error) { - o, err := makeOptions(d.Context(), options...) +func Referrers(d name.Digest, options ...Option) (v1.ImageIndex, error) { + o, err := makeOptions(options...) + if err != nil { + return nil, err + } + return newPuller(o).referrers(o.context, d, o.filter) +} + +// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#referrers-tag-schema +func fallbackTag(d name.Digest) name.Tag { + return d.Context().Tag(strings.Replace(d.DigestStr(), ":", "-", 1)) +} + +func (f *fetcher) fetchReferrers(ctx context.Context, filter map[string]string, d name.Digest) (v1.ImageIndex, error) { + // Check the Referrers API endpoint first. + u := f.url("referrers", d.DigestStr()) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil) if err != nil { return nil, err } - f, err := makeFetcher(d, o) + req.Header.Set("Accept", string(types.OCIImageIndex)) + + resp, err := f.client.Do(req) if err != nil { return nil, err } - return f.fetchReferrers(o.context, o.filter, d) + defer resp.Body.Close() + + if err := transport.CheckError(resp, http.StatusOK, http.StatusNotFound, http.StatusBadRequest); err != nil { + return nil, err + } + + var b []byte + if resp.StatusCode == http.StatusOK { + b, err = io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + } else { + // The registry doesn't support the Referrers API endpoint, so we'll use the fallback tag scheme. + b, _, err = f.fetchManifest(ctx, fallbackTag(d), []types.MediaType{types.OCIImageIndex}) + var terr *transport.Error + if errors.As(err, &terr) && terr.StatusCode == http.StatusNotFound { + // Not found just means there are no attachments yet. Start with an empty manifest. + return empty.Index, nil + } else if err != nil { + return nil, err + } + } + + h, sz, err := v1.SHA256(bytes.NewReader(b)) + if err != nil { + return nil, err + } + idx := &remoteIndex{ + fetcher: *f, + ctx: ctx, + manifest: b, + mediaType: types.OCIImageIndex, + descriptor: &v1.Descriptor{ + Digest: h, + MediaType: types.OCIImageIndex, + Size: sz, + }, + } + return filterReferrersResponse(filter, idx), nil +} + +// If filter applied, filter out by artifactType. +// See https://github.com/opencontainers/distribution-spec/blob/main/spec.md#listing-referrers +func filterReferrersResponse(filter map[string]string, in v1.ImageIndex) v1.ImageIndex { + if filter == nil { + return in + } + v, ok := filter["artifactType"] + if !ok { + return in + } + return mutate.RemoveManifests(in, func(desc v1.Descriptor) bool { + return desc.ArtifactType != v + }) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/schema1.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/schema1.go new file mode 100644 index 000000000..4bc1c4c45 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/schema1.go @@ -0,0 +1,118 @@ +// Copyright 2023 Google LLC 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 remote + +import ( + "bytes" + "context" + "encoding/json" + + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/partial" + "github.com/google/go-containerregistry/pkg/v1/types" +) + +type schema1 struct { + ref name.Reference + ctx context.Context + fetcher fetcher + manifest []byte + mediaType types.MediaType + descriptor *v1.Descriptor +} + +func (s *schema1) Layers() ([]v1.Layer, error) { + m := schema1Manifest{} + if err := json.NewDecoder(bytes.NewReader(s.manifest)).Decode(&m); err != nil { + return nil, err + } + + layers := []v1.Layer{} + for i := len(m.FSLayers) - 1; i >= 0; i-- { + fsl := m.FSLayers[i] + + h, err := v1.NewHash(fsl.BlobSum) + if err != nil { + return nil, err + } + l, err := s.LayerByDigest(h) + if err != nil { + return nil, err + } + layers = append(layers, l) + } + + return layers, nil +} + +func (s *schema1) MediaType() (types.MediaType, error) { + return s.mediaType, nil +} + +func (s *schema1) Size() (int64, error) { + return s.descriptor.Size, nil +} + +func (s *schema1) ConfigName() (v1.Hash, error) { + return partial.ConfigName(s) +} + +func (s *schema1) ConfigFile() (*v1.ConfigFile, error) { + return nil, newErrSchema1(s.mediaType) +} + +func (s *schema1) RawConfigFile() ([]byte, error) { + return []byte("{}"), nil +} + +func (s *schema1) Digest() (v1.Hash, error) { + return s.descriptor.Digest, nil +} + +func (s *schema1) Manifest() (*v1.Manifest, error) { + return nil, newErrSchema1(s.mediaType) +} + +func (s *schema1) RawManifest() ([]byte, error) { + return s.manifest, nil +} + +func (s *schema1) LayerByDigest(h v1.Hash) (v1.Layer, error) { + l, err := partial.CompressedToLayer(&remoteLayer{ + fetcher: s.fetcher, + ctx: s.ctx, + digest: h, + }) + if err != nil { + return nil, err + } + return &MountableLayer{ + Layer: l, + Reference: s.ref.Context().Digest(h.String()), + }, nil +} + +func (s *schema1) LayerByDiffID(v1.Hash) (v1.Layer, error) { + return nil, newErrSchema1(s.mediaType) +} + +type fslayer struct { + BlobSum string `json:"blobSum"` +} + +type schema1Manifest struct { + FSLayers []fslayer `json:"fsLayers"` +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/error.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/error.go index c0e433730..482a4adee 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/error.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/error.go @@ -34,6 +34,9 @@ type Error struct { Request *http.Request // The raw body if we couldn't understand it. rawBody string + + // Bit of a hack to make it easier to force a retry. + temporary bool } // Check that Error implements error @@ -72,6 +75,10 @@ func (e *Error) responseErr() string { // Temporary returns whether the request that preceded the error is temporary. func (e *Error) Temporary() bool { + if e.temporary { + return true + } + if len(e.Errors) == 0 { _, ok := temporaryStatusCodes[e.StatusCode] return ok @@ -153,21 +160,37 @@ func CheckError(resp *http.Response, codes ...int) error { return nil } } + b, err := io.ReadAll(resp.Body) if err != nil { return err } + return makeError(resp, b) +} + +func makeError(resp *http.Response, body []byte) *Error { // https://github.com/docker/distribution/blob/master/docs/spec/api.md#errors structuredError := &Error{} // This can fail if e.g. the response body is not valid JSON. That's fine, // we'll construct an appropriate error string from the body and status code. - _ = json.Unmarshal(b, structuredError) + _ = json.Unmarshal(body, structuredError) - structuredError.rawBody = string(b) + structuredError.rawBody = string(body) structuredError.StatusCode = resp.StatusCode structuredError.Request = resp.Request return structuredError } + +func retryError(resp *http.Response) error { + b, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + + rerr := makeError(resp, b) + rerr.temporary = true + return rerr +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/retry.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/retry.go index e5621e305..093f55d02 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/retry.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/retry.go @@ -100,7 +100,7 @@ func (t *retryTransport) RoundTrip(in *http.Request) (out *http.Response, err er if out != nil { for _, code := range t.codes { if out.StatusCode == code { - return CheckError(out) + return retryError(out) } } } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go index 5dbaa7c23..f4369e2a0 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go @@ -25,17 +25,17 @@ import ( "net/url" "sort" "strings" + "sync" "github.com/google/go-containerregistry/internal/redact" "github.com/google/go-containerregistry/internal/retry" + "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/logs" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" - "github.com/google/go-containerregistry/pkg/v1/partial" "github.com/google/go-containerregistry/pkg/v1/remote/transport" "github.com/google/go-containerregistry/pkg/v1/stream" "github.com/google/go-containerregistry/pkg/v1/types" - "golang.org/x/sync/errgroup" ) // Taggable is an interface that enables a manifest PUT (e.g. for tagging). @@ -45,146 +45,101 @@ type Taggable interface { // Write pushes the provided img to the specified image reference. func Write(ref name.Reference, img v1.Image, options ...Option) (rerr error) { - o, err := makeOptions(ref.Context(), options...) + o, err := makeOptions(options...) if err != nil { return err } + if o.progress != nil { + defer func() { o.progress.Close(rerr) }() + } + return newPusher(o).Push(o.context, ref, img) +} + +// writer writes the elements of an image to a remote image reference. +type writer struct { + repo name.Repository + auth authn.Authenticator + transport http.RoundTripper + + client *http.Client - var p *progress - if o.updates != nil { - p = &progress{updates: o.updates} - p.lastUpdate = &v1.Update{} - p.lastUpdate.Total, err = countImage(img, o.allowNondistributableArtifacts) + progress *progress + backoff Backoff + predicate retry.Predicate + + scopeLock sync.Mutex + // Keep track of scopes that we have already requested. + scopeSet map[string]struct{} + scopes []string +} + +func makeWriter(ctx context.Context, repo name.Repository, ls []v1.Layer, o *options) (*writer, error) { + auth := o.auth + if o.keychain != nil { + kauth, err := o.keychain.Resolve(repo) if err != nil { - return err + return nil, err } - defer close(o.updates) - defer func() { _ = p.err(rerr) }() + auth = kauth } - return writeImage(o.context, ref, img, o, p) -} - -func writeImage(ctx context.Context, ref name.Reference, img v1.Image, o *options, progress *progress) error { - ls, err := img.Layers() + scopes := scopesForUploadingImage(repo, ls) + tr, err := transport.NewWithContext(ctx, repo.Registry, auth, o.transport, scopes) if err != nil { - return err + return nil, err } - scopes := scopesForUploadingImage(ref.Context(), ls) - tr, err := transport.NewWithContext(o.context, ref.Context().Registry, o.auth, o.transport, scopes) - if err != nil { - return err + + scopeSet := map[string]struct{}{} + for _, scope := range scopes { + scopeSet[scope] = struct{}{} } - w := writer{ - repo: ref.Context(), + return &writer{ + repo: repo, client: &http.Client{Transport: tr}, - progress: progress, + auth: auth, + transport: o.transport, + progress: o.progress, backoff: o.retryBackoff, predicate: o.retryPredicate, - } + scopes: scopes, + scopeSet: scopeSet, + }, nil +} - // Upload individual blobs and collect any errors. - blobChan := make(chan v1.Layer, 2*o.jobs) - g, gctx := errgroup.WithContext(ctx) - for i := 0; i < o.jobs; i++ { - // Start N workers consuming blobs to upload. - g.Go(func() error { - for b := range blobChan { - if err := w.uploadOne(gctx, b); err != nil { - return err - } - } - return nil - }) +// url returns a url.Url for the specified path in the context of this remote image reference. +func (w *writer) url(path string) url.URL { + return url.URL{ + Scheme: w.repo.Registry.Scheme(), + Host: w.repo.RegistryStr(), + Path: path, } +} - // Upload individual layers in goroutines and collect any errors. - // If we can dedupe by the layer digest, try to do so. If we can't determine - // the digest for whatever reason, we can't dedupe and might re-upload. - g.Go(func() error { - defer close(blobChan) - uploaded := map[v1.Hash]bool{} - for _, l := range ls { - l := l +func (w *writer) maybeUpdateScopes(ctx context.Context, ml *MountableLayer) error { + if ml.Reference.Context().String() == w.repo.String() { + return nil + } + if ml.Reference.Context().Registry.String() != w.repo.Registry.String() { + return nil + } - // Handle foreign layers. - mt, err := l.MediaType() - if err != nil { - return err - } - if !mt.IsDistributable() && !o.allowNondistributableArtifacts { - continue - } + scope := ml.Reference.Scope(transport.PullScope) - // Streaming layers calculate their digests while uploading them. Assume - // an error here indicates we need to upload the layer. - h, err := l.Digest() - if err == nil { - // If we can determine the layer's digest ahead of - // time, use it to dedupe uploads. - if uploaded[h] { - continue // Already uploading. - } - uploaded[h] = true - } - select { - case blobChan <- l: - case <-gctx.Done(): - return gctx.Err() - } - } - return nil - }) + w.scopeLock.Lock() + defer w.scopeLock.Unlock() - if l, err := partial.ConfigLayer(img); err != nil { - // We can't read the ConfigLayer, possibly because of streaming layers, - // since the layer DiffIDs haven't been calculated yet. Attempt to wait - // for the other layers to be uploaded, then try the config again. - if err := g.Wait(); err != nil { - return err - } + if _, ok := w.scopeSet[scope]; !ok { + w.scopeSet[scope] = struct{}{} + w.scopes = append(w.scopes, scope) - // Now that all the layers are uploaded, try to upload the config file blob. - l, err := partial.ConfigLayer(img) + logs.Debug.Printf("Refreshing token to add scope %q", scope) + wt, err := transport.NewWithContext(ctx, w.repo.Registry, w.auth, w.transport, w.scopes) if err != nil { return err } - if err := w.uploadOne(ctx, l); err != nil { - return err - } - } else { - // We *can* read the ConfigLayer, so upload it concurrently with the layers. - g.Go(func() error { - return w.uploadOne(gctx, l) - }) - - // Wait for the layers + config. - if err := g.Wait(); err != nil { - return err - } + w.client = &http.Client{Transport: wt} } - // With all of the constituent elements uploaded, upload the manifest - // to commit the image. - return w.commitManifest(ctx, img, ref) -} - -// writer writes the elements of an image to a remote image reference. -type writer struct { - repo name.Repository - client *http.Client - - progress *progress - backoff Backoff - predicate retry.Predicate -} - -// url returns a url.Url for the specified path in the context of this remote image reference. -func (w *writer) url(path string) url.URL { - return url.URL{ - Scheme: w.repo.Registry.Scheme(), - Host: w.repo.RegistryStr(), - Path: path, - } + return nil } // nextLocation extracts the fully-qualified URL to which we should send the next request in an upload sequence. @@ -228,30 +183,6 @@ func (w *writer) checkExistingBlob(ctx context.Context, h v1.Hash) (bool, error) return resp.StatusCode == http.StatusOK, nil } -// checkExistingManifest checks if a manifest exists already in the repository -// by making a HEAD request to the manifest API. -func (w *writer) checkExistingManifest(ctx context.Context, h v1.Hash, mt types.MediaType) (bool, error) { - u := w.url(fmt.Sprintf("/v2/%s/manifests/%s", w.repo.RepositoryStr(), h.String())) - - req, err := http.NewRequest(http.MethodHead, u.String(), nil) - if err != nil { - return false, err - } - req.Header.Set("Accept", string(mt)) - - resp, err := w.client.Do(req.WithContext(ctx)) - if err != nil { - return false, err - } - defer resp.Body.Close() - - if err := transport.CheckError(resp, http.StatusOK, http.StatusNotFound); err != nil { - return false, err - } - - return resp.StatusCode == http.StatusOK, nil -} - // initiateUpload initiates the blob upload, which starts with a POST that can // optionally include the hash of the layer and a list of repositories from // which that layer might be read. On failure, an error is returned. @@ -279,6 +210,11 @@ func (w *writer) initiateUpload(ctx context.Context, from, mount, origin string) req.Header.Set("Content-Type", "application/json") resp, err := w.client.Do(req.WithContext(ctx)) if err != nil { + if origin != "" && origin != w.repo.RegistryStr() { + // https://github.com/google/go-containerregistry/issues/1679 + logs.Warn.Printf("retrying without mount: %v", err) + return w.initiateUpload(ctx, "", "", "") + } return "", false, err } defer resp.Body.Close() @@ -421,6 +357,9 @@ func (w *writer) uploadOne(ctx context.Context, l v1.Layer) error { mount = h.String() } if ml, ok := l.(*MountableLayer); ok { + if err := w.maybeUpdateScopes(ctx, ml); err != nil { + return err + } from = ml.Reference.Context().RepositoryStr() origin = ml.Reference.Context().RegistryStr() } @@ -474,69 +413,6 @@ func (w *writer) uploadOne(ctx context.Context, l v1.Layer) error { return retry.Retry(tryUpload, w.predicate, w.backoff) } -type withLayer interface { - Layer(v1.Hash) (v1.Layer, error) -} - -func (w *writer) writeIndex(ctx context.Context, ref name.Reference, ii v1.ImageIndex, options ...Option) error { - index, err := ii.IndexManifest() - if err != nil { - return err - } - - o, err := makeOptions(ref.Context(), options...) - if err != nil { - return err - } - - // TODO(#803): Pipe through remote.WithJobs and upload these in parallel. - for _, desc := range index.Manifests { - ref := ref.Context().Digest(desc.Digest.String()) - exists, err := w.checkExistingManifest(ctx, desc.Digest, desc.MediaType) - if err != nil { - return err - } - if exists { - logs.Progress.Print("existing manifest: ", desc.Digest) - continue - } - - switch desc.MediaType { - case types.OCIImageIndex, types.DockerManifestList: - ii, err := ii.ImageIndex(desc.Digest) - if err != nil { - return err - } - if err := w.writeIndex(ctx, ref, ii, options...); err != nil { - return err - } - case types.OCIManifestSchema1, types.DockerManifestSchema2: - img, err := ii.Image(desc.Digest) - if err != nil { - return err - } - if err := writeImage(ctx, ref, img, o, w.progress); err != nil { - return err - } - default: - // Workaround for #819. - if wl, ok := ii.(withLayer); ok { - layer, err := wl.Layer(desc.Digest) - if err != nil { - return err - } - if err := w.uploadOne(ctx, layer); err != nil { - return err - } - } - } - } - - // With all of the constituent elements uploaded, upload the manifest - // to commit the image. - return w.commitManifest(ctx, ii, ref) -} - type withMediaType interface { MediaType() (types.MediaType, error) } @@ -655,10 +531,7 @@ func (w *writer) commitSubjectReferrers(ctx context.Context, sub name.Digest, ad return im.Manifests[i].Digest.String() < im.Manifests[j].Digest.String() }) logs.Progress.Printf("updating fallback tag %s with new referrer", t.Identifier()) - if err := w.commitManifest(ctx, fallbackTaggable{im}, t); err != nil { - return err - } - return nil + return w.commitManifest(ctx, fallbackTaggable{im}, t) } type fallbackTaggable struct { @@ -770,183 +643,26 @@ func scopesForUploadingImage(repo name.Repository, layers []v1.Layer) []string { // WriteIndex will attempt to push all of the referenced manifests before // attempting to push the ImageIndex, to retain referential integrity. func WriteIndex(ref name.Reference, ii v1.ImageIndex, options ...Option) (rerr error) { - o, err := makeOptions(ref.Context(), options...) + o, err := makeOptions(options...) if err != nil { return err } - - scopes := []string{ref.Scope(transport.PushScope)} - tr, err := transport.NewWithContext(o.context, ref.Context().Registry, o.auth, o.transport, scopes) - if err != nil { - return err - } - w := writer{ - repo: ref.Context(), - client: &http.Client{Transport: tr}, - backoff: o.retryBackoff, - predicate: o.retryPredicate, - } - - if o.updates != nil { - w.progress = &progress{updates: o.updates} - w.progress.lastUpdate = &v1.Update{} - - defer close(o.updates) - defer func() { w.progress.err(rerr) }() - - w.progress.lastUpdate.Total, err = countIndex(ii, o.allowNondistributableArtifacts) - if err != nil { - return err - } + if o.progress != nil { + defer func() { o.progress.Close(rerr) }() } - - return w.writeIndex(o.context, ref, ii, options...) -} - -// countImage counts the total size of all layers + config blob + manifest for -// an image. It de-dupes duplicate layers. -func countImage(img v1.Image, allowNondistributableArtifacts bool) (int64, error) { - var total int64 - ls, err := img.Layers() - if err != nil { - return 0, err - } - seen := map[v1.Hash]bool{} - for _, l := range ls { - // Handle foreign layers. - mt, err := l.MediaType() - if err != nil { - return 0, err - } - if !mt.IsDistributable() && !allowNondistributableArtifacts { - continue - } - - // TODO: support streaming layers which update the total count as they write. - if _, ok := l.(*stream.Layer); ok { - return 0, errors.New("cannot use stream.Layer and WithProgress") - } - - // Dedupe layers. - d, err := l.Digest() - if err != nil { - return 0, err - } - if seen[d] { - continue - } - seen[d] = true - - size, err := l.Size() - if err != nil { - return 0, err - } - total += size - } - b, err := img.RawConfigFile() - if err != nil { - return 0, err - } - total += int64(len(b)) - size, err := img.Size() - if err != nil { - return 0, err - } - total += size - return total, nil -} - -// countIndex counts the total size of all images + sub-indexes for an index. -// It does not attempt to de-dupe duplicate images, etc. -func countIndex(idx v1.ImageIndex, allowNondistributableArtifacts bool) (int64, error) { - var total int64 - mf, err := idx.IndexManifest() - if err != nil { - return 0, err - } - - for _, desc := range mf.Manifests { - switch desc.MediaType { - case types.OCIImageIndex, types.DockerManifestList: - sidx, err := idx.ImageIndex(desc.Digest) - if err != nil { - return 0, err - } - size, err := countIndex(sidx, allowNondistributableArtifacts) - if err != nil { - return 0, err - } - total += size - case types.OCIManifestSchema1, types.DockerManifestSchema2: - simg, err := idx.Image(desc.Digest) - if err != nil { - return 0, err - } - size, err := countImage(simg, allowNondistributableArtifacts) - if err != nil { - return 0, err - } - total += size - default: - // Workaround for #819. - if wl, ok := idx.(withLayer); ok { - layer, err := wl.Layer(desc.Digest) - if err != nil { - return 0, err - } - size, err := layer.Size() - if err != nil { - return 0, err - } - total += size - } - } - } - - size, err := idx.Size() - if err != nil { - return 0, err - } - total += size - return total, nil + return newPusher(o).Push(o.context, ref, ii) } // WriteLayer uploads the provided Layer to the specified repo. func WriteLayer(repo name.Repository, layer v1.Layer, options ...Option) (rerr error) { - o, err := makeOptions(repo, options...) - if err != nil { - return err - } - scopes := scopesForUploadingImage(repo, []v1.Layer{layer}) - tr, err := transport.NewWithContext(o.context, repo.Registry, o.auth, o.transport, scopes) + o, err := makeOptions(options...) if err != nil { return err } - w := writer{ - repo: repo, - client: &http.Client{Transport: tr}, - backoff: o.retryBackoff, - predicate: o.retryPredicate, - } - - if o.updates != nil { - w.progress = &progress{updates: o.updates} - w.progress.lastUpdate = &v1.Update{} - - defer close(o.updates) - defer func() { w.progress.err(rerr) }() - - // TODO: support streaming layers which update the total count as they write. - if _, ok := layer.(*stream.Layer); ok { - return errors.New("cannot use stream.Layer and WithProgress") - } - size, err := layer.Size() - if err != nil { - return err - } - w.progress.total(size) + if o.progress != nil { + defer func() { o.progress.Close(rerr) }() } - return w.uploadOne(o.context, layer) + return newPusher(o).Upload(o.context, repo, layer) } // Tag adds a tag to the given Taggable via PUT /v2/.../manifests/ @@ -976,28 +692,9 @@ func Tag(tag name.Tag, t Taggable, options ...Option) error { // should ensure that all blobs or manifests that are referenced by t exist // in the target registry. func Put(ref name.Reference, t Taggable, options ...Option) error { - o, err := makeOptions(ref.Context(), options...) - if err != nil { - return err - } - scopes := []string{ref.Scope(transport.PushScope)} - - // TODO: This *always* does a token exchange. For some registries, - // that's pretty slow. Some ideas; - // * Tag could take a list of tags. - // * Allow callers to pass in a transport.Transport, typecheck - // it to allow them to reuse the transport across multiple calls. - // * WithTag option to do multiple manifest PUTs in commitManifest. - tr, err := transport.NewWithContext(o.context, ref.Context().Registry, o.auth, o.transport, scopes) + o, err := makeOptions(options...) if err != nil { return err } - w := writer{ - repo: ref.Context(), - client: &http.Client{Transport: tr}, - backoff: o.retryBackoff, - predicate: o.retryPredicate, - } - - return w.commitManifest(o.context, t, ref) + return newPusher(o).Push(o.context, ref, t) } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/stream/layer.go b/vendor/github.com/google/go-containerregistry/pkg/v1/stream/layer.go index d6f2df8f0..2b0354479 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/stream/layer.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/stream/layer.go @@ -130,6 +130,8 @@ func (l *Layer) Uncompressed() (io.ReadCloser, error) { // Compressed implements v1.Layer. func (l *Layer) Compressed() (io.ReadCloser, error) { + l.mu.Lock() + defer l.mu.Unlock() if l.consumed { return nil, ErrConsumed } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/README.md b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/README.md new file mode 100644 index 000000000..03f339b06 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/README.md @@ -0,0 +1,280 @@ +# `tarball` + +[![GoDoc](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/tarball?status.svg)](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/tarball) + +This package produces tarballs that can consumed via `docker load`. Note +that this is a _different_ format from the [`legacy`](/pkg/legacy/tarball) +tarballs that are produced by `docker save`, but this package is still able to +read the legacy tarballs produced by `docker save`. + +## Usage + +```go +package main + +import ( + "os" + + "github.com/google/go-containerregistry/pkg/name" + "github.com/google/go-containerregistry/pkg/v1/tarball" +) + +func main() { + // Read a tarball from os.Args[1] that contains ubuntu. + tag, err := name.NewTag("ubuntu") + if err != nil { + panic(err) + } + img, err := tarball.ImageFromPath(os.Args[1], &tag) + if err != nil { + panic(err) + } + + // Write that tarball to os.Args[2] with a different tag. + newTag, err := name.NewTag("ubuntu:newest") + if err != nil { + panic(err) + } + f, err := os.Create(os.Args[2]) + if err != nil { + panic(err) + } + defer f.Close() + + if err := tarball.Write(newTag, img, f); err != nil { + panic(err) + } +} +``` + +## Structure + +

+ +

+ +Let's look at what happens when we write out a tarball: + + +### `ubuntu:latest` + +``` +$ crane pull ubuntu ubuntu.tar && mkdir ubuntu && tar xf ubuntu.tar -C ubuntu && rm ubuntu.tar +$ tree ubuntu/ +ubuntu/ +├── 423ae2b273f4c17ceee9e8482fa8d071d90c7d052ae208e1fe4963fceb3d6954.tar.gz +├── b6b53be908de2c0c78070fff0a9f04835211b3156c4e73785747af365e71a0d7.tar.gz +├── de83a2304fa1f7c4a13708a0d15b9704f5945c2be5cbb2b3ed9b2ccb718d0b3d.tar.gz +├── f9a83bce3af0648efaa60b9bb28225b09136d2d35d0bed25ac764297076dec1b.tar.gz +├── manifest.json +└── sha256:72300a873c2ca11c70d0c8642177ce76ff69ae04d61a5813ef58d40ff66e3e7c + +0 directories, 6 files +``` + +There are a couple interesting files here. + +`manifest.json` is the entrypoint: a list of [`tarball.Descriptor`s](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/tarball#Descriptor) +that describe the images contained in this tarball. + +For each image, this has the `RepoTags` (how it was pulled), a `Config` file +that points to the image's config file, a list of `Layers`, and (optionally) +`LayerSources`. + +``` +$ jq < ubuntu/manifest.json +[ + { + "Config": "sha256:72300a873c2ca11c70d0c8642177ce76ff69ae04d61a5813ef58d40ff66e3e7c", + "RepoTags": [ + "ubuntu" + ], + "Layers": [ + "423ae2b273f4c17ceee9e8482fa8d071d90c7d052ae208e1fe4963fceb3d6954.tar.gz", + "de83a2304fa1f7c4a13708a0d15b9704f5945c2be5cbb2b3ed9b2ccb718d0b3d.tar.gz", + "f9a83bce3af0648efaa60b9bb28225b09136d2d35d0bed25ac764297076dec1b.tar.gz", + "b6b53be908de2c0c78070fff0a9f04835211b3156c4e73785747af365e71a0d7.tar.gz" + ] + } +] +``` + +The config file and layers are exactly what you would expect, and match the +registry representations of the same artifacts. You'll notice that the +`manifest.json` contains similar information as the registry manifest, but isn't +quite the same: + +``` +$ crane manifest ubuntu@sha256:0925d086715714114c1988f7c947db94064fd385e171a63c07730f1fa014e6f9 +{ + "schemaVersion": 2, + "mediaType": "application/vnd.docker.distribution.manifest.v2+json", + "config": { + "mediaType": "application/vnd.docker.container.image.v1+json", + "size": 3408, + "digest": "sha256:72300a873c2ca11c70d0c8642177ce76ff69ae04d61a5813ef58d40ff66e3e7c" + }, + "layers": [ + { + "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", + "size": 26692096, + "digest": "sha256:423ae2b273f4c17ceee9e8482fa8d071d90c7d052ae208e1fe4963fceb3d6954" + }, + { + "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", + "size": 35365, + "digest": "sha256:de83a2304fa1f7c4a13708a0d15b9704f5945c2be5cbb2b3ed9b2ccb718d0b3d" + }, + { + "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", + "size": 852, + "digest": "sha256:f9a83bce3af0648efaa60b9bb28225b09136d2d35d0bed25ac764297076dec1b" + }, + { + "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", + "size": 163, + "digest": "sha256:b6b53be908de2c0c78070fff0a9f04835211b3156c4e73785747af365e71a0d7" + } + ] +} +``` + +This makes it difficult to maintain image digests when roundtripping images +through the tarball format, so it's not a great format if you care about +provenance. + +The ubuntu example didn't have any `LayerSources` -- let's look at another image +that does. + +### `hello-world:nanoserver` + +``` +$ crane pull hello-world:nanoserver@sha256:63c287625c2b0b72900e562de73c0e381472a83b1b39217aef3856cd398eca0b nanoserver.tar +$ mkdir nanoserver && tar xf nanoserver.tar -C nanoserver && rm nanoserver.tar +$ tree nanoserver/ +nanoserver/ +├── 10d1439be4eb8819987ec2e9c140d44d74d6b42a823d57fe1953bd99948e1bc0.tar.gz +├── a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053.tar.gz +├── be21f08f670160cbae227e3053205b91d6bfa3de750b90c7e00bd2c511ccb63a.tar.gz +├── manifest.json +└── sha256:bc5d255ea81f83c8c38a982a6d29a6f2198427d258aea5f166e49856896b2da6 + +0 directories, 5 files + +$ jq < nanoserver/manifest.json +[ + { + "Config": "sha256:bc5d255ea81f83c8c38a982a6d29a6f2198427d258aea5f166e49856896b2da6", + "RepoTags": [ + "index.docker.io/library/hello-world:i-was-a-digest" + ], + "Layers": [ + "a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053.tar.gz", + "be21f08f670160cbae227e3053205b91d6bfa3de750b90c7e00bd2c511ccb63a.tar.gz", + "10d1439be4eb8819987ec2e9c140d44d74d6b42a823d57fe1953bd99948e1bc0.tar.gz" + ], + "LayerSources": { + "sha256:26fd2d9d4c64a4f965bbc77939a454a31b607470f430b5d69fc21ded301fa55e": { + "mediaType": "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip", + "size": 101145811, + "digest": "sha256:a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053", + "urls": [ + "https://mcr.microsoft.com/v2/windows/nanoserver/blobs/sha256:a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053" + ] + } + } + } +] +``` + +A couple things to note about this `manifest.json` versus the other: +* The `RepoTags` field is a bit weird here. `hello-world` is a multi-platform + image, so We had to pull this image by digest, since we're (I'm) on + amd64/linux and wanted to grab a windows image. Since the tarball format + expects a tag under `RepoTags`, and we didn't pull by tag, we replace the + digest with a sentinel `i-was-a-digest` "tag" to appease docker. +* The `LayerSources` has enough information to reconstruct the foreign layers + pointer when pushing/pulling from the registry. For legal reasons, microsoft + doesn't want anyone but them to serve windows base images, so the mediaType + here indicates a "foreign" or "non-distributable" layer with an URL for where + you can download it from microsoft (see the [OCI + image-spec](https://github.com/opencontainers/image-spec/blob/master/layer.md#non-distributable-layers)). + +We can look at what's in the registry to explain both of these things: +``` +$ crane manifest hello-world:nanoserver | jq . +{ + "manifests": [ + { + "digest": "sha256:63c287625c2b0b72900e562de73c0e381472a83b1b39217aef3856cd398eca0b", + "mediaType": "application/vnd.docker.distribution.manifest.v2+json", + "platform": { + "architecture": "amd64", + "os": "windows", + "os.version": "10.0.17763.1040" + }, + "size": 1124 + } + ], + "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json", + "schemaVersion": 2 +} + + +# Note the media type and "urls" field. +$ crane manifest hello-world:nanoserver@sha256:63c287625c2b0b72900e562de73c0e381472a83b1b39217aef3856cd398eca0b | jq . +{ + "schemaVersion": 2, + "mediaType": "application/vnd.docker.distribution.manifest.v2+json", + "config": { + "mediaType": "application/vnd.docker.container.image.v1+json", + "size": 1721, + "digest": "sha256:bc5d255ea81f83c8c38a982a6d29a6f2198427d258aea5f166e49856896b2da6" + }, + "layers": [ + { + "mediaType": "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip", + "size": 101145811, + "digest": "sha256:a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053", + "urls": [ + "https://mcr.microsoft.com/v2/windows/nanoserver/blobs/sha256:a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053" + ] + }, + { + "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", + "size": 1669, + "digest": "sha256:be21f08f670160cbae227e3053205b91d6bfa3de750b90c7e00bd2c511ccb63a" + }, + { + "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", + "size": 949, + "digest": "sha256:10d1439be4eb8819987ec2e9c140d44d74d6b42a823d57fe1953bd99948e1bc0" + } + ] +} +``` + +The `LayerSources` map is keyed by the diffid. Note that `sha256:26fd2d9d4c64a4f965bbc77939a454a31b607470f430b5d69fc21ded301fa55e` matches the first layer in the config file: +``` +$ jq '.[0].LayerSources' < nanoserver/manifest.json +{ + "sha256:26fd2d9d4c64a4f965bbc77939a454a31b607470f430b5d69fc21ded301fa55e": { + "mediaType": "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip", + "size": 101145811, + "digest": "sha256:a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053", + "urls": [ + "https://mcr.microsoft.com/v2/windows/nanoserver/blobs/sha256:a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053" + ] + } +} + +$ jq < nanoserver/sha256\:bc5d255ea81f83c8c38a982a6d29a6f2198427d258aea5f166e49856896b2da6 | jq .rootfs +{ + "type": "layers", + "diff_ids": [ + "sha256:26fd2d9d4c64a4f965bbc77939a454a31b607470f430b5d69fc21ded301fa55e", + "sha256:601cf7d78c62e4b4d32a7bbf96a17606a9cea5bd9d22ffa6f34aa431d056b0e8", + "sha256:a1e1a3bf6529adcce4d91dce2cad86c2604a66b507ccbc4d2239f3da0ec5aab9" + ] +} +``` diff --git a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginversion/pluginversionlist/usage.gen.go b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/doc.go similarity index 70% rename from vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginversion/pluginversionlist/usage.gen.go rename to vendor/github.com/google/go-containerregistry/pkg/v1/tarball/doc.go index a81068e33..4eb79bb4e 100644 --- a/vendor/github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginversion/pluginversionlist/usage.gen.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/doc.go @@ -1,10 +1,10 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2018 Google LLC 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 +// 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, @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Generated. DO NOT EDIT. - -package pluginversionlist - -import _ "github.com/bufbuild/buf/private/usage" +// Package tarball provides facilities for reading/writing v1.Images from/to +// a tarball on-disk. +package tarball diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/image.go b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/image.go new file mode 100644 index 000000000..c984f3c8f --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/image.go @@ -0,0 +1,429 @@ +// Copyright 2018 Google LLC 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 tarball + +import ( + "archive/tar" + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "os" + "path" + "path/filepath" + "sync" + + comp "github.com/google/go-containerregistry/internal/compression" + "github.com/google/go-containerregistry/pkg/compression" + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/partial" + "github.com/google/go-containerregistry/pkg/v1/types" +) + +type image struct { + opener Opener + manifest *Manifest + config []byte + imgDescriptor *Descriptor + + tag *name.Tag +} + +type uncompressedImage struct { + *image +} + +type compressedImage struct { + *image + manifestLock sync.Mutex // Protects manifest + manifest *v1.Manifest +} + +var _ partial.UncompressedImageCore = (*uncompressedImage)(nil) +var _ partial.CompressedImageCore = (*compressedImage)(nil) + +// Opener is a thunk for opening a tar file. +type Opener func() (io.ReadCloser, error) + +func pathOpener(path string) Opener { + return func() (io.ReadCloser, error) { + return os.Open(path) + } +} + +// ImageFromPath returns a v1.Image from a tarball located on path. +func ImageFromPath(path string, tag *name.Tag) (v1.Image, error) { + return Image(pathOpener(path), tag) +} + +// LoadManifest load manifest +func LoadManifest(opener Opener) (Manifest, error) { + m, err := extractFileFromTar(opener, "manifest.json") + if err != nil { + return nil, err + } + defer m.Close() + + var manifest Manifest + + if err := json.NewDecoder(m).Decode(&manifest); err != nil { + return nil, err + } + return manifest, nil +} + +// Image exposes an image from the tarball at the provided path. +func Image(opener Opener, tag *name.Tag) (v1.Image, error) { + img := &image{ + opener: opener, + tag: tag, + } + if err := img.loadTarDescriptorAndConfig(); err != nil { + return nil, err + } + + // Peek at the first layer and see if it's compressed. + if len(img.imgDescriptor.Layers) > 0 { + compressed, err := img.areLayersCompressed() + if err != nil { + return nil, err + } + if compressed { + c := compressedImage{ + image: img, + } + return partial.CompressedToImage(&c) + } + } + + uc := uncompressedImage{ + image: img, + } + return partial.UncompressedToImage(&uc) +} + +func (i *image) MediaType() (types.MediaType, error) { + return types.DockerManifestSchema2, nil +} + +// Descriptor stores the manifest data for a single image inside a `docker save` tarball. +type Descriptor struct { + Config string + RepoTags []string + Layers []string + + // Tracks foreign layer info. Key is DiffID. + LayerSources map[v1.Hash]v1.Descriptor `json:",omitempty"` +} + +// Manifest represents the manifests of all images as the `manifest.json` file in a `docker save` tarball. +type Manifest []Descriptor + +func (m Manifest) findDescriptor(tag *name.Tag) (*Descriptor, error) { + if tag == nil { + if len(m) != 1 { + return nil, errors.New("tarball must contain only a single image to be used with tarball.Image") + } + return &(m)[0], nil + } + for _, img := range m { + for _, tagStr := range img.RepoTags { + repoTag, err := name.NewTag(tagStr) + if err != nil { + return nil, err + } + + // Compare the resolved names, since there are several ways to specify the same tag. + if repoTag.Name() == tag.Name() { + return &img, nil + } + } + } + return nil, fmt.Errorf("tag %s not found in tarball", tag) +} + +func (i *image) areLayersCompressed() (bool, error) { + if len(i.imgDescriptor.Layers) == 0 { + return false, errors.New("0 layers found in image") + } + layer := i.imgDescriptor.Layers[0] + blob, err := extractFileFromTar(i.opener, layer) + if err != nil { + return false, err + } + defer blob.Close() + + cp, _, err := comp.PeekCompression(blob) + if err != nil { + return false, err + } + + return cp != compression.None, nil +} + +func (i *image) loadTarDescriptorAndConfig() error { + m, err := extractFileFromTar(i.opener, "manifest.json") + if err != nil { + return err + } + defer m.Close() + + if err := json.NewDecoder(m).Decode(&i.manifest); err != nil { + return err + } + + if i.manifest == nil { + return errors.New("no valid manifest.json in tarball") + } + + i.imgDescriptor, err = i.manifest.findDescriptor(i.tag) + if err != nil { + return err + } + + cfg, err := extractFileFromTar(i.opener, i.imgDescriptor.Config) + if err != nil { + return err + } + defer cfg.Close() + + i.config, err = io.ReadAll(cfg) + if err != nil { + return err + } + return nil +} + +func (i *image) RawConfigFile() ([]byte, error) { + return i.config, nil +} + +// tarFile represents a single file inside a tar. Closing it closes the tar itself. +type tarFile struct { + io.Reader + io.Closer +} + +func extractFileFromTar(opener Opener, filePath string) (io.ReadCloser, error) { + f, err := opener() + if err != nil { + return nil, err + } + needClose := true + defer func() { + if needClose { + f.Close() + } + }() + + tf := tar.NewReader(f) + for { + hdr, err := tf.Next() + if errors.Is(err, io.EOF) { + break + } + if err != nil { + return nil, err + } + if hdr.Name == filePath { + if hdr.Typeflag == tar.TypeSymlink || hdr.Typeflag == tar.TypeLink { + currentDir := filepath.Dir(filePath) + return extractFileFromTar(opener, path.Join(currentDir, path.Clean(hdr.Linkname))) + } + needClose = false + return tarFile{ + Reader: tf, + Closer: f, + }, nil + } + } + return nil, fmt.Errorf("file %s not found in tar", filePath) +} + +// uncompressedLayerFromTarball implements partial.UncompressedLayer +type uncompressedLayerFromTarball struct { + diffID v1.Hash + mediaType types.MediaType + opener Opener + filePath string +} + +// foreignUncompressedLayer implements partial.UncompressedLayer but returns +// a custom descriptor. This allows the foreign layer URLs to be included in +// the generated image manifest for uncompressed layers. +type foreignUncompressedLayer struct { + uncompressedLayerFromTarball + desc v1.Descriptor +} + +func (fl *foreignUncompressedLayer) Descriptor() (*v1.Descriptor, error) { + return &fl.desc, nil +} + +// DiffID implements partial.UncompressedLayer +func (ulft *uncompressedLayerFromTarball) DiffID() (v1.Hash, error) { + return ulft.diffID, nil +} + +// Uncompressed implements partial.UncompressedLayer +func (ulft *uncompressedLayerFromTarball) Uncompressed() (io.ReadCloser, error) { + return extractFileFromTar(ulft.opener, ulft.filePath) +} + +func (ulft *uncompressedLayerFromTarball) MediaType() (types.MediaType, error) { + return ulft.mediaType, nil +} + +func (i *uncompressedImage) LayerByDiffID(h v1.Hash) (partial.UncompressedLayer, error) { + cfg, err := partial.ConfigFile(i) + if err != nil { + return nil, err + } + for idx, diffID := range cfg.RootFS.DiffIDs { + if diffID == h { + // Technically the media type should be 'application/tar' but given that our + // v1.Layer doesn't force consumers to care about whether the layer is compressed + // we should be fine returning the DockerLayer media type + mt := types.DockerLayer + if bd, ok := i.imgDescriptor.LayerSources[h]; ok { + // Overwrite the mediaType for foreign layers. + return &foreignUncompressedLayer{ + uncompressedLayerFromTarball: uncompressedLayerFromTarball{ + diffID: diffID, + mediaType: bd.MediaType, + opener: i.opener, + filePath: i.imgDescriptor.Layers[idx], + }, + desc: bd, + }, nil + } + return &uncompressedLayerFromTarball{ + diffID: diffID, + mediaType: mt, + opener: i.opener, + filePath: i.imgDescriptor.Layers[idx], + }, nil + } + } + return nil, fmt.Errorf("diff id %q not found", h) +} + +func (c *compressedImage) Manifest() (*v1.Manifest, error) { + c.manifestLock.Lock() + defer c.manifestLock.Unlock() + if c.manifest != nil { + return c.manifest, nil + } + + b, err := c.RawConfigFile() + if err != nil { + return nil, err + } + + cfgHash, cfgSize, err := v1.SHA256(bytes.NewReader(b)) + if err != nil { + return nil, err + } + + c.manifest = &v1.Manifest{ + SchemaVersion: 2, + MediaType: types.DockerManifestSchema2, + Config: v1.Descriptor{ + MediaType: types.DockerConfigJSON, + Size: cfgSize, + Digest: cfgHash, + }, + } + + for i, p := range c.imgDescriptor.Layers { + cfg, err := partial.ConfigFile(c) + if err != nil { + return nil, err + } + diffid := cfg.RootFS.DiffIDs[i] + if d, ok := c.imgDescriptor.LayerSources[diffid]; ok { + // If it's a foreign layer, just append the descriptor so we can avoid + // reading the entire file. + c.manifest.Layers = append(c.manifest.Layers, d) + } else { + l, err := extractFileFromTar(c.opener, p) + if err != nil { + return nil, err + } + defer l.Close() + sha, size, err := v1.SHA256(l) + if err != nil { + return nil, err + } + c.manifest.Layers = append(c.manifest.Layers, v1.Descriptor{ + MediaType: types.DockerLayer, + Size: size, + Digest: sha, + }) + } + } + return c.manifest, nil +} + +func (c *compressedImage) RawManifest() ([]byte, error) { + return partial.RawManifest(c) +} + +// compressedLayerFromTarball implements partial.CompressedLayer +type compressedLayerFromTarball struct { + desc v1.Descriptor + opener Opener + filePath string +} + +// Digest implements partial.CompressedLayer +func (clft *compressedLayerFromTarball) Digest() (v1.Hash, error) { + return clft.desc.Digest, nil +} + +// Compressed implements partial.CompressedLayer +func (clft *compressedLayerFromTarball) Compressed() (io.ReadCloser, error) { + return extractFileFromTar(clft.opener, clft.filePath) +} + +// MediaType implements partial.CompressedLayer +func (clft *compressedLayerFromTarball) MediaType() (types.MediaType, error) { + return clft.desc.MediaType, nil +} + +// Size implements partial.CompressedLayer +func (clft *compressedLayerFromTarball) Size() (int64, error) { + return clft.desc.Size, nil +} + +func (c *compressedImage) LayerByDigest(h v1.Hash) (partial.CompressedLayer, error) { + m, err := c.Manifest() + if err != nil { + return nil, err + } + for i, l := range m.Layers { + if l.Digest == h { + fp := c.imgDescriptor.Layers[i] + return &compressedLayerFromTarball{ + desc: l, + opener: c.opener, + filePath: fp, + }, nil + } + } + return nil, fmt.Errorf("blob %v not found", h) +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/layer.go b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/layer.go new file mode 100644 index 000000000..8a2630961 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/layer.go @@ -0,0 +1,354 @@ +// Copyright 2018 Google LLC 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 tarball + +import ( + "bytes" + "compress/gzip" + "fmt" + "io" + "os" + "sync" + + "github.com/containerd/stargz-snapshotter/estargz" + "github.com/google/go-containerregistry/internal/and" + comp "github.com/google/go-containerregistry/internal/compression" + gestargz "github.com/google/go-containerregistry/internal/estargz" + ggzip "github.com/google/go-containerregistry/internal/gzip" + "github.com/google/go-containerregistry/internal/zstd" + "github.com/google/go-containerregistry/pkg/compression" + "github.com/google/go-containerregistry/pkg/logs" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/types" +) + +type layer struct { + digest v1.Hash + diffID v1.Hash + size int64 + compressedopener Opener + uncompressedopener Opener + compression compression.Compression + compressionLevel int + annotations map[string]string + estgzopts []estargz.Option + mediaType types.MediaType +} + +// Descriptor implements partial.withDescriptor. +func (l *layer) Descriptor() (*v1.Descriptor, error) { + digest, err := l.Digest() + if err != nil { + return nil, err + } + return &v1.Descriptor{ + Size: l.size, + Digest: digest, + Annotations: l.annotations, + MediaType: l.mediaType, + }, nil +} + +// Digest implements v1.Layer +func (l *layer) Digest() (v1.Hash, error) { + return l.digest, nil +} + +// DiffID implements v1.Layer +func (l *layer) DiffID() (v1.Hash, error) { + return l.diffID, nil +} + +// Compressed implements v1.Layer +func (l *layer) Compressed() (io.ReadCloser, error) { + return l.compressedopener() +} + +// Uncompressed implements v1.Layer +func (l *layer) Uncompressed() (io.ReadCloser, error) { + return l.uncompressedopener() +} + +// Size implements v1.Layer +func (l *layer) Size() (int64, error) { + return l.size, nil +} + +// MediaType implements v1.Layer +func (l *layer) MediaType() (types.MediaType, error) { + return l.mediaType, nil +} + +// LayerOption applies options to layer +type LayerOption func(*layer) + +// WithCompression is a functional option for overriding the default +// compression algorithm used for compressing uncompressed tarballs. +// Please note that WithCompression(compression.ZStd) should be used +// in conjunction with WithMediaType(types.OCILayerZStd) +func WithCompression(comp compression.Compression) LayerOption { + return func(l *layer) { + switch comp { + case compression.ZStd: + l.compression = compression.ZStd + case compression.GZip: + l.compression = compression.GZip + case compression.None: + logs.Warn.Printf("Compression type 'none' is not supported for tarball layers; using gzip compression.") + l.compression = compression.GZip + default: + logs.Warn.Printf("Unexpected compression type for WithCompression(): %s; using gzip compression instead.", comp) + l.compression = compression.GZip + } + } +} + +// WithCompressionLevel is a functional option for overriding the default +// compression level used for compressing uncompressed tarballs. +func WithCompressionLevel(level int) LayerOption { + return func(l *layer) { + l.compressionLevel = level + } +} + +// WithMediaType is a functional option for overriding the layer's media type. +func WithMediaType(mt types.MediaType) LayerOption { + return func(l *layer) { + l.mediaType = mt + } +} + +// WithCompressedCaching is a functional option that overrides the +// logic for accessing the compressed bytes to memoize the result +// and avoid expensive repeated gzips. +func WithCompressedCaching(l *layer) { + var once sync.Once + var err error + + buf := bytes.NewBuffer(nil) + og := l.compressedopener + + l.compressedopener = func() (io.ReadCloser, error) { + once.Do(func() { + var rc io.ReadCloser + rc, err = og() + if err == nil { + defer rc.Close() + _, err = io.Copy(buf, rc) + } + }) + if err != nil { + return nil, err + } + + return io.NopCloser(bytes.NewBuffer(buf.Bytes())), nil + } +} + +// WithEstargzOptions is a functional option that allow the caller to pass +// through estargz.Options to the underlying compression layer. This is +// only meaningful when estargz is enabled. +// +// Deprecated: WithEstargz is deprecated, and will be removed in a future release. +func WithEstargzOptions(opts ...estargz.Option) LayerOption { + return func(l *layer) { + l.estgzopts = opts + } +} + +// WithEstargz is a functional option that explicitly enables estargz support. +// +// Deprecated: WithEstargz is deprecated, and will be removed in a future release. +func WithEstargz(l *layer) { + oguncompressed := l.uncompressedopener + estargz := func() (io.ReadCloser, error) { + crc, err := oguncompressed() + if err != nil { + return nil, err + } + eopts := append(l.estgzopts, estargz.WithCompressionLevel(l.compressionLevel)) + rc, h, err := gestargz.ReadCloser(crc, eopts...) + if err != nil { + return nil, err + } + l.annotations[estargz.TOCJSONDigestAnnotation] = h.String() + return &and.ReadCloser{ + Reader: rc, + CloseFunc: func() error { + err := rc.Close() + if err != nil { + return err + } + // As an optimization, leverage the DiffID exposed by the estargz ReadCloser + l.diffID, err = v1.NewHash(rc.DiffID().String()) + return err + }, + }, nil + } + uncompressed := func() (io.ReadCloser, error) { + urc, err := estargz() + if err != nil { + return nil, err + } + return ggzip.UnzipReadCloser(urc) + } + + l.compressedopener = estargz + l.uncompressedopener = uncompressed +} + +// LayerFromFile returns a v1.Layer given a tarball +func LayerFromFile(path string, opts ...LayerOption) (v1.Layer, error) { + opener := func() (io.ReadCloser, error) { + return os.Open(path) + } + return LayerFromOpener(opener, opts...) +} + +// LayerFromOpener returns a v1.Layer given an Opener function. +// The Opener may return either an uncompressed tarball (common), +// or a compressed tarball (uncommon). +// +// When using this in conjunction with something like remote.Write +// the uncompressed path may end up gzipping things multiple times: +// 1. Compute the layer SHA256 +// 2. Upload the compressed layer. +// +// Since gzip can be expensive, we support an option to memoize the +// compression that can be passed here: tarball.WithCompressedCaching +func LayerFromOpener(opener Opener, opts ...LayerOption) (v1.Layer, error) { + comp, err := comp.GetCompression(opener) + if err != nil { + return nil, err + } + + layer := &layer{ + compression: compression.GZip, + compressionLevel: gzip.BestSpeed, + annotations: make(map[string]string, 1), + mediaType: types.DockerLayer, + } + + if estgz := os.Getenv("GGCR_EXPERIMENT_ESTARGZ"); estgz == "1" { + logs.Warn.Println("GGCR_EXPERIMENT_ESTARGZ is deprecated, and will be removed in a future release.") + opts = append([]LayerOption{WithEstargz}, opts...) + } + + switch comp { + case compression.GZip: + layer.compressedopener = opener + layer.uncompressedopener = func() (io.ReadCloser, error) { + urc, err := opener() + if err != nil { + return nil, err + } + return ggzip.UnzipReadCloser(urc) + } + case compression.ZStd: + layer.compressedopener = opener + layer.uncompressedopener = func() (io.ReadCloser, error) { + urc, err := opener() + if err != nil { + return nil, err + } + return zstd.UnzipReadCloser(urc) + } + default: + layer.uncompressedopener = opener + layer.compressedopener = func() (io.ReadCloser, error) { + crc, err := opener() + if err != nil { + return nil, err + } + + if layer.compression == compression.ZStd { + return zstd.ReadCloserLevel(crc, layer.compressionLevel), nil + } + + return ggzip.ReadCloserLevel(crc, layer.compressionLevel), nil + } + } + + for _, opt := range opts { + opt(layer) + } + + // Warn if media type does not match compression + var mediaTypeMismatch = false + switch layer.compression { + case compression.GZip: + mediaTypeMismatch = + layer.mediaType != types.OCILayer && + layer.mediaType != types.OCIRestrictedLayer && + layer.mediaType != types.DockerLayer + + case compression.ZStd: + mediaTypeMismatch = layer.mediaType != types.OCILayerZStd + } + + if mediaTypeMismatch { + logs.Warn.Printf("Unexpected mediaType (%s) for selected compression in %s in LayerFromOpener().", layer.mediaType, layer.compression) + } + + if layer.digest, layer.size, err = computeDigest(layer.compressedopener); err != nil { + return nil, err + } + + empty := v1.Hash{} + if layer.diffID == empty { + if layer.diffID, err = computeDiffID(layer.uncompressedopener); err != nil { + return nil, err + } + } + + return layer, nil +} + +// LayerFromReader returns a v1.Layer given a io.Reader. +// +// The reader's contents are read and buffered to a temp file in the process. +// +// Deprecated: Use LayerFromOpener or stream.NewLayer instead, if possible. +func LayerFromReader(reader io.Reader, opts ...LayerOption) (v1.Layer, error) { + tmp, err := os.CreateTemp("", "") + if err != nil { + return nil, fmt.Errorf("creating temp file to buffer reader: %w", err) + } + if _, err := io.Copy(tmp, reader); err != nil { + return nil, fmt.Errorf("writing temp file to buffer reader: %w", err) + } + return LayerFromFile(tmp.Name(), opts...) +} + +func computeDigest(opener Opener) (v1.Hash, int64, error) { + rc, err := opener() + if err != nil { + return v1.Hash{}, 0, err + } + defer rc.Close() + + return v1.SHA256(rc) +} + +func computeDiffID(opener Opener) (v1.Hash, error) { + rc, err := opener() + if err != nil { + return v1.Hash{}, err + } + defer rc.Close() + + digest, _, err := v1.SHA256(rc) + return digest, err +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go new file mode 100644 index 000000000..e607df164 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go @@ -0,0 +1,457 @@ +// Copyright 2018 Google LLC 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 tarball + +import ( + "archive/tar" + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "os" + "sort" + "strings" + + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/partial" +) + +// WriteToFile writes in the compressed format to a tarball, on disk. +// This is just syntactic sugar wrapping tarball.Write with a new file. +func WriteToFile(p string, ref name.Reference, img v1.Image, opts ...WriteOption) error { + w, err := os.Create(p) + if err != nil { + return err + } + defer w.Close() + + return Write(ref, img, w, opts...) +} + +// MultiWriteToFile writes in the compressed format to a tarball, on disk. +// This is just syntactic sugar wrapping tarball.MultiWrite with a new file. +func MultiWriteToFile(p string, tagToImage map[name.Tag]v1.Image, opts ...WriteOption) error { + refToImage := make(map[name.Reference]v1.Image, len(tagToImage)) + for i, d := range tagToImage { + refToImage[i] = d + } + return MultiRefWriteToFile(p, refToImage, opts...) +} + +// MultiRefWriteToFile writes in the compressed format to a tarball, on disk. +// This is just syntactic sugar wrapping tarball.MultiRefWrite with a new file. +func MultiRefWriteToFile(p string, refToImage map[name.Reference]v1.Image, opts ...WriteOption) error { + w, err := os.Create(p) + if err != nil { + return err + } + defer w.Close() + + return MultiRefWrite(refToImage, w, opts...) +} + +// Write is a wrapper to write a single image and tag to a tarball. +func Write(ref name.Reference, img v1.Image, w io.Writer, opts ...WriteOption) error { + return MultiRefWrite(map[name.Reference]v1.Image{ref: img}, w, opts...) +} + +// MultiWrite writes the contents of each image to the provided writer, in the compressed format. +// The contents are written in the following format: +// One manifest.json file at the top level containing information about several images. +// One file for each layer, named after the layer's SHA. +// One file for the config blob, named after its SHA. +func MultiWrite(tagToImage map[name.Tag]v1.Image, w io.Writer, opts ...WriteOption) error { + refToImage := make(map[name.Reference]v1.Image, len(tagToImage)) + for i, d := range tagToImage { + refToImage[i] = d + } + return MultiRefWrite(refToImage, w, opts...) +} + +// MultiRefWrite writes the contents of each image to the provided writer, in the compressed format. +// The contents are written in the following format: +// One manifest.json file at the top level containing information about several images. +// One file for each layer, named after the layer's SHA. +// One file for the config blob, named after its SHA. +func MultiRefWrite(refToImage map[name.Reference]v1.Image, w io.Writer, opts ...WriteOption) error { + // process options + o := &writeOptions{ + updates: nil, + } + for _, option := range opts { + if err := option(o); err != nil { + return err + } + } + + imageToTags := dedupRefToImage(refToImage) + size, mBytes, err := getSizeAndManifest(imageToTags) + if err != nil { + return sendUpdateReturn(o, err) + } + + return writeImagesToTar(imageToTags, mBytes, size, w, o) +} + +// sendUpdateReturn return the passed in error message, also sending on update channel, if it exists +func sendUpdateReturn(o *writeOptions, err error) error { + if o != nil && o.updates != nil { + o.updates <- v1.Update{ + Error: err, + } + } + return err +} + +// sendProgressWriterReturn return the passed in error message, also sending on update channel, if it exists, along with downloaded information +func sendProgressWriterReturn(pw *progressWriter, err error) error { + if pw != nil { + return pw.Error(err) + } + return err +} + +// writeImagesToTar writes the images to the tarball +func writeImagesToTar(imageToTags map[v1.Image][]string, m []byte, size int64, w io.Writer, o *writeOptions) (err error) { + if w == nil { + return sendUpdateReturn(o, errors.New("must pass valid writer")) + } + + tw := w + var pw *progressWriter + + // we only calculate the sizes and use a progressWriter if we were provided + // an option with a progress channel + if o != nil && o.updates != nil { + pw = &progressWriter{ + w: w, + updates: o.updates, + size: size, + } + tw = pw + } + + tf := tar.NewWriter(tw) + defer tf.Close() + + seenLayerDigests := make(map[string]struct{}) + + for img := range imageToTags { + // Write the config. + cfgName, err := img.ConfigName() + if err != nil { + return sendProgressWriterReturn(pw, err) + } + cfgBlob, err := img.RawConfigFile() + if err != nil { + return sendProgressWriterReturn(pw, err) + } + if err := writeTarEntry(tf, cfgName.String(), bytes.NewReader(cfgBlob), int64(len(cfgBlob))); err != nil { + return sendProgressWriterReturn(pw, err) + } + + // Write the layers. + layers, err := img.Layers() + if err != nil { + return sendProgressWriterReturn(pw, err) + } + layerFiles := make([]string, len(layers)) + for i, l := range layers { + d, err := l.Digest() + if err != nil { + return sendProgressWriterReturn(pw, err) + } + // Munge the file name to appease ancient technology. + // + // tar assumes anything with a colon is a remote tape drive: + // https://www.gnu.org/software/tar/manual/html_section/tar_45.html + // Drop the algorithm prefix, e.g. "sha256:" + hex := d.Hex + + // gunzip expects certain file extensions: + // https://www.gnu.org/software/gzip/manual/html_node/Overview.html + layerFiles[i] = fmt.Sprintf("%s.tar.gz", hex) + + if _, ok := seenLayerDigests[hex]; ok { + continue + } + seenLayerDigests[hex] = struct{}{} + + r, err := l.Compressed() + if err != nil { + return sendProgressWriterReturn(pw, err) + } + blobSize, err := l.Size() + if err != nil { + return sendProgressWriterReturn(pw, err) + } + + if err := writeTarEntry(tf, layerFiles[i], r, blobSize); err != nil { + return sendProgressWriterReturn(pw, err) + } + } + } + if err := writeTarEntry(tf, "manifest.json", bytes.NewReader(m), int64(len(m))); err != nil { + return sendProgressWriterReturn(pw, err) + } + + // be sure to close the tar writer so everything is flushed out before we send our EOF + if err := tf.Close(); err != nil { + return sendProgressWriterReturn(pw, err) + } + // send an EOF to indicate finished on the channel, but nil as our return error + _ = sendProgressWriterReturn(pw, io.EOF) + return nil +} + +// calculateManifest calculates the manifest and optionally the size of the tar file +func calculateManifest(imageToTags map[v1.Image][]string) (m Manifest, err error) { + if len(imageToTags) == 0 { + return nil, errors.New("set of images is empty") + } + + for img, tags := range imageToTags { + cfgName, err := img.ConfigName() + if err != nil { + return nil, err + } + + // Store foreign layer info. + layerSources := make(map[v1.Hash]v1.Descriptor) + + // Write the layers. + layers, err := img.Layers() + if err != nil { + return nil, err + } + layerFiles := make([]string, len(layers)) + for i, l := range layers { + d, err := l.Digest() + if err != nil { + return nil, err + } + // Munge the file name to appease ancient technology. + // + // tar assumes anything with a colon is a remote tape drive: + // https://www.gnu.org/software/tar/manual/html_section/tar_45.html + // Drop the algorithm prefix, e.g. "sha256:" + hex := d.Hex + + // gunzip expects certain file extensions: + // https://www.gnu.org/software/gzip/manual/html_node/Overview.html + layerFiles[i] = fmt.Sprintf("%s.tar.gz", hex) + + // Add to LayerSources if it's a foreign layer. + desc, err := partial.BlobDescriptor(img, d) + if err != nil { + return nil, err + } + if !desc.MediaType.IsDistributable() { + diffid, err := partial.BlobToDiffID(img, d) + if err != nil { + return nil, err + } + layerSources[diffid] = *desc + } + } + + // Generate the tar descriptor and write it. + m = append(m, Descriptor{ + Config: cfgName.String(), + RepoTags: tags, + Layers: layerFiles, + LayerSources: layerSources, + }) + } + // sort by name of the repotags so it is consistent. Alternatively, we could sort by hash of the + // descriptor, but that would make it hard for humans to process + sort.Slice(m, func(i, j int) bool { + return strings.Join(m[i].RepoTags, ",") < strings.Join(m[j].RepoTags, ",") + }) + + return m, nil +} + +// CalculateSize calculates the expected complete size of the output tar file +func CalculateSize(refToImage map[name.Reference]v1.Image) (size int64, err error) { + imageToTags := dedupRefToImage(refToImage) + size, _, err = getSizeAndManifest(imageToTags) + return size, err +} + +func getSizeAndManifest(imageToTags map[v1.Image][]string) (int64, []byte, error) { + m, err := calculateManifest(imageToTags) + if err != nil { + return 0, nil, fmt.Errorf("unable to calculate manifest: %w", err) + } + mBytes, err := json.Marshal(m) + if err != nil { + return 0, nil, fmt.Errorf("could not marshall manifest to bytes: %w", err) + } + + size, err := calculateTarballSize(imageToTags, mBytes) + if err != nil { + return 0, nil, fmt.Errorf("error calculating tarball size: %w", err) + } + return size, mBytes, nil +} + +// calculateTarballSize calculates the size of the tar file +func calculateTarballSize(imageToTags map[v1.Image][]string, mBytes []byte) (size int64, err error) { + seenLayerDigests := make(map[string]struct{}) + for img, name := range imageToTags { + manifest, err := img.Manifest() + if err != nil { + return size, fmt.Errorf("unable to get manifest for img %s: %w", name, err) + } + size += calculateSingleFileInTarSize(manifest.Config.Size) + for _, l := range manifest.Layers { + hex := l.Digest.Hex + if _, ok := seenLayerDigests[hex]; ok { + continue + } + seenLayerDigests[hex] = struct{}{} + size += calculateSingleFileInTarSize(l.Size) + } + } + // add the manifest + size += calculateSingleFileInTarSize(int64(len(mBytes))) + + // add the two padding blocks that indicate end of a tar file + size += 1024 + return size, nil +} + +func dedupRefToImage(refToImage map[name.Reference]v1.Image) map[v1.Image][]string { + imageToTags := make(map[v1.Image][]string) + + for ref, img := range refToImage { + if tag, ok := ref.(name.Tag); ok { + if tags, ok := imageToTags[img]; !ok || tags == nil { + imageToTags[img] = []string{} + } + // Docker cannot load tarballs without an explicit tag: + // https://github.com/google/go-containerregistry/issues/890 + // + // We can't use the fully qualified tag.Name() because of rules_docker: + // https://github.com/google/go-containerregistry/issues/527 + // + // If the tag is "latest", but tag.String() doesn't end in ":latest", + // just append it. Kind of gross, but should work for now. + ts := tag.String() + if tag.Identifier() == name.DefaultTag && !strings.HasSuffix(ts, ":"+name.DefaultTag) { + ts = fmt.Sprintf("%s:%s", ts, name.DefaultTag) + } + imageToTags[img] = append(imageToTags[img], ts) + } else if _, ok := imageToTags[img]; !ok { + imageToTags[img] = nil + } + } + + return imageToTags +} + +// writeTarEntry writes a file to the provided writer with a corresponding tar header +func writeTarEntry(tf *tar.Writer, path string, r io.Reader, size int64) error { + hdr := &tar.Header{ + Mode: 0644, + Typeflag: tar.TypeReg, + Size: size, + Name: path, + } + if err := tf.WriteHeader(hdr); err != nil { + return err + } + _, err := io.Copy(tf, r) + return err +} + +// ComputeManifest get the manifest.json that will be written to the tarball +// for multiple references +func ComputeManifest(refToImage map[name.Reference]v1.Image) (Manifest, error) { + imageToTags := dedupRefToImage(refToImage) + return calculateManifest(imageToTags) +} + +// WriteOption a function option to pass to Write() +type WriteOption func(*writeOptions) error +type writeOptions struct { + updates chan<- v1.Update +} + +// WithProgress create a WriteOption for passing to Write() that enables +// a channel to receive updates as they are downloaded and written to disk. +func WithProgress(updates chan<- v1.Update) WriteOption { + return func(o *writeOptions) error { + o.updates = updates + return nil + } +} + +// progressWriter is a writer which will send the download progress +type progressWriter struct { + w io.Writer + updates chan<- v1.Update + size, complete int64 +} + +func (pw *progressWriter) Write(p []byte) (int, error) { + n, err := pw.w.Write(p) + if err != nil { + return n, err + } + + pw.complete += int64(n) + + pw.updates <- v1.Update{ + Total: pw.size, + Complete: pw.complete, + } + + return n, err +} + +func (pw *progressWriter) Error(err error) error { + pw.updates <- v1.Update{ + Total: pw.size, + Complete: pw.complete, + Error: err, + } + return err +} + +func (pw *progressWriter) Close() error { + pw.updates <- v1.Update{ + Total: pw.size, + Complete: pw.complete, + Error: io.EOF, + } + return io.EOF +} + +// calculateSingleFileInTarSize calculate the size a file will take up in a tar archive, +// given the input data. Provided by rounding up to nearest whole block (512) +// and adding header 512 +func calculateSingleFileInTarSize(in int64) (out int64) { + // doing this manually, because math.Round() works with float64 + out += in + if remainder := out % 512; remainder != 0 { + out += (512 - remainder) + } + out += 512 + return out +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/types/types.go b/vendor/github.com/google/go-containerregistry/pkg/v1/types/types.go index efc6bd6b9..c86657d7b 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/types/types.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/types/types.go @@ -80,3 +80,19 @@ func (m MediaType) IsConfig() bool { } return false } + +func (m MediaType) IsSchema1() bool { + switch m { + case DockerManifestSchema1, DockerManifestSchema1Signed: + return true + } + return false +} + +func (m MediaType) IsLayer() bool { + switch m { + case DockerLayer, DockerUncompressedLayer, OCILayer, OCILayerZStd, OCIUncompressedLayer, DockerForeignLayer, OCIRestrictedLayer, OCIUncompressedRestrictedLayer: + return true + } + return false +} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/counter.go b/vendor/github.com/prometheus/client_golang/prometheus/counter.go index de30de6da..62de4dc59 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/counter.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/counter.go @@ -59,6 +59,18 @@ type ExemplarAdder interface { // CounterOpts is an alias for Opts. See there for doc comments. type CounterOpts Opts +// CounterVecOpts bundles the options to create a CounterVec metric. +// It is mandatory to set CounterOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type CounterVecOpts struct { + CounterOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels +} + // NewCounter creates a new Counter based on the provided CounterOpts. // // The returned implementation also implements ExemplarAdder. It is safe to @@ -140,12 +152,13 @@ func (c *counter) get() float64 { } func (c *counter) Write(out *dto.Metric) error { - val := c.get() - + // Read the Exemplar first and the value second. This is to avoid a race condition + // where users see an exemplar for a not-yet-existing observation. var exemplar *dto.Exemplar if e := c.exemplar.Load(); e != nil { exemplar = e.(*dto.Exemplar) } + val := c.get() return populateMetric(CounterValue, val, c.labelPairs, exemplar, out) } @@ -173,16 +186,24 @@ type CounterVec struct { // NewCounterVec creates a new CounterVec based on the provided CounterOpts and // partitioned by the given label names. func NewCounterVec(opts CounterOpts, labelNames []string) *CounterVec { - desc := NewDesc( + return V2.NewCounterVec(CounterVecOpts{ + CounterOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewCounterVec creates a new CounterVec based on the provided CounterVecOpts. +func (v2) NewCounterVec(opts CounterVecOpts) *CounterVec { + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &CounterVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { if len(lvs) != len(desc.variableLabels) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, lvs)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), lvs)) } result := &counter{desc: desc, labelPairs: MakeLabelPairs(desc, lvs), now: time.Now} result.init(result) // Init self-collection. @@ -245,7 +266,8 @@ func (v *CounterVec) GetMetricWith(labels Labels) (Counter, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Add(42) +// +// myVec.WithLabelValues("404", "GET").Add(42) func (v *CounterVec) WithLabelValues(lvs ...string) Counter { c, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -256,7 +278,8 @@ func (v *CounterVec) WithLabelValues(lvs ...string) Counter { // With works as GetMetricWith, but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) func (v *CounterVec) With(labels Labels) Counter { c, err := v.GetMetricWith(labels) if err != nil { diff --git a/vendor/github.com/prometheus/client_golang/prometheus/desc.go b/vendor/github.com/prometheus/client_golang/prometheus/desc.go index 8bc5e44e2..deedc2dfb 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/desc.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/desc.go @@ -14,20 +14,16 @@ package prometheus import ( - "errors" "fmt" "sort" "strings" "github.com/cespare/xxhash/v2" - - "github.com/prometheus/client_golang/prometheus/internal" - - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" + dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/model" + "google.golang.org/protobuf/proto" - dto "github.com/prometheus/client_model/go" + "github.com/prometheus/client_golang/prometheus/internal" ) // Desc is the descriptor used by every Prometheus Metric. It is essentially @@ -54,9 +50,9 @@ type Desc struct { // constLabelPairs contains precalculated DTO label pairs based on // the constant labels. constLabelPairs []*dto.LabelPair - // variableLabels contains names of labels for which the metric - // maintains variable values. - variableLabels []string + // variableLabels contains names of labels and normalization function for + // which the metric maintains variable values. + variableLabels ConstrainedLabels // id is a hash of the values of the ConstLabels and fqName. This // must be unique among all registered descriptors and can therefore be // used as an identifier of the descriptor. @@ -80,10 +76,24 @@ type Desc struct { // For constLabels, the label values are constant. Therefore, they are fully // specified in the Desc. See the Collector example for a usage pattern. func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *Desc { + return V2.NewDesc(fqName, help, UnconstrainedLabels(variableLabels), constLabels) +} + +// NewDesc allocates and initializes a new Desc. Errors are recorded in the Desc +// and will be reported on registration time. variableLabels and constLabels can +// be nil if no such labels should be set. fqName must not be empty. +// +// variableLabels only contain the label names and normalization functions. Their +// label values are variable and therefore not part of the Desc. (They are managed +// within the Metric.) +// +// For constLabels, the label values are constant. Therefore, they are fully +// specified in the Desc. See the Collector example for a usage pattern. +func (v2) NewDesc(fqName, help string, variableLabels ConstrainableLabels, constLabels Labels) *Desc { d := &Desc{ fqName: fqName, help: help, - variableLabels: variableLabels, + variableLabels: variableLabels.constrainedLabels(), } if !model.IsValidMetricName(model.LabelValue(fqName)) { d.err = fmt.Errorf("%q is not a valid metric name", fqName) @@ -93,7 +103,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) * // their sorted label names) plus the fqName (at position 0). labelValues := make([]string, 1, len(constLabels)+1) labelValues[0] = fqName - labelNames := make([]string, 0, len(constLabels)+len(variableLabels)) + labelNames := make([]string, 0, len(constLabels)+len(d.variableLabels)) labelNameSet := map[string]struct{}{} // First add only the const label names and sort them... for labelName := range constLabels { @@ -118,16 +128,16 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) * // Now add the variable label names, but prefix them with something that // cannot be in a regular label name. That prevents matching the label // dimension with a different mix between preset and variable labels. - for _, labelName := range variableLabels { - if !checkLabelName(labelName) { - d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName) + for _, label := range d.variableLabels { + if !checkLabelName(label.Name) { + d.err = fmt.Errorf("%q is not a valid label name for metric %q", label.Name, fqName) return d } - labelNames = append(labelNames, "$"+labelName) - labelNameSet[labelName] = struct{}{} + labelNames = append(labelNames, "$"+label.Name) + labelNameSet[label.Name] = struct{}{} } if len(labelNames) != len(labelNameSet) { - d.err = errors.New("duplicate label names") + d.err = fmt.Errorf("duplicate label names in constant and variable labels for metric %q", fqName) return d } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/doc.go b/vendor/github.com/prometheus/client_golang/prometheus/doc.go index 98450125d..962608f02 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/doc.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/doc.go @@ -21,55 +21,66 @@ // All exported functions and methods are safe to be used concurrently unless // specified otherwise. // -// A Basic Example +// # A Basic Example // // As a starting point, a very basic usage example: // -// package main -// -// import ( -// "log" -// "net/http" -// -// "github.com/prometheus/client_golang/prometheus" -// "github.com/prometheus/client_golang/prometheus/promhttp" -// ) -// -// var ( -// cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{ -// Name: "cpu_temperature_celsius", -// Help: "Current temperature of the CPU.", -// }) -// hdFailures = prometheus.NewCounterVec( -// prometheus.CounterOpts{ -// Name: "hd_errors_total", -// Help: "Number of hard-disk errors.", -// }, -// []string{"device"}, -// ) -// ) -// -// func init() { -// // Metrics have to be registered to be exposed: -// prometheus.MustRegister(cpuTemp) -// prometheus.MustRegister(hdFailures) -// } -// -// func main() { -// cpuTemp.Set(65.3) -// hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc() -// -// // The Handler function provides a default handler to expose metrics -// // via an HTTP server. "/metrics" is the usual endpoint for that. -// http.Handle("/metrics", promhttp.Handler()) -// log.Fatal(http.ListenAndServe(":8080", nil)) -// } -// +// package main +// +// import ( +// "log" +// "net/http" +// +// "github.com/prometheus/client_golang/prometheus" +// "github.com/prometheus/client_golang/prometheus/promhttp" +// ) +// +// type metrics struct { +// cpuTemp prometheus.Gauge +// hdFailures *prometheus.CounterVec +// } +// +// func NewMetrics(reg prometheus.Registerer) *metrics { +// m := &metrics{ +// cpuTemp: prometheus.NewGauge(prometheus.GaugeOpts{ +// Name: "cpu_temperature_celsius", +// Help: "Current temperature of the CPU.", +// }), +// hdFailures: prometheus.NewCounterVec( +// prometheus.CounterOpts{ +// Name: "hd_errors_total", +// Help: "Number of hard-disk errors.", +// }, +// []string{"device"}, +// ), +// } +// reg.MustRegister(m.cpuTemp) +// reg.MustRegister(m.hdFailures) +// return m +// } +// +// func main() { +// // Create a non-global registry. +// reg := prometheus.NewRegistry() +// +// // Create new metrics and register them using the custom registry. +// m := NewMetrics(reg) +// // Set values for the new created metrics. +// m.cpuTemp.Set(65.3) +// m.hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc() +// +// // Expose metrics and custom registry via an HTTP server +// // using the HandleFor function. "/metrics" is the usual endpoint for that. +// http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: reg})) +// log.Fatal(http.ListenAndServe(":8080", nil)) +// } // // This is a complete program that exports two metrics, a Gauge and a Counter, // the latter with a label attached to turn it into a (one-dimensional) vector. +// It register the metrics using a custom registry and exposes them via an HTTP server +// on the /metrics endpoint. // -// Metrics +// # Metrics // // The number of exported identifiers in this package might appear a bit // overwhelming. However, in addition to the basic plumbing shown in the example @@ -100,7 +111,7 @@ // To create instances of Metrics and their vector versions, you need a suitable // …Opts struct, i.e. GaugeOpts, CounterOpts, SummaryOpts, or HistogramOpts. // -// Custom Collectors and constant Metrics +// # Custom Collectors and constant Metrics // // While you could create your own implementations of Metric, most likely you // will only ever implement the Collector interface on your own. At a first @@ -141,7 +152,7 @@ // a metric, GaugeFunc, CounterFunc, or UntypedFunc might be interesting // shortcuts. // -// Advanced Uses of the Registry +// # Advanced Uses of the Registry // // While MustRegister is the by far most common way of registering a Collector, // sometimes you might want to handle the errors the registration might cause. @@ -176,23 +187,23 @@ // NewProcessCollector). With a custom registry, you are in control and decide // yourself about the Collectors to register. // -// HTTP Exposition +// # HTTP Exposition // // The Registry implements the Gatherer interface. The caller of the Gather // method can then expose the gathered metrics in some way. Usually, the metrics // are served via HTTP on the /metrics endpoint. That's happening in the example // above. The tools to expose metrics via HTTP are in the promhttp sub-package. // -// Pushing to the Pushgateway +// # Pushing to the Pushgateway // // Function for pushing to the Pushgateway can be found in the push sub-package. // -// Graphite Bridge +// # Graphite Bridge // // Functions and examples to push metrics from a Gatherer to Graphite can be // found in the graphite sub-package. // -// Other Means of Exposition +// # Other Means of Exposition // // More ways of exposing metrics can easily be added by following the approaches // of the existing implementations. diff --git a/vendor/github.com/prometheus/client_golang/prometheus/gauge.go b/vendor/github.com/prometheus/client_golang/prometheus/gauge.go index bd0733d6a..f1ea6c76f 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/gauge.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/gauge.go @@ -55,6 +55,18 @@ type Gauge interface { // GaugeOpts is an alias for Opts. See there for doc comments. type GaugeOpts Opts +// GaugeVecOpts bundles the options to create a GaugeVec metric. +// It is mandatory to set GaugeOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type GaugeVecOpts struct { + GaugeOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels +} + // NewGauge creates a new Gauge based on the provided GaugeOpts. // // The returned implementation is optimized for a fast Set method. If you have a @@ -138,16 +150,24 @@ type GaugeVec struct { // NewGaugeVec creates a new GaugeVec based on the provided GaugeOpts and // partitioned by the given label names. func NewGaugeVec(opts GaugeOpts, labelNames []string) *GaugeVec { - desc := NewDesc( + return V2.NewGaugeVec(GaugeVecOpts{ + GaugeOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewGaugeVec creates a new GaugeVec based on the provided GaugeVecOpts. +func (v2) NewGaugeVec(opts GaugeVecOpts) *GaugeVec { + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &GaugeVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { if len(lvs) != len(desc.variableLabels) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, lvs)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), lvs)) } result := &gauge{desc: desc, labelPairs: MakeLabelPairs(desc, lvs)} result.init(result) // Init self-collection. @@ -210,7 +230,8 @@ func (v *GaugeVec) GetMetricWith(labels Labels) (Gauge, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Add(42) +// +// myVec.WithLabelValues("404", "GET").Add(42) func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge { g, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -221,7 +242,8 @@ func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge { // With works as GetMetricWith, but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42) func (v *GaugeVec) With(labels Labels) Gauge { g, err := v.GetMetricWith(labels) if err != nil { diff --git a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go b/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go index 3a2d55e84..2d8d9f64f 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go @@ -23,11 +23,10 @@ import ( "strings" "sync" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - dto "github.com/prometheus/client_model/go" - "github.com/prometheus/client_golang/prometheus/internal" + + dto "github.com/prometheus/client_model/go" + "google.golang.org/protobuf/proto" ) const ( diff --git a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go index 0d47fecdc..8d818afe9 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go @@ -22,25 +22,221 @@ import ( "sync/atomic" "time" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - dto "github.com/prometheus/client_model/go" + + "google.golang.org/protobuf/proto" ) +// nativeHistogramBounds for the frac of observed values. Only relevant for +// schema > 0. The position in the slice is the schema. (0 is never used, just +// here for convenience of using the schema directly as the index.) +// +// TODO(beorn7): Currently, we do a binary search into these slices. There are +// ways to turn it into a small number of simple array lookups. It probably only +// matters for schema 5 and beyond, but should be investigated. See this comment +// as a starting point: +// https://github.com/open-telemetry/opentelemetry-specification/issues/1776#issuecomment-870164310 +var nativeHistogramBounds = [][]float64{ + // Schema "0": + {0.5}, + // Schema 1: + {0.5, 0.7071067811865475}, + // Schema 2: + {0.5, 0.5946035575013605, 0.7071067811865475, 0.8408964152537144}, + // Schema 3: + { + 0.5, 0.5452538663326288, 0.5946035575013605, 0.6484197773255048, + 0.7071067811865475, 0.7711054127039704, 0.8408964152537144, 0.9170040432046711, + }, + // Schema 4: + { + 0.5, 0.5221368912137069, 0.5452538663326288, 0.5693943173783458, + 0.5946035575013605, 0.620928906036742, 0.6484197773255048, 0.6771277734684463, + 0.7071067811865475, 0.7384130729697496, 0.7711054127039704, 0.805245165974627, + 0.8408964152537144, 0.8781260801866495, 0.9170040432046711, 0.9576032806985735, + }, + // Schema 5: + { + 0.5, 0.5109485743270583, 0.5221368912137069, 0.5335702003384117, + 0.5452538663326288, 0.5571933712979462, 0.5693943173783458, 0.5818624293887887, + 0.5946035575013605, 0.6076236799902344, 0.620928906036742, 0.6345254785958666, + 0.6484197773255048, 0.6626183215798706, 0.6771277734684463, 0.6919549409819159, + 0.7071067811865475, 0.7225904034885232, 0.7384130729697496, 0.7545822137967112, + 0.7711054127039704, 0.7879904225539431, 0.805245165974627, 0.8228777390769823, + 0.8408964152537144, 0.8593096490612387, 0.8781260801866495, 0.8973545375015533, + 0.9170040432046711, 0.9370838170551498, 0.9576032806985735, 0.9785720620876999, + }, + // Schema 6: + { + 0.5, 0.5054446430258502, 0.5109485743270583, 0.5165124395106142, + 0.5221368912137069, 0.5278225891802786, 0.5335702003384117, 0.5393803988785598, + 0.5452538663326288, 0.5511912916539204, 0.5571933712979462, 0.5632608093041209, + 0.5693943173783458, 0.5755946149764913, 0.5818624293887887, 0.5881984958251406, + 0.5946035575013605, 0.6010783657263515, 0.6076236799902344, 0.6142402680534349, + 0.620928906036742, 0.6276903785123455, 0.6345254785958666, 0.6414350080393891, + 0.6484197773255048, 0.6554806057623822, 0.6626183215798706, 0.6698337620266515, + 0.6771277734684463, 0.6845012114872953, 0.6919549409819159, 0.6994898362691555, + 0.7071067811865475, 0.7148066691959849, 0.7225904034885232, 0.7304588970903234, + 0.7384130729697496, 0.7464538641456323, 0.7545822137967112, 0.762799075372269, + 0.7711054127039704, 0.7795022001189185, 0.7879904225539431, 0.7965710756711334, + 0.805245165974627, 0.8140137109286738, 0.8228777390769823, 0.8318382901633681, + 0.8408964152537144, 0.8500531768592616, 0.8593096490612387, 0.8686669176368529, + 0.8781260801866495, 0.8876882462632604, 0.8973545375015533, 0.9071260877501991, + 0.9170040432046711, 0.9269895625416926, 0.9370838170551498, 0.9472879907934827, + 0.9576032806985735, 0.9680308967461471, 0.9785720620876999, 0.9892280131939752, + }, + // Schema 7: + { + 0.5, 0.5027149505564014, 0.5054446430258502, 0.5081891574554764, + 0.5109485743270583, 0.5137229745593818, 0.5165124395106142, 0.5193170509806894, + 0.5221368912137069, 0.5249720429003435, 0.5278225891802786, 0.5306886136446309, + 0.5335702003384117, 0.5364674337629877, 0.5393803988785598, 0.5423091811066545, + 0.5452538663326288, 0.5482145409081883, 0.5511912916539204, 0.5541842058618393, + 0.5571933712979462, 0.5602188762048033, 0.5632608093041209, 0.5663192597993595, + 0.5693943173783458, 0.572486072215902, 0.5755946149764913, 0.5787200368168754, + 0.5818624293887887, 0.585021884841625, 0.5881984958251406, 0.5913923554921704, + 0.5946035575013605, 0.5978321960199137, 0.6010783657263515, 0.6043421618132907, + 0.6076236799902344, 0.6109230164863786, 0.6142402680534349, 0.6175755319684665, + 0.620928906036742, 0.6243004885946023, 0.6276903785123455, 0.6310986751971253, + 0.6345254785958666, 0.637970889198196, 0.6414350080393891, 0.6449179367033329, + 0.6484197773255048, 0.6519406325959679, 0.6554806057623822, 0.659039800633032, + 0.6626183215798706, 0.6662162735415805, 0.6698337620266515, 0.6734708931164728, + 0.6771277734684463, 0.6808045103191123, 0.6845012114872953, 0.688217985377265, + 0.6919549409819159, 0.6957121878859629, 0.6994898362691555, 0.7032879969095076, + 0.7071067811865475, 0.7109463010845827, 0.7148066691959849, 0.718687998724491, + 0.7225904034885232, 0.7265139979245261, 0.7304588970903234, 0.7344252166684908, + 0.7384130729697496, 0.7424225829363761, 0.7464538641456323, 0.7505070348132126, + 0.7545822137967112, 0.7586795205991071, 0.762799075372269, 0.7669409989204777, + 0.7711054127039704, 0.7752924388424999, 0.7795022001189185, 0.7837348199827764, + 0.7879904225539431, 0.7922691326262467, 0.7965710756711334, 0.8008963778413465, + 0.805245165974627, 0.8096175675974316, 0.8140137109286738, 0.8184337248834821, + 0.8228777390769823, 0.8273458838280969, 0.8318382901633681, 0.8363550898207981, + 0.8408964152537144, 0.8454623996346523, 0.8500531768592616, 0.8546688815502312, + 0.8593096490612387, 0.8639756154809185, 0.8686669176368529, 0.8733836930995842, + 0.8781260801866495, 0.8828942179666361, 0.8876882462632604, 0.8925083056594671, + 0.8973545375015533, 0.9022270839033115, 0.9071260877501991, 0.9120516927035263, + 0.9170040432046711, 0.9219832844793128, 0.9269895625416926, 0.9320230241988943, + 0.9370838170551498, 0.9421720895161669, 0.9472879907934827, 0.9524316709088368, + 0.9576032806985735, 0.9628029718180622, 0.9680308967461471, 0.9732872087896164, + 0.9785720620876999, 0.9838856116165875, 0.9892280131939752, 0.9945994234836328, + }, + // Schema 8: + { + 0.5, 0.5013556375251013, 0.5027149505564014, 0.5040779490592088, + 0.5054446430258502, 0.5068150424757447, 0.5081891574554764, 0.509566998038869, + 0.5109485743270583, 0.5123338964485679, 0.5137229745593818, 0.5151158188430205, + 0.5165124395106142, 0.5179128468009786, 0.5193170509806894, 0.520725062344158, + 0.5221368912137069, 0.5235525479396449, 0.5249720429003435, 0.526395386502313, + 0.5278225891802786, 0.5292536613972564, 0.5306886136446309, 0.5321274564422321, + 0.5335702003384117, 0.5350168559101208, 0.5364674337629877, 0.5379219445313954, + 0.5393803988785598, 0.5408428074966075, 0.5423091811066545, 0.5437795304588847, + 0.5452538663326288, 0.5467321995364429, 0.5482145409081883, 0.549700901315111, + 0.5511912916539204, 0.5526857228508706, 0.5541842058618393, 0.5556867516724088, + 0.5571933712979462, 0.5587040757836845, 0.5602188762048033, 0.5617377836665098, + 0.5632608093041209, 0.564787964283144, 0.5663192597993595, 0.5678547070789026, + 0.5693943173783458, 0.5709381019847808, 0.572486072215902, 0.5740382394200894, + 0.5755946149764913, 0.5771552102951081, 0.5787200368168754, 0.5802891060137493, + 0.5818624293887887, 0.5834400184762408, 0.585021884841625, 0.5866080400818185, + 0.5881984958251406, 0.5897932637314379, 0.5913923554921704, 0.5929957828304968, + 0.5946035575013605, 0.5962156912915756, 0.5978321960199137, 0.5994530835371903, + 0.6010783657263515, 0.6027080545025619, 0.6043421618132907, 0.6059806996384005, + 0.6076236799902344, 0.6092711149137041, 0.6109230164863786, 0.6125793968185725, + 0.6142402680534349, 0.6159056423670379, 0.6175755319684665, 0.6192499490999082, + 0.620928906036742, 0.622612415087629, 0.6243004885946023, 0.6259931389331581, + 0.6276903785123455, 0.6293922197748583, 0.6310986751971253, 0.6328097572894031, + 0.6345254785958666, 0.6362458516947014, 0.637970889198196, 0.6397006037528346, + 0.6414350080393891, 0.6431741147730128, 0.6449179367033329, 0.6466664866145447, + 0.6484197773255048, 0.6501778216898253, 0.6519406325959679, 0.6537082229673385, + 0.6554806057623822, 0.6572577939746774, 0.659039800633032, 0.6608266388015788, + 0.6626183215798706, 0.6644148621029772, 0.6662162735415805, 0.6680225691020727, + 0.6698337620266515, 0.6716498655934177, 0.6734708931164728, 0.6752968579460171, + 0.6771277734684463, 0.6789636531064505, 0.6808045103191123, 0.6826503586020058, + 0.6845012114872953, 0.6863570825438342, 0.688217985377265, 0.690083933630119, + 0.6919549409819159, 0.6938310211492645, 0.6957121878859629, 0.6975984549830999, + 0.6994898362691555, 0.7013863456101023, 0.7032879969095076, 0.7051948041086352, + 0.7071067811865475, 0.7090239421602076, 0.7109463010845827, 0.7128738720527471, + 0.7148066691959849, 0.7167447066838943, 0.718687998724491, 0.7206365595643126, + 0.7225904034885232, 0.7245495448210174, 0.7265139979245261, 0.7284837772007218, + 0.7304588970903234, 0.7324393720732029, 0.7344252166684908, 0.7364164454346837, + 0.7384130729697496, 0.7404151139112358, 0.7424225829363761, 0.7444354947621984, + 0.7464538641456323, 0.7484777058836176, 0.7505070348132126, 0.7525418658117031, + 0.7545822137967112, 0.7566280937263048, 0.7586795205991071, 0.7607365094544071, + 0.762799075372269, 0.7648672334736434, 0.7669409989204777, 0.7690203869158282, + 0.7711054127039704, 0.7731960915705107, 0.7752924388424999, 0.7773944698885442, + 0.7795022001189185, 0.7816156449856788, 0.7837348199827764, 0.7858597406461707, + 0.7879904225539431, 0.7901268813264122, 0.7922691326262467, 0.7944171921585818, + 0.7965710756711334, 0.7987307989543135, 0.8008963778413465, 0.8030678282083853, + 0.805245165974627, 0.8074284071024302, 0.8096175675974316, 0.8118126635086642, + 0.8140137109286738, 0.8162207259936375, 0.8184337248834821, 0.820652723822003, + 0.8228777390769823, 0.8251087869603088, 0.8273458838280969, 0.8295890460808079, + 0.8318382901633681, 0.8340936325652911, 0.8363550898207981, 0.8386226785089391, + 0.8408964152537144, 0.8431763167241966, 0.8454623996346523, 0.8477546807446661, + 0.8500531768592616, 0.8523579048290255, 0.8546688815502312, 0.8569861239649629, + 0.8593096490612387, 0.8616394738731368, 0.8639756154809185, 0.8663180910111553, + 0.8686669176368529, 0.871022112577578, 0.8733836930995842, 0.8757516765159389, + 0.8781260801866495, 0.8805069215187917, 0.8828942179666361, 0.8852879870317771, + 0.8876882462632604, 0.890095013257712, 0.8925083056594671, 0.8949281411607002, + 0.8973545375015533, 0.8997875124702672, 0.9022270839033115, 0.9046732696855155, + 0.9071260877501991, 0.909585556079304, 0.9120516927035263, 0.9145245157024483, + 0.9170040432046711, 0.9194902933879467, 0.9219832844793128, 0.9244830347552253, + 0.9269895625416926, 0.92950288621441, 0.9320230241988943, 0.9345499949706191, + 0.9370838170551498, 0.93962450902828, 0.9421720895161669, 0.9447265771954693, + 0.9472879907934827, 0.9498563490882775, 0.9524316709088368, 0.9550139751351947, + 0.9576032806985735, 0.9601996065815236, 0.9628029718180622, 0.9654133954938133, + 0.9680308967461471, 0.9706554947643201, 0.9732872087896164, 0.9759260581154889, + 0.9785720620876999, 0.9812252401044634, 0.9838856116165875, 0.9865531961276168, + 0.9892280131939752, 0.9919100824251095, 0.9945994234836328, 0.9972960560854698, + }, +} + +// The nativeHistogramBounds above can be generated with the code below. +// +// TODO(beorn7): It's tempting to actually use `go generate` to generate the +// code above. However, this could lead to slightly different numbers on +// different architectures. We still need to come to terms if we are fine with +// that, or if we might prefer to specify precise numbers in the standard. +// +// var nativeHistogramBounds [][]float64 = make([][]float64, 9) +// +// func init() { +// // Populate nativeHistogramBounds. +// numBuckets := 1 +// for i := range nativeHistogramBounds { +// bounds := []float64{0.5} +// factor := math.Exp2(math.Exp2(float64(-i))) +// for j := 0; j < numBuckets-1; j++ { +// var bound float64 +// if (j+1)%2 == 0 { +// // Use previously calculated value for increased precision. +// bound = nativeHistogramBounds[i-1][j/2+1] +// } else { +// bound = bounds[j] * factor +// } +// bounds = append(bounds, bound) +// } +// numBuckets *= 2 +// nativeHistogramBounds[i] = bounds +// } +// } + // A Histogram counts individual observations from an event or sample stream in -// configurable buckets. Similar to a summary, it also provides a sum of -// observations and an observation count. +// configurable static buckets (or in dynamic sparse buckets as part of the +// experimental Native Histograms, see below for more details). Similar to a +// Summary, it also provides a sum of observations and an observation count. // // On the Prometheus server, quantiles can be calculated from a Histogram using -// the histogram_quantile function in the query language. +// the histogram_quantile PromQL function. // -// Note that Histograms, in contrast to Summaries, can be aggregated with the -// Prometheus query language (see the documentation for detailed -// procedures). However, Histograms require the user to pre-define suitable -// buckets, and they are in general less accurate. The Observe method of a -// Histogram has a very low performance overhead in comparison with the Observe -// method of a Summary. +// Note that Histograms, in contrast to Summaries, can be aggregated in PromQL +// (see the documentation for detailed procedures). However, Histograms require +// the user to pre-define suitable buckets, and they are in general less +// accurate. (Both problems are addressed by the experimental Native +// Histograms. To use them, configure a NativeHistogramBucketFactor in the +// HistogramOpts. They also require a Prometheus server v2.40+ with the +// corresponding feature flag enabled.) +// +// The Observe method of a Histogram has a very low performance overhead in +// comparison with the Observe method of a Summary. // // To create Histogram instances, use NewHistogram. type Histogram interface { @@ -50,7 +246,8 @@ type Histogram interface { // Observe adds a single observation to the histogram. Observations are // usually positive or zero. Negative observations are accepted but // prevent current versions of Prometheus from properly detecting - // counter resets in the sum of observations. See + // counter resets in the sum of observations. (The experimental Native + // Histograms handle negative observations properly.) See // https://prometheus.io/docs/practices/histograms/#count-and-sum-of-observations // for details. Observe(float64) @@ -64,18 +261,28 @@ const bucketLabel = "le" // tailored to broadly measure the response time (in seconds) of a network // service. Most likely, however, you will be required to define buckets // customized to your use case. -var ( - DefBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10} +var DefBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10} - errBucketLabelNotAllowed = fmt.Errorf( - "%q is not allowed as label name in histograms", bucketLabel, - ) +// DefNativeHistogramZeroThreshold is the default value for +// NativeHistogramZeroThreshold in the HistogramOpts. +// +// The value is 2^-128 (or 0.5*2^-127 in the actual IEEE 754 representation), +// which is a bucket boundary at all possible resolutions. +const DefNativeHistogramZeroThreshold = 2.938735877055719e-39 + +// NativeHistogramZeroThresholdZero can be used as NativeHistogramZeroThreshold +// in the HistogramOpts to create a zero bucket of width zero, i.e. a zero +// bucket that only receives observations of precisely zero. +const NativeHistogramZeroThresholdZero = -1 + +var errBucketLabelNotAllowed = fmt.Errorf( + "%q is not allowed as label name in histograms", bucketLabel, ) -// LinearBuckets creates 'count' buckets, each 'width' wide, where the lowest -// bucket has an upper bound of 'start'. The final +Inf bucket is not counted -// and not included in the returned slice. The returned slice is meant to be -// used for the Buckets field of HistogramOpts. +// LinearBuckets creates 'count' regular buckets, each 'width' wide, where the +// lowest bucket has an upper bound of 'start'. The final +Inf bucket is not +// counted and not included in the returned slice. The returned slice is meant +// to be used for the Buckets field of HistogramOpts. // // The function panics if 'count' is zero or negative. func LinearBuckets(start, width float64, count int) []float64 { @@ -90,11 +297,11 @@ func LinearBuckets(start, width float64, count int) []float64 { return buckets } -// ExponentialBuckets creates 'count' buckets, where the lowest bucket has an -// upper bound of 'start' and each following bucket's upper bound is 'factor' -// times the previous bucket's upper bound. The final +Inf bucket is not counted -// and not included in the returned slice. The returned slice is meant to be -// used for the Buckets field of HistogramOpts. +// ExponentialBuckets creates 'count' regular buckets, where the lowest bucket +// has an upper bound of 'start' and each following bucket's upper bound is +// 'factor' times the previous bucket's upper bound. The final +Inf bucket is +// not counted and not included in the returned slice. The returned slice is +// meant to be used for the Buckets field of HistogramOpts. // // The function panics if 'count' is 0 or negative, if 'start' is 0 or negative, // or if 'factor' is less than or equal 1. @@ -180,8 +387,97 @@ type HistogramOpts struct { // element in the slice is the upper inclusive bound of a bucket. The // values must be sorted in strictly increasing order. There is no need // to add a highest bucket with +Inf bound, it will be added - // implicitly. The default value is DefBuckets. + // implicitly. If Buckets is left as nil or set to a slice of length + // zero, it is replaced by default buckets. The default buckets are + // DefBuckets if no buckets for a native histogram (see below) are used, + // otherwise the default is no buckets. (In other words, if you want to + // use both reguler buckets and buckets for a native histogram, you have + // to define the regular buckets here explicitly.) Buckets []float64 + + // If NativeHistogramBucketFactor is greater than one, so-called sparse + // buckets are used (in addition to the regular buckets, if defined + // above). A Histogram with sparse buckets will be ingested as a Native + // Histogram by a Prometheus server with that feature enabled (requires + // Prometheus v2.40+). Sparse buckets are exponential buckets covering + // the whole float64 range (with the exception of the “zero” bucket, see + // NativeHistogramZeroThreshold below). From any one bucket to the next, + // the width of the bucket grows by a constant + // factor. NativeHistogramBucketFactor provides an upper bound for this + // factor (exception see below). The smaller + // NativeHistogramBucketFactor, the more buckets will be used and thus + // the more costly the histogram will become. A generally good trade-off + // between cost and accuracy is a value of 1.1 (each bucket is at most + // 10% wider than the previous one), which will result in each power of + // two divided into 8 buckets (e.g. there will be 8 buckets between 1 + // and 2, same as between 2 and 4, and 4 and 8, etc.). + // + // Details about the actually used factor: The factor is calculated as + // 2^(2^n), where n is an integer number between (and including) -8 and + // 4. n is chosen so that the resulting factor is the largest that is + // still smaller or equal to NativeHistogramBucketFactor. Note that the + // smallest possible factor is therefore approx. 1.00271 (i.e. 2^(2^-8) + // ). If NativeHistogramBucketFactor is greater than 1 but smaller than + // 2^(2^-8), then the actually used factor is still 2^(2^-8) even though + // it is larger than the provided NativeHistogramBucketFactor. + // + // NOTE: Native Histograms are still an experimental feature. Their + // behavior might still change without a major version + // bump. Subsequently, all NativeHistogram... options here might still + // change their behavior or name (or might completely disappear) without + // a major version bump. + NativeHistogramBucketFactor float64 + // All observations with an absolute value of less or equal + // NativeHistogramZeroThreshold are accumulated into a “zero” + // bucket. For best results, this should be close to a bucket + // boundary. This is usually the case if picking a power of two. If + // NativeHistogramZeroThreshold is left at zero, + // DefNativeHistogramZeroThreshold is used as the threshold. To configure + // a zero bucket with an actual threshold of zero (i.e. only + // observations of precisely zero will go into the zero bucket), set + // NativeHistogramZeroThreshold to the NativeHistogramZeroThresholdZero + // constant (or any negative float value). + NativeHistogramZeroThreshold float64 + + // The remaining fields define a strategy to limit the number of + // populated sparse buckets. If NativeHistogramMaxBucketNumber is left + // at zero, the number of buckets is not limited. (Note that this might + // lead to unbounded memory consumption if the values observed by the + // Histogram are sufficiently wide-spread. In particular, this could be + // used as a DoS attack vector. Where the observed values depend on + // external inputs, it is highly recommended to set a + // NativeHistogramMaxBucketNumber.) Once the set + // NativeHistogramMaxBucketNumber is exceeded, the following strategy is + // enacted: First, if the last reset (or the creation) of the histogram + // is at least NativeHistogramMinResetDuration ago, then the whole + // histogram is reset to its initial state (including regular + // buckets). If less time has passed, or if + // NativeHistogramMinResetDuration is zero, no reset is + // performed. Instead, the zero threshold is increased sufficiently to + // reduce the number of buckets to or below + // NativeHistogramMaxBucketNumber, but not to more than + // NativeHistogramMaxZeroThreshold. Thus, if + // NativeHistogramMaxZeroThreshold is already at or below the current + // zero threshold, nothing happens at this step. After that, if the + // number of buckets still exceeds NativeHistogramMaxBucketNumber, the + // resolution of the histogram is reduced by doubling the width of the + // sparse buckets (up to a growth factor between one bucket to the next + // of 2^(2^4) = 65536, see above). + NativeHistogramMaxBucketNumber uint32 + NativeHistogramMinResetDuration time.Duration + NativeHistogramMaxZeroThreshold float64 +} + +// HistogramVecOpts bundles the options to create a HistogramVec metric. +// It is mandatory to set HistogramOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type HistogramVecOpts struct { + HistogramOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels } // NewHistogram creates a new Histogram based on the provided HistogramOpts. It @@ -204,11 +500,11 @@ func NewHistogram(opts HistogramOpts) Histogram { func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogram { if len(desc.variableLabels) != len(labelValues) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, labelValues)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), labelValues)) } for _, n := range desc.variableLabels { - if n == bucketLabel { + if n.Name == bucketLabel { panic(errBucketLabelNotAllowed) } } @@ -218,16 +514,29 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr } } - if len(opts.Buckets) == 0 { - opts.Buckets = DefBuckets - } - h := &histogram{ - desc: desc, - upperBounds: opts.Buckets, - labelPairs: MakeLabelPairs(desc, labelValues), - counts: [2]*histogramCounts{{}, {}}, - now: time.Now, + desc: desc, + upperBounds: opts.Buckets, + labelPairs: MakeLabelPairs(desc, labelValues), + nativeHistogramMaxBuckets: opts.NativeHistogramMaxBucketNumber, + nativeHistogramMaxZeroThreshold: opts.NativeHistogramMaxZeroThreshold, + nativeHistogramMinResetDuration: opts.NativeHistogramMinResetDuration, + lastResetTime: time.Now(), + now: time.Now, + } + if len(h.upperBounds) == 0 && opts.NativeHistogramBucketFactor <= 1 { + h.upperBounds = DefBuckets + } + if opts.NativeHistogramBucketFactor <= 1 { + h.nativeHistogramSchema = math.MinInt32 // To mark that there are no sparse buckets. + } else { + switch { + case opts.NativeHistogramZeroThreshold > 0: + h.nativeHistogramZeroThreshold = opts.NativeHistogramZeroThreshold + case opts.NativeHistogramZeroThreshold == 0: + h.nativeHistogramZeroThreshold = DefNativeHistogramZeroThreshold + } // Leave h.nativeHistogramZeroThreshold at 0 otherwise. + h.nativeHistogramSchema = pickSchema(opts.NativeHistogramBucketFactor) } for i, upperBound := range h.upperBounds { if i < len(h.upperBounds)-1 { @@ -246,8 +555,12 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr } // Finally we know the final length of h.upperBounds and can make buckets // for both counts as well as exemplars: - h.counts[0].buckets = make([]uint64, len(h.upperBounds)) - h.counts[1].buckets = make([]uint64, len(h.upperBounds)) + h.counts[0] = &histogramCounts{buckets: make([]uint64, len(h.upperBounds))} + atomic.StoreUint64(&h.counts[0].nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold)) + atomic.StoreInt32(&h.counts[0].nativeHistogramSchema, h.nativeHistogramSchema) + h.counts[1] = &histogramCounts{buckets: make([]uint64, len(h.upperBounds))} + atomic.StoreUint64(&h.counts[1].nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold)) + atomic.StoreInt32(&h.counts[1].nativeHistogramSchema, h.nativeHistogramSchema) h.exemplars = make([]atomic.Value, len(h.upperBounds)+1) h.init(h) // Init self-collection. @@ -255,13 +568,98 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr } type histogramCounts struct { + // Order in this struct matters for the alignment required by atomic + // operations, see http://golang.org/pkg/sync/atomic/#pkg-note-BUG + // sumBits contains the bits of the float64 representing the sum of all - // observations. sumBits and count have to go first in the struct to - // guarantee alignment for atomic operations. - // http://golang.org/pkg/sync/atomic/#pkg-note-BUG + // observations. sumBits uint64 count uint64 + + // nativeHistogramZeroBucket counts all (positive and negative) + // observations in the zero bucket (with an absolute value less or equal + // the current threshold, see next field. + nativeHistogramZeroBucket uint64 + // nativeHistogramZeroThresholdBits is the bit pattern of the current + // threshold for the zero bucket. It's initially equal to + // nativeHistogramZeroThreshold but may change according to the bucket + // count limitation strategy. + nativeHistogramZeroThresholdBits uint64 + // nativeHistogramSchema may change over time according to the bucket + // count limitation strategy and therefore has to be saved here. + nativeHistogramSchema int32 + // Number of (positive and negative) sparse buckets. + nativeHistogramBucketsNumber uint32 + + // Regular buckets. buckets []uint64 + + // The sparse buckets for native histograms are implemented with a + // sync.Map for now. A dedicated data structure will likely be more + // efficient. There are separate maps for negative and positive + // observations. The map's value is an *int64, counting observations in + // that bucket. (Note that we don't use uint64 as an int64 won't + // overflow in practice, and working with signed numbers from the + // beginning simplifies the handling of deltas.) The map's key is the + // index of the bucket according to the used + // nativeHistogramSchema. Index 0 is for an upper bound of 1. + nativeHistogramBucketsPositive, nativeHistogramBucketsNegative sync.Map +} + +// observe manages the parts of observe that only affects +// histogramCounts. doSparse is true if sparse buckets should be done, +// too. +func (hc *histogramCounts) observe(v float64, bucket int, doSparse bool) { + if bucket < len(hc.buckets) { + atomic.AddUint64(&hc.buckets[bucket], 1) + } + atomicAddFloat(&hc.sumBits, v) + if doSparse && !math.IsNaN(v) { + var ( + key int + schema = atomic.LoadInt32(&hc.nativeHistogramSchema) + zeroThreshold = math.Float64frombits(atomic.LoadUint64(&hc.nativeHistogramZeroThresholdBits)) + bucketCreated, isInf bool + ) + if math.IsInf(v, 0) { + // Pretend v is MaxFloat64 but later increment key by one. + if math.IsInf(v, +1) { + v = math.MaxFloat64 + } else { + v = -math.MaxFloat64 + } + isInf = true + } + frac, exp := math.Frexp(math.Abs(v)) + if schema > 0 { + bounds := nativeHistogramBounds[schema] + key = sort.SearchFloat64s(bounds, frac) + (exp-1)*len(bounds) + } else { + key = exp + if frac == 0.5 { + key-- + } + offset := (1 << -schema) - 1 + key = (key + offset) >> -schema + } + if isInf { + key++ + } + switch { + case v > zeroThreshold: + bucketCreated = addToBucket(&hc.nativeHistogramBucketsPositive, key, 1) + case v < -zeroThreshold: + bucketCreated = addToBucket(&hc.nativeHistogramBucketsNegative, key, 1) + default: + atomic.AddUint64(&hc.nativeHistogramZeroBucket, 1) + } + if bucketCreated { + atomic.AddUint32(&hc.nativeHistogramBucketsNumber, 1) + } + } + // Increment count last as we take it as a signal that the observation + // is complete. + atomic.AddUint64(&hc.count, 1) } type histogram struct { @@ -276,7 +674,7 @@ type histogram struct { // perspective of the histogram) swap the hot–cold under the writeMtx // lock. A cooldown is awaited (while locked) by comparing the number of // observations with the initiation count. Once they match, then the - // last observation on the now cool one has completed. All cool fields must + // last observation on the now cool one has completed. All cold fields must // be merged into the new hot before releasing writeMtx. // // Fields with atomic access first! See alignment constraint: @@ -284,8 +682,10 @@ type histogram struct { countAndHotIdx uint64 selfCollector - desc *Desc - writeMtx sync.Mutex // Only used in the Write method. + desc *Desc + + // Only used in the Write method and for sparse bucket management. + mtx sync.Mutex // Two counts, one is "hot" for lock-free observations, the other is // "cold" for writing out a dto.Metric. It has to be an array of @@ -293,9 +693,15 @@ type histogram struct { // http://golang.org/pkg/sync/atomic/#pkg-note-BUG. counts [2]*histogramCounts - upperBounds []float64 - labelPairs []*dto.LabelPair - exemplars []atomic.Value // One more than buckets (to include +Inf), each a *dto.Exemplar. + upperBounds []float64 + labelPairs []*dto.LabelPair + exemplars []atomic.Value // One more than buckets (to include +Inf), each a *dto.Exemplar. + nativeHistogramSchema int32 // The initial schema. Set to math.MinInt32 if no sparse buckets are used. + nativeHistogramZeroThreshold float64 // The initial zero threshold. + nativeHistogramMaxZeroThreshold float64 + nativeHistogramMaxBuckets uint32 + nativeHistogramMinResetDuration time.Duration + lastResetTime time.Time // Protected by mtx. now func() time.Time // To mock out time.Now() for testing. } @@ -319,8 +725,8 @@ func (h *histogram) Write(out *dto.Metric) error { // the hot path, i.e. Observe is called much more often than Write. The // complication of making Write lock-free isn't worth it, if possible at // all. - h.writeMtx.Lock() - defer h.writeMtx.Unlock() + h.mtx.Lock() + defer h.mtx.Unlock() // Adding 1<<63 switches the hot index (from 0 to 1 or from 1 to 0) // without touching the count bits. See the struct comments for a full @@ -333,16 +739,16 @@ func (h *histogram) Write(out *dto.Metric) error { hotCounts := h.counts[n>>63] coldCounts := h.counts[(^n)>>63] - // Await cooldown. - for count != atomic.LoadUint64(&coldCounts.count) { - runtime.Gosched() // Let observations get work done. - } + waitForCooldown(count, coldCounts) his := &dto.Histogram{ Bucket: make([]*dto.Bucket, len(h.upperBounds)), SampleCount: proto.Uint64(count), SampleSum: proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.sumBits))), } + out.Histogram = his + out.Label = h.labelPairs + var cumCount uint64 for i, upperBound := range h.upperBounds { cumCount += atomic.LoadUint64(&coldCounts.buckets[i]) @@ -363,25 +769,21 @@ func (h *histogram) Write(out *dto.Metric) error { } his.Bucket = append(his.Bucket, b) } - - out.Histogram = his - out.Label = h.labelPairs - - // Finally add all the cold counts to the new hot counts and reset the cold counts. - atomic.AddUint64(&hotCounts.count, count) - atomic.StoreUint64(&coldCounts.count, 0) - for { - oldBits := atomic.LoadUint64(&hotCounts.sumBits) - newBits := math.Float64bits(math.Float64frombits(oldBits) + his.GetSampleSum()) - if atomic.CompareAndSwapUint64(&hotCounts.sumBits, oldBits, newBits) { - atomic.StoreUint64(&coldCounts.sumBits, 0) - break - } - } - for i := range h.upperBounds { - atomic.AddUint64(&hotCounts.buckets[i], atomic.LoadUint64(&coldCounts.buckets[i])) - atomic.StoreUint64(&coldCounts.buckets[i], 0) + if h.nativeHistogramSchema > math.MinInt32 { + his.ZeroThreshold = proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.nativeHistogramZeroThresholdBits))) + his.Schema = proto.Int32(atomic.LoadInt32(&coldCounts.nativeHistogramSchema)) + zeroBucket := atomic.LoadUint64(&coldCounts.nativeHistogramZeroBucket) + + defer func() { + coldCounts.nativeHistogramBucketsPositive.Range(addAndReset(&hotCounts.nativeHistogramBucketsPositive, &hotCounts.nativeHistogramBucketsNumber)) + coldCounts.nativeHistogramBucketsNegative.Range(addAndReset(&hotCounts.nativeHistogramBucketsNegative, &hotCounts.nativeHistogramBucketsNumber)) + }() + + his.ZeroCount = proto.Uint64(zeroBucket) + his.NegativeSpan, his.NegativeDelta = makeBuckets(&coldCounts.nativeHistogramBucketsNegative) + his.PositiveSpan, his.PositiveDelta = makeBuckets(&coldCounts.nativeHistogramBucketsPositive) } + addAndResetCounts(hotCounts, coldCounts) return nil } @@ -402,25 +804,216 @@ func (h *histogram) findBucket(v float64) int { // observe is the implementation for Observe without the findBucket part. func (h *histogram) observe(v float64, bucket int) { + // Do not add to sparse buckets for NaN observations. + doSparse := h.nativeHistogramSchema > math.MinInt32 && !math.IsNaN(v) // We increment h.countAndHotIdx so that the counter in the lower // 63 bits gets incremented. At the same time, we get the new value // back, which we can use to find the currently-hot counts. n := atomic.AddUint64(&h.countAndHotIdx, 1) hotCounts := h.counts[n>>63] + hotCounts.observe(v, bucket, doSparse) + if doSparse { + h.limitBuckets(hotCounts, v, bucket) + } +} - if bucket < len(h.upperBounds) { - atomic.AddUint64(&hotCounts.buckets[bucket], 1) +// limitBuckets applies a strategy to limit the number of populated sparse +// buckets. It's generally best effort, and there are situations where the +// number can go higher (if even the lowest resolution isn't enough to reduce +// the number sufficiently, or if the provided counts aren't fully updated yet +// by a concurrently happening Write call). +func (h *histogram) limitBuckets(counts *histogramCounts, value float64, bucket int) { + if h.nativeHistogramMaxBuckets == 0 { + return // No limit configured. } - for { - oldBits := atomic.LoadUint64(&hotCounts.sumBits) - newBits := math.Float64bits(math.Float64frombits(oldBits) + v) - if atomic.CompareAndSwapUint64(&hotCounts.sumBits, oldBits, newBits) { - break + if h.nativeHistogramMaxBuckets >= atomic.LoadUint32(&counts.nativeHistogramBucketsNumber) { + return // Bucket limit not exceeded yet. + } + + h.mtx.Lock() + defer h.mtx.Unlock() + + // The hot counts might have been swapped just before we acquired the + // lock. Re-fetch the hot counts first... + n := atomic.LoadUint64(&h.countAndHotIdx) + hotIdx := n >> 63 + coldIdx := (^n) >> 63 + hotCounts := h.counts[hotIdx] + coldCounts := h.counts[coldIdx] + // ...and then check again if we really have to reduce the bucket count. + if h.nativeHistogramMaxBuckets >= atomic.LoadUint32(&hotCounts.nativeHistogramBucketsNumber) { + return // Bucket limit not exceeded after all. + } + // Try the various strategies in order. + if h.maybeReset(hotCounts, coldCounts, coldIdx, value, bucket) { + return + } + if h.maybeWidenZeroBucket(hotCounts, coldCounts) { + return + } + h.doubleBucketWidth(hotCounts, coldCounts) +} + +// maybeReset resests the whole histogram if at least h.nativeHistogramMinResetDuration +// has been passed. It returns true if the histogram has been reset. The caller +// must have locked h.mtx. +func (h *histogram) maybeReset(hot, cold *histogramCounts, coldIdx uint64, value float64, bucket int) bool { + // We are using the possibly mocked h.now() rather than + // time.Since(h.lastResetTime) to enable testing. + if h.nativeHistogramMinResetDuration == 0 || h.now().Sub(h.lastResetTime) < h.nativeHistogramMinResetDuration { + return false + } + // Completely reset coldCounts. + h.resetCounts(cold) + // Repeat the latest observation to not lose it completely. + cold.observe(value, bucket, true) + // Make coldCounts the new hot counts while ressetting countAndHotIdx. + n := atomic.SwapUint64(&h.countAndHotIdx, (coldIdx<<63)+1) + count := n & ((1 << 63) - 1) + waitForCooldown(count, hot) + // Finally, reset the formerly hot counts, too. + h.resetCounts(hot) + h.lastResetTime = h.now() + return true +} + +// maybeWidenZeroBucket widens the zero bucket until it includes the existing +// buckets closest to the zero bucket (which could be two, if an equidistant +// negative and a positive bucket exists, but usually it's only one bucket to be +// merged into the new wider zero bucket). h.nativeHistogramMaxZeroThreshold +// limits how far the zero bucket can be extended, and if that's not enough to +// include an existing bucket, the method returns false. The caller must have +// locked h.mtx. +func (h *histogram) maybeWidenZeroBucket(hot, cold *histogramCounts) bool { + currentZeroThreshold := math.Float64frombits(atomic.LoadUint64(&hot.nativeHistogramZeroThresholdBits)) + if currentZeroThreshold >= h.nativeHistogramMaxZeroThreshold { + return false + } + // Find the key of the bucket closest to zero. + smallestKey := findSmallestKey(&hot.nativeHistogramBucketsPositive) + smallestNegativeKey := findSmallestKey(&hot.nativeHistogramBucketsNegative) + if smallestNegativeKey < smallestKey { + smallestKey = smallestNegativeKey + } + if smallestKey == math.MaxInt32 { + return false + } + newZeroThreshold := getLe(smallestKey, atomic.LoadInt32(&hot.nativeHistogramSchema)) + if newZeroThreshold > h.nativeHistogramMaxZeroThreshold { + return false // New threshold would exceed the max threshold. + } + atomic.StoreUint64(&cold.nativeHistogramZeroThresholdBits, math.Float64bits(newZeroThreshold)) + // Remove applicable buckets. + if _, loaded := cold.nativeHistogramBucketsNegative.LoadAndDelete(smallestKey); loaded { + atomicDecUint32(&cold.nativeHistogramBucketsNumber) + } + if _, loaded := cold.nativeHistogramBucketsPositive.LoadAndDelete(smallestKey); loaded { + atomicDecUint32(&cold.nativeHistogramBucketsNumber) + } + // Make cold counts the new hot counts. + n := atomic.AddUint64(&h.countAndHotIdx, 1<<63) + count := n & ((1 << 63) - 1) + // Swap the pointer names to represent the new roles and make + // the rest less confusing. + hot, cold = cold, hot + waitForCooldown(count, cold) + // Add all the now cold counts to the new hot counts... + addAndResetCounts(hot, cold) + // ...adjust the new zero threshold in the cold counts, too... + atomic.StoreUint64(&cold.nativeHistogramZeroThresholdBits, math.Float64bits(newZeroThreshold)) + // ...and then merge the newly deleted buckets into the wider zero + // bucket. + mergeAndDeleteOrAddAndReset := func(hotBuckets, coldBuckets *sync.Map) func(k, v interface{}) bool { + return func(k, v interface{}) bool { + key := k.(int) + bucket := v.(*int64) + if key == smallestKey { + // Merge into hot zero bucket... + atomic.AddUint64(&hot.nativeHistogramZeroBucket, uint64(atomic.LoadInt64(bucket))) + // ...and delete from cold counts. + coldBuckets.Delete(key) + atomicDecUint32(&cold.nativeHistogramBucketsNumber) + } else { + // Add to corresponding hot bucket... + if addToBucket(hotBuckets, key, atomic.LoadInt64(bucket)) { + atomic.AddUint32(&hot.nativeHistogramBucketsNumber, 1) + } + // ...and reset cold bucket. + atomic.StoreInt64(bucket, 0) + } + return true } } - // Increment count last as we take it as a signal that the observation - // is complete. - atomic.AddUint64(&hotCounts.count, 1) + + cold.nativeHistogramBucketsPositive.Range(mergeAndDeleteOrAddAndReset(&hot.nativeHistogramBucketsPositive, &cold.nativeHistogramBucketsPositive)) + cold.nativeHistogramBucketsNegative.Range(mergeAndDeleteOrAddAndReset(&hot.nativeHistogramBucketsNegative, &cold.nativeHistogramBucketsNegative)) + return true +} + +// doubleBucketWidth doubles the bucket width (by decrementing the schema +// number). Note that very sparse buckets could lead to a low reduction of the +// bucket count (or even no reduction at all). The method does nothing if the +// schema is already -4. +func (h *histogram) doubleBucketWidth(hot, cold *histogramCounts) { + coldSchema := atomic.LoadInt32(&cold.nativeHistogramSchema) + if coldSchema == -4 { + return // Already at lowest resolution. + } + coldSchema-- + atomic.StoreInt32(&cold.nativeHistogramSchema, coldSchema) + // Play it simple and just delete all cold buckets. + atomic.StoreUint32(&cold.nativeHistogramBucketsNumber, 0) + deleteSyncMap(&cold.nativeHistogramBucketsNegative) + deleteSyncMap(&cold.nativeHistogramBucketsPositive) + // Make coldCounts the new hot counts. + n := atomic.AddUint64(&h.countAndHotIdx, 1<<63) + count := n & ((1 << 63) - 1) + // Swap the pointer names to represent the new roles and make + // the rest less confusing. + hot, cold = cold, hot + waitForCooldown(count, cold) + // Add all the now cold counts to the new hot counts... + addAndResetCounts(hot, cold) + // ...adjust the schema in the cold counts, too... + atomic.StoreInt32(&cold.nativeHistogramSchema, coldSchema) + // ...and then merge the cold buckets into the wider hot buckets. + merge := func(hotBuckets *sync.Map) func(k, v interface{}) bool { + return func(k, v interface{}) bool { + key := k.(int) + bucket := v.(*int64) + // Adjust key to match the bucket to merge into. + if key > 0 { + key++ + } + key /= 2 + // Add to corresponding hot bucket. + if addToBucket(hotBuckets, key, atomic.LoadInt64(bucket)) { + atomic.AddUint32(&hot.nativeHistogramBucketsNumber, 1) + } + return true + } + } + + cold.nativeHistogramBucketsPositive.Range(merge(&hot.nativeHistogramBucketsPositive)) + cold.nativeHistogramBucketsNegative.Range(merge(&hot.nativeHistogramBucketsNegative)) + // Play it simple again and just delete all cold buckets. + atomic.StoreUint32(&cold.nativeHistogramBucketsNumber, 0) + deleteSyncMap(&cold.nativeHistogramBucketsNegative) + deleteSyncMap(&cold.nativeHistogramBucketsPositive) +} + +func (h *histogram) resetCounts(counts *histogramCounts) { + atomic.StoreUint64(&counts.sumBits, 0) + atomic.StoreUint64(&counts.count, 0) + atomic.StoreUint64(&counts.nativeHistogramZeroBucket, 0) + atomic.StoreUint64(&counts.nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold)) + atomic.StoreInt32(&counts.nativeHistogramSchema, h.nativeHistogramSchema) + atomic.StoreUint32(&counts.nativeHistogramBucketsNumber, 0) + for i := range h.upperBounds { + atomic.StoreUint64(&counts.buckets[i], 0) + } + deleteSyncMap(&counts.nativeHistogramBucketsNegative) + deleteSyncMap(&counts.nativeHistogramBucketsPositive) } // updateExemplar replaces the exemplar for the provided bucket. With empty @@ -448,15 +1041,23 @@ type HistogramVec struct { // NewHistogramVec creates a new HistogramVec based on the provided HistogramOpts and // partitioned by the given label names. func NewHistogramVec(opts HistogramOpts, labelNames []string) *HistogramVec { - desc := NewDesc( + return V2.NewHistogramVec(HistogramVecOpts{ + HistogramOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewHistogramVec creates a new HistogramVec based on the provided HistogramVecOpts. +func (v2) NewHistogramVec(opts HistogramVecOpts) *HistogramVec { + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &HistogramVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { - return newHistogram(desc, opts, lvs...) + return newHistogram(desc, opts.HistogramOpts, lvs...) }), } } @@ -516,7 +1117,8 @@ func (v *HistogramVec) GetMetricWith(labels Labels) (Observer, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Observe(42.21) +// +// myVec.WithLabelValues("404", "GET").Observe(42.21) func (v *HistogramVec) WithLabelValues(lvs ...string) Observer { h, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -527,7 +1129,8 @@ func (v *HistogramVec) WithLabelValues(lvs ...string) Observer { // With works as GetMetricWith but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) func (v *HistogramVec) With(labels Labels) Observer { h, err := v.GetMetricWith(labels) if err != nil { @@ -613,7 +1216,7 @@ func (h *constHistogram) Write(out *dto.Metric) error { // to send it to Prometheus in the Collect method. // // buckets is a map of upper bounds to cumulative counts, excluding the +Inf -// bucket. +// bucket. The +Inf bucket is implicit, and its value is equal to the provided count. // // NewConstHistogram returns an error if the length of labelValues is not // consistent with the variable labels in Desc or if Desc is invalid. @@ -668,3 +1271,229 @@ func (s buckSort) Swap(i, j int) { func (s buckSort) Less(i, j int) bool { return s[i].GetUpperBound() < s[j].GetUpperBound() } + +// pickSchema returns the largest number n between -4 and 8 such that +// 2^(2^-n) is less or equal the provided bucketFactor. +// +// Special cases: +// - bucketFactor <= 1: panics. +// - bucketFactor < 2^(2^-8) (but > 1): still returns 8. +func pickSchema(bucketFactor float64) int32 { + if bucketFactor <= 1 { + panic(fmt.Errorf("bucketFactor %f is <=1", bucketFactor)) + } + floor := math.Floor(math.Log2(math.Log2(bucketFactor))) + switch { + case floor <= -8: + return 8 + case floor >= 4: + return -4 + default: + return -int32(floor) + } +} + +func makeBuckets(buckets *sync.Map) ([]*dto.BucketSpan, []int64) { + var ii []int + buckets.Range(func(k, v interface{}) bool { + ii = append(ii, k.(int)) + return true + }) + sort.Ints(ii) + + if len(ii) == 0 { + return nil, nil + } + + var ( + spans []*dto.BucketSpan + deltas []int64 + prevCount int64 + nextI int + ) + + appendDelta := func(count int64) { + *spans[len(spans)-1].Length++ + deltas = append(deltas, count-prevCount) + prevCount = count + } + + for n, i := range ii { + v, _ := buckets.Load(i) + count := atomic.LoadInt64(v.(*int64)) + // Multiple spans with only small gaps in between are probably + // encoded more efficiently as one larger span with a few empty + // buckets. Needs some research to find the sweet spot. For now, + // we assume that gaps of one ore two buckets should not create + // a new span. + iDelta := int32(i - nextI) + if n == 0 || iDelta > 2 { + // We have to create a new span, either because we are + // at the very beginning, or because we have found a gap + // of more than two buckets. + spans = append(spans, &dto.BucketSpan{ + Offset: proto.Int32(iDelta), + Length: proto.Uint32(0), + }) + } else { + // We have found a small gap (or no gap at all). + // Insert empty buckets as needed. + for j := int32(0); j < iDelta; j++ { + appendDelta(0) + } + } + appendDelta(count) + nextI = i + 1 + } + return spans, deltas +} + +// addToBucket increments the sparse bucket at key by the provided amount. It +// returns true if a new sparse bucket had to be created for that. +func addToBucket(buckets *sync.Map, key int, increment int64) bool { + if existingBucket, ok := buckets.Load(key); ok { + // Fast path without allocation. + atomic.AddInt64(existingBucket.(*int64), increment) + return false + } + // Bucket doesn't exist yet. Slow path allocating new counter. + newBucket := increment // TODO(beorn7): Check if this is sufficient to not let increment escape. + if actualBucket, loaded := buckets.LoadOrStore(key, &newBucket); loaded { + // The bucket was created concurrently in another goroutine. + // Have to increment after all. + atomic.AddInt64(actualBucket.(*int64), increment) + return false + } + return true +} + +// addAndReset returns a function to be used with sync.Map.Range of spare +// buckets in coldCounts. It increments the buckets in the provided hotBuckets +// according to the buckets ranged through. It then resets all buckets ranged +// through to 0 (but leaves them in place so that they don't need to get +// recreated on the next scrape). +func addAndReset(hotBuckets *sync.Map, bucketNumber *uint32) func(k, v interface{}) bool { + return func(k, v interface{}) bool { + bucket := v.(*int64) + if addToBucket(hotBuckets, k.(int), atomic.LoadInt64(bucket)) { + atomic.AddUint32(bucketNumber, 1) + } + atomic.StoreInt64(bucket, 0) + return true + } +} + +func deleteSyncMap(m *sync.Map) { + m.Range(func(k, v interface{}) bool { + m.Delete(k) + return true + }) +} + +func findSmallestKey(m *sync.Map) int { + result := math.MaxInt32 + m.Range(func(k, v interface{}) bool { + key := k.(int) + if key < result { + result = key + } + return true + }) + return result +} + +func getLe(key int, schema int32) float64 { + // Here a bit of context about the behavior for the last bucket counting + // regular numbers (called simply "last bucket" below) and the bucket + // counting observations of ±Inf (called "inf bucket" below, with a key + // one higher than that of the "last bucket"): + // + // If we apply the usual formula to the last bucket, its upper bound + // would be calculated as +Inf. The reason is that the max possible + // regular float64 number (math.MaxFloat64) doesn't coincide with one of + // the calculated bucket boundaries. So the calculated boundary has to + // be larger than math.MaxFloat64, and the only float64 larger than + // math.MaxFloat64 is +Inf. However, we want to count actual + // observations of ±Inf in the inf bucket. Therefore, we have to treat + // the upper bound of the last bucket specially and set it to + // math.MaxFloat64. (The upper bound of the inf bucket, with its key + // being one higher than that of the last bucket, naturally comes out as + // +Inf by the usual formula. So that's fine.) + // + // math.MaxFloat64 has a frac of 0.9999999999999999 and an exp of + // 1024. If there were a float64 number following math.MaxFloat64, it + // would have a frac of 1.0 and an exp of 1024, or equivalently a frac + // of 0.5 and an exp of 1025. However, since frac must be smaller than + // 1, and exp must be smaller than 1025, either representation overflows + // a float64. (Which, in turn, is the reason that math.MaxFloat64 is the + // largest possible float64. Q.E.D.) However, the formula for + // calculating the upper bound from the idx and schema of the last + // bucket results in precisely that. It is either frac=1.0 & exp=1024 + // (for schema < 0) or frac=0.5 & exp=1025 (for schema >=0). (This is, + // by the way, a power of two where the exponent itself is a power of + // two, 2¹⁰ in fact, which coinicides with a bucket boundary in all + // schemas.) So these are the special cases we have to catch below. + if schema < 0 { + exp := key << -schema + if exp == 1024 { + // This is the last bucket before the overflow bucket + // (for ±Inf observations). Return math.MaxFloat64 as + // explained above. + return math.MaxFloat64 + } + return math.Ldexp(1, exp) + } + + fracIdx := key & ((1 << schema) - 1) + frac := nativeHistogramBounds[schema][fracIdx] + exp := (key >> schema) + 1 + if frac == 0.5 && exp == 1025 { + // This is the last bucket before the overflow bucket (for ±Inf + // observations). Return math.MaxFloat64 as explained above. + return math.MaxFloat64 + } + return math.Ldexp(frac, exp) +} + +// waitForCooldown returns after the count field in the provided histogramCounts +// has reached the provided count value. +func waitForCooldown(count uint64, counts *histogramCounts) { + for count != atomic.LoadUint64(&counts.count) { + runtime.Gosched() // Let observations get work done. + } +} + +// atomicAddFloat adds the provided float atomically to another float +// represented by the bit pattern the bits pointer is pointing to. +func atomicAddFloat(bits *uint64, v float64) { + for { + loadedBits := atomic.LoadUint64(bits) + newBits := math.Float64bits(math.Float64frombits(loadedBits) + v) + if atomic.CompareAndSwapUint64(bits, loadedBits, newBits) { + break + } + } +} + +// atomicDecUint32 atomically decrements the uint32 p points to. See +// https://pkg.go.dev/sync/atomic#AddUint32 to understand how this is done. +func atomicDecUint32(p *uint32) { + atomic.AddUint32(p, ^uint32(0)) +} + +// addAndResetCounts adds certain fields (count, sum, conventional buckets, zero +// bucket) from the cold counts to the corresponding fields in the hot +// counts. Those fields are then reset to 0 in the cold counts. +func addAndResetCounts(hot, cold *histogramCounts) { + atomic.AddUint64(&hot.count, atomic.LoadUint64(&cold.count)) + atomic.StoreUint64(&cold.count, 0) + coldSum := math.Float64frombits(atomic.LoadUint64(&cold.sumBits)) + atomicAddFloat(&hot.sumBits, coldSum) + atomic.StoreUint64(&cold.sumBits, 0) + for i := range hot.buckets { + atomic.AddUint64(&hot.buckets[i], atomic.LoadUint64(&cold.buckets[i])) + atomic.StoreUint64(&cold.buckets[i], 0) + } + atomic.AddUint64(&hot.nativeHistogramZeroBucket, atomic.LoadUint64(&cold.nativeHistogramZeroBucket)) + atomic.StoreUint64(&cold.nativeHistogramZeroBucket, 0) +} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go b/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go new file mode 100644 index 000000000..1ed5abe74 --- /dev/null +++ b/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go @@ -0,0 +1,60 @@ +// Copyright (c) 2015 Björn Rabenstein +// +// 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. +// +// The code in this package is copy/paste to avoid a dependency. Hence this file +// carries the copyright of the original repo. +// https://github.com/beorn7/floats +package internal + +import ( + "math" +) + +// minNormalFloat64 is the smallest positive normal value of type float64. +var minNormalFloat64 = math.Float64frombits(0x0010000000000000) + +// AlmostEqualFloat64 returns true if a and b are equal within a relative error +// of epsilon. See http://floating-point-gui.de/errors/comparison/ for the +// details of the applied method. +func AlmostEqualFloat64(a, b, epsilon float64) bool { + if a == b { + return true + } + absA := math.Abs(a) + absB := math.Abs(b) + diff := math.Abs(a - b) + if a == 0 || b == 0 || absA+absB < minNormalFloat64 { + return diff < epsilon*minNormalFloat64 + } + return diff/math.Min(absA+absB, math.MaxFloat64) < epsilon +} + +// AlmostEqualFloat64s is the slice form of AlmostEqualFloat64. +func AlmostEqualFloat64s(a, b []float64, epsilon float64) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if !AlmostEqualFloat64(a[i], b[i], epsilon) { + return false + } + } + return true +} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go b/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go index fd45cadc0..fd0750f2c 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go @@ -201,12 +201,15 @@ func (m *SequenceMatcher) isBJunk(s string) bool { // If IsJunk is not defined: // // Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where -// alo <= i <= i+k <= ahi -// blo <= j <= j+k <= bhi +// +// alo <= i <= i+k <= ahi +// blo <= j <= j+k <= bhi +// // and for all (i',j',k') meeting those conditions, -// k >= k' -// i <= i' -// and if i == i', j <= j' +// +// k >= k' +// i <= i' +// and if i == i', j <= j' // // In other words, of all maximal matching blocks, return one that // starts earliest in a, and of all those maximal matching blocks that diff --git a/vendor/github.com/prometheus/client_golang/prometheus/labels.go b/vendor/github.com/prometheus/client_golang/prometheus/labels.go index 6eee198fe..63ff8683c 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/labels.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/labels.go @@ -25,12 +25,85 @@ import ( // Labels represents a collection of label name -> value mappings. This type is // commonly used with the With(Labels) and GetMetricWith(Labels) methods of // metric vector Collectors, e.g.: -// myVec.With(Labels{"code": "404", "method": "GET"}).Add(42) +// +// myVec.With(Labels{"code": "404", "method": "GET"}).Add(42) // // The other use-case is the specification of constant label pairs in Opts or to // create a Desc. type Labels map[string]string +// ConstrainedLabels represents a label name and its constrain function +// to normalize label values. This type is commonly used when constructing +// metric vector Collectors. +type ConstrainedLabel struct { + Name string + Constraint func(string) string +} + +func (cl ConstrainedLabel) Constrain(v string) string { + if cl.Constraint == nil { + return v + } + return cl.Constraint(v) +} + +// ConstrainableLabels is an interface that allows creating of labels that can +// be optionally constrained. +// +// prometheus.V2().NewCounterVec(CounterVecOpts{ +// CounterOpts: {...}, // Usual CounterOpts fields +// VariableLabels: []ConstrainedLabels{ +// {Name: "A"}, +// {Name: "B", Constraint: func(v string) string { ... }}, +// }, +// }) +type ConstrainableLabels interface { + constrainedLabels() ConstrainedLabels + labelNames() []string +} + +// ConstrainedLabels represents a collection of label name -> constrain function +// to normalize label values. This type is commonly used when constructing +// metric vector Collectors. +type ConstrainedLabels []ConstrainedLabel + +func (cls ConstrainedLabels) constrainedLabels() ConstrainedLabels { + return cls +} + +func (cls ConstrainedLabels) labelNames() []string { + names := make([]string, len(cls)) + for i, label := range cls { + names[i] = label.Name + } + return names +} + +// UnconstrainedLabels represents collection of label without any constraint on +// their value. Thus, it is simply a collection of label names. +// +// UnconstrainedLabels([]string{ "A", "B" }) +// +// is equivalent to +// +// ConstrainedLabels { +// { Name: "A" }, +// { Name: "B" }, +// } +type UnconstrainedLabels []string + +func (uls UnconstrainedLabels) constrainedLabels() ConstrainedLabels { + constrainedLabels := make([]ConstrainedLabel, len(uls)) + for i, l := range uls { + constrainedLabels[i] = ConstrainedLabel{Name: l} + } + return constrainedLabels +} + +func (uls UnconstrainedLabels) labelNames() []string { + return uls +} + // reservedLabelPrefix is a prefix which is not legal in user-supplied // label names. const reservedLabelPrefix = "__" diff --git a/vendor/github.com/prometheus/client_golang/prometheus/metric.go b/vendor/github.com/prometheus/client_golang/prometheus/metric.go index f0941f6f0..07bbc9d76 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/metric.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/metric.go @@ -20,11 +20,9 @@ import ( "strings" "time" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - "github.com/prometheus/common/model" - dto "github.com/prometheus/client_model/go" + "github.com/prometheus/common/model" + "google.golang.org/protobuf/proto" ) var separatorByteSlice = []byte{model.SeparatorByte} // For convenient use with xxhash. @@ -187,7 +185,7 @@ func (m *withExemplarsMetric) Write(pb *dto.Metric) error { } else { // The +Inf bucket should be explicitly added if there is an exemplar for it, similar to non-const histogram logic in https://github.com/prometheus/client_golang/blob/main/prometheus/histogram.go#L357-L365. b := &dto.Bucket{ - CumulativeCount: proto.Uint64(pb.Histogram.Bucket[len(pb.Histogram.GetBucket())-1].GetCumulativeCount()), + CumulativeCount: proto.Uint64(pb.Histogram.GetSampleCount()), UpperBound: proto.Float64(math.Inf(1)), Exemplar: e, } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go index a4cc9810b..09b8d2fbe 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go @@ -37,6 +37,7 @@ import ( "fmt" "io" "net/http" + "strconv" "strings" "sync" "time" @@ -47,9 +48,10 @@ import ( ) const ( - contentTypeHeader = "Content-Type" - contentEncodingHeader = "Content-Encoding" - acceptEncodingHeader = "Accept-Encoding" + contentTypeHeader = "Content-Type" + contentEncodingHeader = "Content-Encoding" + acceptEncodingHeader = "Accept-Encoding" + processStartTimeHeader = "Process-Start-Time-Unix" ) var gzipPool = sync.Pool{ @@ -121,6 +123,9 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO } h := http.HandlerFunc(func(rsp http.ResponseWriter, req *http.Request) { + if !opts.ProcessStartTime.IsZero() { + rsp.Header().Set(processStartTimeHeader, strconv.FormatInt(opts.ProcessStartTime.Unix(), 10)) + } if inFlightSem != nil { select { case inFlightSem <- struct{}{}: // All good, carry on. @@ -366,6 +371,14 @@ type HandlerOpts struct { // (which changes the identity of the resulting series on the Prometheus // server). EnableOpenMetrics bool + // ProcessStartTime allows setting process start timevalue that will be exposed + // with "Process-Start-Time-Unix" response header along with the metrics + // payload. This allow callers to have efficient transformations to cumulative + // counters (e.g. OpenTelemetry) or generally _created timestamp estimation per + // scrape target. + // NOTE: This feature is experimental and not covered by OpenMetrics or Prometheus + // exposition format. + ProcessStartTime time.Time } // gzipAccepted returns whether the client will accept gzip-encoded content. diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go index 097aff2df..d3482c40c 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go @@ -68,17 +68,17 @@ func InstrumentRoundTripperCounter(counter *prometheus.CounterVec, next http.Rou o.apply(rtOpts) } - code, method := checkLabels(counter) + // Curry the counter with dynamic labels before checking the remaining labels. + code, method := checkLabels(counter.MustCurryWith(rtOpts.emptyDynamicLabels())) return func(r *http.Request) (*http.Response, error) { resp, err := next.RoundTrip(r) if err == nil { - exemplarAdd( - counter.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)), - 1, - rtOpts.getExemplarFn(r.Context()), - ) - counter.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)).Inc() + l := labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...) + for label, resolve := range rtOpts.extraLabelsFromCtx { + l[label] = resolve(resp.Request.Context()) + } + addWithExemplar(counter.With(l), 1, rtOpts.getExemplarFn(r.Context())) } return resp, err } @@ -111,17 +111,18 @@ func InstrumentRoundTripperDuration(obs prometheus.ObserverVec, next http.RoundT o.apply(rtOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(rtOpts.emptyDynamicLabels())) return func(r *http.Request) (*http.Response, error) { start := time.Now() resp, err := next.RoundTrip(r) if err == nil { - exemplarObserve( - obs.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)), - time.Since(start).Seconds(), - rtOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...) + for label, resolve := range rtOpts.extraLabelsFromCtx { + l[label] = resolve(resp.Request.Context()) + } + observeWithExemplar(obs.With(l), time.Since(start).Seconds(), rtOpts.getExemplarFn(r.Context())) } return resp, err } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go index bfe500987..3793036ad 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go @@ -28,7 +28,9 @@ import ( // magicString is used for the hacky label test in checkLabels. Remove once fixed. const magicString = "zZgWfBxLqvG8kc8IMv3POi2Bb0tZI3vAnBx+gBaFi9FyPzB/CzKUer1yufDa" -func exemplarObserve(obs prometheus.Observer, val float64, labels map[string]string) { +// observeWithExemplar is a wrapper for [prometheus.ExemplarAdder.ExemplarObserver], +// which falls back to [prometheus.Observer.Observe] if no labels are provided. +func observeWithExemplar(obs prometheus.Observer, val float64, labels map[string]string) { if labels == nil { obs.Observe(val) return @@ -36,7 +38,9 @@ func exemplarObserve(obs prometheus.Observer, val float64, labels map[string]str obs.(prometheus.ExemplarObserver).ObserveWithExemplar(val, labels) } -func exemplarAdd(obs prometheus.Counter, val float64, labels map[string]string) { +// addWithExemplar is a wrapper for [prometheus.ExemplarAdder.AddWithExemplar], +// which falls back to [prometheus.Counter.Add] if no labels are provided. +func addWithExemplar(obs prometheus.Counter, val float64, labels map[string]string) { if labels == nil { obs.Add(val) return @@ -83,7 +87,8 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler, op o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) if code { return func(w http.ResponseWriter, r *http.Request) { @@ -91,23 +96,22 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler, op d := newDelegator(w, nil) next.ServeHTTP(d, r) - exemplarObserve( - obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - time.Since(now).Seconds(), - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) } } return func(w http.ResponseWriter, r *http.Request) { now := time.Now() next.ServeHTTP(w, r) - - exemplarObserve( - obs.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)), - time.Since(now).Seconds(), - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, 0, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) } } @@ -134,28 +138,30 @@ func InstrumentHandlerCounter(counter *prometheus.CounterVec, next http.Handler, o.apply(hOpts) } - code, method := checkLabels(counter) + // Curry the counter with dynamic labels before checking the remaining labels. + code, method := checkLabels(counter.MustCurryWith(hOpts.emptyDynamicLabels())) if code { return func(w http.ResponseWriter, r *http.Request) { d := newDelegator(w, nil) next.ServeHTTP(d, r) - exemplarAdd( - counter.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - 1, - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r.Context())) } } return func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) - exemplarAdd( - counter.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)), - 1, - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, 0, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r.Context())) } } @@ -187,16 +193,17 @@ func InstrumentHandlerTimeToWriteHeader(obs prometheus.ObserverVec, next http.Ha o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) return func(w http.ResponseWriter, r *http.Request) { now := time.Now() d := newDelegator(w, func(status int) { - exemplarObserve( - obs.With(labels(code, method, r.Method, status, hOpts.extraMethods...)), - time.Since(now).Seconds(), - hOpts.getExemplarFn(r.Context()), - ) + l := labels(code, method, r.Method, status, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context())) }) next.ServeHTTP(d, r) } @@ -227,28 +234,32 @@ func InstrumentHandlerRequestSize(obs prometheus.ObserverVec, next http.Handler, o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) + if code { return func(w http.ResponseWriter, r *http.Request) { d := newDelegator(w, nil) next.ServeHTTP(d, r) size := computeApproximateRequestSize(r) - exemplarObserve( - obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - float64(size), - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r.Context())) } } return func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) size := computeApproximateRequestSize(r) - exemplarObserve( - obs.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)), - float64(size), - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, 0, hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r.Context())) } } @@ -277,16 +288,18 @@ func InstrumentHandlerResponseSize(obs prometheus.ObserverVec, next http.Handler o.apply(hOpts) } - code, method := checkLabels(obs) + // Curry the observer with dynamic labels before checking the remaining labels. + code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels())) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { d := newDelegator(w, nil) next.ServeHTTP(d, r) - exemplarObserve( - obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)), - float64(d.Written()), - hOpts.getExemplarFn(r.Context()), - ) + + l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...) + for label, resolve := range hOpts.extraLabelsFromCtx { + l[label] = resolve(r.Context()) + } + observeWithExemplar(obs.With(l), float64(d.Written()), hOpts.getExemplarFn(r.Context())) }) } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go index c590d912c..5d4383aa1 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/option.go @@ -24,14 +24,32 @@ type Option interface { apply(*options) } +// LabelValueFromCtx are used to compute the label value from request context. +// Context can be filled with values from request through middleware. +type LabelValueFromCtx func(ctx context.Context) string + // options store options for both a handler or round tripper. type options struct { - extraMethods []string - getExemplarFn func(requestCtx context.Context) prometheus.Labels + extraMethods []string + getExemplarFn func(requestCtx context.Context) prometheus.Labels + extraLabelsFromCtx map[string]LabelValueFromCtx } func defaultOptions() *options { - return &options{getExemplarFn: func(ctx context.Context) prometheus.Labels { return nil }} + return &options{ + getExemplarFn: func(ctx context.Context) prometheus.Labels { return nil }, + extraLabelsFromCtx: map[string]LabelValueFromCtx{}, + } +} + +func (o *options) emptyDynamicLabels() prometheus.Labels { + labels := prometheus.Labels{} + + for label := range o.extraLabelsFromCtx { + labels[label] = "" + } + + return labels } type optionApplyFunc func(*options) @@ -48,11 +66,19 @@ func WithExtraMethods(methods ...string) Option { }) } -// WithExemplarFromContext adds allows to put a hook to all counter and histogram metrics. -// If the hook function returns non-nil labels, exemplars will be added for that request, otherwise metric -// will get instrumented without exemplar. +// WithExemplarFromContext allows to inject function that will get exemplar from context that will be put to counter and histogram metrics. +// If the function returns nil labels or the metric does not support exemplars, no exemplar will be added (noop), but +// metric will continue to observe/increment. func WithExemplarFromContext(getExemplarFn func(requestCtx context.Context) prometheus.Labels) Option { return optionApplyFunc(func(o *options) { o.getExemplarFn = getExemplarFn }) } + +// WithLabelFromCtx registers a label for dynamic resolution with access to context. +// See the example for ExampleInstrumentHandlerWithLabelResolver for example usage +func WithLabelFromCtx(name string, valueFn LabelValueFromCtx) Option { + return optionApplyFunc(func(o *options) { + o.extraLabelsFromCtx[name] = valueFn + }) +} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/registry.go b/vendor/github.com/prometheus/client_golang/prometheus/registry.go index 325f665ff..44da9433b 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/registry.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/registry.go @@ -21,18 +21,17 @@ import ( "path/filepath" "runtime" "sort" + "strconv" "strings" "sync" "unicode/utf8" - "github.com/cespare/xxhash/v2" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - "github.com/prometheus/common/expfmt" + "github.com/prometheus/client_golang/prometheus/internal" + "github.com/cespare/xxhash/v2" dto "github.com/prometheus/client_model/go" - - "github.com/prometheus/client_golang/prometheus/internal" + "github.com/prometheus/common/expfmt" + "google.golang.org/protobuf/proto" ) const ( @@ -252,9 +251,12 @@ func (errs MultiError) MaybeUnwrap() error { } // Registry registers Prometheus collectors, collects their metrics, and gathers -// them into MetricFamilies for exposition. It implements both Registerer and -// Gatherer. The zero value is not usable. Create instances with NewRegistry or -// NewPedanticRegistry. +// them into MetricFamilies for exposition. It implements Registerer, Gatherer, +// and Collector. The zero value is not usable. Create instances with +// NewRegistry or NewPedanticRegistry. +// +// Registry implements Collector to allow it to be used for creating groups of +// metrics. See the Grouping example for how this can be done. type Registry struct { mtx sync.RWMutex collectorsByID map[uint64]Collector // ID is a hash of the descIDs. @@ -556,6 +558,31 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) { return internal.NormalizeMetricFamilies(metricFamiliesByName), errs.MaybeUnwrap() } +// Describe implements Collector. +func (r *Registry) Describe(ch chan<- *Desc) { + r.mtx.RLock() + defer r.mtx.RUnlock() + + // Only report the checked Collectors; unchecked collectors don't report any + // Desc. + for _, c := range r.collectorsByID { + c.Describe(ch) + } +} + +// Collect implements Collector. +func (r *Registry) Collect(ch chan<- Metric) { + r.mtx.RLock() + defer r.mtx.RUnlock() + + for _, c := range r.collectorsByID { + c.Collect(ch) + } + for _, c := range r.uncheckedCollectors { + c.Collect(ch) + } +} + // WriteToTextfile calls Gather on the provided Gatherer, encodes the result in the // Prometheus text format, and writes it to a temporary file. Upon success, the // temporary file is renamed to the provided filename. @@ -905,6 +932,10 @@ func checkMetricConsistency( h.WriteString(lp.GetValue()) h.Write(separatorByteSlice) } + if dtoMetric.TimestampMs != nil { + h.WriteString(strconv.FormatInt(*(dtoMetric.TimestampMs), 10)) + h.Write(separatorByteSlice) + } hSum := h.Sum64() if _, exists := metricHashes[hSum]; exists { return fmt.Errorf( @@ -934,7 +965,7 @@ func checkDescConsistency( copy(lpsFromDesc, desc.constLabelPairs) for _, l := range desc.variableLabels { lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{ - Name: proto.String(l), + Name: proto.String(l.Name), }) } if len(lpsFromDesc) != len(dtoMetric.Label) { diff --git a/vendor/github.com/prometheus/client_golang/prometheus/summary.go b/vendor/github.com/prometheus/client_golang/prometheus/summary.go index c5fa8ed7c..dd359264e 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/summary.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/summary.go @@ -22,11 +22,10 @@ import ( "sync/atomic" "time" - "github.com/beorn7/perks/quantile" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - dto "github.com/prometheus/client_model/go" + + "github.com/beorn7/perks/quantile" + "google.golang.org/protobuf/proto" ) // quantileLabel is used for the label that defines the quantile in a @@ -148,6 +147,18 @@ type SummaryOpts struct { BufCap uint32 } +// SummaryVecOpts bundles the options to create a SummaryVec metric. +// It is mandatory to set SummaryOpts, see there for mandatory fields. VariableLabels +// is optional and can safely be left to its default value. +type SummaryVecOpts struct { + SummaryOpts + + // VariableLabels are used to partition the metric vector by the given set + // of labels. Each label value will be constrained with the optional Contraint + // function, if provided. + VariableLabels ConstrainableLabels +} + // Problem with the sliding-window decay algorithm... The Merge method of // perk/quantile is actually not working as advertised - and it might be // unfixable, as the underlying algorithm is apparently not capable of merging @@ -178,11 +189,11 @@ func NewSummary(opts SummaryOpts) Summary { func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary { if len(desc.variableLabels) != len(labelValues) { - panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, labelValues)) + panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.labelNames(), labelValues)) } for _, n := range desc.variableLabels { - if n == quantileLabel { + if n.Name == quantileLabel { panic(errQuantileLabelNotAllowed) } } @@ -530,20 +541,28 @@ type SummaryVec struct { // it is handled by the Prometheus server internally, “quantile” is an illegal // label name. NewSummaryVec will panic if this label name is used. func NewSummaryVec(opts SummaryOpts, labelNames []string) *SummaryVec { - for _, ln := range labelNames { + return V2.NewSummaryVec(SummaryVecOpts{ + SummaryOpts: opts, + VariableLabels: UnconstrainedLabels(labelNames), + }) +} + +// NewSummaryVec creates a new SummaryVec based on the provided SummaryVecOpts. +func (v2) NewSummaryVec(opts SummaryVecOpts) *SummaryVec { + for _, ln := range opts.VariableLabels.labelNames() { if ln == quantileLabel { panic(errQuantileLabelNotAllowed) } } - desc := NewDesc( + desc := V2.NewDesc( BuildFQName(opts.Namespace, opts.Subsystem, opts.Name), opts.Help, - labelNames, + opts.VariableLabels, opts.ConstLabels, ) return &SummaryVec{ MetricVec: NewMetricVec(desc, func(lvs ...string) Metric { - return newSummary(desc, opts, lvs...) + return newSummary(desc, opts.SummaryOpts, lvs...) }), } } @@ -603,7 +622,8 @@ func (v *SummaryVec) GetMetricWith(labels Labels) (Observer, error) { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like -// myVec.WithLabelValues("404", "GET").Observe(42.21) +// +// myVec.WithLabelValues("404", "GET").Observe(42.21) func (v *SummaryVec) WithLabelValues(lvs ...string) Observer { s, err := v.GetMetricWithLabelValues(lvs...) if err != nil { @@ -614,7 +634,8 @@ func (v *SummaryVec) WithLabelValues(lvs ...string) Observer { // With works as GetMetricWith, but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like -// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) +// +// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) func (v *SummaryVec) With(labels Labels) Observer { s, err := v.GetMetricWith(labels) if err != nil { @@ -701,7 +722,8 @@ func (s *constSummary) Write(out *dto.Metric) error { // // quantiles maps ranks to quantile values. For example, a median latency of // 0.23s and a 99th percentile latency of 0.56s would be expressed as: -// map[float64]float64{0.5: 0.23, 0.99: 0.56} +// +// map[float64]float64{0.5: 0.23, 0.99: 0.56} // // NewConstSummary returns an error if the length of labelValues is not // consistent with the variable labels in Desc or if Desc is invalid. diff --git a/vendor/github.com/prometheus/client_golang/prometheus/testutil/promlint/promlint.go b/vendor/github.com/prometheus/client_golang/prometheus/testutil/promlint/promlint.go index a20f159b7..c8864b6c3 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/testutil/promlint/promlint.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/testutil/promlint/promlint.go @@ -287,17 +287,15 @@ func lintUnitAbbreviations(mf *dto.MetricFamily) []Problem { func metricUnits(m string) (unit, base string, ok bool) { ss := strings.Split(m, "_") - for unit, base := range units { - // Also check for "no prefix". - for _, p := range append(unitPrefixes, "") { - for _, s := range ss { - // Attempt to explicitly match a known unit with a known prefix, - // as some words may look like "units" when matching suffix. - // - // As an example, "thermometers" should not match "meters", but - // "kilometers" should. - if s == p+unit { - return p + unit, base, true + for _, s := range ss { + if base, found := units[s]; found { + return s, base, true + } + + for _, p := range unitPrefixes { + if strings.HasPrefix(s, p) { + if base, found := units[s[len(p):]]; found { + return s, base, true } } } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/timer.go b/vendor/github.com/prometheus/client_golang/prometheus/timer.go index 8d5f10523..52344fef5 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/timer.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/timer.go @@ -23,13 +23,24 @@ type Timer struct { } // NewTimer creates a new Timer. The provided Observer is used to observe a -// duration in seconds. Timer is usually used to time a function call in the +// duration in seconds. If the Observer implements ExemplarObserver, passing exemplar +// later on will be also supported. +// Timer is usually used to time a function call in the // following way: -// func TimeMe() { -// timer := NewTimer(myHistogram) -// defer timer.ObserveDuration() -// // Do actual work. -// } +// +// func TimeMe() { +// timer := NewTimer(myHistogram) +// defer timer.ObserveDuration() +// // Do actual work. +// } +// +// or +// +// func TimeMeWithExemplar() { +// timer := NewTimer(myHistogram) +// defer timer.ObserveDurationWithExemplar(exemplar) +// // Do actual work. +// } func NewTimer(o Observer) *Timer { return &Timer{ begin: time.Now(), @@ -52,3 +63,19 @@ func (t *Timer) ObserveDuration() time.Duration { } return d } + +// ObserveDurationWithExemplar is like ObserveDuration, but it will also +// observe exemplar with the duration unless exemplar is nil or provided Observer can't +// be casted to ExemplarObserver. +func (t *Timer) ObserveDurationWithExemplar(exemplar Labels) time.Duration { + d := time.Since(t.begin) + eo, ok := t.observer.(ExemplarObserver) + if ok && exemplar != nil { + eo.ObserveWithExemplar(d.Seconds(), exemplar) + return d + } + if t.observer != nil { + t.observer.Observe(d.Seconds()) + } + return d +} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/value.go b/vendor/github.com/prometheus/client_golang/prometheus/value.go index 2d3abc1cb..5f6bb8001 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/value.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/value.go @@ -19,13 +19,11 @@ import ( "time" "unicode/utf8" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" - "google.golang.org/protobuf/types/known/timestamppb" - "github.com/prometheus/client_golang/prometheus/internal" dto "github.com/prometheus/client_model/go" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/timestamppb" ) // ValueType is an enumeration of metric types that represent a simple value. @@ -188,9 +186,9 @@ func MakeLabelPairs(desc *Desc, labelValues []string) []*dto.LabelPair { return desc.constLabelPairs } labelPairs := make([]*dto.LabelPair, 0, totalLen) - for i, n := range desc.variableLabels { + for i, l := range desc.variableLabels { labelPairs = append(labelPairs, &dto.LabelPair{ - Name: proto.String(n), + Name: proto.String(l.Name), Value: proto.String(labelValues[i]), }) } diff --git a/vendor/github.com/prometheus/client_golang/prometheus/vec.go b/vendor/github.com/prometheus/client_golang/prometheus/vec.go index 7ae322590..f0d0015a0 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/vec.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/vec.go @@ -20,6 +20,24 @@ import ( "github.com/prometheus/common/model" ) +var labelsPool = &sync.Pool{ + New: func() interface{} { + return make(Labels) + }, +} + +func getLabelsFromPool() Labels { + return labelsPool.Get().(Labels) +} + +func putLabelsToPool(labels Labels) { + for k := range labels { + delete(labels, k) + } + + labelsPool.Put(labels) +} + // MetricVec is a Collector to bundle metrics of the same name that differ in // their label values. MetricVec is not used directly but as a building block // for implementations of vectors of a given metric type, like GaugeVec, @@ -72,6 +90,7 @@ func NewMetricVec(desc *Desc, newMetric func(lvs ...string) Metric) *MetricVec { // with a performance overhead (for creating and processing the Labels map). // See also the CounterVec example. func (m *MetricVec) DeleteLabelValues(lvs ...string) bool { + lvs = constrainLabelValues(m.desc, lvs, m.curry) h, err := m.hashLabelValues(lvs) if err != nil { return false @@ -91,6 +110,9 @@ func (m *MetricVec) DeleteLabelValues(lvs ...string) bool { // This method is used for the same purpose as DeleteLabelValues(...string). See // there for pros and cons of the two methods. func (m *MetricVec) Delete(labels Labels) bool { + labels = constrainLabels(m.desc, labels) + defer putLabelsToPool(labels) + h, err := m.hashLabels(labels) if err != nil { return false @@ -106,6 +128,9 @@ func (m *MetricVec) Delete(labels Labels) bool { // Note that curried labels will never be matched if deleting from the curried vector. // To match curried labels with DeletePartialMatch, it must be called on the base vector. func (m *MetricVec) DeletePartialMatch(labels Labels) int { + labels = constrainLabels(m.desc, labels) + defer putLabelsToPool(labels) + return m.metricMap.deleteByLabels(labels, m.curry) } @@ -145,10 +170,10 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) { iCurry int ) for i, label := range m.desc.variableLabels { - val, ok := labels[label] + val, ok := labels[label.Name] if iCurry < len(oldCurry) && oldCurry[iCurry].index == i { if ok { - return nil, fmt.Errorf("label name %q is already curried", label) + return nil, fmt.Errorf("label name %q is already curried", label.Name) } newCurry = append(newCurry, oldCurry[iCurry]) iCurry++ @@ -156,7 +181,7 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) { if !ok { continue // Label stays uncurried. } - newCurry = append(newCurry, curriedLabelValue{i, val}) + newCurry = append(newCurry, curriedLabelValue{i, label.Constrain(val)}) } } if l := len(oldCurry) + len(labels) - len(newCurry); l > 0 { @@ -199,6 +224,7 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) { // a wrapper around MetricVec, implementing a vector for a specific Metric // implementation, for example GaugeVec. func (m *MetricVec) GetMetricWithLabelValues(lvs ...string) (Metric, error) { + lvs = constrainLabelValues(m.desc, lvs, m.curry) h, err := m.hashLabelValues(lvs) if err != nil { return nil, err @@ -224,6 +250,9 @@ func (m *MetricVec) GetMetricWithLabelValues(lvs ...string) (Metric, error) { // around MetricVec, implementing a vector for a specific Metric implementation, // for example GaugeVec. func (m *MetricVec) GetMetricWith(labels Labels) (Metric, error) { + labels = constrainLabels(m.desc, labels) + defer putLabelsToPool(labels) + h, err := m.hashLabels(labels) if err != nil { return nil, err @@ -266,16 +295,16 @@ func (m *MetricVec) hashLabels(labels Labels) (uint64, error) { iCurry int ) for i, label := range m.desc.variableLabels { - val, ok := labels[label] + val, ok := labels[label.Name] if iCurry < len(curry) && curry[iCurry].index == i { if ok { - return 0, fmt.Errorf("label name %q is already curried", label) + return 0, fmt.Errorf("label name %q is already curried", label.Name) } h = m.hashAdd(h, curry[iCurry].value) iCurry++ } else { if !ok { - return 0, fmt.Errorf("label name %q missing in label map", label) + return 0, fmt.Errorf("label name %q missing in label map", label.Name) } h = m.hashAdd(h, val) } @@ -453,7 +482,7 @@ func valueMatchesVariableOrCurriedValue(targetValue string, index int, values [] func matchPartialLabels(desc *Desc, values []string, labels Labels, curry []curriedLabelValue) bool { for l, v := range labels { // Check if the target label exists in our metrics and get the index. - varLabelIndex, validLabel := indexOf(l, desc.variableLabels) + varLabelIndex, validLabel := indexOf(l, desc.variableLabels.labelNames()) if validLabel { // Check the value of that label against the target value. // We don't consider curried values in partial matches. @@ -605,7 +634,7 @@ func matchLabels(desc *Desc, values []string, labels Labels, curry []curriedLabe iCurry++ continue } - if values[i] != labels[k] { + if values[i] != labels[k.Name] { return false } } @@ -621,7 +650,7 @@ func extractLabelValues(desc *Desc, labels Labels, curry []curriedLabelValue) [] iCurry++ continue } - labelValues[i] = labels[k] + labelValues[i] = labels[k.Name] } return labelValues } @@ -640,3 +669,35 @@ func inlineLabelValues(lvs []string, curry []curriedLabelValue) []string { } return labelValues } + +func constrainLabels(desc *Desc, labels Labels) Labels { + constrainedLabels := getLabelsFromPool() + for l, v := range labels { + if i, ok := indexOf(l, desc.variableLabels.labelNames()); ok { + v = desc.variableLabels[i].Constrain(v) + } + + constrainedLabels[l] = v + } + + return constrainedLabels +} + +func constrainLabelValues(desc *Desc, lvs []string, curry []curriedLabelValue) []string { + constrainedValues := make([]string, len(lvs)) + var iCurry, iLVs int + for i := 0; i < len(lvs)+len(curry); i++ { + if iCurry < len(curry) && curry[iCurry].index == i { + iCurry++ + continue + } + + if i < len(desc.variableLabels) { + constrainedValues[iLVs] = desc.variableLabels[i].Constrain(lvs[iLVs]) + } else { + constrainedValues[iLVs] = lvs[iLVs] + } + iLVs++ + } + return constrainedValues +} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/vnext.go b/vendor/github.com/prometheus/client_golang/prometheus/vnext.go new file mode 100644 index 000000000..42bc3a8f0 --- /dev/null +++ b/vendor/github.com/prometheus/client_golang/prometheus/vnext.go @@ -0,0 +1,23 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package prometheus + +type v2 struct{} + +// V2 is a struct that can be referenced to access experimental API that might +// be present in v2 of client golang someday. It offers extended functionality +// of v1 with slightly changed API. It is acceptable to use some pieces from v1 +// and e.g `prometheus.NewGauge` and some from v2 e.g. `prometheus.V2.NewDesc` +// in the same codebase. +var V2 = v2{} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/wrap.go b/vendor/github.com/prometheus/client_golang/prometheus/wrap.go index 1498ee144..25da157f1 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/wrap.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/wrap.go @@ -17,12 +17,10 @@ import ( "fmt" "sort" - //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. - "github.com/golang/protobuf/proto" + "github.com/prometheus/client_golang/prometheus/internal" dto "github.com/prometheus/client_model/go" - - "github.com/prometheus/client_golang/prometheus/internal" + "google.golang.org/protobuf/proto" ) // WrapRegistererWith returns a Registerer wrapping the provided @@ -206,7 +204,7 @@ func wrapDesc(desc *Desc, prefix string, labels Labels) *Desc { constLabels[ln] = lv } // NewDesc will do remaining validations. - newDesc := NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels) + newDesc := V2.NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels) // Propagate errors if there was any. This will override any errer // created by NewDesc above, i.e. earlier errors get precedence. if desc.err != nil { diff --git a/vendor/github.com/prometheus/client_model/go/metrics.pb.go b/vendor/github.com/prometheus/client_model/go/metrics.pb.go index 35904ea19..2b5bca4b9 100644 --- a/vendor/github.com/prometheus/client_model/go/metrics.pb.go +++ b/vendor/github.com/prometheus/client_model/go/metrics.pb.go @@ -1,25 +1,38 @@ +// Copyright 2013 Prometheus Team +// 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. + // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.20.3 // source: io/prometheus/client/metrics.proto package io_prometheus_client import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" ) -// 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.ProtoPackageIsVersion3 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type MetricType int32 @@ -38,23 +51,25 @@ const ( MetricType_GAUGE_HISTOGRAM MetricType = 5 ) -var MetricType_name = map[int32]string{ - 0: "COUNTER", - 1: "GAUGE", - 2: "SUMMARY", - 3: "UNTYPED", - 4: "HISTOGRAM", - 5: "GAUGE_HISTOGRAM", -} - -var MetricType_value = map[string]int32{ - "COUNTER": 0, - "GAUGE": 1, - "SUMMARY": 2, - "UNTYPED": 3, - "HISTOGRAM": 4, - "GAUGE_HISTOGRAM": 5, -} +// Enum value maps for MetricType. +var ( + MetricType_name = map[int32]string{ + 0: "COUNTER", + 1: "GAUGE", + 2: "SUMMARY", + 3: "UNTYPED", + 4: "HISTOGRAM", + 5: "GAUGE_HISTOGRAM", + } + MetricType_value = map[string]int32{ + "COUNTER": 0, + "GAUGE": 1, + "SUMMARY": 2, + "UNTYPED": 3, + "HISTOGRAM": 4, + "GAUGE_HISTOGRAM": 5, + } +) func (x MetricType) Enum() *MetricType { p := new(MetricType) @@ -63,449 +78,519 @@ func (x MetricType) Enum() *MetricType { } func (x MetricType) String() string { - return proto.EnumName(MetricType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (x *MetricType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(MetricType_value, data, "MetricType") +func (MetricType) Descriptor() protoreflect.EnumDescriptor { + return file_io_prometheus_client_metrics_proto_enumTypes[0].Descriptor() +} + +func (MetricType) Type() protoreflect.EnumType { + return &file_io_prometheus_client_metrics_proto_enumTypes[0] +} + +func (x MetricType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *MetricType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = MetricType(value) + *x = MetricType(num) return nil } +// Deprecated: Use MetricType.Descriptor instead. func (MetricType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{0} + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{0} } type LabelPair struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *LabelPair) Reset() { *m = LabelPair{} } -func (m *LabelPair) String() string { return proto.CompactTextString(m) } -func (*LabelPair) ProtoMessage() {} -func (*LabelPair) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{0} + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` } -func (m *LabelPair) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LabelPair.Unmarshal(m, b) -} -func (m *LabelPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LabelPair.Marshal(b, m, deterministic) -} -func (m *LabelPair) XXX_Merge(src proto.Message) { - xxx_messageInfo_LabelPair.Merge(m, src) +func (x *LabelPair) Reset() { + *x = LabelPair{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *LabelPair) XXX_Size() int { - return xxx_messageInfo_LabelPair.Size(m) + +func (x *LabelPair) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *LabelPair) XXX_DiscardUnknown() { - xxx_messageInfo_LabelPair.DiscardUnknown(m) + +func (*LabelPair) ProtoMessage() {} + +func (x *LabelPair) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_LabelPair proto.InternalMessageInfo +// Deprecated: Use LabelPair.ProtoReflect.Descriptor instead. +func (*LabelPair) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{0} +} -func (m *LabelPair) GetName() string { - if m != nil && m.Name != nil { - return *m.Name +func (x *LabelPair) GetName() string { + if x != nil && x.Name != nil { + return *x.Name } return "" } -func (m *LabelPair) GetValue() string { - if m != nil && m.Value != nil { - return *m.Value +func (x *LabelPair) GetValue() string { + if x != nil && x.Value != nil { + return *x.Value } return "" } type Gauge struct { - Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Gauge) Reset() { *m = Gauge{} } -func (m *Gauge) String() string { return proto.CompactTextString(m) } -func (*Gauge) ProtoMessage() {} -func (*Gauge) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{1} + Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` } -func (m *Gauge) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Gauge.Unmarshal(m, b) -} -func (m *Gauge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Gauge.Marshal(b, m, deterministic) -} -func (m *Gauge) XXX_Merge(src proto.Message) { - xxx_messageInfo_Gauge.Merge(m, src) +func (x *Gauge) Reset() { + *x = Gauge{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Gauge) XXX_Size() int { - return xxx_messageInfo_Gauge.Size(m) + +func (x *Gauge) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Gauge) XXX_DiscardUnknown() { - xxx_messageInfo_Gauge.DiscardUnknown(m) + +func (*Gauge) ProtoMessage() {} + +func (x *Gauge) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Gauge proto.InternalMessageInfo +// Deprecated: Use Gauge.ProtoReflect.Descriptor instead. +func (*Gauge) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{1} +} -func (m *Gauge) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Gauge) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } type Counter struct { - Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` - Exemplar *Exemplar `protobuf:"bytes,2,opt,name=exemplar" json:"exemplar,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Counter) Reset() { *m = Counter{} } -func (m *Counter) String() string { return proto.CompactTextString(m) } -func (*Counter) ProtoMessage() {} -func (*Counter) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{2} + Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` + Exemplar *Exemplar `protobuf:"bytes,2,opt,name=exemplar" json:"exemplar,omitempty"` } -func (m *Counter) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Counter.Unmarshal(m, b) -} -func (m *Counter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Counter.Marshal(b, m, deterministic) -} -func (m *Counter) XXX_Merge(src proto.Message) { - xxx_messageInfo_Counter.Merge(m, src) +func (x *Counter) Reset() { + *x = Counter{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Counter) XXX_Size() int { - return xxx_messageInfo_Counter.Size(m) + +func (x *Counter) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Counter) XXX_DiscardUnknown() { - xxx_messageInfo_Counter.DiscardUnknown(m) + +func (*Counter) ProtoMessage() {} + +func (x *Counter) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Counter proto.InternalMessageInfo +// Deprecated: Use Counter.ProtoReflect.Descriptor instead. +func (*Counter) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{2} +} -func (m *Counter) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Counter) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } -func (m *Counter) GetExemplar() *Exemplar { - if m != nil { - return m.Exemplar +func (x *Counter) GetExemplar() *Exemplar { + if x != nil { + return x.Exemplar } return nil } type Quantile struct { - Quantile *float64 `protobuf:"fixed64,1,opt,name=quantile" json:"quantile,omitempty"` - Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Quantile) Reset() { *m = Quantile{} } -func (m *Quantile) String() string { return proto.CompactTextString(m) } -func (*Quantile) ProtoMessage() {} -func (*Quantile) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{3} + Quantile *float64 `protobuf:"fixed64,1,opt,name=quantile" json:"quantile,omitempty"` + Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` } -func (m *Quantile) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Quantile.Unmarshal(m, b) -} -func (m *Quantile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Quantile.Marshal(b, m, deterministic) -} -func (m *Quantile) XXX_Merge(src proto.Message) { - xxx_messageInfo_Quantile.Merge(m, src) +func (x *Quantile) Reset() { + *x = Quantile{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Quantile) XXX_Size() int { - return xxx_messageInfo_Quantile.Size(m) + +func (x *Quantile) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Quantile) XXX_DiscardUnknown() { - xxx_messageInfo_Quantile.DiscardUnknown(m) + +func (*Quantile) ProtoMessage() {} + +func (x *Quantile) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Quantile proto.InternalMessageInfo +// Deprecated: Use Quantile.ProtoReflect.Descriptor instead. +func (*Quantile) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{3} +} -func (m *Quantile) GetQuantile() float64 { - if m != nil && m.Quantile != nil { - return *m.Quantile +func (x *Quantile) GetQuantile() float64 { + if x != nil && x.Quantile != nil { + return *x.Quantile } return 0 } -func (m *Quantile) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Quantile) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } type Summary struct { - SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"` - SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"` - Quantile []*Quantile `protobuf:"bytes,3,rep,name=quantile" json:"quantile,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Summary) Reset() { *m = Summary{} } -func (m *Summary) String() string { return proto.CompactTextString(m) } -func (*Summary) ProtoMessage() {} -func (*Summary) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{4} + SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"` + SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"` + Quantile []*Quantile `protobuf:"bytes,3,rep,name=quantile" json:"quantile,omitempty"` } -func (m *Summary) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Summary.Unmarshal(m, b) -} -func (m *Summary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Summary.Marshal(b, m, deterministic) -} -func (m *Summary) XXX_Merge(src proto.Message) { - xxx_messageInfo_Summary.Merge(m, src) +func (x *Summary) Reset() { + *x = Summary{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Summary) XXX_Size() int { - return xxx_messageInfo_Summary.Size(m) + +func (x *Summary) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Summary) XXX_DiscardUnknown() { - xxx_messageInfo_Summary.DiscardUnknown(m) + +func (*Summary) ProtoMessage() {} + +func (x *Summary) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Summary proto.InternalMessageInfo +// Deprecated: Use Summary.ProtoReflect.Descriptor instead. +func (*Summary) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{4} +} -func (m *Summary) GetSampleCount() uint64 { - if m != nil && m.SampleCount != nil { - return *m.SampleCount +func (x *Summary) GetSampleCount() uint64 { + if x != nil && x.SampleCount != nil { + return *x.SampleCount } return 0 } -func (m *Summary) GetSampleSum() float64 { - if m != nil && m.SampleSum != nil { - return *m.SampleSum +func (x *Summary) GetSampleSum() float64 { + if x != nil && x.SampleSum != nil { + return *x.SampleSum } return 0 } -func (m *Summary) GetQuantile() []*Quantile { - if m != nil { - return m.Quantile +func (x *Summary) GetQuantile() []*Quantile { + if x != nil { + return x.Quantile } return nil } type Untyped struct { - Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Untyped) Reset() { *m = Untyped{} } -func (m *Untyped) String() string { return proto.CompactTextString(m) } -func (*Untyped) ProtoMessage() {} -func (*Untyped) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{5} + Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"` } -func (m *Untyped) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Untyped.Unmarshal(m, b) -} -func (m *Untyped) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Untyped.Marshal(b, m, deterministic) -} -func (m *Untyped) XXX_Merge(src proto.Message) { - xxx_messageInfo_Untyped.Merge(m, src) +func (x *Untyped) Reset() { + *x = Untyped{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Untyped) XXX_Size() int { - return xxx_messageInfo_Untyped.Size(m) + +func (x *Untyped) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Untyped) XXX_DiscardUnknown() { - xxx_messageInfo_Untyped.DiscardUnknown(m) + +func (*Untyped) ProtoMessage() {} + +func (x *Untyped) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Untyped proto.InternalMessageInfo +// Deprecated: Use Untyped.ProtoReflect.Descriptor instead. +func (*Untyped) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{5} +} -func (m *Untyped) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Untyped) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } type Histogram struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"` - SampleCountFloat *float64 `protobuf:"fixed64,4,opt,name=sample_count_float,json=sampleCountFloat" json:"sample_count_float,omitempty"` + SampleCountFloat *float64 `protobuf:"fixed64,4,opt,name=sample_count_float,json=sampleCountFloat" json:"sample_count_float,omitempty"` // Overrides sample_count if > 0. SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"` // Buckets for the conventional histogram. - Bucket []*Bucket `protobuf:"bytes,3,rep,name=bucket" json:"bucket,omitempty"` + Bucket []*Bucket `protobuf:"bytes,3,rep,name=bucket" json:"bucket,omitempty"` // Ordered in increasing order of upper_bound, +Inf bucket is optional. // schema defines the bucket schema. Currently, valid numbers are -4 <= n <= 8. // They are all for base-2 bucket schemas, where 1 is a bucket boundary in each case, and // then each power of two is divided into 2^n logarithmic buckets. // Or in other words, each bucket boundary is the previous boundary times 2^(2^-n). // In the future, more bucket schemas may be added using numbers < -4 or > 8. Schema *int32 `protobuf:"zigzag32,5,opt,name=schema" json:"schema,omitempty"` - ZeroThreshold *float64 `protobuf:"fixed64,6,opt,name=zero_threshold,json=zeroThreshold" json:"zero_threshold,omitempty"` - ZeroCount *uint64 `protobuf:"varint,7,opt,name=zero_count,json=zeroCount" json:"zero_count,omitempty"` - ZeroCountFloat *float64 `protobuf:"fixed64,8,opt,name=zero_count_float,json=zeroCountFloat" json:"zero_count_float,omitempty"` + ZeroThreshold *float64 `protobuf:"fixed64,6,opt,name=zero_threshold,json=zeroThreshold" json:"zero_threshold,omitempty"` // Breadth of the zero bucket. + ZeroCount *uint64 `protobuf:"varint,7,opt,name=zero_count,json=zeroCount" json:"zero_count,omitempty"` // Count in zero bucket. + ZeroCountFloat *float64 `protobuf:"fixed64,8,opt,name=zero_count_float,json=zeroCountFloat" json:"zero_count_float,omitempty"` // Overrides sb_zero_count if > 0. // Negative buckets for the native histogram. NegativeSpan []*BucketSpan `protobuf:"bytes,9,rep,name=negative_span,json=negativeSpan" json:"negative_span,omitempty"` // Use either "negative_delta" or "negative_count", the former for // regular histograms with integer counts, the latter for float // histograms. - NegativeDelta []int64 `protobuf:"zigzag64,10,rep,name=negative_delta,json=negativeDelta" json:"negative_delta,omitempty"` - NegativeCount []float64 `protobuf:"fixed64,11,rep,name=negative_count,json=negativeCount" json:"negative_count,omitempty"` + NegativeDelta []int64 `protobuf:"zigzag64,10,rep,name=negative_delta,json=negativeDelta" json:"negative_delta,omitempty"` // Count delta of each bucket compared to previous one (or to zero for 1st bucket). + NegativeCount []float64 `protobuf:"fixed64,11,rep,name=negative_count,json=negativeCount" json:"negative_count,omitempty"` // Absolute count of each bucket. // Positive buckets for the native histogram. PositiveSpan []*BucketSpan `protobuf:"bytes,12,rep,name=positive_span,json=positiveSpan" json:"positive_span,omitempty"` // Use either "positive_delta" or "positive_count", the former for // regular histograms with integer counts, the latter for float // histograms. - PositiveDelta []int64 `protobuf:"zigzag64,13,rep,name=positive_delta,json=positiveDelta" json:"positive_delta,omitempty"` - PositiveCount []float64 `protobuf:"fixed64,14,rep,name=positive_count,json=positiveCount" json:"positive_count,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + PositiveDelta []int64 `protobuf:"zigzag64,13,rep,name=positive_delta,json=positiveDelta" json:"positive_delta,omitempty"` // Count delta of each bucket compared to previous one (or to zero for 1st bucket). + PositiveCount []float64 `protobuf:"fixed64,14,rep,name=positive_count,json=positiveCount" json:"positive_count,omitempty"` // Absolute count of each bucket. } -func (m *Histogram) Reset() { *m = Histogram{} } -func (m *Histogram) String() string { return proto.CompactTextString(m) } -func (*Histogram) ProtoMessage() {} -func (*Histogram) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{6} +func (x *Histogram) Reset() { + *x = Histogram{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Histogram) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Histogram.Unmarshal(m, b) +func (x *Histogram) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Histogram) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Histogram.Marshal(b, m, deterministic) -} -func (m *Histogram) XXX_Merge(src proto.Message) { - xxx_messageInfo_Histogram.Merge(m, src) -} -func (m *Histogram) XXX_Size() int { - return xxx_messageInfo_Histogram.Size(m) -} -func (m *Histogram) XXX_DiscardUnknown() { - xxx_messageInfo_Histogram.DiscardUnknown(m) + +func (*Histogram) ProtoMessage() {} + +func (x *Histogram) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Histogram proto.InternalMessageInfo +// Deprecated: Use Histogram.ProtoReflect.Descriptor instead. +func (*Histogram) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{6} +} -func (m *Histogram) GetSampleCount() uint64 { - if m != nil && m.SampleCount != nil { - return *m.SampleCount +func (x *Histogram) GetSampleCount() uint64 { + if x != nil && x.SampleCount != nil { + return *x.SampleCount } return 0 } -func (m *Histogram) GetSampleCountFloat() float64 { - if m != nil && m.SampleCountFloat != nil { - return *m.SampleCountFloat +func (x *Histogram) GetSampleCountFloat() float64 { + if x != nil && x.SampleCountFloat != nil { + return *x.SampleCountFloat } return 0 } -func (m *Histogram) GetSampleSum() float64 { - if m != nil && m.SampleSum != nil { - return *m.SampleSum +func (x *Histogram) GetSampleSum() float64 { + if x != nil && x.SampleSum != nil { + return *x.SampleSum } return 0 } -func (m *Histogram) GetBucket() []*Bucket { - if m != nil { - return m.Bucket +func (x *Histogram) GetBucket() []*Bucket { + if x != nil { + return x.Bucket } return nil } -func (m *Histogram) GetSchema() int32 { - if m != nil && m.Schema != nil { - return *m.Schema +func (x *Histogram) GetSchema() int32 { + if x != nil && x.Schema != nil { + return *x.Schema } return 0 } -func (m *Histogram) GetZeroThreshold() float64 { - if m != nil && m.ZeroThreshold != nil { - return *m.ZeroThreshold +func (x *Histogram) GetZeroThreshold() float64 { + if x != nil && x.ZeroThreshold != nil { + return *x.ZeroThreshold } return 0 } -func (m *Histogram) GetZeroCount() uint64 { - if m != nil && m.ZeroCount != nil { - return *m.ZeroCount +func (x *Histogram) GetZeroCount() uint64 { + if x != nil && x.ZeroCount != nil { + return *x.ZeroCount } return 0 } -func (m *Histogram) GetZeroCountFloat() float64 { - if m != nil && m.ZeroCountFloat != nil { - return *m.ZeroCountFloat +func (x *Histogram) GetZeroCountFloat() float64 { + if x != nil && x.ZeroCountFloat != nil { + return *x.ZeroCountFloat } return 0 } -func (m *Histogram) GetNegativeSpan() []*BucketSpan { - if m != nil { - return m.NegativeSpan +func (x *Histogram) GetNegativeSpan() []*BucketSpan { + if x != nil { + return x.NegativeSpan } return nil } -func (m *Histogram) GetNegativeDelta() []int64 { - if m != nil { - return m.NegativeDelta +func (x *Histogram) GetNegativeDelta() []int64 { + if x != nil { + return x.NegativeDelta } return nil } -func (m *Histogram) GetNegativeCount() []float64 { - if m != nil { - return m.NegativeCount +func (x *Histogram) GetNegativeCount() []float64 { + if x != nil { + return x.NegativeCount } return nil } -func (m *Histogram) GetPositiveSpan() []*BucketSpan { - if m != nil { - return m.PositiveSpan +func (x *Histogram) GetPositiveSpan() []*BucketSpan { + if x != nil { + return x.PositiveSpan } return nil } -func (m *Histogram) GetPositiveDelta() []int64 { - if m != nil { - return m.PositiveDelta +func (x *Histogram) GetPositiveDelta() []int64 { + if x != nil { + return x.PositiveDelta } return nil } -func (m *Histogram) GetPositiveCount() []float64 { - if m != nil { - return m.PositiveCount +func (x *Histogram) GetPositiveCount() []float64 { + if x != nil { + return x.PositiveCount } return nil } @@ -513,64 +598,72 @@ func (m *Histogram) GetPositiveCount() []float64 { // A Bucket of a conventional histogram, each of which is treated as // an individual counter-like time series by Prometheus. type Bucket struct { - CumulativeCount *uint64 `protobuf:"varint,1,opt,name=cumulative_count,json=cumulativeCount" json:"cumulative_count,omitempty"` - CumulativeCountFloat *float64 `protobuf:"fixed64,4,opt,name=cumulative_count_float,json=cumulativeCountFloat" json:"cumulative_count_float,omitempty"` - UpperBound *float64 `protobuf:"fixed64,2,opt,name=upper_bound,json=upperBound" json:"upper_bound,omitempty"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CumulativeCount *uint64 `protobuf:"varint,1,opt,name=cumulative_count,json=cumulativeCount" json:"cumulative_count,omitempty"` // Cumulative in increasing order. + CumulativeCountFloat *float64 `protobuf:"fixed64,4,opt,name=cumulative_count_float,json=cumulativeCountFloat" json:"cumulative_count_float,omitempty"` // Overrides cumulative_count if > 0. + UpperBound *float64 `protobuf:"fixed64,2,opt,name=upper_bound,json=upperBound" json:"upper_bound,omitempty"` // Inclusive. Exemplar *Exemplar `protobuf:"bytes,3,opt,name=exemplar" json:"exemplar,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` } -func (m *Bucket) Reset() { *m = Bucket{} } -func (m *Bucket) String() string { return proto.CompactTextString(m) } -func (*Bucket) ProtoMessage() {} -func (*Bucket) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{7} +func (x *Bucket) Reset() { + *x = Bucket{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Bucket) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Bucket.Unmarshal(m, b) -} -func (m *Bucket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Bucket.Marshal(b, m, deterministic) -} -func (m *Bucket) XXX_Merge(src proto.Message) { - xxx_messageInfo_Bucket.Merge(m, src) -} -func (m *Bucket) XXX_Size() int { - return xxx_messageInfo_Bucket.Size(m) +func (x *Bucket) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Bucket) XXX_DiscardUnknown() { - xxx_messageInfo_Bucket.DiscardUnknown(m) + +func (*Bucket) ProtoMessage() {} + +func (x *Bucket) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Bucket proto.InternalMessageInfo +// Deprecated: Use Bucket.ProtoReflect.Descriptor instead. +func (*Bucket) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{7} +} -func (m *Bucket) GetCumulativeCount() uint64 { - if m != nil && m.CumulativeCount != nil { - return *m.CumulativeCount +func (x *Bucket) GetCumulativeCount() uint64 { + if x != nil && x.CumulativeCount != nil { + return *x.CumulativeCount } return 0 } -func (m *Bucket) GetCumulativeCountFloat() float64 { - if m != nil && m.CumulativeCountFloat != nil { - return *m.CumulativeCountFloat +func (x *Bucket) GetCumulativeCountFloat() float64 { + if x != nil && x.CumulativeCountFloat != nil { + return *x.CumulativeCountFloat } return 0 } -func (m *Bucket) GetUpperBound() float64 { - if m != nil && m.UpperBound != nil { - return *m.UpperBound +func (x *Bucket) GetUpperBound() float64 { + if x != nil && x.UpperBound != nil { + return *x.UpperBound } return 0 } -func (m *Bucket) GetExemplar() *Exemplar { - if m != nil { - return m.Exemplar +func (x *Bucket) GetExemplar() *Exemplar { + if x != nil { + return x.Exemplar } return nil } @@ -582,333 +675,658 @@ func (m *Bucket) GetExemplar() *Exemplar { // structured here (with all the buckets in a single array separate // from the Spans). type BucketSpan struct { - Offset *int32 `protobuf:"zigzag32,1,opt,name=offset" json:"offset,omitempty"` - Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *BucketSpan) Reset() { *m = BucketSpan{} } -func (m *BucketSpan) String() string { return proto.CompactTextString(m) } -func (*BucketSpan) ProtoMessage() {} -func (*BucketSpan) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{8} + Offset *int32 `protobuf:"zigzag32,1,opt,name=offset" json:"offset,omitempty"` // Gap to previous span, or starting point for 1st span (which can be negative). + Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` // Length of consecutive buckets. } -func (m *BucketSpan) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_BucketSpan.Unmarshal(m, b) -} -func (m *BucketSpan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_BucketSpan.Marshal(b, m, deterministic) -} -func (m *BucketSpan) XXX_Merge(src proto.Message) { - xxx_messageInfo_BucketSpan.Merge(m, src) +func (x *BucketSpan) Reset() { + *x = BucketSpan{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *BucketSpan) XXX_Size() int { - return xxx_messageInfo_BucketSpan.Size(m) + +func (x *BucketSpan) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *BucketSpan) XXX_DiscardUnknown() { - xxx_messageInfo_BucketSpan.DiscardUnknown(m) + +func (*BucketSpan) ProtoMessage() {} + +func (x *BucketSpan) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_BucketSpan proto.InternalMessageInfo +// Deprecated: Use BucketSpan.ProtoReflect.Descriptor instead. +func (*BucketSpan) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{8} +} -func (m *BucketSpan) GetOffset() int32 { - if m != nil && m.Offset != nil { - return *m.Offset +func (x *BucketSpan) GetOffset() int32 { + if x != nil && x.Offset != nil { + return *x.Offset } return 0 } -func (m *BucketSpan) GetLength() uint32 { - if m != nil && m.Length != nil { - return *m.Length +func (x *BucketSpan) GetLength() uint32 { + if x != nil && x.Length != nil { + return *x.Length } return 0 } type Exemplar struct { - Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` - Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` - Timestamp *timestamp.Timestamp `protobuf:"bytes,3,opt,name=timestamp" json:"timestamp,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Exemplar) Reset() { *m = Exemplar{} } -func (m *Exemplar) String() string { return proto.CompactTextString(m) } -func (*Exemplar) ProtoMessage() {} -func (*Exemplar) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{9} + Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` + Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=timestamp" json:"timestamp,omitempty"` // OpenMetrics-style. } -func (m *Exemplar) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Exemplar.Unmarshal(m, b) -} -func (m *Exemplar) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Exemplar.Marshal(b, m, deterministic) -} -func (m *Exemplar) XXX_Merge(src proto.Message) { - xxx_messageInfo_Exemplar.Merge(m, src) +func (x *Exemplar) Reset() { + *x = Exemplar{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Exemplar) XXX_Size() int { - return xxx_messageInfo_Exemplar.Size(m) + +func (x *Exemplar) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Exemplar) XXX_DiscardUnknown() { - xxx_messageInfo_Exemplar.DiscardUnknown(m) + +func (*Exemplar) ProtoMessage() {} + +func (x *Exemplar) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Exemplar proto.InternalMessageInfo +// Deprecated: Use Exemplar.ProtoReflect.Descriptor instead. +func (*Exemplar) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{9} +} -func (m *Exemplar) GetLabel() []*LabelPair { - if m != nil { - return m.Label +func (x *Exemplar) GetLabel() []*LabelPair { + if x != nil { + return x.Label } return nil } -func (m *Exemplar) GetValue() float64 { - if m != nil && m.Value != nil { - return *m.Value +func (x *Exemplar) GetValue() float64 { + if x != nil && x.Value != nil { + return *x.Value } return 0 } -func (m *Exemplar) GetTimestamp() *timestamp.Timestamp { - if m != nil { - return m.Timestamp +func (x *Exemplar) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp } return nil } type Metric struct { - Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` - Gauge *Gauge `protobuf:"bytes,2,opt,name=gauge" json:"gauge,omitempty"` - Counter *Counter `protobuf:"bytes,3,opt,name=counter" json:"counter,omitempty"` - Summary *Summary `protobuf:"bytes,4,opt,name=summary" json:"summary,omitempty"` - Untyped *Untyped `protobuf:"bytes,5,opt,name=untyped" json:"untyped,omitempty"` - Histogram *Histogram `protobuf:"bytes,7,opt,name=histogram" json:"histogram,omitempty"` - TimestampMs *int64 `protobuf:"varint,6,opt,name=timestamp_ms,json=timestampMs" json:"timestamp_ms,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Metric) Reset() { *m = Metric{} } -func (m *Metric) String() string { return proto.CompactTextString(m) } -func (*Metric) ProtoMessage() {} -func (*Metric) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{10} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` + Gauge *Gauge `protobuf:"bytes,2,opt,name=gauge" json:"gauge,omitempty"` + Counter *Counter `protobuf:"bytes,3,opt,name=counter" json:"counter,omitempty"` + Summary *Summary `protobuf:"bytes,4,opt,name=summary" json:"summary,omitempty"` + Untyped *Untyped `protobuf:"bytes,5,opt,name=untyped" json:"untyped,omitempty"` + Histogram *Histogram `protobuf:"bytes,7,opt,name=histogram" json:"histogram,omitempty"` + TimestampMs *int64 `protobuf:"varint,6,opt,name=timestamp_ms,json=timestampMs" json:"timestamp_ms,omitempty"` +} + +func (x *Metric) Reset() { + *x = Metric{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Metric) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Metric.Unmarshal(m, b) +func (x *Metric) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Metric) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Metric.Marshal(b, m, deterministic) -} -func (m *Metric) XXX_Merge(src proto.Message) { - xxx_messageInfo_Metric.Merge(m, src) -} -func (m *Metric) XXX_Size() int { - return xxx_messageInfo_Metric.Size(m) -} -func (m *Metric) XXX_DiscardUnknown() { - xxx_messageInfo_Metric.DiscardUnknown(m) + +func (*Metric) ProtoMessage() {} + +func (x *Metric) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Metric proto.InternalMessageInfo +// Deprecated: Use Metric.ProtoReflect.Descriptor instead. +func (*Metric) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{10} +} -func (m *Metric) GetLabel() []*LabelPair { - if m != nil { - return m.Label +func (x *Metric) GetLabel() []*LabelPair { + if x != nil { + return x.Label } return nil } -func (m *Metric) GetGauge() *Gauge { - if m != nil { - return m.Gauge +func (x *Metric) GetGauge() *Gauge { + if x != nil { + return x.Gauge } return nil } -func (m *Metric) GetCounter() *Counter { - if m != nil { - return m.Counter +func (x *Metric) GetCounter() *Counter { + if x != nil { + return x.Counter } return nil } -func (m *Metric) GetSummary() *Summary { - if m != nil { - return m.Summary +func (x *Metric) GetSummary() *Summary { + if x != nil { + return x.Summary } return nil } -func (m *Metric) GetUntyped() *Untyped { - if m != nil { - return m.Untyped +func (x *Metric) GetUntyped() *Untyped { + if x != nil { + return x.Untyped } return nil } -func (m *Metric) GetHistogram() *Histogram { - if m != nil { - return m.Histogram +func (x *Metric) GetHistogram() *Histogram { + if x != nil { + return x.Histogram } return nil } -func (m *Metric) GetTimestampMs() int64 { - if m != nil && m.TimestampMs != nil { - return *m.TimestampMs +func (x *Metric) GetTimestampMs() int64 { + if x != nil && x.TimestampMs != nil { + return *x.TimestampMs } return 0 } type MetricFamily struct { - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Help *string `protobuf:"bytes,2,opt,name=help" json:"help,omitempty"` - Type *MetricType `protobuf:"varint,3,opt,name=type,enum=io.prometheus.client.MetricType" json:"type,omitempty"` - Metric []*Metric `protobuf:"bytes,4,rep,name=metric" json:"metric,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *MetricFamily) Reset() { *m = MetricFamily{} } -func (m *MetricFamily) String() string { return proto.CompactTextString(m) } -func (*MetricFamily) ProtoMessage() {} -func (*MetricFamily) Descriptor() ([]byte, []int) { - return fileDescriptor_d1e5ddb18987a258, []int{11} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Help *string `protobuf:"bytes,2,opt,name=help" json:"help,omitempty"` + Type *MetricType `protobuf:"varint,3,opt,name=type,enum=io.prometheus.client.MetricType" json:"type,omitempty"` + Metric []*Metric `protobuf:"bytes,4,rep,name=metric" json:"metric,omitempty"` +} + +func (x *MetricFamily) Reset() { + *x = MetricFamily{} + if protoimpl.UnsafeEnabled { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *MetricFamily) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_MetricFamily.Unmarshal(m, b) -} -func (m *MetricFamily) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_MetricFamily.Marshal(b, m, deterministic) -} -func (m *MetricFamily) XXX_Merge(src proto.Message) { - xxx_messageInfo_MetricFamily.Merge(m, src) -} -func (m *MetricFamily) XXX_Size() int { - return xxx_messageInfo_MetricFamily.Size(m) +func (x *MetricFamily) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *MetricFamily) XXX_DiscardUnknown() { - xxx_messageInfo_MetricFamily.DiscardUnknown(m) + +func (*MetricFamily) ProtoMessage() {} + +func (x *MetricFamily) ProtoReflect() protoreflect.Message { + mi := &file_io_prometheus_client_metrics_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_MetricFamily proto.InternalMessageInfo +// Deprecated: Use MetricFamily.ProtoReflect.Descriptor instead. +func (*MetricFamily) Descriptor() ([]byte, []int) { + return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{11} +} -func (m *MetricFamily) GetName() string { - if m != nil && m.Name != nil { - return *m.Name +func (x *MetricFamily) GetName() string { + if x != nil && x.Name != nil { + return *x.Name } return "" } -func (m *MetricFamily) GetHelp() string { - if m != nil && m.Help != nil { - return *m.Help +func (x *MetricFamily) GetHelp() string { + if x != nil && x.Help != nil { + return *x.Help } return "" } -func (m *MetricFamily) GetType() MetricType { - if m != nil && m.Type != nil { - return *m.Type +func (x *MetricFamily) GetType() MetricType { + if x != nil && x.Type != nil { + return *x.Type } return MetricType_COUNTER } -func (m *MetricFamily) GetMetric() []*Metric { - if m != nil { - return m.Metric +func (x *MetricFamily) GetMetric() []*Metric { + if x != nil { + return x.Metric } return nil } -func init() { - proto.RegisterEnum("io.prometheus.client.MetricType", MetricType_name, MetricType_value) - proto.RegisterType((*LabelPair)(nil), "io.prometheus.client.LabelPair") - proto.RegisterType((*Gauge)(nil), "io.prometheus.client.Gauge") - proto.RegisterType((*Counter)(nil), "io.prometheus.client.Counter") - proto.RegisterType((*Quantile)(nil), "io.prometheus.client.Quantile") - proto.RegisterType((*Summary)(nil), "io.prometheus.client.Summary") - proto.RegisterType((*Untyped)(nil), "io.prometheus.client.Untyped") - proto.RegisterType((*Histogram)(nil), "io.prometheus.client.Histogram") - proto.RegisterType((*Bucket)(nil), "io.prometheus.client.Bucket") - proto.RegisterType((*BucketSpan)(nil), "io.prometheus.client.BucketSpan") - proto.RegisterType((*Exemplar)(nil), "io.prometheus.client.Exemplar") - proto.RegisterType((*Metric)(nil), "io.prometheus.client.Metric") - proto.RegisterType((*MetricFamily)(nil), "io.prometheus.client.MetricFamily") -} - -func init() { - proto.RegisterFile("io/prometheus/client/metrics.proto", fileDescriptor_d1e5ddb18987a258) -} - -var fileDescriptor_d1e5ddb18987a258 = []byte{ - // 896 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xdd, 0x8e, 0xdb, 0x44, - 0x18, 0xc5, 0x9b, 0x5f, 0x7f, 0xd9, 0x6c, 0xd3, 0x61, 0x55, 0x59, 0x0b, 0xcb, 0x06, 0x4b, 0x48, - 0x0b, 0x42, 0x8e, 0x40, 0x5b, 0x81, 0x0a, 0x5c, 0xec, 0xb6, 0xe9, 0x16, 0x89, 0xb4, 0x65, 0x92, - 0x5c, 0x14, 0x2e, 0xac, 0x49, 0x32, 0xeb, 0x58, 0x78, 0x3c, 0xc6, 0x1e, 0x57, 0x2c, 0x2f, 0xc0, - 0x35, 0xaf, 0xc0, 0xc3, 0xf0, 0x22, 0x3c, 0x08, 0x68, 0xfe, 0xec, 0xdd, 0xe2, 0x94, 0xd2, 0x3b, - 0x7f, 0x67, 0xce, 0xf7, 0xcd, 0x39, 0xe3, 0xc9, 0x71, 0xc0, 0x8f, 0xf9, 0x24, 0xcb, 0x39, 0xa3, - 0x62, 0x4b, 0xcb, 0x62, 0xb2, 0x4e, 0x62, 0x9a, 0x8a, 0x09, 0xa3, 0x22, 0x8f, 0xd7, 0x45, 0x90, - 0xe5, 0x5c, 0x70, 0x74, 0x18, 0xf3, 0xa0, 0xe6, 0x04, 0x9a, 0x73, 0x74, 0x12, 0x71, 0x1e, 0x25, - 0x74, 0xa2, 0x38, 0xab, 0xf2, 0x6a, 0x22, 0x62, 0x46, 0x0b, 0x41, 0x58, 0xa6, 0xdb, 0xfc, 0xfb, - 0xe0, 0x7e, 0x47, 0x56, 0x34, 0x79, 0x4e, 0xe2, 0x1c, 0x21, 0x68, 0xa7, 0x84, 0x51, 0xcf, 0x19, - 0x3b, 0xa7, 0x2e, 0x56, 0xcf, 0xe8, 0x10, 0x3a, 0x2f, 0x49, 0x52, 0x52, 0x6f, 0x4f, 0x81, 0xba, - 0xf0, 0x8f, 0xa1, 0x73, 0x49, 0xca, 0xe8, 0xc6, 0xb2, 0xec, 0x71, 0xec, 0xf2, 0x8f, 0xd0, 0x7b, - 0xc8, 0xcb, 0x54, 0xd0, 0xbc, 0x99, 0x80, 0x1e, 0x40, 0x9f, 0xfe, 0x42, 0x59, 0x96, 0x90, 0x5c, - 0x0d, 0x1e, 0x7c, 0xfe, 0x41, 0xd0, 0x64, 0x20, 0x98, 0x1a, 0x16, 0xae, 0xf8, 0xfe, 0xd7, 0xd0, - 0xff, 0xbe, 0x24, 0xa9, 0x88, 0x13, 0x8a, 0x8e, 0xa0, 0xff, 0xb3, 0x79, 0x36, 0x1b, 0x54, 0xf5, - 0x6d, 0xe5, 0x95, 0xb4, 0xdf, 0x1c, 0xe8, 0xcd, 0x4b, 0xc6, 0x48, 0x7e, 0x8d, 0x3e, 0x84, 0xfd, - 0x82, 0xb0, 0x2c, 0xa1, 0xe1, 0x5a, 0xaa, 0x55, 0x13, 0xda, 0x78, 0xa0, 0x31, 0x65, 0x00, 0x1d, - 0x03, 0x18, 0x4a, 0x51, 0x32, 0x33, 0xc9, 0xd5, 0xc8, 0xbc, 0x64, 0xd2, 0x47, 0xb5, 0x7f, 0x6b, - 0xdc, 0xda, 0xed, 0xc3, 0x2a, 0xae, 0xf5, 0xf9, 0x27, 0xd0, 0x5b, 0xa6, 0xe2, 0x3a, 0xa3, 0x9b, - 0x1d, 0xa7, 0xf8, 0x57, 0x1b, 0xdc, 0x27, 0x71, 0x21, 0x78, 0x94, 0x13, 0xf6, 0x26, 0x62, 0x3f, - 0x05, 0x74, 0x93, 0x12, 0x5e, 0x25, 0x9c, 0x08, 0xaf, 0xad, 0x66, 0x8e, 0x6e, 0x10, 0x1f, 0x4b, - 0xfc, 0xbf, 0xac, 0x9d, 0x41, 0x77, 0x55, 0xae, 0x7f, 0xa2, 0xc2, 0x18, 0x7b, 0xbf, 0xd9, 0xd8, - 0x85, 0xe2, 0x60, 0xc3, 0x45, 0xf7, 0xa0, 0x5b, 0xac, 0xb7, 0x94, 0x11, 0xaf, 0x33, 0x76, 0x4e, - 0xef, 0x62, 0x53, 0xa1, 0x8f, 0xe0, 0xe0, 0x57, 0x9a, 0xf3, 0x50, 0x6c, 0x73, 0x5a, 0x6c, 0x79, - 0xb2, 0xf1, 0xba, 0x6a, 0xc3, 0xa1, 0x44, 0x17, 0x16, 0x94, 0x9a, 0x14, 0x4d, 0x5b, 0xec, 0x29, - 0x8b, 0xae, 0x44, 0xb4, 0xc1, 0x53, 0x18, 0xd5, 0xcb, 0xc6, 0x5e, 0x5f, 0xcd, 0x39, 0xa8, 0x48, - 0xda, 0xdc, 0x14, 0x86, 0x29, 0x8d, 0x88, 0x88, 0x5f, 0xd2, 0xb0, 0xc8, 0x48, 0xea, 0xb9, 0xca, - 0xc4, 0xf8, 0x75, 0x26, 0xe6, 0x19, 0x49, 0xf1, 0xbe, 0x6d, 0x93, 0x95, 0x94, 0x5d, 0x8d, 0xd9, - 0xd0, 0x44, 0x10, 0x0f, 0xc6, 0xad, 0x53, 0x84, 0xab, 0xe1, 0x8f, 0x24, 0x78, 0x8b, 0xa6, 0xa5, - 0x0f, 0xc6, 0x2d, 0xe9, 0xce, 0xa2, 0x5a, 0xfe, 0x14, 0x86, 0x19, 0x2f, 0xe2, 0x5a, 0xd4, 0xfe, - 0x9b, 0x8a, 0xb2, 0x6d, 0x56, 0x54, 0x35, 0x46, 0x8b, 0x1a, 0x6a, 0x51, 0x16, 0xad, 0x44, 0x55, - 0x34, 0x2d, 0xea, 0x40, 0x8b, 0xb2, 0xa8, 0x12, 0xe5, 0xff, 0xe9, 0x40, 0x57, 0x6f, 0x85, 0x3e, - 0x86, 0xd1, 0xba, 0x64, 0x65, 0x72, 0xd3, 0x88, 0xbe, 0x66, 0x77, 0x6a, 0x5c, 0x5b, 0x39, 0x83, - 0x7b, 0xaf, 0x52, 0x6f, 0x5d, 0xb7, 0xc3, 0x57, 0x1a, 0xf4, 0x5b, 0x39, 0x81, 0x41, 0x99, 0x65, - 0x34, 0x0f, 0x57, 0xbc, 0x4c, 0x37, 0xe6, 0xce, 0x81, 0x82, 0x2e, 0x24, 0x72, 0x2b, 0x17, 0x5a, - 0xff, 0x3b, 0x17, 0xa0, 0x3e, 0x32, 0x79, 0x11, 0xf9, 0xd5, 0x55, 0x41, 0xb5, 0x83, 0xbb, 0xd8, - 0x54, 0x12, 0x4f, 0x68, 0x1a, 0x89, 0xad, 0xda, 0x7d, 0x88, 0x4d, 0xe5, 0xff, 0xee, 0x40, 0xdf, - 0x0e, 0x45, 0xf7, 0xa1, 0x93, 0xc8, 0x54, 0xf4, 0x1c, 0xf5, 0x82, 0x4e, 0x9a, 0x35, 0x54, 0xc1, - 0x89, 0x35, 0xbb, 0x39, 0x71, 0xd0, 0x97, 0xe0, 0x56, 0xa9, 0x6b, 0x4c, 0x1d, 0x05, 0x3a, 0x97, - 0x03, 0x9b, 0xcb, 0xc1, 0xc2, 0x32, 0x70, 0x4d, 0xf6, 0xff, 0xde, 0x83, 0xee, 0x4c, 0xa5, 0xfc, - 0xdb, 0x2a, 0xfa, 0x0c, 0x3a, 0x91, 0xcc, 0x69, 0x13, 0xb2, 0xef, 0x35, 0xb7, 0xa9, 0x28, 0xc7, - 0x9a, 0x89, 0xbe, 0x80, 0xde, 0x5a, 0x67, 0xb7, 0x11, 0x7b, 0xdc, 0xdc, 0x64, 0x02, 0x1e, 0x5b, - 0xb6, 0x6c, 0x2c, 0x74, 0xb0, 0xaa, 0x3b, 0xb0, 0xb3, 0xd1, 0xa4, 0x2f, 0xb6, 0x6c, 0xd9, 0x58, - 0xea, 0x20, 0x54, 0xa1, 0xb1, 0xb3, 0xd1, 0xa4, 0x25, 0xb6, 0x6c, 0xf4, 0x0d, 0xb8, 0x5b, 0x9b, - 0x8f, 0x2a, 0x2c, 0x76, 0x1e, 0x4c, 0x15, 0xa3, 0xb8, 0xee, 0x90, 0x89, 0x5a, 0x9d, 0x75, 0xc8, - 0x0a, 0x95, 0x48, 0x2d, 0x3c, 0xa8, 0xb0, 0x59, 0xe1, 0xff, 0xe1, 0xc0, 0xbe, 0x7e, 0x03, 0x8f, - 0x09, 0x8b, 0x93, 0xeb, 0xc6, 0x4f, 0x24, 0x82, 0xf6, 0x96, 0x26, 0x99, 0xf9, 0x42, 0xaa, 0x67, - 0x74, 0x06, 0x6d, 0xa9, 0x51, 0x1d, 0xe1, 0xc1, 0xae, 0x5f, 0xb8, 0x9e, 0xbc, 0xb8, 0xce, 0x28, - 0x56, 0x6c, 0x99, 0xb9, 0xfa, 0xab, 0xee, 0xb5, 0x5f, 0x97, 0xb9, 0xba, 0x0f, 0x1b, 0xee, 0x27, - 0x2b, 0x80, 0x7a, 0x12, 0x1a, 0x40, 0xef, 0xe1, 0xb3, 0xe5, 0xd3, 0xc5, 0x14, 0x8f, 0xde, 0x41, - 0x2e, 0x74, 0x2e, 0xcf, 0x97, 0x97, 0xd3, 0x91, 0x23, 0xf1, 0xf9, 0x72, 0x36, 0x3b, 0xc7, 0x2f, - 0x46, 0x7b, 0xb2, 0x58, 0x3e, 0x5d, 0xbc, 0x78, 0x3e, 0x7d, 0x34, 0x6a, 0xa1, 0x21, 0xb8, 0x4f, - 0xbe, 0x9d, 0x2f, 0x9e, 0x5d, 0xe2, 0xf3, 0xd9, 0xa8, 0x8d, 0xde, 0x85, 0x3b, 0xaa, 0x27, 0xac, - 0xc1, 0xce, 0x05, 0x86, 0xc6, 0x3f, 0x18, 0x3f, 0x3c, 0x88, 0x62, 0xb1, 0x2d, 0x57, 0xc1, 0x9a, - 0xb3, 0x7f, 0xff, 0x45, 0x09, 0x19, 0xdf, 0xd0, 0x64, 0x12, 0xf1, 0xaf, 0x62, 0x1e, 0xd6, 0xab, - 0xa1, 0x5e, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0x16, 0x77, 0x81, 0x98, 0xd7, 0x08, 0x00, 0x00, +var File_io_prometheus_client_metrics_proto protoreflect.FileDescriptor + +var file_io_prometheus_client_metrics_proto_rawDesc = []byte{ + 0x0a, 0x22, 0x69, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2f, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, + 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x35, 0x0a, 0x09, 0x4c, + 0x61, 0x62, 0x65, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x22, 0x1d, 0x0a, 0x05, 0x47, 0x61, 0x75, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x22, 0x5b, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x12, 0x3a, 0x0a, 0x08, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, + 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x78, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x72, 0x52, 0x08, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x22, 0x3c, + 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x87, 0x01, 0x0a, + 0x07, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, + 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, + 0x09, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x53, 0x75, 0x6d, 0x12, 0x3a, 0x0a, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, + 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x2e, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x52, 0x08, 0x71, 0x75, + 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x22, 0x1f, 0x0a, 0x07, 0x55, 0x6e, 0x74, 0x79, 0x70, 0x65, + 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xe3, 0x04, 0x0a, 0x09, 0x48, 0x69, 0x73, 0x74, + 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x73, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x01, 0x52, 0x10, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x5f, 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x53, 0x75, 0x6d, 0x12, 0x34, 0x0a, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, + 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x42, 0x75, 0x63, + 0x6b, 0x65, 0x74, 0x52, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x11, 0x52, 0x06, 0x73, 0x63, 0x68, + 0x65, 0x6d, 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x7a, 0x65, 0x72, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, + 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0d, 0x7a, 0x65, 0x72, + 0x6f, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x7a, 0x65, + 0x72, 0x6f, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, + 0x7a, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x7a, 0x65, 0x72, + 0x6f, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x0e, 0x7a, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x6c, + 0x6f, 0x61, 0x74, 0x12, 0x45, 0x0a, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, + 0x73, 0x70, 0x61, 0x6e, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x6f, 0x2e, + 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x52, 0x0c, 0x6e, 0x65, + 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6e, 0x65, + 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x74, 0x61, 0x18, 0x0a, 0x20, 0x03, + 0x28, 0x12, 0x52, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x44, 0x65, 0x6c, 0x74, + 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x01, 0x52, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, + 0x69, 0x76, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x45, 0x0a, 0x0d, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x76, 0x65, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x20, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x70, 0x61, + 0x6e, 0x52, 0x0c, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x12, + 0x25, 0x0a, 0x0e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x74, + 0x61, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x12, 0x52, 0x0d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, + 0x65, 0x44, 0x65, 0x6c, 0x74, 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x01, 0x52, 0x0d, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xc6, 0x01, + 0x0a, 0x06, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x75, 0x6d, 0x75, + 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0f, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x12, 0x34, 0x0a, 0x16, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, + 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x14, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x70, 0x70, + 0x65, 0x72, 0x5f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0a, + 0x75, 0x70, 0x70, 0x65, 0x72, 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x3a, 0x0a, 0x08, 0x65, 0x78, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, + 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x52, 0x08, 0x65, 0x78, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x22, 0x3c, 0x0a, 0x0a, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, + 0x53, 0x70, 0x61, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x11, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, + 0x6e, 0x67, 0x74, 0x68, 0x22, 0x91, 0x01, 0x0a, 0x08, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x72, 0x12, 0x35, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, + 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x50, 0x61, 0x69, + 0x72, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x38, + 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xff, 0x02, 0x0a, 0x06, 0x4d, 0x65, 0x74, + 0x72, 0x69, 0x63, 0x12, 0x35, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, + 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x50, + 0x61, 0x69, 0x72, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x31, 0x0a, 0x05, 0x67, 0x61, + 0x75, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x69, 0x6f, 0x2e, 0x70, + 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x2e, 0x47, 0x61, 0x75, 0x67, 0x65, 0x52, 0x05, 0x67, 0x61, 0x75, 0x67, 0x65, 0x12, 0x37, 0x0a, + 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, + 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x07, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, + 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x53, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, + 0x37, 0x0a, 0x07, 0x75, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1d, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, + 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x55, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x64, 0x52, + 0x07, 0x75, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x64, 0x12, 0x3d, 0x0a, 0x09, 0x68, 0x69, 0x73, 0x74, + 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6f, + 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x52, 0x09, 0x68, 0x69, + 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x6d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x4d, 0x73, 0x22, 0xa2, 0x01, 0x0a, 0x0c, 0x4d, + 0x65, 0x74, 0x72, 0x69, 0x63, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x68, 0x65, 0x6c, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, + 0x65, 0x6c, 0x70, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x20, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, + 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x54, + 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x34, 0x0a, 0x06, 0x6d, 0x65, 0x74, + 0x72, 0x69, 0x63, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x69, 0x6f, 0x2e, 0x70, + 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x2a, + 0x62, 0x0a, 0x0a, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, + 0x07, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x47, 0x41, + 0x55, 0x47, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x4d, 0x4d, 0x41, 0x52, 0x59, + 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x54, 0x59, 0x50, 0x45, 0x44, 0x10, 0x03, 0x12, + 0x0d, 0x0a, 0x09, 0x48, 0x49, 0x53, 0x54, 0x4f, 0x47, 0x52, 0x41, 0x4d, 0x10, 0x04, 0x12, 0x13, + 0x0a, 0x0f, 0x47, 0x41, 0x55, 0x47, 0x45, 0x5f, 0x48, 0x49, 0x53, 0x54, 0x4f, 0x47, 0x52, 0x41, + 0x4d, 0x10, 0x05, 0x42, 0x52, 0x0a, 0x14, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, + 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5a, 0x3a, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, + 0x75, 0x73, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, + 0x67, 0x6f, 0x3b, 0x69, 0x6f, 0x5f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, + 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, +} + +var ( + file_io_prometheus_client_metrics_proto_rawDescOnce sync.Once + file_io_prometheus_client_metrics_proto_rawDescData = file_io_prometheus_client_metrics_proto_rawDesc +) + +func file_io_prometheus_client_metrics_proto_rawDescGZIP() []byte { + file_io_prometheus_client_metrics_proto_rawDescOnce.Do(func() { + file_io_prometheus_client_metrics_proto_rawDescData = protoimpl.X.CompressGZIP(file_io_prometheus_client_metrics_proto_rawDescData) + }) + return file_io_prometheus_client_metrics_proto_rawDescData +} + +var file_io_prometheus_client_metrics_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_io_prometheus_client_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_io_prometheus_client_metrics_proto_goTypes = []interface{}{ + (MetricType)(0), // 0: io.prometheus.client.MetricType + (*LabelPair)(nil), // 1: io.prometheus.client.LabelPair + (*Gauge)(nil), // 2: io.prometheus.client.Gauge + (*Counter)(nil), // 3: io.prometheus.client.Counter + (*Quantile)(nil), // 4: io.prometheus.client.Quantile + (*Summary)(nil), // 5: io.prometheus.client.Summary + (*Untyped)(nil), // 6: io.prometheus.client.Untyped + (*Histogram)(nil), // 7: io.prometheus.client.Histogram + (*Bucket)(nil), // 8: io.prometheus.client.Bucket + (*BucketSpan)(nil), // 9: io.prometheus.client.BucketSpan + (*Exemplar)(nil), // 10: io.prometheus.client.Exemplar + (*Metric)(nil), // 11: io.prometheus.client.Metric + (*MetricFamily)(nil), // 12: io.prometheus.client.MetricFamily + (*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp +} +var file_io_prometheus_client_metrics_proto_depIdxs = []int32{ + 10, // 0: io.prometheus.client.Counter.exemplar:type_name -> io.prometheus.client.Exemplar + 4, // 1: io.prometheus.client.Summary.quantile:type_name -> io.prometheus.client.Quantile + 8, // 2: io.prometheus.client.Histogram.bucket:type_name -> io.prometheus.client.Bucket + 9, // 3: io.prometheus.client.Histogram.negative_span:type_name -> io.prometheus.client.BucketSpan + 9, // 4: io.prometheus.client.Histogram.positive_span:type_name -> io.prometheus.client.BucketSpan + 10, // 5: io.prometheus.client.Bucket.exemplar:type_name -> io.prometheus.client.Exemplar + 1, // 6: io.prometheus.client.Exemplar.label:type_name -> io.prometheus.client.LabelPair + 13, // 7: io.prometheus.client.Exemplar.timestamp:type_name -> google.protobuf.Timestamp + 1, // 8: io.prometheus.client.Metric.label:type_name -> io.prometheus.client.LabelPair + 2, // 9: io.prometheus.client.Metric.gauge:type_name -> io.prometheus.client.Gauge + 3, // 10: io.prometheus.client.Metric.counter:type_name -> io.prometheus.client.Counter + 5, // 11: io.prometheus.client.Metric.summary:type_name -> io.prometheus.client.Summary + 6, // 12: io.prometheus.client.Metric.untyped:type_name -> io.prometheus.client.Untyped + 7, // 13: io.prometheus.client.Metric.histogram:type_name -> io.prometheus.client.Histogram + 0, // 14: io.prometheus.client.MetricFamily.type:type_name -> io.prometheus.client.MetricType + 11, // 15: io.prometheus.client.MetricFamily.metric:type_name -> io.prometheus.client.Metric + 16, // [16:16] is the sub-list for method output_type + 16, // [16:16] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name +} + +func init() { file_io_prometheus_client_metrics_proto_init() } +func file_io_prometheus_client_metrics_proto_init() { + if File_io_prometheus_client_metrics_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_io_prometheus_client_metrics_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LabelPair); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Gauge); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Counter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Quantile); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Summary); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Untyped); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Histogram); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Bucket); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BucketSpan); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Exemplar); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Metric); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_io_prometheus_client_metrics_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MetricFamily); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_io_prometheus_client_metrics_proto_rawDesc, + NumEnums: 1, + NumMessages: 12, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_io_prometheus_client_metrics_proto_goTypes, + DependencyIndexes: file_io_prometheus_client_metrics_proto_depIdxs, + EnumInfos: file_io_prometheus_client_metrics_proto_enumTypes, + MessageInfos: file_io_prometheus_client_metrics_proto_msgTypes, + }.Build() + File_io_prometheus_client_metrics_proto = out.File + file_io_prometheus_client_metrics_proto_rawDesc = nil + file_io_prometheus_client_metrics_proto_goTypes = nil + file_io_prometheus_client_metrics_proto_depIdxs = nil } diff --git a/vendor/github.com/prometheus/common/expfmt/decode.go b/vendor/github.com/prometheus/common/expfmt/decode.go index 7657f841d..906397815 100644 --- a/vendor/github.com/prometheus/common/expfmt/decode.go +++ b/vendor/github.com/prometheus/common/expfmt/decode.go @@ -115,32 +115,31 @@ func (d *protoDecoder) Decode(v *dto.MetricFamily) error { // textDecoder implements the Decoder interface for the text protocol. type textDecoder struct { r io.Reader - p TextParser - fams []*dto.MetricFamily + fams map[string]*dto.MetricFamily + err error } // Decode implements the Decoder interface. func (d *textDecoder) Decode(v *dto.MetricFamily) error { - // TODO(fabxc): Wrap this as a line reader to make streaming safer. - if len(d.fams) == 0 { - // No cached metric families, read everything and parse metrics. - fams, err := d.p.TextToMetricFamilies(d.r) - if err != nil { - return err - } - if len(fams) == 0 { - return io.EOF - } - d.fams = make([]*dto.MetricFamily, 0, len(fams)) - for _, f := range fams { - d.fams = append(d.fams, f) + if d.err == nil { + // Read all metrics in one shot. + var p TextParser + d.fams, d.err = p.TextToMetricFamilies(d.r) + // If we don't get an error, store io.EOF for the end. + if d.err == nil { + d.err = io.EOF } } - - *v = *d.fams[0] - d.fams = d.fams[1:] - - return nil + // Pick off one MetricFamily per Decode until there's nothing left. + for key, fam := range d.fams { + v.Name = fam.Name + v.Help = fam.Help + v.Type = fam.Type + v.Metric = fam.Metric + delete(d.fams, key) + return nil + } + return d.err } // SampleDecoder wraps a Decoder to extract samples from the metric families diff --git a/vendor/github.com/prometheus/common/expfmt/encode.go b/vendor/github.com/prometheus/common/expfmt/encode.go index 64dc0eb40..7f611ffaa 100644 --- a/vendor/github.com/prometheus/common/expfmt/encode.go +++ b/vendor/github.com/prometheus/common/expfmt/encode.go @@ -18,9 +18,9 @@ import ( "io" "net/http" - "github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. "github.com/matttproud/golang_protobuf_extensions/pbutil" "github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg" + "google.golang.org/protobuf/encoding/prototext" dto "github.com/prometheus/client_model/go" ) @@ -99,8 +99,11 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format { if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") { return FmtText } - if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion || ver == "") { - return FmtOpenMetrics + if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion_0_0_1 || ver == OpenMetricsVersion_1_0_0 || ver == "") { + if ver == OpenMetricsVersion_1_0_0 { + return FmtOpenMetrics_1_0_0 + } + return FmtOpenMetrics_0_0_1 } } return FmtText @@ -133,7 +136,7 @@ func NewEncoder(w io.Writer, format Format) Encoder { case FmtProtoText: return encoderCloser{ encode: func(v *dto.MetricFamily) error { - _, err := fmt.Fprintln(w, proto.MarshalTextString(v)) + _, err := fmt.Fprintln(w, prototext.Format(v)) return err }, close: func() error { return nil }, @@ -146,7 +149,7 @@ func NewEncoder(w io.Writer, format Format) Encoder { }, close: func() error { return nil }, } - case FmtOpenMetrics: + case FmtOpenMetrics_0_0_1, FmtOpenMetrics_1_0_0: return encoderCloser{ encode: func(v *dto.MetricFamily) error { _, err := MetricFamilyToOpenMetrics(w, v) diff --git a/vendor/github.com/prometheus/common/expfmt/expfmt.go b/vendor/github.com/prometheus/common/expfmt/expfmt.go index 0f176fa64..c4cb20f0d 100644 --- a/vendor/github.com/prometheus/common/expfmt/expfmt.go +++ b/vendor/github.com/prometheus/common/expfmt/expfmt.go @@ -19,20 +19,22 @@ type Format string // Constants to assemble the Content-Type values for the different wire protocols. const ( - TextVersion = "0.0.4" - ProtoType = `application/vnd.google.protobuf` - ProtoProtocol = `io.prometheus.client.MetricFamily` - ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";" - OpenMetricsType = `application/openmetrics-text` - OpenMetricsVersion = "0.0.1" + TextVersion = "0.0.4" + ProtoType = `application/vnd.google.protobuf` + ProtoProtocol = `io.prometheus.client.MetricFamily` + ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";" + OpenMetricsType = `application/openmetrics-text` + OpenMetricsVersion_0_0_1 = "0.0.1" + OpenMetricsVersion_1_0_0 = "1.0.0" // The Content-Type values for the different wire protocols. - FmtUnknown Format = `` - FmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8` - FmtProtoDelim Format = ProtoFmt + ` encoding=delimited` - FmtProtoText Format = ProtoFmt + ` encoding=text` - FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text` - FmtOpenMetrics Format = OpenMetricsType + `; version=` + OpenMetricsVersion + `; charset=utf-8` + FmtUnknown Format = `` + FmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8` + FmtProtoDelim Format = ProtoFmt + ` encoding=delimited` + FmtProtoText Format = ProtoFmt + ` encoding=text` + FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text` + FmtOpenMetrics_1_0_0 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_1_0_0 + `; charset=utf-8` + FmtOpenMetrics_0_0_1 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_0_0_1 + `; charset=utf-8` ) const ( diff --git a/vendor/github.com/prometheus/common/expfmt/fuzz.go b/vendor/github.com/prometheus/common/expfmt/fuzz.go index f819e4f8b..dfac962a4 100644 --- a/vendor/github.com/prometheus/common/expfmt/fuzz.go +++ b/vendor/github.com/prometheus/common/expfmt/fuzz.go @@ -21,8 +21,8 @@ import "bytes" // Fuzz text metric parser with with github.com/dvyukov/go-fuzz: // -// go-fuzz-build github.com/prometheus/common/expfmt -// go-fuzz -bin expfmt-fuzz.zip -workdir fuzz +// go-fuzz-build github.com/prometheus/common/expfmt +// go-fuzz -bin expfmt-fuzz.zip -workdir fuzz // // Further input samples should go in the folder fuzz/corpus. func Fuzz(in []byte) int { diff --git a/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go b/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go index 9d94ae9ef..21cdddcf0 100644 --- a/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go +++ b/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go @@ -46,20 +46,20 @@ import ( // missing features and peculiarities to avoid complications when switching from // Prometheus to OpenMetrics or vice versa: // -// - Counters are expected to have the `_total` suffix in their metric name. In -// the output, the suffix will be truncated from the `# TYPE` and `# HELP` -// line. A counter with a missing `_total` suffix is not an error. However, -// its type will be set to `unknown` in that case to avoid invalid OpenMetrics -// output. +// - Counters are expected to have the `_total` suffix in their metric name. In +// the output, the suffix will be truncated from the `# TYPE` and `# HELP` +// line. A counter with a missing `_total` suffix is not an error. However, +// its type will be set to `unknown` in that case to avoid invalid OpenMetrics +// output. // -// - No support for the following (optional) features: `# UNIT` line, `_created` -// line, info type, stateset type, gaugehistogram type. +// - No support for the following (optional) features: `# UNIT` line, `_created` +// line, info type, stateset type, gaugehistogram type. // -// - The size of exemplar labels is not checked (i.e. it's possible to create -// exemplars that are larger than allowed by the OpenMetrics specification). +// - The size of exemplar labels is not checked (i.e. it's possible to create +// exemplars that are larger than allowed by the OpenMetrics specification). // -// - The value of Counters is not checked. (OpenMetrics doesn't allow counters -// with a `NaN` value.) +// - The value of Counters is not checked. (OpenMetrics doesn't allow counters +// with a `NaN` value.) func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily) (written int, err error) { name := in.GetName() if name == "" { diff --git a/vendor/github.com/prometheus/common/expfmt/text_create.go b/vendor/github.com/prometheus/common/expfmt/text_create.go index 5ba503b06..2946b8f1a 100644 --- a/vendor/github.com/prometheus/common/expfmt/text_create.go +++ b/vendor/github.com/prometheus/common/expfmt/text_create.go @@ -17,7 +17,6 @@ import ( "bufio" "fmt" "io" - "io/ioutil" "math" "strconv" "strings" @@ -44,7 +43,7 @@ const ( var ( bufPool = sync.Pool{ New: func() interface{} { - return bufio.NewWriter(ioutil.Discard) + return bufio.NewWriter(io.Discard) }, } numBufPool = sync.Pool{ diff --git a/vendor/github.com/prometheus/common/expfmt/text_parse.go b/vendor/github.com/prometheus/common/expfmt/text_parse.go index 84be0643e..35db1cc9d 100644 --- a/vendor/github.com/prometheus/common/expfmt/text_parse.go +++ b/vendor/github.com/prometheus/common/expfmt/text_parse.go @@ -24,8 +24,8 @@ import ( dto "github.com/prometheus/client_model/go" - "github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. "github.com/prometheus/common/model" + "google.golang.org/protobuf/proto" ) // A stateFn is a function that represents a state in a state machine. By @@ -142,9 +142,13 @@ func (p *TextParser) reset(in io.Reader) { func (p *TextParser) startOfLine() stateFn { p.lineCount++ if p.skipBlankTab(); p.err != nil { - // End of input reached. This is the only case where - // that is not an error but a signal that we are done. - p.err = nil + // This is the only place that we expect to see io.EOF, + // which is not an error but the signal that we are done. + // Any other error that happens to align with the start of + // a line is still an error. + if p.err == io.EOF { + p.err = nil + } return nil } switch p.currentByte { diff --git a/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go b/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go index 26e92288c..a21b9d15d 100644 --- a/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go +++ b/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go @@ -11,18 +11,18 @@ 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 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. + 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 the Open Knowledge Foundation Ltd. nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. + Neither the name of the Open Knowledge Foundation Ltd. 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 @@ -35,8 +35,6 @@ 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 goautoneg diff --git a/vendor/github.com/prometheus/common/model/time.go b/vendor/github.com/prometheus/common/model/time.go index c909b8aa8..5727452c1 100644 --- a/vendor/github.com/prometheus/common/model/time.go +++ b/vendor/github.com/prometheus/common/model/time.go @@ -18,7 +18,6 @@ import ( "errors" "fmt" "math" - "regexp" "strconv" "strings" "time" @@ -183,54 +182,78 @@ func (d *Duration) Type() string { return "duration" } -var durationRE = regexp.MustCompile("^(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?$") +func isdigit(c byte) bool { return c >= '0' && c <= '9' } + +// Units are required to go in order from biggest to smallest. +// This guards against confusion from "1m1d" being 1 minute + 1 day, not 1 month + 1 day. +var unitMap = map[string]struct { + pos int + mult uint64 +}{ + "ms": {7, uint64(time.Millisecond)}, + "s": {6, uint64(time.Second)}, + "m": {5, uint64(time.Minute)}, + "h": {4, uint64(time.Hour)}, + "d": {3, uint64(24 * time.Hour)}, + "w": {2, uint64(7 * 24 * time.Hour)}, + "y": {1, uint64(365 * 24 * time.Hour)}, +} // ParseDuration parses a string into a time.Duration, assuming that a year // always has 365d, a week always has 7d, and a day always has 24h. -func ParseDuration(durationStr string) (Duration, error) { - switch durationStr { +func ParseDuration(s string) (Duration, error) { + switch s { case "0": // Allow 0 without a unit. return 0, nil case "": return 0, errors.New("empty duration string") } - matches := durationRE.FindStringSubmatch(durationStr) - if matches == nil { - return 0, fmt.Errorf("not a valid duration string: %q", durationStr) - } - var dur time.Duration - // Parse the match at pos `pos` in the regex and use `mult` to turn that - // into ms, then add that value to the total parsed duration. - var overflowErr error - m := func(pos int, mult time.Duration) { - if matches[pos] == "" { - return + orig := s + var dur uint64 + lastUnitPos := 0 + + for s != "" { + if !isdigit(s[0]) { + return 0, fmt.Errorf("not a valid duration string: %q", orig) + } + // Consume [0-9]* + i := 0 + for ; i < len(s) && isdigit(s[i]); i++ { + } + v, err := strconv.ParseUint(s[:i], 10, 0) + if err != nil { + return 0, fmt.Errorf("not a valid duration string: %q", orig) } - n, _ := strconv.Atoi(matches[pos]) + s = s[i:] + // Consume unit. + for i = 0; i < len(s) && !isdigit(s[i]); i++ { + } + if i == 0 { + return 0, fmt.Errorf("not a valid duration string: %q", orig) + } + u := s[:i] + s = s[i:] + unit, ok := unitMap[u] + if !ok { + return 0, fmt.Errorf("unknown unit %q in duration %q", u, orig) + } + if unit.pos <= lastUnitPos { // Units must go in order from biggest to smallest. + return 0, fmt.Errorf("not a valid duration string: %q", orig) + } + lastUnitPos = unit.pos // Check if the provided duration overflows time.Duration (> ~ 290years). - if n > int((1<<63-1)/mult/time.Millisecond) { - overflowErr = errors.New("duration out of range") + if v > 1<<63/unit.mult { + return 0, errors.New("duration out of range") } - d := time.Duration(n) * time.Millisecond - dur += d * mult - - if dur < 0 { - overflowErr = errors.New("duration out of range") + dur += v * unit.mult + if dur > 1<<63-1 { + return 0, errors.New("duration out of range") } } - - m(2, 1000*60*60*24*365) // y - m(4, 1000*60*60*24*7) // w - m(6, 1000*60*60*24) // d - m(8, 1000*60*60) // h - m(10, 1000*60) // m - m(12, 1000) // s - m(14, 1) // ms - - return Duration(dur), overflowErr + return Duration(dur), nil } func (d Duration) String() string { diff --git a/vendor/github.com/prometheus/common/model/value.go b/vendor/github.com/prometheus/common/model/value.go index c9d8fb1a2..9eb440413 100644 --- a/vendor/github.com/prometheus/common/model/value.go +++ b/vendor/github.com/prometheus/common/model/value.go @@ -16,20 +16,12 @@ package model import ( "encoding/json" "fmt" - "math" "sort" "strconv" "strings" ) var ( - // ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a - // non-existing sample pair. It is a SamplePair with timestamp Earliest and - // value 0.0. Note that the natural zero value of SamplePair has a timestamp - // of 0, which is possible to appear in a real SamplePair and thus not - // suitable to signal a non-existing SamplePair. - ZeroSamplePair = SamplePair{Timestamp: Earliest} - // ZeroSample is the pseudo zero-value of Sample used to signal a // non-existing sample. It is a Sample with timestamp Earliest, value 0.0, // and metric nil. Note that the natural zero value of Sample has a timestamp @@ -38,82 +30,14 @@ var ( ZeroSample = Sample{Timestamp: Earliest} ) -// A SampleValue is a representation of a value for a given sample at a given -// time. -type SampleValue float64 - -// MarshalJSON implements json.Marshaler. -func (v SampleValue) MarshalJSON() ([]byte, error) { - return json.Marshal(v.String()) -} - -// UnmarshalJSON implements json.Unmarshaler. -func (v *SampleValue) UnmarshalJSON(b []byte) error { - if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { - return fmt.Errorf("sample value must be a quoted string") - } - f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) - if err != nil { - return err - } - *v = SampleValue(f) - return nil -} - -// Equal returns true if the value of v and o is equal or if both are NaN. Note -// that v==o is false if both are NaN. If you want the conventional float -// behavior, use == to compare two SampleValues. -func (v SampleValue) Equal(o SampleValue) bool { - if v == o { - return true - } - return math.IsNaN(float64(v)) && math.IsNaN(float64(o)) -} - -func (v SampleValue) String() string { - return strconv.FormatFloat(float64(v), 'f', -1, 64) -} - -// SamplePair pairs a SampleValue with a Timestamp. -type SamplePair struct { - Timestamp Time - Value SampleValue -} - -// MarshalJSON implements json.Marshaler. -func (s SamplePair) MarshalJSON() ([]byte, error) { - t, err := json.Marshal(s.Timestamp) - if err != nil { - return nil, err - } - v, err := json.Marshal(s.Value) - if err != nil { - return nil, err - } - return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (s *SamplePair) UnmarshalJSON(b []byte) error { - v := [...]json.Unmarshaler{&s.Timestamp, &s.Value} - return json.Unmarshal(b, &v) -} - -// Equal returns true if this SamplePair and o have equal Values and equal -// Timestamps. The semantics of Value equality is defined by SampleValue.Equal. -func (s *SamplePair) Equal(o *SamplePair) bool { - return s == o || (s.Value.Equal(o.Value) && s.Timestamp.Equal(o.Timestamp)) -} - -func (s SamplePair) String() string { - return fmt.Sprintf("%s @[%s]", s.Value, s.Timestamp) -} - -// Sample is a sample pair associated with a metric. +// Sample is a sample pair associated with a metric. A single sample must either +// define Value or Histogram but not both. Histogram == nil implies the Value +// field is used, otherwise it should be ignored. type Sample struct { - Metric Metric `json:"metric"` - Value SampleValue `json:"value"` - Timestamp Time `json:"timestamp"` + Metric Metric `json:"metric"` + Value SampleValue `json:"value"` + Timestamp Time `json:"timestamp"` + Histogram *SampleHistogram `json:"histogram"` } // Equal compares first the metrics, then the timestamp, then the value. The @@ -129,11 +53,19 @@ func (s *Sample) Equal(o *Sample) bool { if !s.Timestamp.Equal(o.Timestamp) { return false } - + if s.Histogram != nil { + return s.Histogram.Equal(o.Histogram) + } return s.Value.Equal(o.Value) } func (s Sample) String() string { + if s.Histogram != nil { + return fmt.Sprintf("%s => %s", s.Metric, SampleHistogramPair{ + Timestamp: s.Timestamp, + Histogram: s.Histogram, + }) + } return fmt.Sprintf("%s => %s", s.Metric, SamplePair{ Timestamp: s.Timestamp, Value: s.Value, @@ -142,6 +74,19 @@ func (s Sample) String() string { // MarshalJSON implements json.Marshaler. func (s Sample) MarshalJSON() ([]byte, error) { + if s.Histogram != nil { + v := struct { + Metric Metric `json:"metric"` + Histogram SampleHistogramPair `json:"histogram"` + }{ + Metric: s.Metric, + Histogram: SampleHistogramPair{ + Timestamp: s.Timestamp, + Histogram: s.Histogram, + }, + } + return json.Marshal(&v) + } v := struct { Metric Metric `json:"metric"` Value SamplePair `json:"value"` @@ -152,21 +97,25 @@ func (s Sample) MarshalJSON() ([]byte, error) { Value: s.Value, }, } - return json.Marshal(&v) } // UnmarshalJSON implements json.Unmarshaler. func (s *Sample) UnmarshalJSON(b []byte) error { v := struct { - Metric Metric `json:"metric"` - Value SamplePair `json:"value"` + Metric Metric `json:"metric"` + Value SamplePair `json:"value"` + Histogram SampleHistogramPair `json:"histogram"` }{ Metric: s.Metric, Value: SamplePair{ Timestamp: s.Timestamp, Value: s.Value, }, + Histogram: SampleHistogramPair{ + Timestamp: s.Timestamp, + Histogram: s.Histogram, + }, } if err := json.Unmarshal(b, &v); err != nil { @@ -174,8 +123,13 @@ func (s *Sample) UnmarshalJSON(b []byte) error { } s.Metric = v.Metric - s.Timestamp = v.Value.Timestamp - s.Value = v.Value.Value + if v.Histogram.Histogram != nil { + s.Timestamp = v.Histogram.Timestamp + s.Histogram = v.Histogram.Histogram + } else { + s.Timestamp = v.Value.Timestamp + s.Value = v.Value.Value + } return nil } @@ -221,80 +175,76 @@ func (s Samples) Equal(o Samples) bool { // SampleStream is a stream of Values belonging to an attached COWMetric. type SampleStream struct { - Metric Metric `json:"metric"` - Values []SamplePair `json:"values"` + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + Histograms []SampleHistogramPair `json:"histograms"` } func (ss SampleStream) String() string { - vals := make([]string, len(ss.Values)) + valuesLength := len(ss.Values) + vals := make([]string, valuesLength+len(ss.Histograms)) for i, v := range ss.Values { vals[i] = v.String() } + for i, v := range ss.Histograms { + vals[i+valuesLength] = v.String() + } return fmt.Sprintf("%s =>\n%s", ss.Metric, strings.Join(vals, "\n")) } -// Value is a generic interface for values resulting from a query evaluation. -type Value interface { - Type() ValueType - String() string +func (ss SampleStream) MarshalJSON() ([]byte, error) { + if len(ss.Histograms) > 0 && len(ss.Values) > 0 { + v := struct { + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + Histograms []SampleHistogramPair `json:"histograms"` + }{ + Metric: ss.Metric, + Values: ss.Values, + Histograms: ss.Histograms, + } + return json.Marshal(&v) + } else if len(ss.Histograms) > 0 { + v := struct { + Metric Metric `json:"metric"` + Histograms []SampleHistogramPair `json:"histograms"` + }{ + Metric: ss.Metric, + Histograms: ss.Histograms, + } + return json.Marshal(&v) + } else { + v := struct { + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + }{ + Metric: ss.Metric, + Values: ss.Values, + } + return json.Marshal(&v) + } } -func (Matrix) Type() ValueType { return ValMatrix } -func (Vector) Type() ValueType { return ValVector } -func (*Scalar) Type() ValueType { return ValScalar } -func (*String) Type() ValueType { return ValString } - -type ValueType int - -const ( - ValNone ValueType = iota - ValScalar - ValVector - ValMatrix - ValString -) - -// MarshalJSON implements json.Marshaler. -func (et ValueType) MarshalJSON() ([]byte, error) { - return json.Marshal(et.String()) -} +func (ss *SampleStream) UnmarshalJSON(b []byte) error { + v := struct { + Metric Metric `json:"metric"` + Values []SamplePair `json:"values"` + Histograms []SampleHistogramPair `json:"histograms"` + }{ + Metric: ss.Metric, + Values: ss.Values, + Histograms: ss.Histograms, + } -func (et *ValueType) UnmarshalJSON(b []byte) error { - var s string - if err := json.Unmarshal(b, &s); err != nil { + if err := json.Unmarshal(b, &v); err != nil { return err } - switch s { - case "": - *et = ValNone - case "scalar": - *et = ValScalar - case "vector": - *et = ValVector - case "matrix": - *et = ValMatrix - case "string": - *et = ValString - default: - return fmt.Errorf("unknown value type %q", s) - } - return nil -} -func (e ValueType) String() string { - switch e { - case ValNone: - return "" - case ValScalar: - return "scalar" - case ValVector: - return "vector" - case ValMatrix: - return "matrix" - case ValString: - return "string" - } - panic("ValueType.String: unhandled value type") + ss.Metric = v.Metric + ss.Values = v.Values + ss.Histograms = v.Histograms + + return nil } // Scalar is a scalar value evaluated at the set timestamp. diff --git a/vendor/github.com/prometheus/common/model/value_float.go b/vendor/github.com/prometheus/common/model/value_float.go new file mode 100644 index 000000000..0f615a705 --- /dev/null +++ b/vendor/github.com/prometheus/common/model/value_float.go @@ -0,0 +1,100 @@ +// Copyright 2013 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package model + +import ( + "encoding/json" + "fmt" + "math" + "strconv" +) + +var ( + // ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a + // non-existing sample pair. It is a SamplePair with timestamp Earliest and + // value 0.0. Note that the natural zero value of SamplePair has a timestamp + // of 0, which is possible to appear in a real SamplePair and thus not + // suitable to signal a non-existing SamplePair. + ZeroSamplePair = SamplePair{Timestamp: Earliest} +) + +// A SampleValue is a representation of a value for a given sample at a given +// time. +type SampleValue float64 + +// MarshalJSON implements json.Marshaler. +func (v SampleValue) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +// UnmarshalJSON implements json.Unmarshaler. +func (v *SampleValue) UnmarshalJSON(b []byte) error { + if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { + return fmt.Errorf("sample value must be a quoted string") + } + f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) + if err != nil { + return err + } + *v = SampleValue(f) + return nil +} + +// Equal returns true if the value of v and o is equal or if both are NaN. Note +// that v==o is false if both are NaN. If you want the conventional float +// behavior, use == to compare two SampleValues. +func (v SampleValue) Equal(o SampleValue) bool { + if v == o { + return true + } + return math.IsNaN(float64(v)) && math.IsNaN(float64(o)) +} + +func (v SampleValue) String() string { + return strconv.FormatFloat(float64(v), 'f', -1, 64) +} + +// SamplePair pairs a SampleValue with a Timestamp. +type SamplePair struct { + Timestamp Time + Value SampleValue +} + +func (s SamplePair) MarshalJSON() ([]byte, error) { + t, err := json.Marshal(s.Timestamp) + if err != nil { + return nil, err + } + v, err := json.Marshal(s.Value) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (s *SamplePair) UnmarshalJSON(b []byte) error { + v := [...]json.Unmarshaler{&s.Timestamp, &s.Value} + return json.Unmarshal(b, &v) +} + +// Equal returns true if this SamplePair and o have equal Values and equal +// Timestamps. The semantics of Value equality is defined by SampleValue.Equal. +func (s *SamplePair) Equal(o *SamplePair) bool { + return s == o || (s.Value.Equal(o.Value) && s.Timestamp.Equal(o.Timestamp)) +} + +func (s SamplePair) String() string { + return fmt.Sprintf("%s @[%s]", s.Value, s.Timestamp) +} diff --git a/vendor/github.com/prometheus/common/model/value_histogram.go b/vendor/github.com/prometheus/common/model/value_histogram.go new file mode 100644 index 000000000..54bb038cf --- /dev/null +++ b/vendor/github.com/prometheus/common/model/value_histogram.go @@ -0,0 +1,178 @@ +// Copyright 2013 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package model + +import ( + "encoding/json" + "fmt" + "strconv" + "strings" +) + +type FloatString float64 + +func (v FloatString) String() string { + return strconv.FormatFloat(float64(v), 'f', -1, 64) +} + +func (v FloatString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +func (v *FloatString) UnmarshalJSON(b []byte) error { + if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { + return fmt.Errorf("float value must be a quoted string") + } + f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) + if err != nil { + return err + } + *v = FloatString(f) + return nil +} + +type HistogramBucket struct { + Boundaries int32 + Lower FloatString + Upper FloatString + Count FloatString +} + +func (s HistogramBucket) MarshalJSON() ([]byte, error) { + b, err := json.Marshal(s.Boundaries) + if err != nil { + return nil, err + } + l, err := json.Marshal(s.Lower) + if err != nil { + return nil, err + } + u, err := json.Marshal(s.Upper) + if err != nil { + return nil, err + } + c, err := json.Marshal(s.Count) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf("[%s,%s,%s,%s]", b, l, u, c)), nil +} + +func (s *HistogramBucket) UnmarshalJSON(buf []byte) error { + tmp := []interface{}{&s.Boundaries, &s.Lower, &s.Upper, &s.Count} + wantLen := len(tmp) + if err := json.Unmarshal(buf, &tmp); err != nil { + return err + } + if gotLen := len(tmp); gotLen != wantLen { + return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen) + } + return nil +} + +func (s *HistogramBucket) Equal(o *HistogramBucket) bool { + return s == o || (s.Boundaries == o.Boundaries && s.Lower == o.Lower && s.Upper == o.Upper && s.Count == o.Count) +} + +func (b HistogramBucket) String() string { + var sb strings.Builder + lowerInclusive := b.Boundaries == 1 || b.Boundaries == 3 + upperInclusive := b.Boundaries == 0 || b.Boundaries == 3 + if lowerInclusive { + sb.WriteRune('[') + } else { + sb.WriteRune('(') + } + fmt.Fprintf(&sb, "%g,%g", b.Lower, b.Upper) + if upperInclusive { + sb.WriteRune(']') + } else { + sb.WriteRune(')') + } + fmt.Fprintf(&sb, ":%v", b.Count) + return sb.String() +} + +type HistogramBuckets []*HistogramBucket + +func (s HistogramBuckets) Equal(o HistogramBuckets) bool { + if len(s) != len(o) { + return false + } + + for i, bucket := range s { + if !bucket.Equal(o[i]) { + return false + } + } + return true +} + +type SampleHistogram struct { + Count FloatString `json:"count"` + Sum FloatString `json:"sum"` + Buckets HistogramBuckets `json:"buckets"` +} + +func (s SampleHistogram) String() string { + return fmt.Sprintf("Count: %f, Sum: %f, Buckets: %v", s.Count, s.Sum, s.Buckets) +} + +func (s *SampleHistogram) Equal(o *SampleHistogram) bool { + return s == o || (s.Count == o.Count && s.Sum == o.Sum && s.Buckets.Equal(o.Buckets)) +} + +type SampleHistogramPair struct { + Timestamp Time + // Histogram should never be nil, it's only stored as pointer for efficiency. + Histogram *SampleHistogram +} + +func (s SampleHistogramPair) MarshalJSON() ([]byte, error) { + if s.Histogram == nil { + return nil, fmt.Errorf("histogram is nil") + } + t, err := json.Marshal(s.Timestamp) + if err != nil { + return nil, err + } + v, err := json.Marshal(s.Histogram) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil +} + +func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error { + tmp := []interface{}{&s.Timestamp, &s.Histogram} + wantLen := len(tmp) + if err := json.Unmarshal(buf, &tmp); err != nil { + return err + } + if gotLen := len(tmp); gotLen != wantLen { + return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen) + } + if s.Histogram == nil { + return fmt.Errorf("histogram is null") + } + return nil +} + +func (s SampleHistogramPair) String() string { + return fmt.Sprintf("%s @[%s]", s.Histogram, s.Timestamp) +} + +func (s *SampleHistogramPair) Equal(o *SampleHistogramPair) bool { + return s == o || (s.Histogram.Equal(o.Histogram) && s.Timestamp.Equal(o.Timestamp)) +} diff --git a/vendor/github.com/prometheus/common/model/value_type.go b/vendor/github.com/prometheus/common/model/value_type.go new file mode 100644 index 000000000..726c50ee6 --- /dev/null +++ b/vendor/github.com/prometheus/common/model/value_type.go @@ -0,0 +1,83 @@ +// Copyright 2013 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package model + +import ( + "encoding/json" + "fmt" +) + +// Value is a generic interface for values resulting from a query evaluation. +type Value interface { + Type() ValueType + String() string +} + +func (Matrix) Type() ValueType { return ValMatrix } +func (Vector) Type() ValueType { return ValVector } +func (*Scalar) Type() ValueType { return ValScalar } +func (*String) Type() ValueType { return ValString } + +type ValueType int + +const ( + ValNone ValueType = iota + ValScalar + ValVector + ValMatrix + ValString +) + +// MarshalJSON implements json.Marshaler. +func (et ValueType) MarshalJSON() ([]byte, error) { + return json.Marshal(et.String()) +} + +func (et *ValueType) UnmarshalJSON(b []byte) error { + var s string + if err := json.Unmarshal(b, &s); err != nil { + return err + } + switch s { + case "": + *et = ValNone + case "scalar": + *et = ValScalar + case "vector": + *et = ValVector + case "matrix": + *et = ValMatrix + case "string": + *et = ValString + default: + return fmt.Errorf("unknown value type %q", s) + } + return nil +} + +func (e ValueType) String() string { + switch e { + case ValNone: + return "" + case ValScalar: + return "scalar" + case ValVector: + return "vector" + case ValMatrix: + return "matrix" + case ValString: + return "string" + } + panic("ValueType.String: unhandled value type") +} diff --git a/vendor/github.com/prometheus/procfs/.golangci.yml b/vendor/github.com/prometheus/procfs/.golangci.yml index a197699a1..c24864a92 100644 --- a/vendor/github.com/prometheus/procfs/.golangci.yml +++ b/vendor/github.com/prometheus/procfs/.golangci.yml @@ -2,6 +2,7 @@ linters: enable: - godot + - misspell - revive linter-settings: @@ -10,3 +11,5 @@ linter-settings: exclude: # Ignore "See: URL" - 'See:' + misspell: + locale: US diff --git a/vendor/github.com/prometheus/procfs/Makefile.common b/vendor/github.com/prometheus/procfs/Makefile.common index 6c8e3e219..b111d2562 100644 --- a/vendor/github.com/prometheus/procfs/Makefile.common +++ b/vendor/github.com/prometheus/procfs/Makefile.common @@ -55,19 +55,22 @@ ifneq ($(shell which gotestsum),) endif endif -PROMU_VERSION ?= 0.13.0 +PROMU_VERSION ?= 0.14.0 PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz +SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v1.45.2 +GOLANGCI_LINT_VERSION ?= v1.51.2 # golangci-lint only supports linux, darwin and windows platforms on i386/amd64. # windows isn't included here because of the path separator being different. ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386)) # If we're in CI and there is an Actions file, that means the linter # is being run in Actions, so we don't need to run it here. - ifeq (,$(CIRCLE_JOB)) + ifneq (,$(SKIP_GOLANGCI_LINT)) + GOLANGCI_LINT := + else ifeq (,$(CIRCLE_JOB)) GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint else ifeq (,$(wildcard .github/workflows/golangci-lint.yml)) GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint @@ -88,6 +91,8 @@ BUILD_DOCKER_ARCHS = $(addprefix common-docker-,$(DOCKER_ARCHS)) PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS)) TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS)) +SANITIZED_DOCKER_IMAGE_TAG := $(subst +,-,$(DOCKER_IMAGE_TAG)) + ifeq ($(GOHOSTARCH),amd64) ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin windows)) # Only supported on amd64 @@ -202,7 +207,7 @@ common-tarball: promu .PHONY: common-docker $(BUILD_DOCKER_ARCHS) common-docker: $(BUILD_DOCKER_ARCHS) $(BUILD_DOCKER_ARCHS): common-docker-%: - docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" \ + docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" \ -f $(DOCKERFILE_PATH) \ --build-arg ARCH="$*" \ --build-arg OS="linux" \ @@ -211,19 +216,19 @@ $(BUILD_DOCKER_ARCHS): common-docker-%: .PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS) common-docker-publish: $(PUBLISH_DOCKER_ARCHS) $(PUBLISH_DOCKER_ARCHS): common-docker-publish-%: - docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" + docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" DOCKER_MAJOR_VERSION_TAG = $(firstword $(subst ., ,$(shell cat VERSION))) .PHONY: common-docker-tag-latest $(TAG_DOCKER_ARCHS) common-docker-tag-latest: $(TAG_DOCKER_ARCHS) $(TAG_DOCKER_ARCHS): common-docker-tag-latest-%: - docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest" - docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)" + docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest" + docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)" .PHONY: common-docker-manifest common-docker-manifest: - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(DOCKER_IMAGE_TAG)) - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" + DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(SANITIZED_DOCKER_IMAGE_TAG)) + DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)" .PHONY: promu promu: $(PROMU) diff --git a/vendor/github.com/prometheus/procfs/README.md b/vendor/github.com/prometheus/procfs/README.md index 43c37735a..1224816c2 100644 --- a/vendor/github.com/prometheus/procfs/README.md +++ b/vendor/github.com/prometheus/procfs/README.md @@ -51,11 +51,11 @@ ensure the `fixtures` directory is up to date by removing the existing directory extracting the ttar file using `make fixtures/.unpacked` or just `make test`. ```bash -rm -rf fixtures +rm -rf testdata/fixtures make test ``` Next, make the required changes to the extracted files in the `fixtures` directory. When the changes are complete, run `make update_fixtures` to create a new `fixtures.ttar` file based on the updated `fixtures` directory. And finally, verify the changes using -`git diff fixtures.ttar`. +`git diff testdata/fixtures.ttar`. diff --git a/vendor/github.com/prometheus/procfs/arp.go b/vendor/github.com/prometheus/procfs/arp.go index 68f36e888..28783e2dd 100644 --- a/vendor/github.com/prometheus/procfs/arp.go +++ b/vendor/github.com/prometheus/procfs/arp.go @@ -55,7 +55,7 @@ type ARPEntry struct { func (fs FS) GatherARPEntries() ([]ARPEntry, error) { data, err := os.ReadFile(fs.proc.Path("net/arp")) if err != nil { - return nil, fmt.Errorf("error reading arp %q: %w", fs.proc.Path("net/arp"), err) + return nil, fmt.Errorf("%s: error reading arp %s: %w", ErrFileRead, fs.proc.Path("net/arp"), err) } return parseARPEntries(data) @@ -78,11 +78,11 @@ func parseARPEntries(data []byte) ([]ARPEntry, error) { } else if width == expectedDataWidth { entry, err := parseARPEntry(columns) if err != nil { - return []ARPEntry{}, fmt.Errorf("failed to parse ARP entry: %w", err) + return []ARPEntry{}, fmt.Errorf("%s: Failed to parse ARP entry: %v: %w", ErrFileParse, entry, err) } entries = append(entries, entry) } else { - return []ARPEntry{}, fmt.Errorf("%d columns were detected, but %d were expected", width, expectedDataWidth) + return []ARPEntry{}, fmt.Errorf("%s: %d columns found, but expected %d: %w", ErrFileParse, width, expectedDataWidth, err) } } diff --git a/vendor/github.com/prometheus/procfs/buddyinfo.go b/vendor/github.com/prometheus/procfs/buddyinfo.go index f5b7939b2..4a173636c 100644 --- a/vendor/github.com/prometheus/procfs/buddyinfo.go +++ b/vendor/github.com/prometheus/procfs/buddyinfo.go @@ -55,7 +55,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { parts := strings.Fields(line) if len(parts) < 4 { - return nil, fmt.Errorf("invalid number of fields when parsing buddyinfo") + return nil, fmt.Errorf("%w: Invalid number of fields, found: %v", ErrFileParse, parts) } node := strings.TrimRight(parts[1], ",") @@ -66,7 +66,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { bucketCount = arraySize } else { if bucketCount != arraySize { - return nil, fmt.Errorf("mismatch in number of buddyinfo buckets, previous count %d, new count %d", bucketCount, arraySize) + return nil, fmt.Errorf("%w: mismatch in number of buddyinfo buckets, previous count %d, new count %d", ErrFileParse, bucketCount, arraySize) } } @@ -74,7 +74,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) { for i := 0; i < arraySize; i++ { sizes[i], err = strconv.ParseFloat(parts[i+4], 64) if err != nil { - return nil, fmt.Errorf("invalid value in buddyinfo: %w", err) + return nil, fmt.Errorf("%s: Invalid valid in buddyinfo: %f: %w", ErrFileParse, sizes[i], err) } } diff --git a/vendor/github.com/prometheus/procfs/cpuinfo.go b/vendor/github.com/prometheus/procfs/cpuinfo.go index ff6b927da..f4f5501c6 100644 --- a/vendor/github.com/prometheus/procfs/cpuinfo.go +++ b/vendor/github.com/prometheus/procfs/cpuinfo.go @@ -79,7 +79,7 @@ func parseCPUInfoX86(info []byte) ([]CPUInfo, error) { // find the first "processor" line firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) v, err := strconv.ParseUint(field[1], 0, 32) @@ -192,9 +192,10 @@ func parseCPUInfoARM(info []byte) ([]CPUInfo, error) { scanner := bufio.NewScanner(bytes.NewReader(info)) firstLine := firstNonEmptyLine(scanner) - match, _ := regexp.MatchString("^[Pp]rocessor", firstLine) + match, err := regexp.MatchString("^[Pp]rocessor", firstLine) if !match || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%s: Cannot parse line: %q: %w", ErrFileParse, firstLine, err) + } field := strings.SplitN(firstLine, ": ", 2) cpuinfo := []CPUInfo{} @@ -258,7 +259,7 @@ func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) { firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "vendor_id") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) cpuinfo := []CPUInfo{} @@ -283,7 +284,7 @@ func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) { if strings.HasPrefix(line, "processor") { match := cpuinfoS390XProcessorRegexp.FindStringSubmatch(line) if len(match) < 2 { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } cpu := commonCPUInfo v, err := strconv.ParseUint(match[1], 0, 32) @@ -343,7 +344,7 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) { // find the first "processor" line firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) cpuinfo := []CPUInfo{} @@ -380,12 +381,48 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) { return cpuinfo, nil } +func parseCPUInfoLoong(info []byte) ([]CPUInfo, error) { + scanner := bufio.NewScanner(bytes.NewReader(info)) + // find the first "processor" line + firstLine := firstNonEmptyLine(scanner) + if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") { + return nil, errors.New("invalid cpuinfo file: " + firstLine) + } + field := strings.SplitN(firstLine, ": ", 2) + cpuinfo := []CPUInfo{} + systemType := field[1] + i := 0 + for scanner.Scan() { + line := scanner.Text() + if !strings.Contains(line, ":") { + continue + } + field := strings.SplitN(line, ": ", 2) + switch strings.TrimSpace(field[0]) { + case "processor": + v, err := strconv.ParseUint(field[1], 0, 32) + if err != nil { + return nil, err + } + i = int(v) + cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor + cpuinfo[i].Processor = uint(v) + cpuinfo[i].VendorID = systemType + case "CPU Family": + cpuinfo[i].CPUFamily = field[1] + case "Model Name": + cpuinfo[i].ModelName = field[1] + } + } + return cpuinfo, nil +} + func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) { scanner := bufio.NewScanner(bytes.NewReader(info)) firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) v, err := strconv.ParseUint(field[1], 0, 32) @@ -430,7 +467,7 @@ func parseCPUInfoRISCV(info []byte) ([]CPUInfo, error) { firstLine := firstNonEmptyLine(scanner) if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") { - return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine) + return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine) } field := strings.SplitN(firstLine, ": ", 2) v, err := strconv.ParseUint(field[1], 0, 32) diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go b/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go new file mode 100644 index 000000000..d88442f0e --- /dev/null +++ b/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go @@ -0,0 +1,19 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build linux +// +build linux + +package procfs + +var parseCPUInfo = parseCPUInfoLoong diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_others.go b/vendor/github.com/prometheus/procfs/cpuinfo_others.go index ea41bf2ca..a6b2b3127 100644 --- a/vendor/github.com/prometheus/procfs/cpuinfo_others.go +++ b/vendor/github.com/prometheus/procfs/cpuinfo_others.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build linux && !386 && !amd64 && !arm && !arm64 && !mips && !mips64 && !mips64le && !mipsle && !ppc64 && !ppc64le && !riscv64 && !s390x -// +build linux,!386,!amd64,!arm,!arm64,!mips,!mips64,!mips64le,!mipsle,!ppc64,!ppc64le,!riscv64,!s390x +//go:build linux && !386 && !amd64 && !arm && !arm64 && !loong64 && !mips && !mips64 && !mips64le && !mipsle && !ppc64 && !ppc64le && !riscv64 && !s390x +// +build linux,!386,!amd64,!arm,!arm64,!loong64,!mips,!mips64,!mips64le,!mipsle,!ppc64,!ppc64le,!riscv64,!s390x package procfs diff --git a/vendor/github.com/prometheus/procfs/crypto.go b/vendor/github.com/prometheus/procfs/crypto.go index 5048ad1f2..9a73e2639 100644 --- a/vendor/github.com/prometheus/procfs/crypto.go +++ b/vendor/github.com/prometheus/procfs/crypto.go @@ -55,12 +55,13 @@ func (fs FS) Crypto() ([]Crypto, error) { path := fs.proc.Path("crypto") b, err := util.ReadFileNoStat(path) if err != nil { - return nil, fmt.Errorf("error reading crypto %q: %w", path, err) + return nil, fmt.Errorf("%s: Cannot read file %v: %w", ErrFileRead, b, err) + } crypto, err := parseCrypto(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("error parsing crypto %q: %w", path, err) + return nil, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, crypto, err) } return crypto, nil @@ -83,7 +84,7 @@ func parseCrypto(r io.Reader) ([]Crypto, error) { kv := strings.Split(text, ":") if len(kv) != 2 { - return nil, fmt.Errorf("malformed crypto line: %q", text) + return nil, fmt.Errorf("%w: Cannot parae line: %q", ErrFileParse, text) } k := strings.TrimSpace(kv[0]) diff --git a/vendor/github.com/prometheus/procfs/doc.go b/vendor/github.com/prometheus/procfs/doc.go index d31a82600..f9d961e44 100644 --- a/vendor/github.com/prometheus/procfs/doc.go +++ b/vendor/github.com/prometheus/procfs/doc.go @@ -16,30 +16,29 @@ // // Example: // -// package main -// -// import ( -// "fmt" -// "log" -// -// "github.com/prometheus/procfs" -// ) -// -// func main() { -// p, err := procfs.Self() -// if err != nil { -// log.Fatalf("could not get process: %s", err) -// } -// -// stat, err := p.Stat() -// if err != nil { -// log.Fatalf("could not get process stat: %s", err) -// } -// -// fmt.Printf("command: %s\n", stat.Comm) -// fmt.Printf("cpu time: %fs\n", stat.CPUTime()) -// fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) -// fmt.Printf("rss: %dB\n", stat.ResidentMemory()) -// } -// +// package main +// +// import ( +// "fmt" +// "log" +// +// "github.com/prometheus/procfs" +// ) +// +// func main() { +// p, err := procfs.Self() +// if err != nil { +// log.Fatalf("could not get process: %s", err) +// } +// +// stat, err := p.Stat() +// if err != nil { +// log.Fatalf("could not get process stat: %s", err) +// } +// +// fmt.Printf("command: %s\n", stat.Comm) +// fmt.Printf("cpu time: %fs\n", stat.CPUTime()) +// fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) +// fmt.Printf("rss: %dB\n", stat.ResidentMemory()) +// } package procfs diff --git a/vendor/github.com/prometheus/procfs/fs.go b/vendor/github.com/prometheus/procfs/fs.go index 0102ab0fd..60c551e02 100644 --- a/vendor/github.com/prometheus/procfs/fs.go +++ b/vendor/github.com/prometheus/procfs/fs.go @@ -21,6 +21,7 @@ import ( // kernel data structures. type FS struct { proc fs.FS + real bool } // DefaultMountPoint is the common mount point of the proc filesystem. @@ -39,5 +40,11 @@ func NewFS(mountPoint string) (FS, error) { if err != nil { return FS{}, err } - return FS{fs}, nil + + real, err := isRealProc(mountPoint) + if err != nil { + return FS{}, err + } + + return FS{fs, real}, nil } diff --git a/vendor/github.com/prometheus/procfs/fs_statfs_notype.go b/vendor/github.com/prometheus/procfs/fs_statfs_notype.go new file mode 100644 index 000000000..800576968 --- /dev/null +++ b/vendor/github.com/prometheus/procfs/fs_statfs_notype.go @@ -0,0 +1,23 @@ +// Copyright 2018 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build netbsd || openbsd || solaris || windows +// +build netbsd openbsd solaris windows + +package procfs + +// isRealProc returns true on architectures that don't have a Type argument +// in their Statfs_t struct +func isRealProc(mountPoint string) (bool, error) { + return true, nil +} diff --git a/vendor/github.com/prometheus/procfs/fs_statfs_type.go b/vendor/github.com/prometheus/procfs/fs_statfs_type.go new file mode 100644 index 000000000..6233217ad --- /dev/null +++ b/vendor/github.com/prometheus/procfs/fs_statfs_type.go @@ -0,0 +1,33 @@ +// Copyright 2018 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !netbsd && !openbsd && !solaris && !windows +// +build !netbsd,!openbsd,!solaris,!windows + +package procfs + +import ( + "syscall" +) + +// isRealProc determines whether supplied mountpoint is really a proc filesystem. +func isRealProc(mountPoint string) (bool, error) { + stat := syscall.Statfs_t{} + err := syscall.Statfs(mountPoint, &stat) + if err != nil { + return false, err + } + + // 0x9fa0 is PROC_SUPER_MAGIC: https://elixir.bootlin.com/linux/v6.1/source/include/uapi/linux/magic.h#L87 + return stat.Type == 0x9fa0, nil +} diff --git a/vendor/github.com/prometheus/procfs/fscache.go b/vendor/github.com/prometheus/procfs/fscache.go index f8070e6e2..f560a8db3 100644 --- a/vendor/github.com/prometheus/procfs/fscache.go +++ b/vendor/github.com/prometheus/procfs/fscache.go @@ -236,7 +236,7 @@ func (fs FS) Fscacheinfo() (Fscacheinfo, error) { m, err := parseFscacheinfo(bytes.NewReader(b)) if err != nil { - return Fscacheinfo{}, fmt.Errorf("failed to parse Fscacheinfo: %w", err) + return Fscacheinfo{}, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, m, err) } return *m, nil @@ -245,7 +245,7 @@ func (fs FS) Fscacheinfo() (Fscacheinfo, error) { func setFSCacheFields(fields []string, setFields ...*uint64) error { var err error if len(fields) < len(setFields) { - return fmt.Errorf("Insufficient number of fields, expected %v, got %v", len(setFields), len(fields)) + return fmt.Errorf("%s: Expected %d, but got %d: %w", ErrFileParse, len(setFields), len(fields), err) } for i := range setFields { @@ -263,7 +263,7 @@ func parseFscacheinfo(r io.Reader) (*Fscacheinfo, error) { for s.Scan() { fields := strings.Fields(s.Text()) if len(fields) < 2 { - return nil, fmt.Errorf("malformed Fscacheinfo line: %q", s.Text()) + return nil, fmt.Errorf("%w: malformed Fscacheinfo line: %q", ErrFileParse, s.Text()) } switch fields[0] { diff --git a/vendor/github.com/prometheus/procfs/internal/util/parse.go b/vendor/github.com/prometheus/procfs/internal/util/parse.go index b030951fa..14272dc78 100644 --- a/vendor/github.com/prometheus/procfs/internal/util/parse.go +++ b/vendor/github.com/prometheus/procfs/internal/util/parse.go @@ -64,6 +64,21 @@ func ParsePInt64s(ss []string) ([]*int64, error) { return us, nil } +// Parses a uint64 from given hex in string. +func ParseHexUint64s(ss []string) ([]*uint64, error) { + us := make([]*uint64, 0, len(ss)) + for _, s := range ss { + u, err := strconv.ParseUint(s, 16, 64) + if err != nil { + return nil, err + } + + us = append(us, &u) + } + + return us, nil +} + // ReadUintFromFile reads a file and attempts to parse a uint64 from it. func ReadUintFromFile(path string) (uint64, error) { data, err := os.ReadFile(path) diff --git a/vendor/github.com/prometheus/procfs/ipvs.go b/vendor/github.com/prometheus/procfs/ipvs.go index 391c07957..5a145bbfe 100644 --- a/vendor/github.com/prometheus/procfs/ipvs.go +++ b/vendor/github.com/prometheus/procfs/ipvs.go @@ -221,15 +221,16 @@ func parseIPPort(s string) (net.IP, uint16, error) { case 46: ip = net.ParseIP(s[1:40]) if ip == nil { - return nil, 0, fmt.Errorf("invalid IPv6 address: %s", s[1:40]) + return nil, 0, fmt.Errorf("%s: Invalid IPv6 addr %s: %w", ErrFileParse, s[1:40], err) } default: - return nil, 0, fmt.Errorf("unexpected IP:Port: %s", s) + return nil, 0, fmt.Errorf("%s: Unexpected IP:Port %s: %w", ErrFileParse, s, err) } portString := s[len(s)-4:] if len(portString) != 4 { - return nil, 0, fmt.Errorf("unexpected port string format: %s", portString) + return nil, 0, + fmt.Errorf("%s: Unexpected port string format %s: %w", ErrFileParse, portString, err) } port, err := strconv.ParseUint(portString, 16, 16) if err != nil { diff --git a/vendor/github.com/prometheus/procfs/loadavg.go b/vendor/github.com/prometheus/procfs/loadavg.go index 0096cafbd..59465c5bb 100644 --- a/vendor/github.com/prometheus/procfs/loadavg.go +++ b/vendor/github.com/prometheus/procfs/loadavg.go @@ -44,14 +44,14 @@ func parseLoad(loadavgBytes []byte) (*LoadAvg, error) { loads := make([]float64, 3) parts := strings.Fields(string(loadavgBytes)) if len(parts) < 3 { - return nil, fmt.Errorf("malformed loadavg line: too few fields in loadavg string: %q", string(loadavgBytes)) + return nil, fmt.Errorf("%w: Malformed line %q", ErrFileParse, string(loadavgBytes)) } var err error for i, load := range parts[0:3] { loads[i], err = strconv.ParseFloat(load, 64) if err != nil { - return nil, fmt.Errorf("could not parse load %q: %w", load, err) + return nil, fmt.Errorf("%s: Cannot parse load: %f: %w", ErrFileParse, loads[i], err) } } return &LoadAvg{ diff --git a/vendor/github.com/prometheus/procfs/mdstat.go b/vendor/github.com/prometheus/procfs/mdstat.go index a95c889cb..fdd4b9544 100644 --- a/vendor/github.com/prometheus/procfs/mdstat.go +++ b/vendor/github.com/prometheus/procfs/mdstat.go @@ -70,7 +70,7 @@ func (fs FS) MDStat() ([]MDStat, error) { } mdstat, err := parseMDStat(data) if err != nil { - return nil, fmt.Errorf("error parsing mdstat %q: %w", fs.proc.Path("mdstat"), err) + return nil, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, fs.proc.Path("mdstat"), err) } return mdstat, nil } @@ -90,13 +90,13 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { deviceFields := strings.Fields(line) if len(deviceFields) < 3 { - return nil, fmt.Errorf("not enough fields in mdline (expected at least 3): %s", line) + return nil, fmt.Errorf("%s: Expected 3+ lines, got %q", ErrFileParse, line) } mdName := deviceFields[0] // mdx state := deviceFields[2] // active or inactive if len(lines) <= i+3 { - return nil, fmt.Errorf("error parsing %q: too few lines for md device", mdName) + return nil, fmt.Errorf("%w: Too few lines for md device: %q", ErrFileParse, mdName) } // Failed disks have the suffix (F) & Spare disks have the suffix (S). @@ -105,7 +105,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { active, total, down, size, err := evalStatusLine(lines[i], lines[i+1]) if err != nil { - return nil, fmt.Errorf("error parsing md device lines: %w", err) + return nil, fmt.Errorf("%s: Cannot parse md device lines: %v: %w", ErrFileParse, active, err) } syncLineIdx := i + 2 @@ -140,7 +140,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { } else { syncedBlocks, pct, finish, speed, err = evalRecoveryLine(lines[syncLineIdx]) if err != nil { - return nil, fmt.Errorf("error parsing sync line in md device %q: %w", mdName, err) + return nil, fmt.Errorf("%s: Cannot parse sync line in md device: %q: %w", ErrFileParse, mdName, err) } } } @@ -168,13 +168,13 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) { func evalStatusLine(deviceLine, statusLine string) (active, total, down, size int64, err error) { statusFields := strings.Fields(statusLine) if len(statusFields) < 1 { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q", statusLine) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err) } sizeStr := statusFields[0] size, err = strconv.ParseInt(sizeStr, 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err) } if strings.Contains(deviceLine, "raid0") || strings.Contains(deviceLine, "linear") { @@ -189,17 +189,17 @@ func evalStatusLine(deviceLine, statusLine string) (active, total, down, size in matches := statusLineRE.FindStringSubmatch(statusLine) if len(matches) != 5 { - return 0, 0, 0, 0, fmt.Errorf("couldn't find all the substring matches: %s", statusLine) + return 0, 0, 0, 0, fmt.Errorf("%s: Could not fild all substring matches %s: %w", ErrFileParse, statusLine, err) } total, err = strconv.ParseInt(matches[2], 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err) } active, err = strconv.ParseInt(matches[3], 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected active %d: %w", ErrFileParse, active, err) } down = int64(strings.Count(matches[4], "_")) @@ -209,42 +209,42 @@ func evalStatusLine(deviceLine, statusLine string) (active, total, down, size in func evalRecoveryLine(recoveryLine string) (syncedBlocks int64, pct float64, finish float64, speed float64, err error) { matches := recoveryLineBlocksRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return 0, 0, 0, 0, fmt.Errorf("unexpected recoveryLine: %s", recoveryLine) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected recoveryLine %s: %w", ErrFileParse, recoveryLine, err) } syncedBlocks, err = strconv.ParseInt(matches[1], 10, 64) if err != nil { - return 0, 0, 0, 0, fmt.Errorf("error parsing int from recoveryLine %q: %w", recoveryLine, err) + return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected parsing of recoveryLine %q: %w", ErrFileParse, recoveryLine, err) } // Get percentage complete matches = recoveryLinePctRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return syncedBlocks, 0, 0, 0, fmt.Errorf("unexpected recoveryLine matching percentage: %s", recoveryLine) + return syncedBlocks, 0, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching percentage %s", ErrFileParse, recoveryLine) } pct, err = strconv.ParseFloat(strings.TrimSpace(matches[1]), 64) if err != nil { - return syncedBlocks, 0, 0, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err) + return syncedBlocks, 0, 0, 0, fmt.Errorf("%w: Error parsing float from recoveryLine %q", ErrFileParse, recoveryLine) } // Get time expected left to complete matches = recoveryLineFinishRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return syncedBlocks, pct, 0, 0, fmt.Errorf("unexpected recoveryLine matching est. finish time: %s", recoveryLine) + return syncedBlocks, pct, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching est. finish time: %s", ErrFileParse, recoveryLine) } finish, err = strconv.ParseFloat(matches[1], 64) if err != nil { - return syncedBlocks, pct, 0, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err) + return syncedBlocks, pct, 0, 0, fmt.Errorf("%w: Unable to parse float from recoveryLine: %q", ErrFileParse, recoveryLine) } // Get recovery speed matches = recoveryLineSpeedRE.FindStringSubmatch(recoveryLine) if len(matches) != 2 { - return syncedBlocks, pct, finish, 0, fmt.Errorf("unexpected recoveryLine matching speed: %s", recoveryLine) + return syncedBlocks, pct, finish, 0, fmt.Errorf("%w: Unexpected recoveryLine value: %s", ErrFileParse, recoveryLine) } speed, err = strconv.ParseFloat(matches[1], 64) if err != nil { - return syncedBlocks, pct, finish, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err) + return syncedBlocks, pct, finish, 0, fmt.Errorf("%s: Error parsing float from recoveryLine: %q: %w", ErrFileParse, recoveryLine, err) } return syncedBlocks, pct, finish, speed, nil diff --git a/vendor/github.com/prometheus/procfs/meminfo.go b/vendor/github.com/prometheus/procfs/meminfo.go index f65e174e5..eaf00e224 100644 --- a/vendor/github.com/prometheus/procfs/meminfo.go +++ b/vendor/github.com/prometheus/procfs/meminfo.go @@ -152,7 +152,7 @@ func (fs FS) Meminfo() (Meminfo, error) { m, err := parseMemInfo(bytes.NewReader(b)) if err != nil { - return Meminfo{}, fmt.Errorf("failed to parse meminfo: %w", err) + return Meminfo{}, fmt.Errorf("%s: %w", ErrFileParse, err) } return *m, nil @@ -165,7 +165,7 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) { // Each line has at least a name and value; we ignore the unit. fields := strings.Fields(s.Text()) if len(fields) < 2 { - return nil, fmt.Errorf("malformed meminfo line: %q", s.Text()) + return nil, fmt.Errorf("%w: Malformed line %q", ErrFileParse, s.Text()) } v, err := strconv.ParseUint(fields[1], 0, 64) diff --git a/vendor/github.com/prometheus/procfs/mountinfo.go b/vendor/github.com/prometheus/procfs/mountinfo.go index 59f4d5055..388ebf396 100644 --- a/vendor/github.com/prometheus/procfs/mountinfo.go +++ b/vendor/github.com/prometheus/procfs/mountinfo.go @@ -78,11 +78,11 @@ func parseMountInfoString(mountString string) (*MountInfo, error) { mountInfo := strings.Split(mountString, " ") mountInfoLength := len(mountInfo) if mountInfoLength < 10 { - return nil, fmt.Errorf("couldn't find enough fields in mount string: %s", mountString) + return nil, fmt.Errorf("%w: Too few fields in mount string: %s", ErrFileParse, mountString) } if mountInfo[mountInfoLength-4] != "-" { - return nil, fmt.Errorf("couldn't find separator in expected field: %s", mountInfo[mountInfoLength-4]) + return nil, fmt.Errorf("%w: couldn't find separator in expected field: %s", ErrFileParse, mountInfo[mountInfoLength-4]) } mount := &MountInfo{ @@ -98,18 +98,18 @@ func parseMountInfoString(mountString string) (*MountInfo, error) { mount.MountID, err = strconv.Atoi(mountInfo[0]) if err != nil { - return nil, fmt.Errorf("failed to parse mount ID") + return nil, fmt.Errorf("%w: mount ID: %q", ErrFileParse, mount.MountID) } mount.ParentID, err = strconv.Atoi(mountInfo[1]) if err != nil { - return nil, fmt.Errorf("failed to parse parent ID") + return nil, fmt.Errorf("%w: parent ID: %q", ErrFileParse, mount.ParentID) } // Has optional fields, which is a space separated list of values. // Example: shared:2 master:7 if mountInfo[6] != "" { mount.OptionalFields, err = mountOptionsParseOptionalFields(mountInfo[6 : mountInfoLength-4]) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: %w", ErrFileParse, err) } } return mount, nil diff --git a/vendor/github.com/prometheus/procfs/mountstats.go b/vendor/github.com/prometheus/procfs/mountstats.go index f7a828bb1..852c8c4a0 100644 --- a/vendor/github.com/prometheus/procfs/mountstats.go +++ b/vendor/github.com/prometheus/procfs/mountstats.go @@ -186,6 +186,8 @@ type NFSOperationStats struct { CumulativeTotalResponseMilliseconds uint64 // Duration from when a request was enqueued to when it was completely handled. CumulativeTotalRequestMilliseconds uint64 + // The average time from the point the client sends RPC requests until it receives the response. + AverageRTTMilliseconds float64 // The count of operations that complete with tk_status < 0. These statuses usually indicate error conditions. Errors uint64 } @@ -264,7 +266,7 @@ func parseMountStats(r io.Reader) ([]*Mount, error) { if len(ss) > deviceEntryLen { // Only NFSv3 and v4 are supported for parsing statistics if m.Type != nfs3Type && m.Type != nfs4Type { - return nil, fmt.Errorf("cannot parse MountStats for fstype %q", m.Type) + return nil, fmt.Errorf("%w: Cannot parse MountStats for %q", ErrFileParse, m.Type) } statVersion := strings.TrimPrefix(ss[8], statVersionPrefix) @@ -284,10 +286,11 @@ func parseMountStats(r io.Reader) ([]*Mount, error) { } // parseMount parses an entry in /proc/[pid]/mountstats in the format: -// device [device] mounted on [mount] with fstype [type] +// +// device [device] mounted on [mount] with fstype [type] func parseMount(ss []string) (*Mount, error) { if len(ss) < deviceEntryLen { - return nil, fmt.Errorf("invalid device entry: %v", ss) + return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss) } // Check for specific words appearing at specific indices to ensure @@ -305,7 +308,7 @@ func parseMount(ss []string) (*Mount, error) { for _, f := range format { if ss[f.i] != f.s { - return nil, fmt.Errorf("invalid device entry: %v", ss) + return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss) } } @@ -342,7 +345,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e switch ss[0] { case fieldOpts: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss) } if stats.Opts == nil { stats.Opts = map[string]string{} @@ -357,7 +360,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e } case fieldAge: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss) } // Age integer is in seconds d, err := time.ParseDuration(ss[1] + "s") @@ -368,7 +371,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e stats.Age = d case fieldBytes: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss) } bstats, err := parseNFSBytesStats(ss[1:]) if err != nil { @@ -378,7 +381,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e stats.Bytes = *bstats case fieldEvents: if len(ss) < 2 { - return nil, fmt.Errorf("not enough information for NFS stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS events: %v", ErrFileParse, ss) } estats, err := parseNFSEventsStats(ss[1:]) if err != nil { @@ -388,7 +391,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e stats.Events = *estats case fieldTransport: if len(ss) < 3 { - return nil, fmt.Errorf("not enough information for NFS transport stats: %v", ss) + return nil, fmt.Errorf("%w: Incomplete information for NFS transport stats: %v", ErrFileParse, ss) } tstats, err := parseNFSTransportStats(ss[1:], statVersion) @@ -427,7 +430,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e // integer fields. func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) { if len(ss) != fieldBytesLen { - return nil, fmt.Errorf("invalid NFS bytes stats: %v", ss) + return nil, fmt.Errorf("%w: Invalid NFS bytes stats: %v", ErrFileParse, ss) } ns := make([]uint64, 0, fieldBytesLen) @@ -456,7 +459,7 @@ func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) { // integer fields. func parseNFSEventsStats(ss []string) (*NFSEventsStats, error) { if len(ss) != fieldEventsLen { - return nil, fmt.Errorf("invalid NFS events stats: %v", ss) + return nil, fmt.Errorf("%w: invalid NFS events stats: %v", ErrFileParse, ss) } ns := make([]uint64, 0, fieldEventsLen) @@ -520,7 +523,7 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { } if len(ss) < minFields { - return nil, fmt.Errorf("invalid NFS per-operations stats: %v", ss) + return nil, fmt.Errorf("%w: invalid NFS per-operations stats: %v", ErrFileParse, ss) } // Skip string operation name for integers @@ -533,7 +536,6 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { ns = append(ns, n) } - opStats := NFSOperationStats{ Operation: strings.TrimSuffix(ss[0], ":"), Requests: ns[0], @@ -545,6 +547,9 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) { CumulativeTotalResponseMilliseconds: ns[6], CumulativeTotalRequestMilliseconds: ns[7], } + if ns[0] != 0 { + opStats.AverageRTTMilliseconds = float64(ns[6]) / float64(ns[0]) + } if len(ns) > 8 { opStats.Errors = ns[8] @@ -571,10 +576,10 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats } else if protocol == "udp" { expectedLength = fieldTransport10UDPLen } else { - return nil, fmt.Errorf("invalid NFS protocol \"%s\" in stats 1.0 statement: %v", protocol, ss) + return nil, fmt.Errorf("%w: Invalid NFS protocol \"%s\" in stats 1.0 statement: %v", ErrFileParse, protocol, ss) } if len(ss) != expectedLength { - return nil, fmt.Errorf("invalid NFS transport stats 1.0 statement: %v", ss) + return nil, fmt.Errorf("%w: Invalid NFS transport stats 1.0 statement: %v", ErrFileParse, ss) } case statVersion11: var expectedLength int @@ -583,13 +588,13 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats } else if protocol == "udp" { expectedLength = fieldTransport11UDPLen } else { - return nil, fmt.Errorf("invalid NFS protocol \"%s\" in stats 1.1 statement: %v", protocol, ss) + return nil, fmt.Errorf("%w: invalid NFS protocol \"%s\" in stats 1.1 statement: %v", ErrFileParse, protocol, ss) } if len(ss) != expectedLength { - return nil, fmt.Errorf("invalid NFS transport stats 1.1 statement: %v", ss) + return nil, fmt.Errorf("%w: invalid NFS transport stats 1.1 statement: %v", ErrFileParse, ss) } default: - return nil, fmt.Errorf("unrecognized NFS transport stats version: %q", statVersion) + return nil, fmt.Errorf("%s: Unrecognized NFS transport stats version: %q", ErrFileParse, statVersion) } // Allocate enough for v1.1 stats since zero value for v1.1 stats will be okay diff --git a/vendor/github.com/prometheus/procfs/net_conntrackstat.go b/vendor/github.com/prometheus/procfs/net_conntrackstat.go index 8300daca0..fdfa45611 100644 --- a/vendor/github.com/prometheus/procfs/net_conntrackstat.go +++ b/vendor/github.com/prometheus/procfs/net_conntrackstat.go @@ -18,7 +18,6 @@ import ( "bytes" "fmt" "io" - "strconv" "strings" "github.com/prometheus/procfs/internal/util" @@ -28,9 +27,13 @@ import ( // and contains netfilter conntrack statistics at one CPU core. type ConntrackStatEntry struct { Entries uint64 + Searched uint64 Found uint64 + New uint64 Invalid uint64 Ignore uint64 + Delete uint64 + DeleteList uint64 Insert uint64 InsertFailed uint64 Drop uint64 @@ -55,7 +58,7 @@ func readConntrackStat(path string) ([]ConntrackStatEntry, error) { stat, err := parseConntrackStat(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("failed to read conntrack stats from %q: %w", path, err) + return nil, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, path, err) } return stat, nil @@ -81,73 +84,35 @@ func parseConntrackStat(r io.Reader) ([]ConntrackStatEntry, error) { // Parses a ConntrackStatEntry from given array of fields. func parseConntrackStatEntry(fields []string) (*ConntrackStatEntry, error) { - if len(fields) != 17 { - return nil, fmt.Errorf("invalid conntrackstat entry, missing fields") - } - entry := &ConntrackStatEntry{} - - entries, err := parseConntrackStatField(fields[0]) - if err != nil { - return nil, err - } - entry.Entries = entries - - found, err := parseConntrackStatField(fields[2]) - if err != nil { - return nil, err - } - entry.Found = found - - invalid, err := parseConntrackStatField(fields[4]) - if err != nil { - return nil, err - } - entry.Invalid = invalid - - ignore, err := parseConntrackStatField(fields[5]) - if err != nil { - return nil, err - } - entry.Ignore = ignore - - insert, err := parseConntrackStatField(fields[8]) + entries, err := util.ParseHexUint64s(fields) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: Cannot parse entry: %d: %w", ErrFileParse, entries, err) } - entry.Insert = insert - - insertFailed, err := parseConntrackStatField(fields[9]) - if err != nil { - return nil, err + numEntries := len(entries) + if numEntries < 16 || numEntries > 17 { + return nil, + fmt.Errorf("%w: invalid conntrackstat entry, invalid number of fields: %d", ErrFileParse, numEntries) } - entry.InsertFailed = insertFailed - drop, err := parseConntrackStatField(fields[10]) - if err != nil { - return nil, err + stats := &ConntrackStatEntry{ + Entries: *entries[0], + Searched: *entries[1], + Found: *entries[2], + New: *entries[3], + Invalid: *entries[4], + Ignore: *entries[5], + Delete: *entries[6], + DeleteList: *entries[7], + Insert: *entries[8], + InsertFailed: *entries[9], + Drop: *entries[10], + EarlyDrop: *entries[11], } - entry.Drop = drop - earlyDrop, err := parseConntrackStatField(fields[11]) - if err != nil { - return nil, err + // Ignore missing search_restart on Linux < 2.6.35. + if numEntries == 17 { + stats.SearchRestart = *entries[16] } - entry.EarlyDrop = earlyDrop - searchRestart, err := parseConntrackStatField(fields[16]) - if err != nil { - return nil, err - } - entry.SearchRestart = searchRestart - - return entry, nil -} - -// Parses a uint64 from given hex in string. -func parseConntrackStatField(field string) (uint64, error) { - val, err := strconv.ParseUint(field, 16, 64) - if err != nil { - return 0, fmt.Errorf("couldn't parse %q field: %w", field, err) - } - return val, err + return stats, nil } diff --git a/vendor/github.com/prometheus/procfs/net_ip_socket.go b/vendor/github.com/prometheus/procfs/net_ip_socket.go index 7fd57d7f4..4da81ea57 100644 --- a/vendor/github.com/prometheus/procfs/net_ip_socket.go +++ b/vendor/github.com/prometheus/procfs/net_ip_socket.go @@ -130,7 +130,7 @@ func parseIP(hexIP string) (net.IP, error) { var byteIP []byte byteIP, err := hex.DecodeString(hexIP) if err != nil { - return nil, fmt.Errorf("cannot parse address field in socket line %q", hexIP) + return nil, fmt.Errorf("%s: Cannot parse socket field in %q: %w", ErrFileParse, hexIP, err) } switch len(byteIP) { case 4: @@ -144,7 +144,7 @@ func parseIP(hexIP string) (net.IP, error) { } return i, nil default: - return nil, fmt.Errorf("Unable to parse IP %s", hexIP) + return nil, fmt.Errorf("%s: Unable to parse IP %s: %w", ErrFileParse, hexIP, nil) } } @@ -153,7 +153,8 @@ func parseNetIPSocketLine(fields []string) (*netIPSocketLine, error) { line := &netIPSocketLine{} if len(fields) < 10 { return nil, fmt.Errorf( - "cannot parse net socket line as it has less then 10 columns %q", + "%w: Less than 10 columns found %q", + ErrFileParse, strings.Join(fields, " "), ) } @@ -162,64 +163,65 @@ func parseNetIPSocketLine(fields []string) (*netIPSocketLine, error) { // sl s := strings.Split(fields[0], ":") if len(s) != 2 { - return nil, fmt.Errorf("cannot parse sl field in socket line %q", fields[0]) + return nil, fmt.Errorf("%w: Unable to parse sl field in line %q", ErrFileParse, fields[0]) } if line.Sl, err = strconv.ParseUint(s[0], 0, 64); err != nil { - return nil, fmt.Errorf("cannot parse sl value in socket line: %w", err) + return nil, fmt.Errorf("%s: Unable to parse sl field in %q: %w", ErrFileParse, line.Sl, err) } // local_address l := strings.Split(fields[1], ":") if len(l) != 2 { - return nil, fmt.Errorf("cannot parse local_address field in socket line %q", fields[1]) + return nil, fmt.Errorf("%w: Unable to parse local_address field in %q", ErrFileParse, fields[1]) } if line.LocalAddr, err = parseIP(l[0]); err != nil { return nil, err } if line.LocalPort, err = strconv.ParseUint(l[1], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse local_address port value in socket line: %w", err) + return nil, fmt.Errorf("%s: Unable to parse local_address port value line %q: %w", ErrFileParse, line.LocalPort, err) } // remote_address r := strings.Split(fields[2], ":") if len(r) != 2 { - return nil, fmt.Errorf("cannot parse rem_address field in socket line %q", fields[1]) + return nil, fmt.Errorf("%w: Unable to parse rem_address field in %q", ErrFileParse, fields[1]) } if line.RemAddr, err = parseIP(r[0]); err != nil { return nil, err } if line.RemPort, err = strconv.ParseUint(r[1], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse rem_address port value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse rem_address port value in %q: %w", ErrFileParse, line.RemPort, err) } // st if line.St, err = strconv.ParseUint(fields[3], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse st value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse st value in %q: %w", ErrFileParse, line.St, err) } // tx_queue and rx_queue q := strings.Split(fields[4], ":") if len(q) != 2 { return nil, fmt.Errorf( - "cannot parse tx/rx queues in socket line as it has a missing colon %q", + "%w: Missing colon for tx/rx queues in socket line %q", + ErrFileParse, fields[4], ) } if line.TxQueue, err = strconv.ParseUint(q[0], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse tx_queue value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse tx_queue value in %q: %w", ErrFileParse, line.TxQueue, err) } if line.RxQueue, err = strconv.ParseUint(q[1], 16, 64); err != nil { - return nil, fmt.Errorf("cannot parse rx_queue value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse trx_queue value in %q: %w", ErrFileParse, line.RxQueue, err) } // uid if line.UID, err = strconv.ParseUint(fields[7], 0, 64); err != nil { - return nil, fmt.Errorf("cannot parse uid value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse UID value in %q: %w", ErrFileParse, line.UID, err) } // inode if line.Inode, err = strconv.ParseUint(fields[9], 0, 64); err != nil { - return nil, fmt.Errorf("cannot parse inode value in socket line: %w", err) + return nil, fmt.Errorf("%s: Cannot parse inode value in %q: %w", ErrFileParse, line.Inode, err) } return line, nil diff --git a/vendor/github.com/prometheus/procfs/net_protocols.go b/vendor/github.com/prometheus/procfs/net_protocols.go index 374b6f73f..b6c77b709 100644 --- a/vendor/github.com/prometheus/procfs/net_protocols.go +++ b/vendor/github.com/prometheus/procfs/net_protocols.go @@ -131,7 +131,7 @@ func (ps NetProtocolStats) parseLine(rawLine string) (*NetProtocolStatLine, erro } else if fields[6] == disabled { line.Slab = false } else { - return nil, fmt.Errorf("unable to parse capability for protocol: %s", line.Name) + return nil, fmt.Errorf("%w: capability for protocol: %s", ErrFileParse, line.Name) } line.ModuleName = fields[7] @@ -173,7 +173,7 @@ func (pc *NetProtocolCapabilities) parseCapabilities(capabilities []string) erro } else if capabilities[i] == "n" { *capabilityFields[i] = false } else { - return fmt.Errorf("unable to parse capability block for protocol: position %d", i) + return fmt.Errorf("%w: capability block for protocol: position %d", ErrFileParse, i) } } return nil diff --git a/vendor/github.com/prometheus/procfs/net_route.go b/vendor/github.com/prometheus/procfs/net_route.go new file mode 100644 index 000000000..deb7029fe --- /dev/null +++ b/vendor/github.com/prometheus/procfs/net_route.go @@ -0,0 +1,143 @@ +// Copyright 2023 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strconv" + "strings" + + "github.com/prometheus/procfs/internal/util" +) + +const ( + blackholeRepresentation string = "*" + blackholeIfaceName string = "blackhole" + routeLineColumns int = 11 +) + +// A NetRouteLine represents one line from net/route. +type NetRouteLine struct { + Iface string + Destination uint32 + Gateway uint32 + Flags uint32 + RefCnt uint32 + Use uint32 + Metric uint32 + Mask uint32 + MTU uint32 + Window uint32 + IRTT uint32 +} + +func (fs FS) NetRoute() ([]NetRouteLine, error) { + return readNetRoute(fs.proc.Path("net", "route")) +} + +func readNetRoute(path string) ([]NetRouteLine, error) { + b, err := util.ReadFileNoStat(path) + if err != nil { + return nil, err + } + + routelines, err := parseNetRoute(bytes.NewReader(b)) + if err != nil { + return nil, fmt.Errorf("failed to read net route from %s: %w", path, err) + } + return routelines, nil +} + +func parseNetRoute(r io.Reader) ([]NetRouteLine, error) { + var routelines []NetRouteLine + + scanner := bufio.NewScanner(r) + scanner.Scan() + for scanner.Scan() { + fields := strings.Fields(scanner.Text()) + routeline, err := parseNetRouteLine(fields) + if err != nil { + return nil, err + } + routelines = append(routelines, *routeline) + } + return routelines, nil +} + +func parseNetRouteLine(fields []string) (*NetRouteLine, error) { + if len(fields) != routeLineColumns { + return nil, fmt.Errorf("invalid routeline, num of digits: %d", len(fields)) + } + iface := fields[0] + if iface == blackholeRepresentation { + iface = blackholeIfaceName + } + destination, err := strconv.ParseUint(fields[1], 16, 32) + if err != nil { + return nil, err + } + gateway, err := strconv.ParseUint(fields[2], 16, 32) + if err != nil { + return nil, err + } + flags, err := strconv.ParseUint(fields[3], 10, 32) + if err != nil { + return nil, err + } + refcnt, err := strconv.ParseUint(fields[4], 10, 32) + if err != nil { + return nil, err + } + use, err := strconv.ParseUint(fields[5], 10, 32) + if err != nil { + return nil, err + } + metric, err := strconv.ParseUint(fields[6], 10, 32) + if err != nil { + return nil, err + } + mask, err := strconv.ParseUint(fields[7], 16, 32) + if err != nil { + return nil, err + } + mtu, err := strconv.ParseUint(fields[8], 10, 32) + if err != nil { + return nil, err + } + window, err := strconv.ParseUint(fields[9], 10, 32) + if err != nil { + return nil, err + } + irtt, err := strconv.ParseUint(fields[10], 10, 32) + if err != nil { + return nil, err + } + routeline := &NetRouteLine{ + Iface: iface, + Destination: uint32(destination), + Gateway: uint32(gateway), + Flags: uint32(flags), + RefCnt: uint32(refcnt), + Use: uint32(use), + Metric: uint32(metric), + Mask: uint32(mask), + MTU: uint32(mtu), + Window: uint32(window), + IRTT: uint32(irtt), + } + return routeline, nil +} diff --git a/vendor/github.com/prometheus/procfs/net_sockstat.go b/vendor/github.com/prometheus/procfs/net_sockstat.go index e36f4872d..360e36af7 100644 --- a/vendor/github.com/prometheus/procfs/net_sockstat.go +++ b/vendor/github.com/prometheus/procfs/net_sockstat.go @@ -16,7 +16,6 @@ package procfs import ( "bufio" "bytes" - "errors" "fmt" "io" "strings" @@ -70,7 +69,7 @@ func readSockstat(name string) (*NetSockstat, error) { stat, err := parseSockstat(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("failed to read sockstats from %q: %w", name, err) + return nil, fmt.Errorf("%s: sockstats from %q: %w", ErrFileRead, name, err) } return stat, nil @@ -84,13 +83,13 @@ func parseSockstat(r io.Reader) (*NetSockstat, error) { // Expect a minimum of a protocol and one key/value pair. fields := strings.Split(s.Text(), " ") if len(fields) < 3 { - return nil, fmt.Errorf("malformed sockstat line: %q", s.Text()) + return nil, fmt.Errorf("%w: Malformed sockstat line: %q", ErrFileParse, s.Text()) } // The remaining fields are key/value pairs. kvs, err := parseSockstatKVs(fields[1:]) if err != nil { - return nil, fmt.Errorf("error parsing sockstat key/value pairs from %q: %w", s.Text(), err) + return nil, fmt.Errorf("%s: sockstat key/value pairs from %q: %w", ErrFileParse, s.Text(), err) } // The first field is the protocol. We must trim its colon suffix. @@ -119,7 +118,7 @@ func parseSockstat(r io.Reader) (*NetSockstat, error) { // parseSockstatKVs parses a string slice into a map of key/value pairs. func parseSockstatKVs(kvs []string) (map[string]int, error) { if len(kvs)%2 != 0 { - return nil, errors.New("odd number of fields in key/value pairs") + return nil, fmt.Errorf("%w:: Odd number of fields in key/value pairs %q", ErrFileParse, kvs) } // Iterate two values at a time to gather key/value pairs. diff --git a/vendor/github.com/prometheus/procfs/net_softnet.go b/vendor/github.com/prometheus/procfs/net_softnet.go index a94f86dc4..c77085291 100644 --- a/vendor/github.com/prometheus/procfs/net_softnet.go +++ b/vendor/github.com/prometheus/procfs/net_softnet.go @@ -27,8 +27,9 @@ import ( // For the proc file format details, // See: // * Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2343 -// * Linux 4.17 https://elixir.bootlin.com/linux/v4.17/source/net/core/net-procfs.c#L162 -// and https://elixir.bootlin.com/linux/v4.17/source/include/linux/netdevice.h#L2810. +// * Linux 2.6.39 https://elixir.bootlin.com/linux/v2.6.39/source/net/core/dev.c#L4086 +// * Linux 4.18 https://elixir.bootlin.com/linux/v4.18/source/net/core/net-procfs.c#L162 +// * Linux 5.14 https://elixir.bootlin.com/linux/v5.14/source/net/core/net-procfs.c#L169 // SoftnetStat contains a single row of data from /proc/net/softnet_stat. type SoftnetStat struct { @@ -38,6 +39,18 @@ type SoftnetStat struct { Dropped uint32 // Number of times processing packets ran out of quota. TimeSqueezed uint32 + // Number of collision occur while obtaining device lock while transmitting. + CPUCollision uint32 + // Number of times cpu woken up received_rps. + ReceivedRps uint32 + // number of times flow limit has been reached. + FlowLimitCount uint32 + // Softnet backlog status. + SoftnetBacklogLen uint32 + // CPU id owning this softnet_data. + Index uint32 + // softnet_data's Width. + Width int } var softNetProcFile = "net/softnet_stat" @@ -51,7 +64,7 @@ func (fs FS) NetSoftnetStat() ([]SoftnetStat, error) { entries, err := parseSoftnet(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("failed to parse /proc/net/softnet_stat: %w", err) + return nil, fmt.Errorf("%s: /proc/net/softnet_stat: %w", ErrFileParse, err) } return entries, nil @@ -63,25 +76,65 @@ func parseSoftnet(r io.Reader) ([]SoftnetStat, error) { s := bufio.NewScanner(r) var stats []SoftnetStat + cpuIndex := 0 for s.Scan() { columns := strings.Fields(s.Text()) width := len(columns) + softnetStat := SoftnetStat{} if width < minColumns { - return nil, fmt.Errorf("%d columns were detected, but at least %d were expected", width, minColumns) + return nil, fmt.Errorf("%w: detected %d columns, but expected at least %d", ErrFileParse, width, minColumns) } - // We only parse the first three columns at the moment. - us, err := parseHexUint32s(columns[0:3]) - if err != nil { - return nil, err + // Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2347 + if width >= minColumns { + us, err := parseHexUint32s(columns[0:9]) + if err != nil { + return nil, err + } + + softnetStat.Processed = us[0] + softnetStat.Dropped = us[1] + softnetStat.TimeSqueezed = us[2] + softnetStat.CPUCollision = us[8] + } + + // Linux 2.6.39 https://elixir.bootlin.com/linux/v2.6.39/source/net/core/dev.c#L4086 + if width >= 10 { + us, err := parseHexUint32s(columns[9:10]) + if err != nil { + return nil, err + } + + softnetStat.ReceivedRps = us[0] } - stats = append(stats, SoftnetStat{ - Processed: us[0], - Dropped: us[1], - TimeSqueezed: us[2], - }) + // Linux 4.18 https://elixir.bootlin.com/linux/v4.18/source/net/core/net-procfs.c#L162 + if width >= 11 { + us, err := parseHexUint32s(columns[10:11]) + if err != nil { + return nil, err + } + + softnetStat.FlowLimitCount = us[0] + } + + // Linux 5.14 https://elixir.bootlin.com/linux/v5.14/source/net/core/net-procfs.c#L169 + if width >= 13 { + us, err := parseHexUint32s(columns[11:13]) + if err != nil { + return nil, err + } + + softnetStat.SoftnetBacklogLen = us[0] + softnetStat.Index = us[1] + } else { + // For older kernels, create the Index based on the scan line number. + softnetStat.Index = uint32(cpuIndex) + } + softnetStat.Width = width + stats = append(stats, softnetStat) + cpuIndex++ } return stats, nil diff --git a/vendor/github.com/prometheus/procfs/net_unix.go b/vendor/github.com/prometheus/procfs/net_unix.go index 98aa8e1c3..acbbc57ea 100644 --- a/vendor/github.com/prometheus/procfs/net_unix.go +++ b/vendor/github.com/prometheus/procfs/net_unix.go @@ -108,14 +108,14 @@ func parseNetUNIX(r io.Reader) (*NetUNIX, error) { line := s.Text() item, err := nu.parseLine(line, hasInode, minFields) if err != nil { - return nil, fmt.Errorf("failed to parse /proc/net/unix data %q: %w", line, err) + return nil, fmt.Errorf("%s: /proc/net/unix encountered data %q: %w", ErrFileParse, line, err) } nu.Rows = append(nu.Rows, item) } if err := s.Err(); err != nil { - return nil, fmt.Errorf("failed to scan /proc/net/unix data: %w", err) + return nil, fmt.Errorf("%s: /proc/net/unix encountered data: %w", ErrFileParse, err) } return &nu, nil @@ -126,7 +126,7 @@ func (u *NetUNIX) parseLine(line string, hasInode bool, min int) (*NetUNIXLine, l := len(fields) if l < min { - return nil, fmt.Errorf("expected at least %d fields but got %d", min, l) + return nil, fmt.Errorf("%w: expected at least %d fields but got %d", ErrFileParse, min, l) } // Field offsets are as follows: @@ -136,29 +136,29 @@ func (u *NetUNIX) parseLine(line string, hasInode bool, min int) (*NetUNIXLine, users, err := u.parseUsers(fields[1]) if err != nil { - return nil, fmt.Errorf("failed to parse ref count %q: %w", fields[1], err) + return nil, fmt.Errorf("%s: ref count %q: %w", ErrFileParse, fields[1], err) } flags, err := u.parseFlags(fields[3]) if err != nil { - return nil, fmt.Errorf("failed to parse flags %q: %w", fields[3], err) + return nil, fmt.Errorf("%s: Unable to parse flags %q: %w", ErrFileParse, fields[3], err) } typ, err := u.parseType(fields[4]) if err != nil { - return nil, fmt.Errorf("failed to parse type %q: %w", fields[4], err) + return nil, fmt.Errorf("%s: Failed to parse type %q: %w", ErrFileParse, fields[4], err) } state, err := u.parseState(fields[5]) if err != nil { - return nil, fmt.Errorf("failed to parse state %q: %w", fields[5], err) + return nil, fmt.Errorf("%s: Failed to parse state %q: %w", ErrFileParse, fields[5], err) } var inode uint64 if hasInode { inode, err = u.parseInode(fields[6]) if err != nil { - return nil, fmt.Errorf("failed to parse inode %q: %w", fields[6], err) + return nil, fmt.Errorf("%s failed to parse inode %q: %w", ErrFileParse, fields[6], err) } } diff --git a/vendor/github.com/prometheus/procfs/net_wireless.go b/vendor/github.com/prometheus/procfs/net_wireless.go new file mode 100644 index 000000000..7443edca9 --- /dev/null +++ b/vendor/github.com/prometheus/procfs/net_wireless.go @@ -0,0 +1,182 @@ +// Copyright 2023 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strconv" + "strings" + + "github.com/prometheus/procfs/internal/util" +) + +// Wireless models the content of /proc/net/wireless. +type Wireless struct { + Name string + + // Status is the current 4-digit hex value status of the interface. + Status uint64 + + // QualityLink is the link quality. + QualityLink int + + // QualityLevel is the signal gain (dBm). + QualityLevel int + + // QualityNoise is the signal noise baseline (dBm). + QualityNoise int + + // DiscardedNwid is the number of discarded packets with wrong nwid/essid. + DiscardedNwid int + + // DiscardedCrypt is the number of discarded packets with wrong code/decode (WEP). + DiscardedCrypt int + + // DiscardedFrag is the number of discarded packets that can't perform MAC reassembly. + DiscardedFrag int + + // DiscardedRetry is the number of discarded packets that reached max MAC retries. + DiscardedRetry int + + // DiscardedMisc is the number of discarded packets for other reasons. + DiscardedMisc int + + // MissedBeacon is the number of missed beacons/superframe. + MissedBeacon int +} + +// Wireless returns kernel wireless statistics. +func (fs FS) Wireless() ([]*Wireless, error) { + b, err := util.ReadFileNoStat(fs.proc.Path("net/wireless")) + if err != nil { + return nil, err + } + + m, err := parseWireless(bytes.NewReader(b)) + if err != nil { + return nil, fmt.Errorf("%s: wireless: %w", ErrFileParse, err) + } + + return m, nil +} + +// parseWireless parses the contents of /proc/net/wireless. +/* +Inter-| sta-| Quality | Discarded packets | Missed | WE +face | tus | link level noise | nwid crypt frag retry misc | beacon | 22 + eth1: 0000 5. -256. -10. 0 1 0 3 0 0 + eth2: 0000 5. -256. -20. 0 2 0 4 0 0 +*/ +func parseWireless(r io.Reader) ([]*Wireless, error) { + var ( + interfaces []*Wireless + scanner = bufio.NewScanner(r) + ) + + for n := 0; scanner.Scan(); n++ { + // Skip the 2 header lines. + if n < 2 { + continue + } + + line := scanner.Text() + + parts := strings.Split(line, ":") + if len(parts) != 2 { + return nil, fmt.Errorf("%w: expected 2 parts after splitting line by ':', got %d for line %q", ErrFileParse, len(parts), line) + } + + name := strings.TrimSpace(parts[0]) + stats := strings.Fields(parts[1]) + + if len(stats) < 10 { + return nil, fmt.Errorf("%w: invalid number of fields in line %d, expected 10+, got %d: %q", ErrFileParse, n, len(stats), line) + } + + status, err := strconv.ParseUint(stats[0], 16, 16) + if err != nil { + return nil, fmt.Errorf("%w: invalid status in line %d: %q", ErrFileParse, n, line) + } + + qlink, err := strconv.Atoi(strings.TrimSuffix(stats[1], ".")) + if err != nil { + return nil, fmt.Errorf("%s: parse Quality:link as integer %q: %w", ErrFileParse, qlink, err) + } + + qlevel, err := strconv.Atoi(strings.TrimSuffix(stats[2], ".")) + if err != nil { + return nil, fmt.Errorf("%s: Quality:level as integer %q: %w", ErrFileParse, qlevel, err) + } + + qnoise, err := strconv.Atoi(strings.TrimSuffix(stats[3], ".")) + if err != nil { + return nil, fmt.Errorf("%s: Quality:noise as integer %q: %w", ErrFileParse, qnoise, err) + } + + dnwid, err := strconv.Atoi(stats[4]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:nwid as integer %q: %w", ErrFileParse, dnwid, err) + } + + dcrypt, err := strconv.Atoi(stats[5]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:crypt as integer %q: %w", ErrFileParse, dcrypt, err) + } + + dfrag, err := strconv.Atoi(stats[6]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:frag as integer %q: %w", ErrFileParse, dfrag, err) + } + + dretry, err := strconv.Atoi(stats[7]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:retry as integer %q: %w", ErrFileParse, dretry, err) + } + + dmisc, err := strconv.Atoi(stats[8]) + if err != nil { + return nil, fmt.Errorf("%s: Discarded:misc as integer %q: %w", ErrFileParse, dmisc, err) + } + + mbeacon, err := strconv.Atoi(stats[9]) + if err != nil { + return nil, fmt.Errorf("%s: Missed:beacon as integer %q: %w", ErrFileParse, mbeacon, err) + } + + w := &Wireless{ + Name: name, + Status: status, + QualityLink: qlink, + QualityLevel: qlevel, + QualityNoise: qnoise, + DiscardedNwid: dnwid, + DiscardedCrypt: dcrypt, + DiscardedFrag: dfrag, + DiscardedRetry: dretry, + DiscardedMisc: dmisc, + MissedBeacon: mbeacon, + } + + interfaces = append(interfaces, w) + } + + if err := scanner.Err(); err != nil { + return nil, fmt.Errorf("%s: Failed to scan /proc/net/wireless: %w", ErrFileRead, err) + } + + return interfaces, nil +} diff --git a/vendor/github.com/prometheus/procfs/net_xfrm.go b/vendor/github.com/prometheus/procfs/net_xfrm.go index f9d9d243d..932ef2046 100644 --- a/vendor/github.com/prometheus/procfs/net_xfrm.go +++ b/vendor/github.com/prometheus/procfs/net_xfrm.go @@ -115,7 +115,7 @@ func (fs FS) NewXfrmStat() (XfrmStat, error) { fields := strings.Fields(s.Text()) if len(fields) != 2 { - return XfrmStat{}, fmt.Errorf("couldn't parse %q line %q", file.Name(), s.Text()) + return XfrmStat{}, fmt.Errorf("%w: %q line %q", ErrFileParse, file.Name(), s.Text()) } name := fields[0] diff --git a/vendor/github.com/prometheus/procfs/netstat.go b/vendor/github.com/prometheus/procfs/netstat.go index dcea9c5a6..742dff453 100644 --- a/vendor/github.com/prometheus/procfs/netstat.go +++ b/vendor/github.com/prometheus/procfs/netstat.go @@ -37,32 +37,46 @@ func (fs FS) NetStat() ([]NetStat, error) { var netStatsTotal []NetStat for _, filePath := range statFiles { - file, err := os.Open(filePath) + procNetstat, err := parseNetstat(filePath) if err != nil { return nil, err } + procNetstat.Filename = filepath.Base(filePath) - netStatFile := NetStat{ - Filename: filepath.Base(filePath), - Stats: make(map[string][]uint64), - } - scanner := bufio.NewScanner(file) - scanner.Scan() - // First string is always a header for stats - var headers []string - headers = append(headers, strings.Fields(scanner.Text())...) + netStatsTotal = append(netStatsTotal, procNetstat) + } + return netStatsTotal, nil +} + +// parseNetstat parses the metrics from `/proc/net/stat/` file +// and returns a NetStat structure. +func parseNetstat(filePath string) (NetStat, error) { + netStat := NetStat{ + Stats: make(map[string][]uint64), + } + file, err := os.Open(filePath) + if err != nil { + return netStat, err + } + defer file.Close() + + scanner := bufio.NewScanner(file) + scanner.Scan() - // Other strings represent per-CPU counters - for scanner.Scan() { - for num, counter := range strings.Fields(scanner.Text()) { - value, err := strconv.ParseUint(counter, 16, 64) - if err != nil { - return nil, err - } - netStatFile.Stats[headers[num]] = append(netStatFile.Stats[headers[num]], value) + // First string is always a header for stats + var headers []string + headers = append(headers, strings.Fields(scanner.Text())...) + + // Other strings represent per-CPU counters + for scanner.Scan() { + for num, counter := range strings.Fields(scanner.Text()) { + value, err := strconv.ParseUint(counter, 16, 64) + if err != nil { + return NetStat{}, err } + netStat.Stats[headers[num]] = append(netStat.Stats[headers[num]], value) } - netStatsTotal = append(netStatsTotal, netStatFile) } - return netStatsTotal, nil + + return netStat, nil } diff --git a/vendor/github.com/prometheus/procfs/proc.go b/vendor/github.com/prometheus/procfs/proc.go index c30223af7..e1599961f 100644 --- a/vendor/github.com/prometheus/procfs/proc.go +++ b/vendor/github.com/prometheus/procfs/proc.go @@ -15,13 +15,13 @@ package procfs import ( "bytes" + "errors" "fmt" "io" "os" "strconv" "strings" - "github.com/prometheus/procfs/internal/fs" "github.com/prometheus/procfs/internal/util" ) @@ -30,12 +30,18 @@ type Proc struct { // The process ID. PID int - fs fs.FS + fs FS } // Procs represents a list of Proc structs. type Procs []Proc +var ( + ErrFileParse = errors.New("Error Parsing File") + ErrFileRead = errors.New("Error Reading File") + ErrMountPoint = errors.New("Error Accessing Mount point") +) + func (p Procs) Len() int { return len(p) } func (p Procs) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p Procs) Less(i, j int) bool { return p[i].PID < p[j].PID } @@ -43,7 +49,7 @@ func (p Procs) Less(i, j int) bool { return p[i].PID < p[j].PID } // Self returns a process for the current process read via /proc/self. func Self() (Proc, error) { fs, err := NewFS(DefaultMountPoint) - if err != nil { + if err != nil || errors.Unwrap(err) == ErrMountPoint { return Proc{}, err } return fs.Self() @@ -92,7 +98,7 @@ func (fs FS) Proc(pid int) (Proc, error) { if _, err := os.Stat(fs.proc.Path(strconv.Itoa(pid))); err != nil { return Proc{}, err } - return Proc{PID: pid, fs: fs.proc}, nil + return Proc{PID: pid, fs: fs}, nil } // AllProcs returns a list of all currently available processes. @@ -105,7 +111,7 @@ func (fs FS) AllProcs() (Procs, error) { names, err := d.Readdirnames(-1) if err != nil { - return Procs{}, fmt.Errorf("could not read %q: %w", d.Name(), err) + return Procs{}, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, names, err) } p := Procs{} @@ -114,7 +120,7 @@ func (fs FS) AllProcs() (Procs, error) { if err != nil { continue } - p = append(p, Proc{PID: int(pid), fs: fs.proc}) + p = append(p, Proc{PID: int(pid), fs: fs}) } return p, nil @@ -206,7 +212,7 @@ func (p Proc) FileDescriptors() ([]uintptr, error) { for i, n := range names { fd, err := strconv.ParseInt(n, 10, 32) if err != nil { - return nil, fmt.Errorf("could not parse fd %q: %w", n, err) + return nil, fmt.Errorf("%s: Cannot parse line: %v: %w", ErrFileParse, i, err) } fds[i] = uintptr(fd) } @@ -237,6 +243,19 @@ func (p Proc) FileDescriptorTargets() ([]string, error) { // FileDescriptorsLen returns the number of currently open file descriptors of // a process. func (p Proc) FileDescriptorsLen() (int, error) { + // Use fast path if available (Linux v6.2): https://github.com/torvalds/linux/commit/f1f1f2569901 + if p.fs.real { + stat, err := os.Stat(p.path("fd")) + if err != nil { + return 0, err + } + + size := stat.Size() + if size > 0 { + return int(size), nil + } + } + fds, err := p.fileDescriptors() if err != nil { return 0, err @@ -278,14 +297,14 @@ func (p Proc) fileDescriptors() ([]string, error) { names, err := d.Readdirnames(-1) if err != nil { - return nil, fmt.Errorf("could not read %q: %w", d.Name(), err) + return nil, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, names, err) } return names, nil } func (p Proc) path(pa ...string) string { - return p.fs.Path(append([]string{strconv.Itoa(p.PID)}, pa...)...) + return p.fs.proc.Path(append([]string{strconv.Itoa(p.PID)}, pa...)...) } // FileDescriptorsInfo retrieves information about all file descriptors of diff --git a/vendor/github.com/prometheus/procfs/proc_cgroup.go b/vendor/github.com/prometheus/procfs/proc_cgroup.go index cca03327c..daeed7f57 100644 --- a/vendor/github.com/prometheus/procfs/proc_cgroup.go +++ b/vendor/github.com/prometheus/procfs/proc_cgroup.go @@ -23,7 +23,7 @@ import ( "github.com/prometheus/procfs/internal/util" ) -// Cgroup models one line from /proc/[pid]/cgroup. Each Cgroup struct describes the the placement of a PID inside a +// Cgroup models one line from /proc/[pid]/cgroup. Each Cgroup struct describes the placement of a PID inside a // specific control hierarchy. The kernel has two cgroup APIs, v1 and v2. v1 has one hierarchy per available resource // controller, while v2 has one unified hierarchy shared by all controllers. Regardless of v1 or v2, all hierarchies // contain all running processes, so the question answerable with a Cgroup struct is 'where is this process in @@ -51,7 +51,7 @@ func parseCgroupString(cgroupStr string) (*Cgroup, error) { fields := strings.SplitN(cgroupStr, ":", 3) if len(fields) < 3 { - return nil, fmt.Errorf("at least 3 fields required, found %d fields in cgroup string: %s", len(fields), cgroupStr) + return nil, fmt.Errorf("%w: 3+ fields required, found %d fields in cgroup string: %s", ErrFileParse, len(fields), cgroupStr) } cgroup := &Cgroup{ @@ -60,7 +60,7 @@ func parseCgroupString(cgroupStr string) (*Cgroup, error) { } cgroup.HierarchyID, err = strconv.Atoi(fields[0]) if err != nil { - return nil, fmt.Errorf("failed to parse hierarchy ID") + return nil, fmt.Errorf("%w: hierarchy ID: %q", ErrFileParse, cgroup.HierarchyID) } if fields[1] != "" { ssNames := strings.Split(fields[1], ",") diff --git a/vendor/github.com/prometheus/procfs/proc_cgroups.go b/vendor/github.com/prometheus/procfs/proc_cgroups.go index 24d4dce9c..5dd493899 100644 --- a/vendor/github.com/prometheus/procfs/proc_cgroups.go +++ b/vendor/github.com/prometheus/procfs/proc_cgroups.go @@ -46,7 +46,7 @@ func parseCgroupSummaryString(CgroupSummaryStr string) (*CgroupSummary, error) { fields := strings.Fields(CgroupSummaryStr) // require at least 4 fields if len(fields) < 4 { - return nil, fmt.Errorf("at least 4 fields required, found %d fields in cgroup info string: %s", len(fields), CgroupSummaryStr) + return nil, fmt.Errorf("%w: 4+ fields required, found %d fields in cgroup info string: %s", ErrFileParse, len(fields), CgroupSummaryStr) } CgroupSummary := &CgroupSummary{ @@ -54,15 +54,15 @@ func parseCgroupSummaryString(CgroupSummaryStr string) (*CgroupSummary, error) { } CgroupSummary.Hierarchy, err = strconv.Atoi(fields[1]) if err != nil { - return nil, fmt.Errorf("failed to parse hierarchy ID") + return nil, fmt.Errorf("%w: Unable to parse hierarchy ID from %q", ErrFileParse, fields[1]) } CgroupSummary.Cgroups, err = strconv.Atoi(fields[2]) if err != nil { - return nil, fmt.Errorf("failed to parse Cgroup Num") + return nil, fmt.Errorf("%w: Unable to parse Cgroup Num from %q", ErrFileParse, fields[2]) } CgroupSummary.Enabled, err = strconv.Atoi(fields[3]) if err != nil { - return nil, fmt.Errorf("failed to parse Enabled") + return nil, fmt.Errorf("%w: Unable to parse Enabled from %q", ErrFileParse, fields[3]) } return CgroupSummary, nil } diff --git a/vendor/github.com/prometheus/procfs/proc_fdinfo.go b/vendor/github.com/prometheus/procfs/proc_fdinfo.go index 1bbdd4a8e..4b7933e4f 100644 --- a/vendor/github.com/prometheus/procfs/proc_fdinfo.go +++ b/vendor/github.com/prometheus/procfs/proc_fdinfo.go @@ -111,7 +111,7 @@ func parseInotifyInfo(line string) (*InotifyInfo, error) { } return i, nil } - return nil, fmt.Errorf("invalid inode entry: %q", line) + return nil, fmt.Errorf("%w: invalid inode entry: %q", ErrFileParse, line) } // ProcFDInfos represents a list of ProcFDInfo structs. diff --git a/vendor/github.com/prometheus/procfs/proc_interrupts.go b/vendor/github.com/prometheus/procfs/proc_interrupts.go new file mode 100644 index 000000000..86b4b4524 --- /dev/null +++ b/vendor/github.com/prometheus/procfs/proc_interrupts.go @@ -0,0 +1,98 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "bufio" + "bytes" + "errors" + "fmt" + "io" + "strconv" + "strings" + + "github.com/prometheus/procfs/internal/util" +) + +// Interrupt represents a single interrupt line. +type Interrupt struct { + // Info is the type of interrupt. + Info string + // Devices is the name of the device that is located at that IRQ + Devices string + // Values is the number of interrupts per CPU. + Values []string +} + +// Interrupts models the content of /proc/interrupts. Key is the IRQ number. +// - https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s2-proc-interrupts +// - https://raspberrypi.stackexchange.com/questions/105802/explanation-of-proc-interrupts-output +type Interrupts map[string]Interrupt + +// Interrupts creates a new instance from a given Proc instance. +func (p Proc) Interrupts() (Interrupts, error) { + data, err := util.ReadFileNoStat(p.path("interrupts")) + if err != nil { + return nil, err + } + return parseInterrupts(bytes.NewReader(data)) +} + +func parseInterrupts(r io.Reader) (Interrupts, error) { + var ( + interrupts = Interrupts{} + scanner = bufio.NewScanner(r) + ) + + if !scanner.Scan() { + return nil, errors.New("interrupts empty") + } + cpuNum := len(strings.Fields(scanner.Text())) // one header per cpu + + for scanner.Scan() { + parts := strings.Fields(scanner.Text()) + if len(parts) == 0 { // skip empty lines + continue + } + if len(parts) < 2 { + return nil, fmt.Errorf("%w: Not enough fields in interrupts (expected 2+ fields but got %d): %s", ErrFileParse, len(parts), parts) + } + intName := parts[0][:len(parts[0])-1] // remove trailing : + + if len(parts) == 2 { + interrupts[intName] = Interrupt{ + Info: "", + Devices: "", + Values: []string{ + parts[1], + }, + } + continue + } + + intr := Interrupt{ + Values: parts[1 : cpuNum+1], + } + + if _, err := strconv.Atoi(intName); err == nil { // numeral interrupt + intr.Info = parts[cpuNum+1] + intr.Devices = strings.Join(parts[cpuNum+2:], " ") + } else { + intr.Info = strings.Join(parts[cpuNum+1:], " ") + } + interrupts[intName] = intr + } + + return interrupts, scanner.Err() +} diff --git a/vendor/github.com/prometheus/procfs/proc_limits.go b/vendor/github.com/prometheus/procfs/proc_limits.go index 7a1388185..c86d815d7 100644 --- a/vendor/github.com/prometheus/procfs/proc_limits.go +++ b/vendor/github.com/prometheus/procfs/proc_limits.go @@ -103,7 +103,7 @@ func (p Proc) Limits() (ProcLimits, error) { //fields := limitsMatch.Split(s.Text(), limitsFields) fields := limitsMatch.FindStringSubmatch(s.Text()) if len(fields) != limitsFields { - return ProcLimits{}, fmt.Errorf("couldn't parse %q line %q", f.Name(), s.Text()) + return ProcLimits{}, fmt.Errorf("%w: couldn't parse %q line %q", ErrFileParse, f.Name(), s.Text()) } switch fields[1] { @@ -154,7 +154,7 @@ func parseUint(s string) (uint64, error) { } i, err := strconv.ParseUint(s, 10, 64) if err != nil { - return 0, fmt.Errorf("couldn't parse value %q: %w", s, err) + return 0, fmt.Errorf("%s: couldn't parse value %q: %w", ErrFileParse, s, err) } return i, nil } diff --git a/vendor/github.com/prometheus/procfs/proc_maps.go b/vendor/github.com/prometheus/procfs/proc_maps.go index f1bcbf32b..727549a13 100644 --- a/vendor/github.com/prometheus/procfs/proc_maps.go +++ b/vendor/github.com/prometheus/procfs/proc_maps.go @@ -65,7 +65,7 @@ type ProcMap struct { func parseDevice(s string) (uint64, error) { toks := strings.Split(s, ":") if len(toks) < 2 { - return 0, fmt.Errorf("unexpected number of fields") + return 0, fmt.Errorf("%w: unexpected number of fields, expected: 2, got: %q", ErrFileParse, len(toks)) } major, err := strconv.ParseUint(toks[0], 16, 0) @@ -95,7 +95,7 @@ func parseAddress(s string) (uintptr, error) { func parseAddresses(s string) (uintptr, uintptr, error) { toks := strings.Split(s, "-") if len(toks) < 2 { - return 0, 0, fmt.Errorf("invalid address") + return 0, 0, fmt.Errorf("%w: invalid address", ErrFileParse) } saddr, err := parseAddress(toks[0]) @@ -114,7 +114,7 @@ func parseAddresses(s string) (uintptr, uintptr, error) { // parsePermissions parses a token and returns any that are set. func parsePermissions(s string) (*ProcMapPermissions, error) { if len(s) < 4 { - return nil, fmt.Errorf("invalid permissions token") + return nil, fmt.Errorf("%w: invalid permissions token", ErrFileParse) } perms := ProcMapPermissions{} @@ -141,7 +141,7 @@ func parsePermissions(s string) (*ProcMapPermissions, error) { func parseProcMap(text string) (*ProcMap, error) { fields := strings.Fields(text) if len(fields) < 5 { - return nil, fmt.Errorf("truncated procmap entry") + return nil, fmt.Errorf("%w: truncated procmap entry", ErrFileParse) } saddr, eaddr, err := parseAddresses(fields[0]) diff --git a/vendor/github.com/prometheus/procfs/proc_netstat.go b/vendor/github.com/prometheus/procfs/proc_netstat.go index 48b523819..8e3ff4d79 100644 --- a/vendor/github.com/prometheus/procfs/proc_netstat.go +++ b/vendor/github.com/prometheus/procfs/proc_netstat.go @@ -33,139 +33,140 @@ type ProcNetstat struct { } type TcpExt struct { // nolint:revive - SyncookiesSent float64 - SyncookiesRecv float64 - SyncookiesFailed float64 - EmbryonicRsts float64 - PruneCalled float64 - RcvPruned float64 - OfoPruned float64 - OutOfWindowIcmps float64 - LockDroppedIcmps float64 - ArpFilter float64 - TW float64 - TWRecycled float64 - TWKilled float64 - PAWSActive float64 - PAWSEstab float64 - DelayedACKs float64 - DelayedACKLocked float64 - DelayedACKLost float64 - ListenOverflows float64 - ListenDrops float64 - TCPHPHits float64 - TCPPureAcks float64 - TCPHPAcks float64 - TCPRenoRecovery float64 - TCPSackRecovery float64 - TCPSACKReneging float64 - TCPSACKReorder float64 - TCPRenoReorder float64 - TCPTSReorder float64 - TCPFullUndo float64 - TCPPartialUndo float64 - TCPDSACKUndo float64 - TCPLossUndo float64 - TCPLostRetransmit float64 - TCPRenoFailures float64 - TCPSackFailures float64 - TCPLossFailures float64 - TCPFastRetrans float64 - TCPSlowStartRetrans float64 - TCPTimeouts float64 - TCPLossProbes float64 - TCPLossProbeRecovery float64 - TCPRenoRecoveryFail float64 - TCPSackRecoveryFail float64 - TCPRcvCollapsed float64 - TCPDSACKOldSent float64 - TCPDSACKOfoSent float64 - TCPDSACKRecv float64 - TCPDSACKOfoRecv float64 - TCPAbortOnData float64 - TCPAbortOnClose float64 - TCPAbortOnMemory float64 - TCPAbortOnTimeout float64 - TCPAbortOnLinger float64 - TCPAbortFailed float64 - TCPMemoryPressures float64 - TCPMemoryPressuresChrono float64 - TCPSACKDiscard float64 - TCPDSACKIgnoredOld float64 - TCPDSACKIgnoredNoUndo float64 - TCPSpuriousRTOs float64 - TCPMD5NotFound float64 - TCPMD5Unexpected float64 - TCPMD5Failure float64 - TCPSackShifted float64 - TCPSackMerged float64 - TCPSackShiftFallback float64 - TCPBacklogDrop float64 - PFMemallocDrop float64 - TCPMinTTLDrop float64 - TCPDeferAcceptDrop float64 - IPReversePathFilter float64 - TCPTimeWaitOverflow float64 - TCPReqQFullDoCookies float64 - TCPReqQFullDrop float64 - TCPRetransFail float64 - TCPRcvCoalesce float64 - TCPOFOQueue float64 - TCPOFODrop float64 - TCPOFOMerge float64 - TCPChallengeACK float64 - TCPSYNChallenge float64 - TCPFastOpenActive float64 - TCPFastOpenActiveFail float64 - TCPFastOpenPassive float64 - TCPFastOpenPassiveFail float64 - TCPFastOpenListenOverflow float64 - TCPFastOpenCookieReqd float64 - TCPFastOpenBlackhole float64 - TCPSpuriousRtxHostQueues float64 - BusyPollRxPackets float64 - TCPAutoCorking float64 - TCPFromZeroWindowAdv float64 - TCPToZeroWindowAdv float64 - TCPWantZeroWindowAdv float64 - TCPSynRetrans float64 - TCPOrigDataSent float64 - TCPHystartTrainDetect float64 - TCPHystartTrainCwnd float64 - TCPHystartDelayDetect float64 - TCPHystartDelayCwnd float64 - TCPACKSkippedSynRecv float64 - TCPACKSkippedPAWS float64 - TCPACKSkippedSeq float64 - TCPACKSkippedFinWait2 float64 - TCPACKSkippedTimeWait float64 - TCPACKSkippedChallenge float64 - TCPWinProbe float64 - TCPKeepAlive float64 - TCPMTUPFail float64 - TCPMTUPSuccess float64 - TCPWqueueTooBig float64 + SyncookiesSent *float64 + SyncookiesRecv *float64 + SyncookiesFailed *float64 + EmbryonicRsts *float64 + PruneCalled *float64 + RcvPruned *float64 + OfoPruned *float64 + OutOfWindowIcmps *float64 + LockDroppedIcmps *float64 + ArpFilter *float64 + TW *float64 + TWRecycled *float64 + TWKilled *float64 + PAWSActive *float64 + PAWSEstab *float64 + DelayedACKs *float64 + DelayedACKLocked *float64 + DelayedACKLost *float64 + ListenOverflows *float64 + ListenDrops *float64 + TCPHPHits *float64 + TCPPureAcks *float64 + TCPHPAcks *float64 + TCPRenoRecovery *float64 + TCPSackRecovery *float64 + TCPSACKReneging *float64 + TCPSACKReorder *float64 + TCPRenoReorder *float64 + TCPTSReorder *float64 + TCPFullUndo *float64 + TCPPartialUndo *float64 + TCPDSACKUndo *float64 + TCPLossUndo *float64 + TCPLostRetransmit *float64 + TCPRenoFailures *float64 + TCPSackFailures *float64 + TCPLossFailures *float64 + TCPFastRetrans *float64 + TCPSlowStartRetrans *float64 + TCPTimeouts *float64 + TCPLossProbes *float64 + TCPLossProbeRecovery *float64 + TCPRenoRecoveryFail *float64 + TCPSackRecoveryFail *float64 + TCPRcvCollapsed *float64 + TCPDSACKOldSent *float64 + TCPDSACKOfoSent *float64 + TCPDSACKRecv *float64 + TCPDSACKOfoRecv *float64 + TCPAbortOnData *float64 + TCPAbortOnClose *float64 + TCPAbortOnMemory *float64 + TCPAbortOnTimeout *float64 + TCPAbortOnLinger *float64 + TCPAbortFailed *float64 + TCPMemoryPressures *float64 + TCPMemoryPressuresChrono *float64 + TCPSACKDiscard *float64 + TCPDSACKIgnoredOld *float64 + TCPDSACKIgnoredNoUndo *float64 + TCPSpuriousRTOs *float64 + TCPMD5NotFound *float64 + TCPMD5Unexpected *float64 + TCPMD5Failure *float64 + TCPSackShifted *float64 + TCPSackMerged *float64 + TCPSackShiftFallback *float64 + TCPBacklogDrop *float64 + PFMemallocDrop *float64 + TCPMinTTLDrop *float64 + TCPDeferAcceptDrop *float64 + IPReversePathFilter *float64 + TCPTimeWaitOverflow *float64 + TCPReqQFullDoCookies *float64 + TCPReqQFullDrop *float64 + TCPRetransFail *float64 + TCPRcvCoalesce *float64 + TCPRcvQDrop *float64 + TCPOFOQueue *float64 + TCPOFODrop *float64 + TCPOFOMerge *float64 + TCPChallengeACK *float64 + TCPSYNChallenge *float64 + TCPFastOpenActive *float64 + TCPFastOpenActiveFail *float64 + TCPFastOpenPassive *float64 + TCPFastOpenPassiveFail *float64 + TCPFastOpenListenOverflow *float64 + TCPFastOpenCookieReqd *float64 + TCPFastOpenBlackhole *float64 + TCPSpuriousRtxHostQueues *float64 + BusyPollRxPackets *float64 + TCPAutoCorking *float64 + TCPFromZeroWindowAdv *float64 + TCPToZeroWindowAdv *float64 + TCPWantZeroWindowAdv *float64 + TCPSynRetrans *float64 + TCPOrigDataSent *float64 + TCPHystartTrainDetect *float64 + TCPHystartTrainCwnd *float64 + TCPHystartDelayDetect *float64 + TCPHystartDelayCwnd *float64 + TCPACKSkippedSynRecv *float64 + TCPACKSkippedPAWS *float64 + TCPACKSkippedSeq *float64 + TCPACKSkippedFinWait2 *float64 + TCPACKSkippedTimeWait *float64 + TCPACKSkippedChallenge *float64 + TCPWinProbe *float64 + TCPKeepAlive *float64 + TCPMTUPFail *float64 + TCPMTUPSuccess *float64 + TCPWqueueTooBig *float64 } type IpExt struct { // nolint:revive - InNoRoutes float64 - InTruncatedPkts float64 - InMcastPkts float64 - OutMcastPkts float64 - InBcastPkts float64 - OutBcastPkts float64 - InOctets float64 - OutOctets float64 - InMcastOctets float64 - OutMcastOctets float64 - InBcastOctets float64 - OutBcastOctets float64 - InCsumErrors float64 - InNoECTPkts float64 - InECT1Pkts float64 - InECT0Pkts float64 - InCEPkts float64 - ReasmOverlaps float64 + InNoRoutes *float64 + InTruncatedPkts *float64 + InMcastPkts *float64 + OutMcastPkts *float64 + InBcastPkts *float64 + OutBcastPkts *float64 + InOctets *float64 + OutOctets *float64 + InMcastOctets *float64 + OutMcastOctets *float64 + InBcastOctets *float64 + OutBcastOctets *float64 + InCsumErrors *float64 + InNoECTPkts *float64 + InECT1Pkts *float64 + InECT0Pkts *float64 + InCEPkts *float64 + ReasmOverlaps *float64 } func (p Proc) Netstat() (ProcNetstat, error) { @@ -174,14 +175,14 @@ func (p Proc) Netstat() (ProcNetstat, error) { if err != nil { return ProcNetstat{PID: p.PID}, err } - procNetstat, err := parseNetstat(bytes.NewReader(data), filename) + procNetstat, err := parseProcNetstat(bytes.NewReader(data), filename) procNetstat.PID = p.PID return procNetstat, err } -// parseNetstat parses the metrics from proc//net/netstat file +// parseProcNetstat parses the metrics from proc//net/netstat file // and returns a ProcNetstat structure. -func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) { +func parseProcNetstat(r io.Reader, fileName string) (ProcNetstat, error) { var ( scanner = bufio.NewScanner(r) procNetstat = ProcNetstat{} @@ -194,8 +195,8 @@ func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) { // Remove trailing :. protocol := strings.TrimSuffix(nameParts[0], ":") if len(nameParts) != len(valueParts) { - return procNetstat, fmt.Errorf("mismatch field count mismatch in %s: %s", - fileName, protocol) + return procNetstat, fmt.Errorf("%w: mismatch field count mismatch in %s: %s", + ErrFileParse, fileName, protocol) } for i := 1; i < len(nameParts); i++ { value, err := strconv.ParseFloat(valueParts[i], 64) @@ -208,230 +209,232 @@ func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) { case "TcpExt": switch key { case "SyncookiesSent": - procNetstat.TcpExt.SyncookiesSent = value + procNetstat.TcpExt.SyncookiesSent = &value case "SyncookiesRecv": - procNetstat.TcpExt.SyncookiesRecv = value + procNetstat.TcpExt.SyncookiesRecv = &value case "SyncookiesFailed": - procNetstat.TcpExt.SyncookiesFailed = value + procNetstat.TcpExt.SyncookiesFailed = &value case "EmbryonicRsts": - procNetstat.TcpExt.EmbryonicRsts = value + procNetstat.TcpExt.EmbryonicRsts = &value case "PruneCalled": - procNetstat.TcpExt.PruneCalled = value + procNetstat.TcpExt.PruneCalled = &value case "RcvPruned": - procNetstat.TcpExt.RcvPruned = value + procNetstat.TcpExt.RcvPruned = &value case "OfoPruned": - procNetstat.TcpExt.OfoPruned = value + procNetstat.TcpExt.OfoPruned = &value case "OutOfWindowIcmps": - procNetstat.TcpExt.OutOfWindowIcmps = value + procNetstat.TcpExt.OutOfWindowIcmps = &value case "LockDroppedIcmps": - procNetstat.TcpExt.LockDroppedIcmps = value + procNetstat.TcpExt.LockDroppedIcmps = &value case "ArpFilter": - procNetstat.TcpExt.ArpFilter = value + procNetstat.TcpExt.ArpFilter = &value case "TW": - procNetstat.TcpExt.TW = value + procNetstat.TcpExt.TW = &value case "TWRecycled": - procNetstat.TcpExt.TWRecycled = value + procNetstat.TcpExt.TWRecycled = &value case "TWKilled": - procNetstat.TcpExt.TWKilled = value + procNetstat.TcpExt.TWKilled = &value case "PAWSActive": - procNetstat.TcpExt.PAWSActive = value + procNetstat.TcpExt.PAWSActive = &value case "PAWSEstab": - procNetstat.TcpExt.PAWSEstab = value + procNetstat.TcpExt.PAWSEstab = &value case "DelayedACKs": - procNetstat.TcpExt.DelayedACKs = value + procNetstat.TcpExt.DelayedACKs = &value case "DelayedACKLocked": - procNetstat.TcpExt.DelayedACKLocked = value + procNetstat.TcpExt.DelayedACKLocked = &value case "DelayedACKLost": - procNetstat.TcpExt.DelayedACKLost = value + procNetstat.TcpExt.DelayedACKLost = &value case "ListenOverflows": - procNetstat.TcpExt.ListenOverflows = value + procNetstat.TcpExt.ListenOverflows = &value case "ListenDrops": - procNetstat.TcpExt.ListenDrops = value + procNetstat.TcpExt.ListenDrops = &value case "TCPHPHits": - procNetstat.TcpExt.TCPHPHits = value + procNetstat.TcpExt.TCPHPHits = &value case "TCPPureAcks": - procNetstat.TcpExt.TCPPureAcks = value + procNetstat.TcpExt.TCPPureAcks = &value case "TCPHPAcks": - procNetstat.TcpExt.TCPHPAcks = value + procNetstat.TcpExt.TCPHPAcks = &value case "TCPRenoRecovery": - procNetstat.TcpExt.TCPRenoRecovery = value + procNetstat.TcpExt.TCPRenoRecovery = &value case "TCPSackRecovery": - procNetstat.TcpExt.TCPSackRecovery = value + procNetstat.TcpExt.TCPSackRecovery = &value case "TCPSACKReneging": - procNetstat.TcpExt.TCPSACKReneging = value + procNetstat.TcpExt.TCPSACKReneging = &value case "TCPSACKReorder": - procNetstat.TcpExt.TCPSACKReorder = value + procNetstat.TcpExt.TCPSACKReorder = &value case "TCPRenoReorder": - procNetstat.TcpExt.TCPRenoReorder = value + procNetstat.TcpExt.TCPRenoReorder = &value case "TCPTSReorder": - procNetstat.TcpExt.TCPTSReorder = value + procNetstat.TcpExt.TCPTSReorder = &value case "TCPFullUndo": - procNetstat.TcpExt.TCPFullUndo = value + procNetstat.TcpExt.TCPFullUndo = &value case "TCPPartialUndo": - procNetstat.TcpExt.TCPPartialUndo = value + procNetstat.TcpExt.TCPPartialUndo = &value case "TCPDSACKUndo": - procNetstat.TcpExt.TCPDSACKUndo = value + procNetstat.TcpExt.TCPDSACKUndo = &value case "TCPLossUndo": - procNetstat.TcpExt.TCPLossUndo = value + procNetstat.TcpExt.TCPLossUndo = &value case "TCPLostRetransmit": - procNetstat.TcpExt.TCPLostRetransmit = value + procNetstat.TcpExt.TCPLostRetransmit = &value case "TCPRenoFailures": - procNetstat.TcpExt.TCPRenoFailures = value + procNetstat.TcpExt.TCPRenoFailures = &value case "TCPSackFailures": - procNetstat.TcpExt.TCPSackFailures = value + procNetstat.TcpExt.TCPSackFailures = &value case "TCPLossFailures": - procNetstat.TcpExt.TCPLossFailures = value + procNetstat.TcpExt.TCPLossFailures = &value case "TCPFastRetrans": - procNetstat.TcpExt.TCPFastRetrans = value + procNetstat.TcpExt.TCPFastRetrans = &value case "TCPSlowStartRetrans": - procNetstat.TcpExt.TCPSlowStartRetrans = value + procNetstat.TcpExt.TCPSlowStartRetrans = &value case "TCPTimeouts": - procNetstat.TcpExt.TCPTimeouts = value + procNetstat.TcpExt.TCPTimeouts = &value case "TCPLossProbes": - procNetstat.TcpExt.TCPLossProbes = value + procNetstat.TcpExt.TCPLossProbes = &value case "TCPLossProbeRecovery": - procNetstat.TcpExt.TCPLossProbeRecovery = value + procNetstat.TcpExt.TCPLossProbeRecovery = &value case "TCPRenoRecoveryFail": - procNetstat.TcpExt.TCPRenoRecoveryFail = value + procNetstat.TcpExt.TCPRenoRecoveryFail = &value case "TCPSackRecoveryFail": - procNetstat.TcpExt.TCPSackRecoveryFail = value + procNetstat.TcpExt.TCPSackRecoveryFail = &value case "TCPRcvCollapsed": - procNetstat.TcpExt.TCPRcvCollapsed = value + procNetstat.TcpExt.TCPRcvCollapsed = &value case "TCPDSACKOldSent": - procNetstat.TcpExt.TCPDSACKOldSent = value + procNetstat.TcpExt.TCPDSACKOldSent = &value case "TCPDSACKOfoSent": - procNetstat.TcpExt.TCPDSACKOfoSent = value + procNetstat.TcpExt.TCPDSACKOfoSent = &value case "TCPDSACKRecv": - procNetstat.TcpExt.TCPDSACKRecv = value + procNetstat.TcpExt.TCPDSACKRecv = &value case "TCPDSACKOfoRecv": - procNetstat.TcpExt.TCPDSACKOfoRecv = value + procNetstat.TcpExt.TCPDSACKOfoRecv = &value case "TCPAbortOnData": - procNetstat.TcpExt.TCPAbortOnData = value + procNetstat.TcpExt.TCPAbortOnData = &value case "TCPAbortOnClose": - procNetstat.TcpExt.TCPAbortOnClose = value + procNetstat.TcpExt.TCPAbortOnClose = &value case "TCPDeferAcceptDrop": - procNetstat.TcpExt.TCPDeferAcceptDrop = value + procNetstat.TcpExt.TCPDeferAcceptDrop = &value case "IPReversePathFilter": - procNetstat.TcpExt.IPReversePathFilter = value + procNetstat.TcpExt.IPReversePathFilter = &value case "TCPTimeWaitOverflow": - procNetstat.TcpExt.TCPTimeWaitOverflow = value + procNetstat.TcpExt.TCPTimeWaitOverflow = &value case "TCPReqQFullDoCookies": - procNetstat.TcpExt.TCPReqQFullDoCookies = value + procNetstat.TcpExt.TCPReqQFullDoCookies = &value case "TCPReqQFullDrop": - procNetstat.TcpExt.TCPReqQFullDrop = value + procNetstat.TcpExt.TCPReqQFullDrop = &value case "TCPRetransFail": - procNetstat.TcpExt.TCPRetransFail = value + procNetstat.TcpExt.TCPRetransFail = &value case "TCPRcvCoalesce": - procNetstat.TcpExt.TCPRcvCoalesce = value + procNetstat.TcpExt.TCPRcvCoalesce = &value + case "TCPRcvQDrop": + procNetstat.TcpExt.TCPRcvQDrop = &value case "TCPOFOQueue": - procNetstat.TcpExt.TCPOFOQueue = value + procNetstat.TcpExt.TCPOFOQueue = &value case "TCPOFODrop": - procNetstat.TcpExt.TCPOFODrop = value + procNetstat.TcpExt.TCPOFODrop = &value case "TCPOFOMerge": - procNetstat.TcpExt.TCPOFOMerge = value + procNetstat.TcpExt.TCPOFOMerge = &value case "TCPChallengeACK": - procNetstat.TcpExt.TCPChallengeACK = value + procNetstat.TcpExt.TCPChallengeACK = &value case "TCPSYNChallenge": - procNetstat.TcpExt.TCPSYNChallenge = value + procNetstat.TcpExt.TCPSYNChallenge = &value case "TCPFastOpenActive": - procNetstat.TcpExt.TCPFastOpenActive = value + procNetstat.TcpExt.TCPFastOpenActive = &value case "TCPFastOpenActiveFail": - procNetstat.TcpExt.TCPFastOpenActiveFail = value + procNetstat.TcpExt.TCPFastOpenActiveFail = &value case "TCPFastOpenPassive": - procNetstat.TcpExt.TCPFastOpenPassive = value + procNetstat.TcpExt.TCPFastOpenPassive = &value case "TCPFastOpenPassiveFail": - procNetstat.TcpExt.TCPFastOpenPassiveFail = value + procNetstat.TcpExt.TCPFastOpenPassiveFail = &value case "TCPFastOpenListenOverflow": - procNetstat.TcpExt.TCPFastOpenListenOverflow = value + procNetstat.TcpExt.TCPFastOpenListenOverflow = &value case "TCPFastOpenCookieReqd": - procNetstat.TcpExt.TCPFastOpenCookieReqd = value + procNetstat.TcpExt.TCPFastOpenCookieReqd = &value case "TCPFastOpenBlackhole": - procNetstat.TcpExt.TCPFastOpenBlackhole = value + procNetstat.TcpExt.TCPFastOpenBlackhole = &value case "TCPSpuriousRtxHostQueues": - procNetstat.TcpExt.TCPSpuriousRtxHostQueues = value + procNetstat.TcpExt.TCPSpuriousRtxHostQueues = &value case "BusyPollRxPackets": - procNetstat.TcpExt.BusyPollRxPackets = value + procNetstat.TcpExt.BusyPollRxPackets = &value case "TCPAutoCorking": - procNetstat.TcpExt.TCPAutoCorking = value + procNetstat.TcpExt.TCPAutoCorking = &value case "TCPFromZeroWindowAdv": - procNetstat.TcpExt.TCPFromZeroWindowAdv = value + procNetstat.TcpExt.TCPFromZeroWindowAdv = &value case "TCPToZeroWindowAdv": - procNetstat.TcpExt.TCPToZeroWindowAdv = value + procNetstat.TcpExt.TCPToZeroWindowAdv = &value case "TCPWantZeroWindowAdv": - procNetstat.TcpExt.TCPWantZeroWindowAdv = value + procNetstat.TcpExt.TCPWantZeroWindowAdv = &value case "TCPSynRetrans": - procNetstat.TcpExt.TCPSynRetrans = value + procNetstat.TcpExt.TCPSynRetrans = &value case "TCPOrigDataSent": - procNetstat.TcpExt.TCPOrigDataSent = value + procNetstat.TcpExt.TCPOrigDataSent = &value case "TCPHystartTrainDetect": - procNetstat.TcpExt.TCPHystartTrainDetect = value + procNetstat.TcpExt.TCPHystartTrainDetect = &value case "TCPHystartTrainCwnd": - procNetstat.TcpExt.TCPHystartTrainCwnd = value + procNetstat.TcpExt.TCPHystartTrainCwnd = &value case "TCPHystartDelayDetect": - procNetstat.TcpExt.TCPHystartDelayDetect = value + procNetstat.TcpExt.TCPHystartDelayDetect = &value case "TCPHystartDelayCwnd": - procNetstat.TcpExt.TCPHystartDelayCwnd = value + procNetstat.TcpExt.TCPHystartDelayCwnd = &value case "TCPACKSkippedSynRecv": - procNetstat.TcpExt.TCPACKSkippedSynRecv = value + procNetstat.TcpExt.TCPACKSkippedSynRecv = &value case "TCPACKSkippedPAWS": - procNetstat.TcpExt.TCPACKSkippedPAWS = value + procNetstat.TcpExt.TCPACKSkippedPAWS = &value case "TCPACKSkippedSeq": - procNetstat.TcpExt.TCPACKSkippedSeq = value + procNetstat.TcpExt.TCPACKSkippedSeq = &value case "TCPACKSkippedFinWait2": - procNetstat.TcpExt.TCPACKSkippedFinWait2 = value + procNetstat.TcpExt.TCPACKSkippedFinWait2 = &value case "TCPACKSkippedTimeWait": - procNetstat.TcpExt.TCPACKSkippedTimeWait = value + procNetstat.TcpExt.TCPACKSkippedTimeWait = &value case "TCPACKSkippedChallenge": - procNetstat.TcpExt.TCPACKSkippedChallenge = value + procNetstat.TcpExt.TCPACKSkippedChallenge = &value case "TCPWinProbe": - procNetstat.TcpExt.TCPWinProbe = value + procNetstat.TcpExt.TCPWinProbe = &value case "TCPKeepAlive": - procNetstat.TcpExt.TCPKeepAlive = value + procNetstat.TcpExt.TCPKeepAlive = &value case "TCPMTUPFail": - procNetstat.TcpExt.TCPMTUPFail = value + procNetstat.TcpExt.TCPMTUPFail = &value case "TCPMTUPSuccess": - procNetstat.TcpExt.TCPMTUPSuccess = value + procNetstat.TcpExt.TCPMTUPSuccess = &value case "TCPWqueueTooBig": - procNetstat.TcpExt.TCPWqueueTooBig = value + procNetstat.TcpExt.TCPWqueueTooBig = &value } case "IpExt": switch key { case "InNoRoutes": - procNetstat.IpExt.InNoRoutes = value + procNetstat.IpExt.InNoRoutes = &value case "InTruncatedPkts": - procNetstat.IpExt.InTruncatedPkts = value + procNetstat.IpExt.InTruncatedPkts = &value case "InMcastPkts": - procNetstat.IpExt.InMcastPkts = value + procNetstat.IpExt.InMcastPkts = &value case "OutMcastPkts": - procNetstat.IpExt.OutMcastPkts = value + procNetstat.IpExt.OutMcastPkts = &value case "InBcastPkts": - procNetstat.IpExt.InBcastPkts = value + procNetstat.IpExt.InBcastPkts = &value case "OutBcastPkts": - procNetstat.IpExt.OutBcastPkts = value + procNetstat.IpExt.OutBcastPkts = &value case "InOctets": - procNetstat.IpExt.InOctets = value + procNetstat.IpExt.InOctets = &value case "OutOctets": - procNetstat.IpExt.OutOctets = value + procNetstat.IpExt.OutOctets = &value case "InMcastOctets": - procNetstat.IpExt.InMcastOctets = value + procNetstat.IpExt.InMcastOctets = &value case "OutMcastOctets": - procNetstat.IpExt.OutMcastOctets = value + procNetstat.IpExt.OutMcastOctets = &value case "InBcastOctets": - procNetstat.IpExt.InBcastOctets = value + procNetstat.IpExt.InBcastOctets = &value case "OutBcastOctets": - procNetstat.IpExt.OutBcastOctets = value + procNetstat.IpExt.OutBcastOctets = &value case "InCsumErrors": - procNetstat.IpExt.InCsumErrors = value + procNetstat.IpExt.InCsumErrors = &value case "InNoECTPkts": - procNetstat.IpExt.InNoECTPkts = value + procNetstat.IpExt.InNoECTPkts = &value case "InECT1Pkts": - procNetstat.IpExt.InECT1Pkts = value + procNetstat.IpExt.InECT1Pkts = &value case "InECT0Pkts": - procNetstat.IpExt.InECT0Pkts = value + procNetstat.IpExt.InECT0Pkts = &value case "InCEPkts": - procNetstat.IpExt.InCEPkts = value + procNetstat.IpExt.InCEPkts = &value case "ReasmOverlaps": - procNetstat.IpExt.ReasmOverlaps = value + procNetstat.IpExt.ReasmOverlaps = &value } } } diff --git a/vendor/github.com/prometheus/procfs/proc_ns.go b/vendor/github.com/prometheus/procfs/proc_ns.go index 391b4cbd1..c22666750 100644 --- a/vendor/github.com/prometheus/procfs/proc_ns.go +++ b/vendor/github.com/prometheus/procfs/proc_ns.go @@ -40,7 +40,7 @@ func (p Proc) Namespaces() (Namespaces, error) { names, err := d.Readdirnames(-1) if err != nil { - return nil, fmt.Errorf("failed to read contents of ns dir: %w", err) + return nil, fmt.Errorf("%s: failed to read contents of ns dir: %w", ErrFileRead, err) } ns := make(Namespaces, len(names)) @@ -52,13 +52,13 @@ func (p Proc) Namespaces() (Namespaces, error) { fields := strings.SplitN(target, ":", 2) if len(fields) != 2 { - return nil, fmt.Errorf("failed to parse namespace type and inode from %q", target) + return nil, fmt.Errorf("%w: namespace type and inode from %q", ErrFileParse, target) } typ := fields[0] inode, err := strconv.ParseUint(strings.Trim(fields[1], "[]"), 10, 32) if err != nil { - return nil, fmt.Errorf("failed to parse inode from %q: %w", fields[1], err) + return nil, fmt.Errorf("%s: inode from %q: %w", ErrFileParse, fields[1], err) } ns[name] = Namespace{typ, uint32(inode)} diff --git a/vendor/github.com/prometheus/procfs/proc_psi.go b/vendor/github.com/prometheus/procfs/proc_psi.go index a68fe1529..152539d35 100644 --- a/vendor/github.com/prometheus/procfs/proc_psi.go +++ b/vendor/github.com/prometheus/procfs/proc_psi.go @@ -61,7 +61,7 @@ type PSIStats struct { func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) { data, err := util.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource))) if err != nil { - return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %q: %w", resource, err) + return PSIStats{}, fmt.Errorf("%s: psi_stats: unavailable for %q: %w", ErrFileRead, resource, err) } return parsePSIStats(resource, bytes.NewReader(data)) diff --git a/vendor/github.com/prometheus/procfs/proc_snmp.go b/vendor/github.com/prometheus/procfs/proc_snmp.go index ae191896c..b9d2cf642 100644 --- a/vendor/github.com/prometheus/procfs/proc_snmp.go +++ b/vendor/github.com/prometheus/procfs/proc_snmp.go @@ -37,100 +37,100 @@ type ProcSnmp struct { } type Ip struct { // nolint:revive - Forwarding float64 - DefaultTTL float64 - InReceives float64 - InHdrErrors float64 - InAddrErrors float64 - ForwDatagrams float64 - InUnknownProtos float64 - InDiscards float64 - InDelivers float64 - OutRequests float64 - OutDiscards float64 - OutNoRoutes float64 - ReasmTimeout float64 - ReasmReqds float64 - ReasmOKs float64 - ReasmFails float64 - FragOKs float64 - FragFails float64 - FragCreates float64 + Forwarding *float64 + DefaultTTL *float64 + InReceives *float64 + InHdrErrors *float64 + InAddrErrors *float64 + ForwDatagrams *float64 + InUnknownProtos *float64 + InDiscards *float64 + InDelivers *float64 + OutRequests *float64 + OutDiscards *float64 + OutNoRoutes *float64 + ReasmTimeout *float64 + ReasmReqds *float64 + ReasmOKs *float64 + ReasmFails *float64 + FragOKs *float64 + FragFails *float64 + FragCreates *float64 } -type Icmp struct { - InMsgs float64 - InErrors float64 - InCsumErrors float64 - InDestUnreachs float64 - InTimeExcds float64 - InParmProbs float64 - InSrcQuenchs float64 - InRedirects float64 - InEchos float64 - InEchoReps float64 - InTimestamps float64 - InTimestampReps float64 - InAddrMasks float64 - InAddrMaskReps float64 - OutMsgs float64 - OutErrors float64 - OutDestUnreachs float64 - OutTimeExcds float64 - OutParmProbs float64 - OutSrcQuenchs float64 - OutRedirects float64 - OutEchos float64 - OutEchoReps float64 - OutTimestamps float64 - OutTimestampReps float64 - OutAddrMasks float64 - OutAddrMaskReps float64 +type Icmp struct { // nolint:revive + InMsgs *float64 + InErrors *float64 + InCsumErrors *float64 + InDestUnreachs *float64 + InTimeExcds *float64 + InParmProbs *float64 + InSrcQuenchs *float64 + InRedirects *float64 + InEchos *float64 + InEchoReps *float64 + InTimestamps *float64 + InTimestampReps *float64 + InAddrMasks *float64 + InAddrMaskReps *float64 + OutMsgs *float64 + OutErrors *float64 + OutDestUnreachs *float64 + OutTimeExcds *float64 + OutParmProbs *float64 + OutSrcQuenchs *float64 + OutRedirects *float64 + OutEchos *float64 + OutEchoReps *float64 + OutTimestamps *float64 + OutTimestampReps *float64 + OutAddrMasks *float64 + OutAddrMaskReps *float64 } type IcmpMsg struct { - InType3 float64 - OutType3 float64 + InType3 *float64 + OutType3 *float64 } type Tcp struct { // nolint:revive - RtoAlgorithm float64 - RtoMin float64 - RtoMax float64 - MaxConn float64 - ActiveOpens float64 - PassiveOpens float64 - AttemptFails float64 - EstabResets float64 - CurrEstab float64 - InSegs float64 - OutSegs float64 - RetransSegs float64 - InErrs float64 - OutRsts float64 - InCsumErrors float64 + RtoAlgorithm *float64 + RtoMin *float64 + RtoMax *float64 + MaxConn *float64 + ActiveOpens *float64 + PassiveOpens *float64 + AttemptFails *float64 + EstabResets *float64 + CurrEstab *float64 + InSegs *float64 + OutSegs *float64 + RetransSegs *float64 + InErrs *float64 + OutRsts *float64 + InCsumErrors *float64 } type Udp struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 - IgnoredMulti float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 + IgnoredMulti *float64 } type UdpLite struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 - IgnoredMulti float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 + IgnoredMulti *float64 } func (p Proc) Snmp() (ProcSnmp, error) { @@ -159,8 +159,8 @@ func parseSnmp(r io.Reader, fileName string) (ProcSnmp, error) { // Remove trailing :. protocol := strings.TrimSuffix(nameParts[0], ":") if len(nameParts) != len(valueParts) { - return procSnmp, fmt.Errorf("mismatch field count mismatch in %s: %s", - fileName, protocol) + return procSnmp, fmt.Errorf("%w: mismatch field count mismatch in %s: %s", + ErrFileParse, fileName, protocol) } for i := 1; i < len(nameParts); i++ { value, err := strconv.ParseFloat(valueParts[i], 64) @@ -173,178 +173,178 @@ func parseSnmp(r io.Reader, fileName string) (ProcSnmp, error) { case "Ip": switch key { case "Forwarding": - procSnmp.Ip.Forwarding = value + procSnmp.Ip.Forwarding = &value case "DefaultTTL": - procSnmp.Ip.DefaultTTL = value + procSnmp.Ip.DefaultTTL = &value case "InReceives": - procSnmp.Ip.InReceives = value + procSnmp.Ip.InReceives = &value case "InHdrErrors": - procSnmp.Ip.InHdrErrors = value + procSnmp.Ip.InHdrErrors = &value case "InAddrErrors": - procSnmp.Ip.InAddrErrors = value + procSnmp.Ip.InAddrErrors = &value case "ForwDatagrams": - procSnmp.Ip.ForwDatagrams = value + procSnmp.Ip.ForwDatagrams = &value case "InUnknownProtos": - procSnmp.Ip.InUnknownProtos = value + procSnmp.Ip.InUnknownProtos = &value case "InDiscards": - procSnmp.Ip.InDiscards = value + procSnmp.Ip.InDiscards = &value case "InDelivers": - procSnmp.Ip.InDelivers = value + procSnmp.Ip.InDelivers = &value case "OutRequests": - procSnmp.Ip.OutRequests = value + procSnmp.Ip.OutRequests = &value case "OutDiscards": - procSnmp.Ip.OutDiscards = value + procSnmp.Ip.OutDiscards = &value case "OutNoRoutes": - procSnmp.Ip.OutNoRoutes = value + procSnmp.Ip.OutNoRoutes = &value case "ReasmTimeout": - procSnmp.Ip.ReasmTimeout = value + procSnmp.Ip.ReasmTimeout = &value case "ReasmReqds": - procSnmp.Ip.ReasmReqds = value + procSnmp.Ip.ReasmReqds = &value case "ReasmOKs": - procSnmp.Ip.ReasmOKs = value + procSnmp.Ip.ReasmOKs = &value case "ReasmFails": - procSnmp.Ip.ReasmFails = value + procSnmp.Ip.ReasmFails = &value case "FragOKs": - procSnmp.Ip.FragOKs = value + procSnmp.Ip.FragOKs = &value case "FragFails": - procSnmp.Ip.FragFails = value + procSnmp.Ip.FragFails = &value case "FragCreates": - procSnmp.Ip.FragCreates = value + procSnmp.Ip.FragCreates = &value } case "Icmp": switch key { case "InMsgs": - procSnmp.Icmp.InMsgs = value + procSnmp.Icmp.InMsgs = &value case "InErrors": - procSnmp.Icmp.InErrors = value + procSnmp.Icmp.InErrors = &value case "InCsumErrors": - procSnmp.Icmp.InCsumErrors = value + procSnmp.Icmp.InCsumErrors = &value case "InDestUnreachs": - procSnmp.Icmp.InDestUnreachs = value + procSnmp.Icmp.InDestUnreachs = &value case "InTimeExcds": - procSnmp.Icmp.InTimeExcds = value + procSnmp.Icmp.InTimeExcds = &value case "InParmProbs": - procSnmp.Icmp.InParmProbs = value + procSnmp.Icmp.InParmProbs = &value case "InSrcQuenchs": - procSnmp.Icmp.InSrcQuenchs = value + procSnmp.Icmp.InSrcQuenchs = &value case "InRedirects": - procSnmp.Icmp.InRedirects = value + procSnmp.Icmp.InRedirects = &value case "InEchos": - procSnmp.Icmp.InEchos = value + procSnmp.Icmp.InEchos = &value case "InEchoReps": - procSnmp.Icmp.InEchoReps = value + procSnmp.Icmp.InEchoReps = &value case "InTimestamps": - procSnmp.Icmp.InTimestamps = value + procSnmp.Icmp.InTimestamps = &value case "InTimestampReps": - procSnmp.Icmp.InTimestampReps = value + procSnmp.Icmp.InTimestampReps = &value case "InAddrMasks": - procSnmp.Icmp.InAddrMasks = value + procSnmp.Icmp.InAddrMasks = &value case "InAddrMaskReps": - procSnmp.Icmp.InAddrMaskReps = value + procSnmp.Icmp.InAddrMaskReps = &value case "OutMsgs": - procSnmp.Icmp.OutMsgs = value + procSnmp.Icmp.OutMsgs = &value case "OutErrors": - procSnmp.Icmp.OutErrors = value + procSnmp.Icmp.OutErrors = &value case "OutDestUnreachs": - procSnmp.Icmp.OutDestUnreachs = value + procSnmp.Icmp.OutDestUnreachs = &value case "OutTimeExcds": - procSnmp.Icmp.OutTimeExcds = value + procSnmp.Icmp.OutTimeExcds = &value case "OutParmProbs": - procSnmp.Icmp.OutParmProbs = value + procSnmp.Icmp.OutParmProbs = &value case "OutSrcQuenchs": - procSnmp.Icmp.OutSrcQuenchs = value + procSnmp.Icmp.OutSrcQuenchs = &value case "OutRedirects": - procSnmp.Icmp.OutRedirects = value + procSnmp.Icmp.OutRedirects = &value case "OutEchos": - procSnmp.Icmp.OutEchos = value + procSnmp.Icmp.OutEchos = &value case "OutEchoReps": - procSnmp.Icmp.OutEchoReps = value + procSnmp.Icmp.OutEchoReps = &value case "OutTimestamps": - procSnmp.Icmp.OutTimestamps = value + procSnmp.Icmp.OutTimestamps = &value case "OutTimestampReps": - procSnmp.Icmp.OutTimestampReps = value + procSnmp.Icmp.OutTimestampReps = &value case "OutAddrMasks": - procSnmp.Icmp.OutAddrMasks = value + procSnmp.Icmp.OutAddrMasks = &value case "OutAddrMaskReps": - procSnmp.Icmp.OutAddrMaskReps = value + procSnmp.Icmp.OutAddrMaskReps = &value } case "IcmpMsg": switch key { case "InType3": - procSnmp.IcmpMsg.InType3 = value + procSnmp.IcmpMsg.InType3 = &value case "OutType3": - procSnmp.IcmpMsg.OutType3 = value + procSnmp.IcmpMsg.OutType3 = &value } case "Tcp": switch key { case "RtoAlgorithm": - procSnmp.Tcp.RtoAlgorithm = value + procSnmp.Tcp.RtoAlgorithm = &value case "RtoMin": - procSnmp.Tcp.RtoMin = value + procSnmp.Tcp.RtoMin = &value case "RtoMax": - procSnmp.Tcp.RtoMax = value + procSnmp.Tcp.RtoMax = &value case "MaxConn": - procSnmp.Tcp.MaxConn = value + procSnmp.Tcp.MaxConn = &value case "ActiveOpens": - procSnmp.Tcp.ActiveOpens = value + procSnmp.Tcp.ActiveOpens = &value case "PassiveOpens": - procSnmp.Tcp.PassiveOpens = value + procSnmp.Tcp.PassiveOpens = &value case "AttemptFails": - procSnmp.Tcp.AttemptFails = value + procSnmp.Tcp.AttemptFails = &value case "EstabResets": - procSnmp.Tcp.EstabResets = value + procSnmp.Tcp.EstabResets = &value case "CurrEstab": - procSnmp.Tcp.CurrEstab = value + procSnmp.Tcp.CurrEstab = &value case "InSegs": - procSnmp.Tcp.InSegs = value + procSnmp.Tcp.InSegs = &value case "OutSegs": - procSnmp.Tcp.OutSegs = value + procSnmp.Tcp.OutSegs = &value case "RetransSegs": - procSnmp.Tcp.RetransSegs = value + procSnmp.Tcp.RetransSegs = &value case "InErrs": - procSnmp.Tcp.InErrs = value + procSnmp.Tcp.InErrs = &value case "OutRsts": - procSnmp.Tcp.OutRsts = value + procSnmp.Tcp.OutRsts = &value case "InCsumErrors": - procSnmp.Tcp.InCsumErrors = value + procSnmp.Tcp.InCsumErrors = &value } case "Udp": switch key { case "InDatagrams": - procSnmp.Udp.InDatagrams = value + procSnmp.Udp.InDatagrams = &value case "NoPorts": - procSnmp.Udp.NoPorts = value + procSnmp.Udp.NoPorts = &value case "InErrors": - procSnmp.Udp.InErrors = value + procSnmp.Udp.InErrors = &value case "OutDatagrams": - procSnmp.Udp.OutDatagrams = value + procSnmp.Udp.OutDatagrams = &value case "RcvbufErrors": - procSnmp.Udp.RcvbufErrors = value + procSnmp.Udp.RcvbufErrors = &value case "SndbufErrors": - procSnmp.Udp.SndbufErrors = value + procSnmp.Udp.SndbufErrors = &value case "InCsumErrors": - procSnmp.Udp.InCsumErrors = value + procSnmp.Udp.InCsumErrors = &value case "IgnoredMulti": - procSnmp.Udp.IgnoredMulti = value + procSnmp.Udp.IgnoredMulti = &value } case "UdpLite": switch key { case "InDatagrams": - procSnmp.UdpLite.InDatagrams = value + procSnmp.UdpLite.InDatagrams = &value case "NoPorts": - procSnmp.UdpLite.NoPorts = value + procSnmp.UdpLite.NoPorts = &value case "InErrors": - procSnmp.UdpLite.InErrors = value + procSnmp.UdpLite.InErrors = &value case "OutDatagrams": - procSnmp.UdpLite.OutDatagrams = value + procSnmp.UdpLite.OutDatagrams = &value case "RcvbufErrors": - procSnmp.UdpLite.RcvbufErrors = value + procSnmp.UdpLite.RcvbufErrors = &value case "SndbufErrors": - procSnmp.UdpLite.SndbufErrors = value + procSnmp.UdpLite.SndbufErrors = &value case "InCsumErrors": - procSnmp.UdpLite.InCsumErrors = value + procSnmp.UdpLite.InCsumErrors = &value case "IgnoredMulti": - procSnmp.UdpLite.IgnoredMulti = value + procSnmp.UdpLite.IgnoredMulti = &value } } } diff --git a/vendor/github.com/prometheus/procfs/proc_snmp6.go b/vendor/github.com/prometheus/procfs/proc_snmp6.go index f611992d5..3059cc6a1 100644 --- a/vendor/github.com/prometheus/procfs/proc_snmp6.go +++ b/vendor/github.com/prometheus/procfs/proc_snmp6.go @@ -36,106 +36,106 @@ type ProcSnmp6 struct { } type Ip6 struct { // nolint:revive - InReceives float64 - InHdrErrors float64 - InTooBigErrors float64 - InNoRoutes float64 - InAddrErrors float64 - InUnknownProtos float64 - InTruncatedPkts float64 - InDiscards float64 - InDelivers float64 - OutForwDatagrams float64 - OutRequests float64 - OutDiscards float64 - OutNoRoutes float64 - ReasmTimeout float64 - ReasmReqds float64 - ReasmOKs float64 - ReasmFails float64 - FragOKs float64 - FragFails float64 - FragCreates float64 - InMcastPkts float64 - OutMcastPkts float64 - InOctets float64 - OutOctets float64 - InMcastOctets float64 - OutMcastOctets float64 - InBcastOctets float64 - OutBcastOctets float64 - InNoECTPkts float64 - InECT1Pkts float64 - InECT0Pkts float64 - InCEPkts float64 + InReceives *float64 + InHdrErrors *float64 + InTooBigErrors *float64 + InNoRoutes *float64 + InAddrErrors *float64 + InUnknownProtos *float64 + InTruncatedPkts *float64 + InDiscards *float64 + InDelivers *float64 + OutForwDatagrams *float64 + OutRequests *float64 + OutDiscards *float64 + OutNoRoutes *float64 + ReasmTimeout *float64 + ReasmReqds *float64 + ReasmOKs *float64 + ReasmFails *float64 + FragOKs *float64 + FragFails *float64 + FragCreates *float64 + InMcastPkts *float64 + OutMcastPkts *float64 + InOctets *float64 + OutOctets *float64 + InMcastOctets *float64 + OutMcastOctets *float64 + InBcastOctets *float64 + OutBcastOctets *float64 + InNoECTPkts *float64 + InECT1Pkts *float64 + InECT0Pkts *float64 + InCEPkts *float64 } type Icmp6 struct { - InMsgs float64 - InErrors float64 - OutMsgs float64 - OutErrors float64 - InCsumErrors float64 - InDestUnreachs float64 - InPktTooBigs float64 - InTimeExcds float64 - InParmProblems float64 - InEchos float64 - InEchoReplies float64 - InGroupMembQueries float64 - InGroupMembResponses float64 - InGroupMembReductions float64 - InRouterSolicits float64 - InRouterAdvertisements float64 - InNeighborSolicits float64 - InNeighborAdvertisements float64 - InRedirects float64 - InMLDv2Reports float64 - OutDestUnreachs float64 - OutPktTooBigs float64 - OutTimeExcds float64 - OutParmProblems float64 - OutEchos float64 - OutEchoReplies float64 - OutGroupMembQueries float64 - OutGroupMembResponses float64 - OutGroupMembReductions float64 - OutRouterSolicits float64 - OutRouterAdvertisements float64 - OutNeighborSolicits float64 - OutNeighborAdvertisements float64 - OutRedirects float64 - OutMLDv2Reports float64 - InType1 float64 - InType134 float64 - InType135 float64 - InType136 float64 - InType143 float64 - OutType133 float64 - OutType135 float64 - OutType136 float64 - OutType143 float64 + InMsgs *float64 + InErrors *float64 + OutMsgs *float64 + OutErrors *float64 + InCsumErrors *float64 + InDestUnreachs *float64 + InPktTooBigs *float64 + InTimeExcds *float64 + InParmProblems *float64 + InEchos *float64 + InEchoReplies *float64 + InGroupMembQueries *float64 + InGroupMembResponses *float64 + InGroupMembReductions *float64 + InRouterSolicits *float64 + InRouterAdvertisements *float64 + InNeighborSolicits *float64 + InNeighborAdvertisements *float64 + InRedirects *float64 + InMLDv2Reports *float64 + OutDestUnreachs *float64 + OutPktTooBigs *float64 + OutTimeExcds *float64 + OutParmProblems *float64 + OutEchos *float64 + OutEchoReplies *float64 + OutGroupMembQueries *float64 + OutGroupMembResponses *float64 + OutGroupMembReductions *float64 + OutRouterSolicits *float64 + OutRouterAdvertisements *float64 + OutNeighborSolicits *float64 + OutNeighborAdvertisements *float64 + OutRedirects *float64 + OutMLDv2Reports *float64 + InType1 *float64 + InType134 *float64 + InType135 *float64 + InType136 *float64 + InType143 *float64 + OutType133 *float64 + OutType135 *float64 + OutType136 *float64 + OutType143 *float64 } type Udp6 struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 - IgnoredMulti float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 + IgnoredMulti *float64 } type UdpLite6 struct { // nolint:revive - InDatagrams float64 - NoPorts float64 - InErrors float64 - OutDatagrams float64 - RcvbufErrors float64 - SndbufErrors float64 - InCsumErrors float64 + InDatagrams *float64 + NoPorts *float64 + InErrors *float64 + OutDatagrams *float64 + RcvbufErrors *float64 + SndbufErrors *float64 + InCsumErrors *float64 } func (p Proc) Snmp6() (ProcSnmp6, error) { @@ -182,197 +182,197 @@ func parseSNMP6Stats(r io.Reader) (ProcSnmp6, error) { case "Ip6": switch key { case "InReceives": - procSnmp6.Ip6.InReceives = value + procSnmp6.Ip6.InReceives = &value case "InHdrErrors": - procSnmp6.Ip6.InHdrErrors = value + procSnmp6.Ip6.InHdrErrors = &value case "InTooBigErrors": - procSnmp6.Ip6.InTooBigErrors = value + procSnmp6.Ip6.InTooBigErrors = &value case "InNoRoutes": - procSnmp6.Ip6.InNoRoutes = value + procSnmp6.Ip6.InNoRoutes = &value case "InAddrErrors": - procSnmp6.Ip6.InAddrErrors = value + procSnmp6.Ip6.InAddrErrors = &value case "InUnknownProtos": - procSnmp6.Ip6.InUnknownProtos = value + procSnmp6.Ip6.InUnknownProtos = &value case "InTruncatedPkts": - procSnmp6.Ip6.InTruncatedPkts = value + procSnmp6.Ip6.InTruncatedPkts = &value case "InDiscards": - procSnmp6.Ip6.InDiscards = value + procSnmp6.Ip6.InDiscards = &value case "InDelivers": - procSnmp6.Ip6.InDelivers = value + procSnmp6.Ip6.InDelivers = &value case "OutForwDatagrams": - procSnmp6.Ip6.OutForwDatagrams = value + procSnmp6.Ip6.OutForwDatagrams = &value case "OutRequests": - procSnmp6.Ip6.OutRequests = value + procSnmp6.Ip6.OutRequests = &value case "OutDiscards": - procSnmp6.Ip6.OutDiscards = value + procSnmp6.Ip6.OutDiscards = &value case "OutNoRoutes": - procSnmp6.Ip6.OutNoRoutes = value + procSnmp6.Ip6.OutNoRoutes = &value case "ReasmTimeout": - procSnmp6.Ip6.ReasmTimeout = value + procSnmp6.Ip6.ReasmTimeout = &value case "ReasmReqds": - procSnmp6.Ip6.ReasmReqds = value + procSnmp6.Ip6.ReasmReqds = &value case "ReasmOKs": - procSnmp6.Ip6.ReasmOKs = value + procSnmp6.Ip6.ReasmOKs = &value case "ReasmFails": - procSnmp6.Ip6.ReasmFails = value + procSnmp6.Ip6.ReasmFails = &value case "FragOKs": - procSnmp6.Ip6.FragOKs = value + procSnmp6.Ip6.FragOKs = &value case "FragFails": - procSnmp6.Ip6.FragFails = value + procSnmp6.Ip6.FragFails = &value case "FragCreates": - procSnmp6.Ip6.FragCreates = value + procSnmp6.Ip6.FragCreates = &value case "InMcastPkts": - procSnmp6.Ip6.InMcastPkts = value + procSnmp6.Ip6.InMcastPkts = &value case "OutMcastPkts": - procSnmp6.Ip6.OutMcastPkts = value + procSnmp6.Ip6.OutMcastPkts = &value case "InOctets": - procSnmp6.Ip6.InOctets = value + procSnmp6.Ip6.InOctets = &value case "OutOctets": - procSnmp6.Ip6.OutOctets = value + procSnmp6.Ip6.OutOctets = &value case "InMcastOctets": - procSnmp6.Ip6.InMcastOctets = value + procSnmp6.Ip6.InMcastOctets = &value case "OutMcastOctets": - procSnmp6.Ip6.OutMcastOctets = value + procSnmp6.Ip6.OutMcastOctets = &value case "InBcastOctets": - procSnmp6.Ip6.InBcastOctets = value + procSnmp6.Ip6.InBcastOctets = &value case "OutBcastOctets": - procSnmp6.Ip6.OutBcastOctets = value + procSnmp6.Ip6.OutBcastOctets = &value case "InNoECTPkts": - procSnmp6.Ip6.InNoECTPkts = value + procSnmp6.Ip6.InNoECTPkts = &value case "InECT1Pkts": - procSnmp6.Ip6.InECT1Pkts = value + procSnmp6.Ip6.InECT1Pkts = &value case "InECT0Pkts": - procSnmp6.Ip6.InECT0Pkts = value + procSnmp6.Ip6.InECT0Pkts = &value case "InCEPkts": - procSnmp6.Ip6.InCEPkts = value + procSnmp6.Ip6.InCEPkts = &value } case "Icmp6": switch key { case "InMsgs": - procSnmp6.Icmp6.InMsgs = value + procSnmp6.Icmp6.InMsgs = &value case "InErrors": - procSnmp6.Icmp6.InErrors = value + procSnmp6.Icmp6.InErrors = &value case "OutMsgs": - procSnmp6.Icmp6.OutMsgs = value + procSnmp6.Icmp6.OutMsgs = &value case "OutErrors": - procSnmp6.Icmp6.OutErrors = value + procSnmp6.Icmp6.OutErrors = &value case "InCsumErrors": - procSnmp6.Icmp6.InCsumErrors = value + procSnmp6.Icmp6.InCsumErrors = &value case "InDestUnreachs": - procSnmp6.Icmp6.InDestUnreachs = value + procSnmp6.Icmp6.InDestUnreachs = &value case "InPktTooBigs": - procSnmp6.Icmp6.InPktTooBigs = value + procSnmp6.Icmp6.InPktTooBigs = &value case "InTimeExcds": - procSnmp6.Icmp6.InTimeExcds = value + procSnmp6.Icmp6.InTimeExcds = &value case "InParmProblems": - procSnmp6.Icmp6.InParmProblems = value + procSnmp6.Icmp6.InParmProblems = &value case "InEchos": - procSnmp6.Icmp6.InEchos = value + procSnmp6.Icmp6.InEchos = &value case "InEchoReplies": - procSnmp6.Icmp6.InEchoReplies = value + procSnmp6.Icmp6.InEchoReplies = &value case "InGroupMembQueries": - procSnmp6.Icmp6.InGroupMembQueries = value + procSnmp6.Icmp6.InGroupMembQueries = &value case "InGroupMembResponses": - procSnmp6.Icmp6.InGroupMembResponses = value + procSnmp6.Icmp6.InGroupMembResponses = &value case "InGroupMembReductions": - procSnmp6.Icmp6.InGroupMembReductions = value + procSnmp6.Icmp6.InGroupMembReductions = &value case "InRouterSolicits": - procSnmp6.Icmp6.InRouterSolicits = value + procSnmp6.Icmp6.InRouterSolicits = &value case "InRouterAdvertisements": - procSnmp6.Icmp6.InRouterAdvertisements = value + procSnmp6.Icmp6.InRouterAdvertisements = &value case "InNeighborSolicits": - procSnmp6.Icmp6.InNeighborSolicits = value + procSnmp6.Icmp6.InNeighborSolicits = &value case "InNeighborAdvertisements": - procSnmp6.Icmp6.InNeighborAdvertisements = value + procSnmp6.Icmp6.InNeighborAdvertisements = &value case "InRedirects": - procSnmp6.Icmp6.InRedirects = value + procSnmp6.Icmp6.InRedirects = &value case "InMLDv2Reports": - procSnmp6.Icmp6.InMLDv2Reports = value + procSnmp6.Icmp6.InMLDv2Reports = &value case "OutDestUnreachs": - procSnmp6.Icmp6.OutDestUnreachs = value + procSnmp6.Icmp6.OutDestUnreachs = &value case "OutPktTooBigs": - procSnmp6.Icmp6.OutPktTooBigs = value + procSnmp6.Icmp6.OutPktTooBigs = &value case "OutTimeExcds": - procSnmp6.Icmp6.OutTimeExcds = value + procSnmp6.Icmp6.OutTimeExcds = &value case "OutParmProblems": - procSnmp6.Icmp6.OutParmProblems = value + procSnmp6.Icmp6.OutParmProblems = &value case "OutEchos": - procSnmp6.Icmp6.OutEchos = value + procSnmp6.Icmp6.OutEchos = &value case "OutEchoReplies": - procSnmp6.Icmp6.OutEchoReplies = value + procSnmp6.Icmp6.OutEchoReplies = &value case "OutGroupMembQueries": - procSnmp6.Icmp6.OutGroupMembQueries = value + procSnmp6.Icmp6.OutGroupMembQueries = &value case "OutGroupMembResponses": - procSnmp6.Icmp6.OutGroupMembResponses = value + procSnmp6.Icmp6.OutGroupMembResponses = &value case "OutGroupMembReductions": - procSnmp6.Icmp6.OutGroupMembReductions = value + procSnmp6.Icmp6.OutGroupMembReductions = &value case "OutRouterSolicits": - procSnmp6.Icmp6.OutRouterSolicits = value + procSnmp6.Icmp6.OutRouterSolicits = &value case "OutRouterAdvertisements": - procSnmp6.Icmp6.OutRouterAdvertisements = value + procSnmp6.Icmp6.OutRouterAdvertisements = &value case "OutNeighborSolicits": - procSnmp6.Icmp6.OutNeighborSolicits = value + procSnmp6.Icmp6.OutNeighborSolicits = &value case "OutNeighborAdvertisements": - procSnmp6.Icmp6.OutNeighborAdvertisements = value + procSnmp6.Icmp6.OutNeighborAdvertisements = &value case "OutRedirects": - procSnmp6.Icmp6.OutRedirects = value + procSnmp6.Icmp6.OutRedirects = &value case "OutMLDv2Reports": - procSnmp6.Icmp6.OutMLDv2Reports = value + procSnmp6.Icmp6.OutMLDv2Reports = &value case "InType1": - procSnmp6.Icmp6.InType1 = value + procSnmp6.Icmp6.InType1 = &value case "InType134": - procSnmp6.Icmp6.InType134 = value + procSnmp6.Icmp6.InType134 = &value case "InType135": - procSnmp6.Icmp6.InType135 = value + procSnmp6.Icmp6.InType135 = &value case "InType136": - procSnmp6.Icmp6.InType136 = value + procSnmp6.Icmp6.InType136 = &value case "InType143": - procSnmp6.Icmp6.InType143 = value + procSnmp6.Icmp6.InType143 = &value case "OutType133": - procSnmp6.Icmp6.OutType133 = value + procSnmp6.Icmp6.OutType133 = &value case "OutType135": - procSnmp6.Icmp6.OutType135 = value + procSnmp6.Icmp6.OutType135 = &value case "OutType136": - procSnmp6.Icmp6.OutType136 = value + procSnmp6.Icmp6.OutType136 = &value case "OutType143": - procSnmp6.Icmp6.OutType143 = value + procSnmp6.Icmp6.OutType143 = &value } case "Udp6": switch key { case "InDatagrams": - procSnmp6.Udp6.InDatagrams = value + procSnmp6.Udp6.InDatagrams = &value case "NoPorts": - procSnmp6.Udp6.NoPorts = value + procSnmp6.Udp6.NoPorts = &value case "InErrors": - procSnmp6.Udp6.InErrors = value + procSnmp6.Udp6.InErrors = &value case "OutDatagrams": - procSnmp6.Udp6.OutDatagrams = value + procSnmp6.Udp6.OutDatagrams = &value case "RcvbufErrors": - procSnmp6.Udp6.RcvbufErrors = value + procSnmp6.Udp6.RcvbufErrors = &value case "SndbufErrors": - procSnmp6.Udp6.SndbufErrors = value + procSnmp6.Udp6.SndbufErrors = &value case "InCsumErrors": - procSnmp6.Udp6.InCsumErrors = value + procSnmp6.Udp6.InCsumErrors = &value case "IgnoredMulti": - procSnmp6.Udp6.IgnoredMulti = value + procSnmp6.Udp6.IgnoredMulti = &value } case "UdpLite6": switch key { case "InDatagrams": - procSnmp6.UdpLite6.InDatagrams = value + procSnmp6.UdpLite6.InDatagrams = &value case "NoPorts": - procSnmp6.UdpLite6.NoPorts = value + procSnmp6.UdpLite6.NoPorts = &value case "InErrors": - procSnmp6.UdpLite6.InErrors = value + procSnmp6.UdpLite6.InErrors = &value case "OutDatagrams": - procSnmp6.UdpLite6.OutDatagrams = value + procSnmp6.UdpLite6.OutDatagrams = &value case "RcvbufErrors": - procSnmp6.UdpLite6.RcvbufErrors = value + procSnmp6.UdpLite6.RcvbufErrors = &value case "SndbufErrors": - procSnmp6.UdpLite6.SndbufErrors = value + procSnmp6.UdpLite6.SndbufErrors = &value case "InCsumErrors": - procSnmp6.UdpLite6.InCsumErrors = value + procSnmp6.UdpLite6.InCsumErrors = &value } } } diff --git a/vendor/github.com/prometheus/procfs/proc_stat.go b/vendor/github.com/prometheus/procfs/proc_stat.go index 06c556ef9..923e55005 100644 --- a/vendor/github.com/prometheus/procfs/proc_stat.go +++ b/vendor/github.com/prometheus/procfs/proc_stat.go @@ -18,7 +18,6 @@ import ( "fmt" "os" - "github.com/prometheus/procfs/internal/fs" "github.com/prometheus/procfs/internal/util" ) @@ -102,6 +101,8 @@ type ProcStat struct { RSS int // Soft limit in bytes on the rss of the process. RSSLimit uint64 + // CPU number last executed on. + Processor uint // Real-time scheduling priority, a number in the range 1 to 99 for processes // scheduled under a real-time policy, or 0, for non-real-time processes. RTPriority uint @@ -110,7 +111,7 @@ type ProcStat struct { // Aggregated block I/O delays, measured in clock ticks (centiseconds). DelayAcctBlkIOTicks uint64 - proc fs.FS + proc FS } // NewStat returns the current status information of the process. @@ -137,7 +138,7 @@ func (p Proc) Stat() (ProcStat, error) { ) if l < 0 || r < 0 { - return ProcStat{}, fmt.Errorf("unexpected format, couldn't extract comm %q", data) + return ProcStat{}, fmt.Errorf("%w: unexpected format, couldn't extract comm %q", ErrFileParse, data) } s.Comm = string(data[l+1 : r]) @@ -184,7 +185,7 @@ func (p Proc) Stat() (ProcStat, error) { &ignoreUint64, &ignoreUint64, &ignoreInt64, - &ignoreInt64, + &s.Processor, &s.RTPriority, &s.Policy, &s.DelayAcctBlkIOTicks, @@ -208,8 +209,7 @@ func (s ProcStat) ResidentMemory() int { // StartTime returns the unix timestamp of the process in seconds. func (s ProcStat) StartTime() (float64, error) { - fs := FS{proc: s.proc} - stat, err := fs.Stat() + stat, err := s.proc.Stat() if err != nil { return 0, err } diff --git a/vendor/github.com/prometheus/procfs/proc_status.go b/vendor/github.com/prometheus/procfs/proc_status.go index 594022ded..c055d075d 100644 --- a/vendor/github.com/prometheus/procfs/proc_status.go +++ b/vendor/github.com/prometheus/procfs/proc_status.go @@ -15,6 +15,7 @@ package procfs import ( "bytes" + "sort" "strconv" "strings" @@ -76,6 +77,9 @@ type ProcStatus struct { UIDs [4]string // GIDs of the process (Real, effective, saved set, and filesystem GIDs) GIDs [4]string + + // CpusAllowedList: List of cpu cores processes are allowed to run on. + CpusAllowedList []uint64 } // NewStatus returns the current status information of the process. @@ -96,10 +100,10 @@ func (p Proc) NewStatus() (ProcStatus, error) { kv := strings.SplitN(line, ":", 2) // removes spaces - k := string(strings.TrimSpace(kv[0])) - v := string(strings.TrimSpace(kv[1])) + k := strings.TrimSpace(kv[0]) + v := strings.TrimSpace(kv[1]) // removes "kB" - v = string(bytes.Trim([]byte(v), " kB")) + v = strings.TrimSuffix(v, " kB") // value to int when possible // we can skip error check here, 'cause vKBytes is not used when value is a string @@ -161,10 +165,38 @@ func (s *ProcStatus) fillStatus(k string, vString string, vUint uint64, vUintByt s.VoluntaryCtxtSwitches = vUint case "nonvoluntary_ctxt_switches": s.NonVoluntaryCtxtSwitches = vUint + case "Cpus_allowed_list": + s.CpusAllowedList = calcCpusAllowedList(vString) } + } // TotalCtxtSwitches returns the total context switch. func (s ProcStatus) TotalCtxtSwitches() uint64 { return s.VoluntaryCtxtSwitches + s.NonVoluntaryCtxtSwitches } + +func calcCpusAllowedList(cpuString string) []uint64 { + s := strings.Split(cpuString, ",") + + var g []uint64 + + for _, cpu := range s { + // parse cpu ranges, example: 1-3=[1,2,3] + if l := strings.Split(strings.TrimSpace(cpu), "-"); len(l) > 1 { + startCPU, _ := strconv.ParseUint(l[0], 10, 64) + endCPU, _ := strconv.ParseUint(l[1], 10, 64) + + for i := startCPU; i <= endCPU; i++ { + g = append(g, i) + } + } else if len(l) == 1 { + cpu, _ := strconv.ParseUint(l[0], 10, 64) + g = append(g, cpu) + } + + } + + sort.Slice(g, func(i, j int) bool { return g[i] < g[j] }) + return g +} diff --git a/vendor/github.com/prometheus/procfs/proc_sys.go b/vendor/github.com/prometheus/procfs/proc_sys.go index d46533ebf..12c5bf05b 100644 --- a/vendor/github.com/prometheus/procfs/proc_sys.go +++ b/vendor/github.com/prometheus/procfs/proc_sys.go @@ -44,7 +44,7 @@ func (fs FS) SysctlInts(sysctl string) ([]int, error) { vp := util.NewValueParser(f) values[i] = vp.Int() if err := vp.Err(); err != nil { - return nil, fmt.Errorf("field %d in sysctl %s is not a valid int: %w", i, sysctl, err) + return nil, fmt.Errorf("%s: field %d in sysctl %s is not a valid int: %w", ErrFileParse, i, sysctl, err) } } return values, nil diff --git a/vendor/github.com/prometheus/procfs/slab.go b/vendor/github.com/prometheus/procfs/slab.go index bc9aaf5c2..8611c9017 100644 --- a/vendor/github.com/prometheus/procfs/slab.go +++ b/vendor/github.com/prometheus/procfs/slab.go @@ -68,7 +68,7 @@ func parseV21SlabEntry(line string) (*Slab, error) { l := slabSpace.ReplaceAllString(line, " ") s := strings.Split(l, " ") if len(s) != 16 { - return nil, fmt.Errorf("unable to parse: %q", line) + return nil, fmt.Errorf("%w: unable to parse: %q", ErrFileParse, line) } var err error i := &Slab{Name: s[0]} diff --git a/vendor/github.com/prometheus/procfs/softirqs.go b/vendor/github.com/prometheus/procfs/softirqs.go index 559129cbc..b8fad677d 100644 --- a/vendor/github.com/prometheus/procfs/softirqs.go +++ b/vendor/github.com/prometheus/procfs/softirqs.go @@ -57,7 +57,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { ) if !scanner.Scan() { - return Softirqs{}, fmt.Errorf("softirqs empty") + return Softirqs{}, fmt.Errorf("%w: softirqs empty", ErrFileRead) } for scanner.Scan() { @@ -74,7 +74,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Hi = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Hi[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (HI%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (HI%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "TIMER:": @@ -82,7 +82,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Timer = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Timer[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (TIMER%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (TIMER%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "NET_TX:": @@ -90,7 +90,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.NetTx = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.NetTx[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (NET_TX%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (NET_TX%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "NET_RX:": @@ -98,7 +98,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.NetRx = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.NetRx[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (NET_RX%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (NET_RX%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "BLOCK:": @@ -106,7 +106,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Block = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Block[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (BLOCK%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (BLOCK%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "IRQ_POLL:": @@ -114,7 +114,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.IRQPoll = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.IRQPoll[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (IRQ_POLL%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (IRQ_POLL%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "TASKLET:": @@ -122,7 +122,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Tasklet = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Tasklet[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (TASKLET%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (TASKLET%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "SCHED:": @@ -130,7 +130,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.Sched = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.Sched[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (SCHED%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (SCHED%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "HRTIMER:": @@ -138,7 +138,7 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.HRTimer = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.HRTimer[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (HRTIMER%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (HRTIMER%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "RCU:": @@ -146,14 +146,14 @@ func parseSoftirqs(r io.Reader) (Softirqs, error) { softirqs.RCU = make([]uint64, len(perCPU)) for i, count := range perCPU { if softirqs.RCU[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse %q (RCU%d): %w", count, i, err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse %q (RCU%d): %w", ErrFileParse, count, i, err) } } } } if err := scanner.Err(); err != nil { - return Softirqs{}, fmt.Errorf("couldn't parse softirqs: %w", err) + return Softirqs{}, fmt.Errorf("%s: couldn't parse softirqs: %w", ErrFileParse, err) } return softirqs, scanner.Err() diff --git a/vendor/github.com/prometheus/procfs/stat.go b/vendor/github.com/prometheus/procfs/stat.go index 33f97caa0..05269c896 100644 --- a/vendor/github.com/prometheus/procfs/stat.go +++ b/vendor/github.com/prometheus/procfs/stat.go @@ -62,7 +62,7 @@ type Stat struct { // Summed up cpu statistics. CPUTotal CPUStat // Per-CPU statistics. - CPU []CPUStat + CPU map[int64]CPUStat // Number of times interrupts were handled, which contains numbered and unnumbered IRQs. IRQTotal uint64 // Number of times a numbered IRQ was triggered. @@ -93,10 +93,10 @@ func parseCPUStat(line string) (CPUStat, int64, error) { &cpuStat.Guest, &cpuStat.GuestNice) if err != nil && err != io.EOF { - return CPUStat{}, -1, fmt.Errorf("couldn't parse %q (cpu): %w", line, err) + return CPUStat{}, -1, fmt.Errorf("%s: couldn't parse %q (cpu): %w", ErrFileParse, line, err) } if count == 0 { - return CPUStat{}, -1, fmt.Errorf("couldn't parse %q (cpu): 0 elements parsed", line) + return CPUStat{}, -1, fmt.Errorf("%w: couldn't parse %q (cpu): 0 elements parsed", ErrFileParse, line) } cpuStat.User /= userHZ @@ -116,7 +116,7 @@ func parseCPUStat(line string) (CPUStat, int64, error) { cpuID, err := strconv.ParseInt(cpu[3:], 10, 64) if err != nil { - return CPUStat{}, -1, fmt.Errorf("couldn't parse %q (cpu/cpuid): %w", line, err) + return CPUStat{}, -1, fmt.Errorf("%s: couldn't parse %q (cpu/cpuid): %w", ErrFileParse, line, err) } return cpuStat, cpuID, nil @@ -136,7 +136,7 @@ func parseSoftIRQStat(line string) (SoftIRQStat, uint64, error) { &softIRQStat.Hrtimer, &softIRQStat.Rcu) if err != nil { - return SoftIRQStat{}, 0, fmt.Errorf("couldn't parse %q (softirq): %w", line, err) + return SoftIRQStat{}, 0, fmt.Errorf("%s: couldn't parse %q (softirq): %w", ErrFileParse, line, err) } return softIRQStat, total, nil @@ -170,10 +170,23 @@ func (fs FS) Stat() (Stat, error) { if err != nil { return Stat{}, err } + procStat, err := parseStat(bytes.NewReader(data), fileName) + if err != nil { + return Stat{}, err + } + return procStat, nil +} - stat := Stat{} +// parseStat parses the metrics from /proc/[pid]/stat. +func parseStat(r io.Reader, fileName string) (Stat, error) { + var ( + scanner = bufio.NewScanner(r) + stat = Stat{ + CPU: make(map[int64]CPUStat), + } + err error + ) - scanner := bufio.NewScanner(bytes.NewReader(data)) for scanner.Scan() { line := scanner.Text() parts := strings.Fields(scanner.Text()) @@ -184,34 +197,34 @@ func (fs FS) Stat() (Stat, error) { switch { case parts[0] == "btime": if stat.BootTime, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (btime): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (btime): %w", ErrFileParse, parts[1], err) } case parts[0] == "intr": if stat.IRQTotal, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (intr): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (intr): %w", ErrFileParse, parts[1], err) } numberedIRQs := parts[2:] stat.IRQ = make([]uint64, len(numberedIRQs)) for i, count := range numberedIRQs { if stat.IRQ[i], err = strconv.ParseUint(count, 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (intr%d): %w", count, i, err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (intr%d): %w", ErrFileParse, count, i, err) } } case parts[0] == "ctxt": if stat.ContextSwitches, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (ctxt): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (ctxt): %w", ErrFileParse, parts[1], err) } case parts[0] == "processes": if stat.ProcessCreated, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (processes): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (processes): %w", ErrFileParse, parts[1], err) } case parts[0] == "procs_running": if stat.ProcessesRunning, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (procs_running): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (procs_running): %w", ErrFileParse, parts[1], err) } case parts[0] == "procs_blocked": if stat.ProcessesBlocked, err = strconv.ParseUint(parts[1], 10, 64); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q (procs_blocked): %w", parts[1], err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q (procs_blocked): %w", ErrFileParse, parts[1], err) } case parts[0] == "softirq": softIRQStats, total, err := parseSoftIRQStat(line) @@ -228,16 +241,13 @@ func (fs FS) Stat() (Stat, error) { if cpuID == -1 { stat.CPUTotal = cpuStat } else { - for int64(len(stat.CPU)) <= cpuID { - stat.CPU = append(stat.CPU, CPUStat{}) - } stat.CPU[cpuID] = cpuStat } } } if err := scanner.Err(); err != nil { - return Stat{}, fmt.Errorf("couldn't parse %q: %w", fileName, err) + return Stat{}, fmt.Errorf("%s: couldn't parse %q: %w", ErrFileParse, fileName, err) } return stat, nil diff --git a/vendor/github.com/prometheus/procfs/swaps.go b/vendor/github.com/prometheus/procfs/swaps.go index 15edc2212..fa00f555d 100644 --- a/vendor/github.com/prometheus/procfs/swaps.go +++ b/vendor/github.com/prometheus/procfs/swaps.go @@ -64,7 +64,7 @@ func parseSwapString(swapString string) (*Swap, error) { swapFields := strings.Fields(swapString) swapLength := len(swapFields) if swapLength < 5 { - return nil, fmt.Errorf("too few fields in swap string: %s", swapString) + return nil, fmt.Errorf("%w: too few fields in swap string: %s", ErrFileParse, swapString) } swap := &Swap{ @@ -74,15 +74,15 @@ func parseSwapString(swapString string) (*Swap, error) { swap.Size, err = strconv.Atoi(swapFields[2]) if err != nil { - return nil, fmt.Errorf("invalid swap size: %s", swapFields[2]) + return nil, fmt.Errorf("%s: invalid swap size: %s: %w", ErrFileParse, swapFields[2], err) } swap.Used, err = strconv.Atoi(swapFields[3]) if err != nil { - return nil, fmt.Errorf("invalid swap used: %s", swapFields[3]) + return nil, fmt.Errorf("%s: invalid swap used: %s: %w", ErrFileParse, swapFields[3], err) } swap.Priority, err = strconv.Atoi(swapFields[4]) if err != nil { - return nil, fmt.Errorf("invalid swap priority: %s", swapFields[4]) + return nil, fmt.Errorf("%s: invalid swap priority: %s: %w", ErrFileParse, swapFields[4], err) } return swap, nil diff --git a/vendor/github.com/prometheus/procfs/thread.go b/vendor/github.com/prometheus/procfs/thread.go new file mode 100644 index 000000000..394762c73 --- /dev/null +++ b/vendor/github.com/prometheus/procfs/thread.go @@ -0,0 +1,80 @@ +// Copyright 2022 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package procfs + +import ( + "fmt" + "os" + "strconv" + + fsi "github.com/prometheus/procfs/internal/fs" +) + +// Provide access to /proc/PID/task/TID files, for thread specific values. Since +// such files have the same structure as /proc/PID/ ones, the data structures +// and the parsers for the latter may be reused. + +// AllThreads returns a list of all currently available threads under /proc/PID. +func AllThreads(pid int) (Procs, error) { + fs, err := NewFS(DefaultMountPoint) + if err != nil { + return Procs{}, err + } + return fs.AllThreads(pid) +} + +// AllThreads returns a list of all currently available threads for PID. +func (fs FS) AllThreads(pid int) (Procs, error) { + taskPath := fs.proc.Path(strconv.Itoa(pid), "task") + d, err := os.Open(taskPath) + if err != nil { + return Procs{}, err + } + defer d.Close() + + names, err := d.Readdirnames(-1) + if err != nil { + return Procs{}, fmt.Errorf("%s: could not read %q: %w", ErrFileRead, d.Name(), err) + } + + t := Procs{} + for _, n := range names { + tid, err := strconv.ParseInt(n, 10, 64) + if err != nil { + continue + } + + t = append(t, Proc{PID: int(tid), fs: FS{fsi.FS(taskPath), fs.real}}) + } + + return t, nil +} + +// Thread returns a process for a given PID, TID. +func (fs FS) Thread(pid, tid int) (Proc, error) { + taskPath := fs.proc.Path(strconv.Itoa(pid), "task") + if _, err := os.Stat(taskPath); err != nil { + return Proc{}, err + } + return Proc{PID: tid, fs: FS{fsi.FS(taskPath), fs.real}}, nil +} + +// Thread returns a process for a given TID of Proc. +func (proc Proc) Thread(tid int) (Proc, error) { + tfs := FS{fsi.FS(proc.path("task")), proc.fs.real} + if _, err := os.Stat(tfs.proc.Path(strconv.Itoa(tid))); err != nil { + return Proc{}, err + } + return Proc{PID: tid, fs: tfs}, nil +} diff --git a/vendor/github.com/prometheus/procfs/vm.go b/vendor/github.com/prometheus/procfs/vm.go index 20ceb77e2..51c49d89e 100644 --- a/vendor/github.com/prometheus/procfs/vm.go +++ b/vendor/github.com/prometheus/procfs/vm.go @@ -26,7 +26,9 @@ import ( ) // The VM interface is described at -// https://www.kernel.org/doc/Documentation/sysctl/vm.txt +// +// https://www.kernel.org/doc/Documentation/sysctl/vm.txt +// // Each setting is exposed as a single file. // Each file contains one line with a single numerical value, except lowmem_reserve_ratio which holds an array // and numa_zonelist_order (deprecated) which is a string. @@ -84,7 +86,7 @@ func (fs FS) VM() (*VM, error) { return nil, err } if !file.Mode().IsDir() { - return nil, fmt.Errorf("%s is not a directory", path) + return nil, fmt.Errorf("%w: %s is not a directory", ErrFileRead, path) } files, err := os.ReadDir(path) diff --git a/vendor/github.com/prometheus/procfs/zoneinfo.go b/vendor/github.com/prometheus/procfs/zoneinfo.go index c745a4c04..ce5fefa5b 100644 --- a/vendor/github.com/prometheus/procfs/zoneinfo.go +++ b/vendor/github.com/prometheus/procfs/zoneinfo.go @@ -75,11 +75,11 @@ var nodeZoneRE = regexp.MustCompile(`(\d+), zone\s+(\w+)`) func (fs FS) Zoneinfo() ([]Zoneinfo, error) { data, err := os.ReadFile(fs.proc.Path("zoneinfo")) if err != nil { - return nil, fmt.Errorf("error reading zoneinfo %q: %w", fs.proc.Path("zoneinfo"), err) + return nil, fmt.Errorf("%s: error reading zoneinfo %q: %w", ErrFileRead, fs.proc.Path("zoneinfo"), err) } zoneinfo, err := parseZoneinfo(data) if err != nil { - return nil, fmt.Errorf("error parsing zoneinfo %q: %w", fs.proc.Path("zoneinfo"), err) + return nil, fmt.Errorf("%s: error parsing zoneinfo %q: %w", ErrFileParse, fs.proc.Path("zoneinfo"), err) } return zoneinfo, nil } diff --git a/vendor/github.com/rogpeppe/go-internal/fmtsort/mapelem.go b/vendor/github.com/rogpeppe/go-internal/fmtsort/mapelem.go index 4e4c29459..98e4e38f4 100644 --- a/vendor/github.com/rogpeppe/go-internal/fmtsort/mapelem.go +++ b/vendor/github.com/rogpeppe/go-internal/fmtsort/mapelem.go @@ -1,6 +1,3 @@ -//go:build go1.12 -// +build go1.12 - package fmtsort import "reflect" diff --git a/vendor/github.com/rogpeppe/go-internal/fmtsort/mapelem_1.11.go b/vendor/github.com/rogpeppe/go-internal/fmtsort/mapelem_1.11.go deleted file mode 100644 index 873bf7f5e..000000000 --- a/vendor/github.com/rogpeppe/go-internal/fmtsort/mapelem_1.11.go +++ /dev/null @@ -1,24 +0,0 @@ -//go:build !go1.12 -// +build !go1.12 - -package fmtsort - -import "reflect" - -const brokenNaNs = true - -func mapElems(mapValue reflect.Value) ([]reflect.Value, []reflect.Value) { - key := mapValue.MapKeys() - value := make([]reflect.Value, 0, len(key)) - for _, k := range key { - v := mapValue.MapIndex(k) - if !v.IsValid() { - // Note: we can't retrieve the value, probably because - // the key is NaN, so just do the best we can and - // add a zero value of the correct type in that case. - v = reflect.Zero(mapValue.Type().Elem()) - } - value = append(value, v) - } - return key, value -} diff --git a/vendor/github.com/rogpeppe/go-internal/fmtsort/sort.go b/vendor/github.com/rogpeppe/go-internal/fmtsort/sort.go index 0fb5187dd..7f5185417 100644 --- a/vendor/github.com/rogpeppe/go-internal/fmtsort/sort.go +++ b/vendor/github.com/rogpeppe/go-internal/fmtsort/sort.go @@ -36,19 +36,18 @@ func (o *SortedMap) Swap(i, j int) { // // The ordering rules are more general than with Go's < operator: // -// - when applicable, nil compares low -// - ints, floats, and strings order by < -// - NaN compares less than non-NaN floats -// - bool compares false before true -// - complex compares real, then imag -// - pointers compare by machine address -// - channel values compare by machine address -// - structs compare each field in turn -// - arrays compare each element in turn. -// Otherwise identical arrays compare by length. -// - interface values compare first by reflect.Type describing the concrete type -// and then by concrete value as described in the previous rules. -// +// - when applicable, nil compares low +// - ints, floats, and strings order by < +// - NaN compares less than non-NaN floats +// - bool compares false before true +// - complex compares real, then imag +// - pointers compare by machine address +// - channel values compare by machine address +// - structs compare each field in turn +// - arrays compare each element in turn. +// Otherwise identical arrays compare by length. +// - interface values compare first by reflect.Type describing the concrete type +// and then by concrete value as described in the previous rules. func Sort(mapValue reflect.Value) *SortedMap { if mapValue.Type().Kind() != reflect.Map { return nil diff --git a/vendor/github.com/shirou/gopsutil/v3/common/env.go b/vendor/github.com/shirou/gopsutil/v3/common/env.go new file mode 100644 index 000000000..4b5f4980c --- /dev/null +++ b/vendor/github.com/shirou/gopsutil/v3/common/env.go @@ -0,0 +1,23 @@ +package common + +type EnvKeyType string + +// EnvKey is a context key that can be used to set programmatically the environment +// gopsutil relies on to perform calls against the OS. +// Example of use: +// +// ctx := context.WithValue(context.Background(), common.EnvKey, EnvMap{common.HostProcEnvKey: "/myproc"}) +// avg, err := load.AvgWithContext(ctx) +var EnvKey = EnvKeyType("env") + +const ( + HostProcEnvKey EnvKeyType = "HOST_PROC" + HostSysEnvKey EnvKeyType = "HOST_SYS" + HostEtcEnvKey EnvKeyType = "HOST_ETC" + HostVarEnvKey EnvKeyType = "HOST_VAR" + HostRunEnvKey EnvKeyType = "HOST_RUN" + HostDevEnvKey EnvKeyType = "HOST_DEV" + HostRootEnvKey EnvKeyType = "HOST_ROOT" +) + +type EnvMap map[EnvKeyType]string diff --git a/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go b/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go index 7acb258d9..41f395e5e 100644 --- a/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" + "github.com/shoenig/go-m1cpu" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" ) @@ -85,11 +86,15 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.CacheSize = int32(cacheSize) c.VendorID, _ = unix.Sysctl("machdep.cpu.vendor") - // Use the rated frequency of the CPU. This is a static value and does not - // account for low power or Turbo Boost modes. - cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") - if err == nil { - c.Mhz = float64(cpuFrequency) / 1000000.0 + if m1cpu.IsAppleSilicon() { + c.Mhz = float64(m1cpu.PCoreHz() / 1_000_000) + } else { + // Use the rated frequency of the CPU. This is a static value and does not + // account for low power or Turbo Boost modes. + cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") + if err == nil { + c.Mhz = float64(cpuFrequency) / 1000000.0 + } } return append(ret, c), nil diff --git a/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go b/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go index 962d34300..1b64241ce 100644 --- a/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go +++ b/vendor/github.com/shirou/gopsutil/v3/cpu/cpu_linux.go @@ -11,8 +11,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "github.com/tklauser/go-sysconf" + + "github.com/shirou/gopsutil/v3/internal/common" ) var ClocksPerSec = float64(100) @@ -95,7 +96,7 @@ func Times(percpu bool) ([]TimesStat, error) { } func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { - filename := common.HostProc("stat") + filename := common.HostProcWithContext(ctx, "stat") lines := []string{} if percpu { statlines, err := common.ReadLines(filename) @@ -125,17 +126,17 @@ func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { return ret, nil } -func sysCPUPath(cpu int32, relPath string) string { - return common.HostSys(fmt.Sprintf("devices/system/cpu/cpu%d", cpu), relPath) +func sysCPUPath(ctx context.Context, cpu int32, relPath string) string { + return common.HostSysWithContext(ctx, fmt.Sprintf("devices/system/cpu/cpu%d", cpu), relPath) } -func finishCPUInfo(c *InfoStat) { +func finishCPUInfo(ctx context.Context, c *InfoStat) { var lines []string var err error var value float64 if len(c.CoreID) == 0 { - lines, err = common.ReadLines(sysCPUPath(c.CPU, "topology/core_id")) + lines, err = common.ReadLines(sysCPUPath(ctx, c.CPU, "topology/core_id")) if err == nil { c.CoreID = lines[0] } @@ -144,7 +145,7 @@ func finishCPUInfo(c *InfoStat) { // override the value of c.Mhz with cpufreq/cpuinfo_max_freq regardless // of the value from /proc/cpuinfo because we want to report the maximum // clock-speed of the CPU for c.Mhz, matching the behaviour of Windows - lines, err = common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq")) + lines, err = common.ReadLines(sysCPUPath(ctx, c.CPU, "cpufreq/cpuinfo_max_freq")) // if we encounter errors below such as there are no cpuinfo_max_freq file, // we just ignore. so let Mhz is 0. if err != nil || len(lines) == 0 { @@ -172,7 +173,7 @@ func Info() ([]InfoStat, error) { } func InfoWithContext(ctx context.Context) ([]InfoStat, error) { - filename := common.HostProc("cpuinfo") + filename := common.HostProcWithContext(ctx, "cpuinfo") lines, _ := common.ReadLines(filename) var ret []InfoStat @@ -192,7 +193,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { processorName = value case "processor", "cpu number": if c.CPU >= 0 { - finishCPUInfo(&c) + finishCPUInfo(ctx, &c) ret = append(ret, c) } c = InfoStat{Cores: 1, ModelName: processorName} @@ -300,7 +301,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { } } if c.CPU >= 0 { - finishCPUInfo(&c) + finishCPUInfo(ctx, &c) ret = append(ret, c) } return ret, nil @@ -389,7 +390,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { if logical { ret := 0 // https://github.com/giampaolo/psutil/blob/d01a9eaa35a8aadf6c519839e987a49d8be2d891/psutil/_pslinux.py#L599 - procCpuinfo := common.HostProc("cpuinfo") + procCpuinfo := common.HostProcWithContext(ctx, "cpuinfo") lines, err := common.ReadLines(procCpuinfo) if err == nil { for _, line := range lines { @@ -403,7 +404,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { } } if ret == 0 { - procStat := common.HostProc("stat") + procStat := common.HostProcWithContext(ctx, "stat") lines, err = common.ReadLines(procStat) if err != nil { return 0, err @@ -424,7 +425,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { // https://github.com/giampaolo/psutil/pull/1727#issuecomment-707624964 // https://lkml.org/lkml/2019/2/26/41 for _, glob := range []string{"devices/system/cpu/cpu[0-9]*/topology/core_cpus_list", "devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list"} { - if files, err := filepath.Glob(common.HostSys(glob)); err == nil { + if files, err := filepath.Glob(common.HostSysWithContext(ctx, glob)); err == nil { for _, file := range files { lines, err := common.ReadLines(file) if err != nil || len(lines) != 1 { @@ -439,7 +440,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) { } } // https://github.com/giampaolo/psutil/blob/122174a10b75c9beebe15f6c07dcf3afbe3b120d/psutil/_pslinux.py#L631-L652 - filename := common.HostProc("cpuinfo") + filename := common.HostProcWithContext(ctx, "cpuinfo") lines, err := common.ReadLines(filename) if err != nil { return 0, err diff --git a/vendor/github.com/shirou/gopsutil/v3/disk/disk.go b/vendor/github.com/shirou/gopsutil/v3/disk/disk.go index dd4cc1d5f..0d4b25345 100644 --- a/vendor/github.com/shirou/gopsutil/v3/disk/disk.go +++ b/vendor/github.com/shirou/gopsutil/v3/disk/disk.go @@ -9,6 +9,8 @@ import ( var invoke common.Invoker = common.Invoke{} +type Warnings = common.Warnings + type UsageStat struct { Path string `json:"path"` Fstype string `json:"fstype"` diff --git a/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go b/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go index 933cb0454..9362d9e5d 100644 --- a/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v3/disk/disk_darwin.go @@ -6,8 +6,9 @@ package disk import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) // PartitionsWithContext returns disk partition. diff --git a/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go b/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go index b6a3adcf5..2a8c50ae4 100644 --- a/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go +++ b/vendor/github.com/shirou/gopsutil/v3/disk/disk_linux.go @@ -16,8 +16,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) const ( @@ -259,10 +260,10 @@ func readMountFile(root string) (lines []string, useMounts bool, filename string func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) { // by default, try "/proc/1/..." first - root := common.HostProc(path.Join("1")) + root := common.HostProcWithContext(ctx, path.Join("1")) // force preference for dirname of HOST_PROC_MOUNTINFO, if set #1271 - hpmPath := os.Getenv("HOST_PROC_MOUNTINFO") + hpmPath := common.HostProcMountInfoWithContext(ctx) if hpmPath != "" { root = filepath.Dir(hpmPath) } @@ -273,13 +274,13 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro return nil, err } // fallback to "/proc/self/..." #1159 - lines, useMounts, filename, err = readMountFile(common.HostProc(path.Join("self"))) + lines, useMounts, filename, err = readMountFile(common.HostProcWithContext(ctx, path.Join("self"))) if err != nil { return nil, err } } - fs, err := getFileSystems() + fs, err := getFileSystems(ctx) if err != nil && !all { return nil, err } @@ -341,7 +342,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro } if strings.HasPrefix(d.Device, "/dev/mapper/") { - devpath, err := filepath.EvalSymlinks(common.HostDev(strings.Replace(d.Device, "/dev", "", 1))) + devpath, err := filepath.EvalSymlinks(common.HostDevWithContext(ctx, strings.Replace(d.Device, "/dev", "", 1))) if err == nil { d.Device = devpath } @@ -350,7 +351,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro // /dev/root is not the real device name // so we get the real device name from its major/minor number if d.Device == "/dev/root" { - devpath, err := os.Readlink(common.HostSys("/dev/block/" + blockDeviceID)) + devpath, err := os.Readlink(common.HostSysWithContext(ctx, "/dev/block/"+blockDeviceID)) if err == nil { d.Device = strings.Replace(d.Device, "root", filepath.Base(devpath), 1) } @@ -363,8 +364,8 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro } // getFileSystems returns supported filesystems from /proc/filesystems -func getFileSystems() ([]string, error) { - filename := common.HostProc("filesystems") +func getFileSystems(ctx context.Context) ([]string, error) { + filename := common.HostProcWithContext(ctx, "filesystems") lines, err := common.ReadLines(filename) if err != nil { return nil, err @@ -386,7 +387,7 @@ func getFileSystems() ([]string, error) { } func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) { - filename := common.HostProc("diskstats") + filename := common.HostProcWithContext(ctx, "diskstats") lines, err := common.ReadLines(filename) if err != nil { return nil, err @@ -491,7 +492,7 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) { minor := unix.Minor(uint64(stat.Rdev)) // Try to get the serial from udev data - udevDataPath := common.HostRun(fmt.Sprintf("udev/data/b%d:%d", major, minor)) + udevDataPath := common.HostRunWithContext(ctx, fmt.Sprintf("udev/data/b%d:%d", major, minor)) if udevdata, err := ioutil.ReadFile(udevDataPath); err == nil { scanner := bufio.NewScanner(bytes.NewReader(udevdata)) for scanner.Scan() { @@ -504,7 +505,7 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) { // Try to get the serial from sysfs, look at the disk device (minor 0) directly // because if it is a partition it is not going to contain any device information - devicePath := common.HostSys(fmt.Sprintf("dev/block/%d:0/device", major)) + devicePath := common.HostSysWithContext(ctx, fmt.Sprintf("dev/block/%d:0/device", major)) model, _ := ioutil.ReadFile(filepath.Join(devicePath, "model")) serial, _ := ioutil.ReadFile(filepath.Join(devicePath, "serial")) if len(model) > 0 && len(serial) > 0 { @@ -515,7 +516,7 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) { func LabelWithContext(ctx context.Context, name string) (string, error) { // Try label based on devicemapper name - dmname_filename := common.HostSys(fmt.Sprintf("block/%s/dm/name", name)) + dmname_filename := common.HostSysWithContext(ctx, fmt.Sprintf("block/%s/dm/name", name)) if !common.PathExists(dmname_filename) { return "", nil diff --git a/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go b/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go index 5dfd1ca98..8a1a28d69 100644 --- a/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go +++ b/vendor/github.com/shirou/gopsutil/v3/disk/disk_windows.go @@ -7,6 +7,7 @@ import ( "bytes" "context" "fmt" + "sync" "syscall" "unsafe" @@ -15,8 +16,6 @@ import ( "golang.org/x/sys/windows/registry" ) -type Warnings = common.Warnings - var ( procGetDiskFreeSpaceExW = common.Modkernel32.NewProc("GetDiskFreeSpaceExW") procGetLogicalDriveStringsW = common.Modkernel32.NewProc("GetLogicalDriveStringsW") @@ -90,12 +89,20 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro var ret []PartitionStat retChan := make(chan []PartitionStat) errChan := make(chan error) - defer close(retChan) - defer close(errChan) - lpBuffer := make([]byte, 254) + var waitgrp sync.WaitGroup + waitgrp.Add(1) + defer waitgrp.Done() + f := func() { + defer func() { + waitgrp.Wait() + // fires when this func and the outside func finishes. + close(errChan) + close(retChan) + }() + diskret, _, err := procGetLogicalDriveStringsW.Call( uintptr(len(lpBuffer)), uintptr(unsafe.Pointer(&lpBuffer[0]))) diff --git a/vendor/github.com/shirou/gopsutil/v3/host/host.go b/vendor/github.com/shirou/gopsutil/v3/host/host.go index f363eed83..c7e84e3a5 100644 --- a/vendor/github.com/shirou/gopsutil/v3/host/host.go +++ b/vendor/github.com/shirou/gopsutil/v3/host/host.go @@ -11,6 +11,8 @@ import ( "github.com/shirou/gopsutil/v3/internal/common" ) +type Warnings = common.Warnings + var invoke common.Invoker = common.Invoke{} // A HostInfoStat describes the host status. diff --git a/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go b/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go index 2f20fc616..1be2e8533 100644 --- a/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v3/host/host_darwin.go @@ -13,9 +13,10 @@ import ( "strings" "unsafe" + "golang.org/x/sys/unix" + "github.com/shirou/gopsutil/v3/internal/common" "github.com/shirou/gopsutil/v3/process" - "golang.org/x/sys/unix" ) // from utmpx.h diff --git a/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go b/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go index 9dc63322b..62a4b3ca9 100644 --- a/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go +++ b/vendor/github.com/shirou/gopsutil/v3/host/host_linux.go @@ -15,11 +15,10 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" -) -type Warnings = common.Warnings + "github.com/shirou/gopsutil/v3/internal/common" +) type lsbStruct struct { ID string @@ -36,9 +35,9 @@ const ( ) func HostIDWithContext(ctx context.Context) (string, error) { - sysProductUUID := common.HostSys("class/dmi/id/product_uuid") - machineID := common.HostEtc("machine-id") - procSysKernelRandomBootID := common.HostProc("sys/kernel/random/boot_id") + sysProductUUID := common.HostSysWithContext(ctx, "class/dmi/id/product_uuid") + machineID := common.HostEtcWithContext(ctx, "machine-id") + procSysKernelRandomBootID := common.HostProcWithContext(ctx, "sys/kernel/random/boot_id") switch { // In order to read this file, needs to be supported by kernel/arch and run as root // so having fallback is important @@ -68,7 +67,7 @@ func HostIDWithContext(ctx context.Context) (string, error) { } func numProcs(ctx context.Context) (uint64, error) { - return common.NumProcs() + return common.NumProcsWithContext(ctx) } func BootTimeWithContext(ctx context.Context) (uint64, error) { @@ -84,7 +83,7 @@ func UptimeWithContext(ctx context.Context) (uint64, error) { } func UsersWithContext(ctx context.Context) ([]UserStat, error) { - utmpfile := common.HostVar("run/utmp") + utmpfile := common.HostVarWithContext(ctx, "run/utmp") file, err := os.Open(utmpfile) if err != nil { @@ -125,10 +124,10 @@ func UsersWithContext(ctx context.Context) ([]UserStat, error) { return ret, nil } -func getlsbStruct() (*lsbStruct, error) { +func getlsbStruct(ctx context.Context) (*lsbStruct, error) { ret := &lsbStruct{} - if common.PathExists(common.HostEtc("lsb-release")) { - contents, err := common.ReadLines(common.HostEtc("lsb-release")) + if common.PathExists(common.HostEtcWithContext(ctx, "lsb-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "lsb-release")) if err != nil { return ret, err // return empty } @@ -176,31 +175,31 @@ func getlsbStruct() (*lsbStruct, error) { } func PlatformInformationWithContext(ctx context.Context) (platform string, family string, version string, err error) { - lsb, err := getlsbStruct() + lsb, err := getlsbStruct(ctx) if err != nil { lsb = &lsbStruct{} } - if common.PathExistsWithContents(common.HostEtc("oracle-release")) { + if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "oracle-release")) { platform = "oracle" - contents, err := common.ReadLines(common.HostEtc("oracle-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "oracle-release")) if err == nil { version = getRedhatishVersion(contents) } - } else if common.PathExistsWithContents(common.HostEtc("enterprise-release")) { + } else if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "enterprise-release")) { platform = "oracle" - contents, err := common.ReadLines(common.HostEtc("enterprise-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "enterprise-release")) if err == nil { version = getRedhatishVersion(contents) } - } else if common.PathExistsWithContents(common.HostEtc("slackware-version")) { + } else if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "slackware-version")) { platform = "slackware" - contents, err := common.ReadLines(common.HostEtc("slackware-version")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "slackware-version")) if err == nil { version = getSlackwareVersion(contents) } - } else if common.PathExistsWithContents(common.HostEtc("debian_version")) { + } else if common.PathExistsWithContents(common.HostEtcWithContext(ctx, "debian_version")) { if lsb.ID == "Ubuntu" { platform = "ubuntu" version = lsb.Release @@ -210,59 +209,62 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil } else if lsb.ID == "Kylin" { platform = "Kylin" version = lsb.Release + } else if lsb.ID == `"Cumulus Linux"` { + platform = "cumuluslinux" + version = lsb.Release } else { if common.PathExistsWithContents("/usr/bin/raspi-config") { platform = "raspbian" } else { platform = "debian" } - contents, err := common.ReadLines(common.HostEtc("debian_version")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "debian_version")) if err == nil && len(contents) > 0 && contents[0] != "" { version = contents[0] } } - } else if common.PathExists(common.HostEtc("neokylin-release")) { - contents, err := common.ReadLines(common.HostEtc("neokylin-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "neokylin-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "neokylin-release")) if err == nil { version = getRedhatishVersion(contents) platform = getRedhatishPlatform(contents) } - } else if common.PathExists(common.HostEtc("redhat-release")) { - contents, err := common.ReadLines(common.HostEtc("redhat-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "redhat-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "redhat-release")) if err == nil { version = getRedhatishVersion(contents) platform = getRedhatishPlatform(contents) } - } else if common.PathExists(common.HostEtc("system-release")) { - contents, err := common.ReadLines(common.HostEtc("system-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "system-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "system-release")) if err == nil { version = getRedhatishVersion(contents) platform = getRedhatishPlatform(contents) } - } else if common.PathExists(common.HostEtc("gentoo-release")) { + } else if common.PathExists(common.HostEtcWithContext(ctx, "gentoo-release")) { platform = "gentoo" - contents, err := common.ReadLines(common.HostEtc("gentoo-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "gentoo-release")) if err == nil { version = getRedhatishVersion(contents) } - } else if common.PathExists(common.HostEtc("SuSE-release")) { - contents, err := common.ReadLines(common.HostEtc("SuSE-release")) + } else if common.PathExists(common.HostEtcWithContext(ctx, "SuSE-release")) { + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "SuSE-release")) if err == nil { version = getSuseVersion(contents) platform = getSusePlatform(contents) } // TODO: slackware detecion - } else if common.PathExists(common.HostEtc("arch-release")) { + } else if common.PathExists(common.HostEtcWithContext(ctx, "arch-release")) { platform = "arch" version = lsb.Release - } else if common.PathExists(common.HostEtc("alpine-release")) { + } else if common.PathExists(common.HostEtcWithContext(ctx, "alpine-release")) { platform = "alpine" - contents, err := common.ReadLines(common.HostEtc("alpine-release")) + contents, err := common.ReadLines(common.HostEtcWithContext(ctx, "alpine-release")) if err == nil && len(contents) > 0 && contents[0] != "" { version = contents[0] } - } else if common.PathExists(common.HostEtc("os-release")) { - p, v, err := common.GetOSRelease() + } else if common.PathExists(common.HostEtcWithContext(ctx, "os-release")) { + p, v, err := common.GetOSReleaseWithContext(ctx) if err == nil { platform = p version = v @@ -287,7 +289,7 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil platform = strings.Trim(platform, `"`) switch platform { - case "debian", "ubuntu", "linuxmint", "raspbian": + case "debian", "ubuntu", "linuxmint", "raspbian", "Kylin", "cumuluslinux": family = "debian" case "fedora": family = "fedora" @@ -388,14 +390,14 @@ func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, err // Only the temp*_input file provides current temperature // value in millidegree Celsius as reported by the temperature to the device: // https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface - if files, err = filepath.Glob(common.HostSys("/class/hwmon/hwmon*/temp*_input")); err != nil { + if files, err = filepath.Glob(common.HostSysWithContext(ctx, "/class/hwmon/hwmon*/temp*_input")); err != nil { return temperatures, err } if len(files) == 0 { // CentOS has an intermediate /device directory: // https://github.com/giampaolo/psutil/issues/971 - if files, err = filepath.Glob(common.HostSys("/class/hwmon/hwmon*/device/temp*_input")); err != nil { + if files, err = filepath.Glob(common.HostSysWithContext(ctx, "/class/hwmon/hwmon*/device/temp*_input")); err != nil { return temperatures, err } } @@ -403,7 +405,7 @@ func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, err var warns Warnings if len(files) == 0 { // handle distributions without hwmon, like raspbian #391, parse legacy thermal_zone files - files, err = filepath.Glob(common.HostSys("/class/thermal/thermal_zone*/")) + files, err = filepath.Glob(common.HostSysWithContext(ctx, "/class/thermal/thermal_zone*/")) if err != nil { return temperatures, err } diff --git a/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go b/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go index c1e96ca7d..9bfece362 100644 --- a/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go +++ b/vendor/github.com/shirou/gopsutil/v3/internal/common/common.go @@ -25,6 +25,8 @@ import ( "strconv" "strings" "time" + + "github.com/shirou/gopsutil/v3/common" ) var ( @@ -321,6 +323,23 @@ func PathExistsWithContents(filename string) bool { return info.Size() > 4 // at least 4 bytes } +// GetEnvWithContext retrieves the environment variable key. If it does not exist it returns the default. +// The context may optionally contain a map superseding os.EnvKey. +func GetEnvWithContext(ctx context.Context, key string, dfault string, combineWith ...string) string { + var value string + if env, ok := ctx.Value(common.EnvKey).(common.EnvMap); ok { + value = env[common.EnvKeyType(key)] + } + if value == "" { + value = os.Getenv(key) + } + if value == "" { + value = dfault + } + + return combine(value, combineWith) +} + // GetEnv retrieves the environment variable key. If it does not exist it returns the default. func GetEnv(key string, dfault string, combineWith ...string) string { value := os.Getenv(key) @@ -328,6 +347,10 @@ func GetEnv(key string, dfault string, combineWith ...string) string { value = dfault } + return combine(value, combineWith) +} + +func combine(value string, combineWith []string) string { switch len(combineWith) { case 0: return value @@ -369,6 +392,38 @@ func HostRoot(combineWith ...string) string { return GetEnv("HOST_ROOT", "/", combineWith...) } +func HostProcWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_PROC", "/proc", combineWith...) +} + +func HostProcMountInfoWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_PROC_MOUNTINFO", "", combineWith...) +} + +func HostSysWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_SYS", "/sys", combineWith...) +} + +func HostEtcWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_ETC", "/etc", combineWith...) +} + +func HostVarWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_VAR", "/var", combineWith...) +} + +func HostRunWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_RUN", "/run", combineWith...) +} + +func HostDevWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_DEV", "/dev", combineWith...) +} + +func HostRootWithContext(ctx context.Context, combineWith ...string) string { + return GetEnvWithContext(ctx, "HOST_ROOT", "/", combineWith...) +} + // getSysctrlEnv sets LC_ALL=C in a list of env vars for use when running // sysctl commands (see DoSysctrl). func getSysctrlEnv(env []string) []string { diff --git a/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go b/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go index fa6373b55..b58edbeb0 100644 --- a/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go +++ b/vendor/github.com/shirou/gopsutil/v3/internal/common/common_linux.go @@ -31,7 +31,11 @@ func DoSysctrl(mib string) ([]string, error) { } func NumProcs() (uint64, error) { - f, err := os.Open(HostProc()) + return NumProcsWithContext(context.Background()) +} + +func NumProcsWithContext(ctx context.Context) (uint64, error) { + f, err := os.Open(HostProcWithContext(ctx)) if err != nil { return 0, err } @@ -67,7 +71,7 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) { statFile = "uptime" } - filename := HostProc(statFile) + filename := HostProcWithContext(ctx, statFile) lines, err := ReadLines(filename) if os.IsPermission(err) { var info syscall.Sysinfo_t @@ -139,7 +143,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } cachedVirtMutex.RUnlock() - filename := HostProc("xen") + filename := HostProcWithContext(ctx, "xen") if PathExists(filename) { system = "xen" role = "guest" // assume guest @@ -154,7 +158,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc("modules") + filename = HostProcWithContext(ctx, "modules") if PathExists(filename) { contents, err := ReadLines(filename) if err == nil { @@ -177,7 +181,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc("cpuinfo") + filename = HostProcWithContext(ctx, "cpuinfo") if PathExists(filename) { contents, err := ReadLines(filename) if err == nil { @@ -190,7 +194,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc("bus/pci/devices") + filename = HostProcWithContext(ctx, "bus/pci/devices") if PathExists(filename) { contents, err := ReadLines(filename) if err == nil { @@ -200,7 +204,7 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - filename = HostProc() + filename = HostProcWithContext(ctx) if PathExists(filepath.Join(filename, "bc", "0")) { system = "openvz" role = "host" @@ -251,15 +255,15 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } } - if PathExists(HostEtc("os-release")) { - p, _, err := GetOSRelease() + if PathExists(HostEtcWithContext(ctx, "os-release")) { + p, _, err := GetOSReleaseWithContext(ctx) if err == nil && p == "coreos" { system = "rkt" // Is it true? role = "host" } } - if PathExists(HostRoot(".dockerenv")) { + if PathExists(HostRootWithContext(ctx, ".dockerenv")) { system = "docker" role = "guest" } @@ -278,7 +282,11 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) { } func GetOSRelease() (platform string, version string, err error) { - contents, err := ReadLines(HostEtc("os-release")) + return GetOSReleaseWithContext(context.Background()) +} + +func GetOSReleaseWithContext(ctx context.Context) (platform string, version string, err error) { + contents, err := ReadLines(HostEtcWithContext(ctx, "os-release")) if err != nil { return "", "", nil // return empty } diff --git a/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go b/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go index 8c35b1722..9bed2419e 100644 --- a/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go +++ b/vendor/github.com/shirou/gopsutil/v3/internal/common/sleep.go @@ -11,6 +11,9 @@ func Sleep(ctx context.Context, interval time.Duration) error { timer := time.NewTimer(interval) select { case <-ctx.Done(): + if !timer.Stop() { + <-timer.C + } return ctx.Err() case <-timer.C: return nil diff --git a/vendor/github.com/shirou/gopsutil/v3/load/load_linux.go b/vendor/github.com/shirou/gopsutil/v3/load/load_linux.go index debf0733c..0298c8bed 100644 --- a/vendor/github.com/shirou/gopsutil/v3/load/load_linux.go +++ b/vendor/github.com/shirou/gopsutil/v3/load/load_linux.go @@ -18,7 +18,7 @@ func Avg() (*AvgStat, error) { } func AvgWithContext(ctx context.Context) (*AvgStat, error) { - stat, err := fileAvgWithContext() + stat, err := fileAvgWithContext(ctx) if err != nil { stat, err = sysinfoAvgWithContext() } @@ -40,8 +40,8 @@ func sysinfoAvgWithContext() (*AvgStat, error) { }, nil } -func fileAvgWithContext() (*AvgStat, error) { - values, err := readLoadAvgFromFile() +func fileAvgWithContext(ctx context.Context) (*AvgStat, error) { + values, err := readLoadAvgFromFile(ctx) if err != nil { return nil, err } @@ -75,7 +75,7 @@ func Misc() (*MiscStat, error) { } func MiscWithContext(ctx context.Context) (*MiscStat, error) { - filename := common.HostProc("stat") + filename := common.HostProcWithContext(ctx, "stat") out, err := ioutil.ReadFile(filename) if err != nil { return nil, err @@ -107,7 +107,7 @@ func MiscWithContext(ctx context.Context) (*MiscStat, error) { } - procsTotal, err := getProcsTotal() + procsTotal, err := getProcsTotal(ctx) if err != nil { return ret, err } @@ -116,16 +116,16 @@ func MiscWithContext(ctx context.Context) (*MiscStat, error) { return ret, nil } -func getProcsTotal() (int64, error) { - values, err := readLoadAvgFromFile() +func getProcsTotal(ctx context.Context) (int64, error) { + values, err := readLoadAvgFromFile(ctx) if err != nil { return 0, err } return strconv.ParseInt(strings.Split(values[3], "/")[1], 10, 64) } -func readLoadAvgFromFile() ([]string, error) { - loadavgFilename := common.HostProc("loadavg") +func readLoadAvgFromFile(ctx context.Context) ([]string, error) { + loadavgFilename := common.HostProcWithContext(ctx, "loadavg") line, err := ioutil.ReadFile(loadavgFilename) if err != nil { return nil, err diff --git a/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go b/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go index 0527dd93c..a05a0faba 100644 --- a/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.go @@ -8,8 +8,9 @@ import ( "fmt" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) func getHwMemsize() (uint64, error) { diff --git a/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go b/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go index 9a5d693b1..361d06bcc 100644 --- a/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go +++ b/vendor/github.com/shirou/gopsutil/v3/mem/mem_linux.go @@ -14,8 +14,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) type VirtualMemoryExStat struct { @@ -36,7 +37,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) { } func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { - vm, _, err := fillFromMeminfoWithContext() + vm, _, err := fillFromMeminfoWithContext(ctx) if err != nil { return nil, err } @@ -48,15 +49,15 @@ func VirtualMemoryEx() (*VirtualMemoryExStat, error) { } func VirtualMemoryExWithContext(ctx context.Context) (*VirtualMemoryExStat, error) { - _, vmEx, err := fillFromMeminfoWithContext() + _, vmEx, err := fillFromMeminfoWithContext(ctx) if err != nil { return nil, err } return vmEx, nil } -func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, error) { - filename := common.HostProc("meminfo") +func fillFromMeminfoWithContext(ctx context.Context) (*VirtualMemoryStat, *VirtualMemoryExStat, error) { + filename := common.HostProcWithContext(ctx, "meminfo") lines, _ := common.ReadLines(filename) // flag if MemAvailable is in /proc/meminfo (kernel 3.14+) @@ -153,13 +154,13 @@ func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, err return ret, retEx, err } retEx.Unevictable = t * 1024 - case "WriteBack": + case "Writeback": t, err := strconv.ParseUint(value, 10, 64) if err != nil { return ret, retEx, err } ret.WriteBack = t * 1024 - case "WriteBackTmp": + case "WritebackTmp": t, err := strconv.ParseUint(value, 10, 64) if err != nil { return ret, retEx, err @@ -317,7 +318,7 @@ func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, err if !memavail { if activeFile && inactiveFile && sReclaimable { - ret.Available = calculateAvailVmem(ret, retEx) + ret.Available = calculateAvailVmem(ctx, ret, retEx) } else { ret.Available = ret.Cached + ret.Free } @@ -350,7 +351,7 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { } else { ret.UsedPercent = 0 } - filename := common.HostProc("vmstat") + filename := common.HostProcWithContext(ctx, "vmstat") lines, _ := common.ReadLines(filename) for _, l := range lines { fields := strings.Fields(l) @@ -402,10 +403,10 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { // calculateAvailVmem is a fallback under kernel 3.14 where /proc/meminfo does not provide // "MemAvailable:" column. It reimplements an algorithm from the link below // https://github.com/giampaolo/psutil/pull/890 -func calculateAvailVmem(ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 { +func calculateAvailVmem(ctx context.Context, ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 { var watermarkLow uint64 - fn := common.HostProc("zoneinfo") + fn := common.HostProcWithContext(ctx, "zoneinfo") lines, err := common.ReadLines(fn) if err != nil { return ret.Free + ret.Cached // fallback under kernel 2.6.13 @@ -457,18 +458,18 @@ func SwapDevices() ([]*SwapDevice, error) { } func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) { - swapsFilePath := common.HostProc(swapsFilename) + swapsFilePath := common.HostProcWithContext(ctx, swapsFilename) f, err := os.Open(swapsFilePath) if err != nil { return nil, err } defer f.Close() - return parseSwapsFile(f) + return parseSwapsFile(ctx, f) } -func parseSwapsFile(r io.Reader) ([]*SwapDevice, error) { - swapsFilePath := common.HostProc(swapsFilename) +func parseSwapsFile(ctx context.Context, r io.Reader) ([]*SwapDevice, error) { + swapsFilePath := common.HostProcWithContext(ctx, swapsFilename) scanner := bufio.NewScanner(r) if !scanner.Scan() { if err := scanner.Err(); err != nil { diff --git a/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go b/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go index 1c8d4f4e3..8a7b63744 100644 --- a/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v3/net/net_darwin.go @@ -259,7 +259,7 @@ func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) { } func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) { - return IOCounters(pernic) + return IOCountersWithContext(ctx, pernic) } func FilterCounters() ([]FilterStat, error) { @@ -278,7 +278,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for Darwin diff --git a/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go b/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go index 7f31851ea..bf8baf094 100644 --- a/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/v3/net/net_freebsd.go @@ -115,7 +115,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for FreeBSD diff --git a/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go b/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go index c7cd0db18..de0ea7345 100644 --- a/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go +++ b/vendor/github.com/shirou/gopsutil/v3/net/net_linux.go @@ -50,7 +50,7 @@ func IOCounters(pernic bool) ([]IOCountersStat, error) { } func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) { - filename := common.HostProc("net/dev") + filename := common.HostProcWithContext(ctx, "net/dev") return IOCountersByFileWithContext(ctx, pernic, filename) } @@ -157,7 +157,7 @@ var netProtocols = []string{ "udplite", } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Available protocols: @@ -177,7 +177,7 @@ func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoC protos[p] = true } - filename := common.HostProc("net/snmp") + filename := common.HostProcWithContext(ctx, "net/snmp") lines, err := common.ReadLines(filename) if err != nil { return nil, err @@ -230,8 +230,8 @@ func FilterCounters() ([]FilterStat, error) { } func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) { - countfile := common.HostProc("sys/net/netfilter/nf_conntrack_count") - maxfile := common.HostProc("sys/net/netfilter/nf_conntrack_max") + countfile := common.HostProcWithContext(ctx, "sys/net/netfilter/nf_conntrack_count") + maxfile := common.HostProcWithContext(ctx, "sys/net/netfilter/nf_conntrack_max") count, err := common.ReadInts(countfile) if err != nil { @@ -260,7 +260,7 @@ func ConntrackStats(percpu bool) ([]ConntrackStat, error) { // ConntrackStatsWithContext returns more detailed info about the conntrack table func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) { - return conntrackStatsFromFile(common.HostProc("net/stat/nf_conntrack"), percpu) + return conntrackStatsFromFile(common.HostProcWithContext(ctx, "net/stat/nf_conntrack"), percpu) } // conntrackStatsFromFile returns more detailed info about the conntrack table @@ -459,7 +459,7 @@ func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, p if !ok { return nil, fmt.Errorf("invalid kind, %s", kind) } - root := common.HostProc() + root := common.HostProcWithContext(ctx) var err error var inodes map[string][]inodeMap if pid == 0 { @@ -531,7 +531,7 @@ func statsFromInodesWithContext(ctx context.Context, root string, pid int32, tma if !skipUids { // fetch process owner Real, effective, saved set, and filesystem UIDs proc := process{Pid: conn.Pid} - conn.Uids, _ = proc.getUids() + conn.Uids, _ = proc.getUids(ctx) } ret = append(ret, conn) @@ -599,7 +599,7 @@ func Pids() ([]int32, error) { func PidsWithContext(ctx context.Context) ([]int32, error) { var ret []int32 - d, err := os.Open(common.HostProc()) + d, err := os.Open(common.HostProcWithContext(ctx)) if err != nil { return nil, err } @@ -631,8 +631,8 @@ type process struct { } // Uids returns user ids of the process as a slice of the int -func (p *process) getUids() ([]int32, error) { - err := p.fillFromStatus() +func (p *process) getUids(ctx context.Context) ([]int32, error) { + err := p.fillFromStatus(ctx) if err != nil { return []int32{}, err } @@ -640,9 +640,9 @@ func (p *process) getUids() ([]int32, error) { } // Get status from /proc/(pid)/status -func (p *process) fillFromStatus() error { +func (p *process) fillFromStatus(ctx context.Context) error { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "status") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "status") contents, err := ioutil.ReadFile(statPath) if err != nil { return err diff --git a/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go b/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go index 5f066a09f..cf48f53e7 100644 --- a/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go +++ b/vendor/github.com/shirou/gopsutil/v3/net/net_openbsd.go @@ -164,7 +164,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for OpenBSD diff --git a/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go b/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go index 68b26bdcd..5d384342f 100644 --- a/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go +++ b/vendor/github.com/shirou/gopsutil/v3/net/net_windows.go @@ -338,7 +338,7 @@ func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackSta return nil, common.ErrNotImplementedError } -// NetProtoCounters returns network statistics for the entire system +// ProtoCounters returns network statistics for the entire system // If protocols is empty then all protocols are returned, otherwise // just the protocols in the list are returned. // Not Implemented for Windows diff --git a/vendor/github.com/shirou/gopsutil/v3/process/process.go b/vendor/github.com/shirou/gopsutil/v3/process/process.go index 0ca26c210..1a7fe1b80 100644 --- a/vendor/github.com/shirou/gopsutil/v3/process/process.go +++ b/vendor/github.com/shirou/gopsutil/v3/process/process.go @@ -335,7 +335,7 @@ func (p *Process) MemoryPercentWithContext(ctx context.Context) (float32, error) return (100 * float32(used) / float32(total)), nil } -// CPU_Percent returns how many percent of the CPU time this process uses +// CPUPercent returns how many percent of the CPU time this process uses func (p *Process) CPUPercent() (float64, error) { return p.CPUPercentWithContext(context.Background()) } @@ -507,7 +507,7 @@ func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { return p.MemoryInfoExWithContext(context.Background()) } -// PageFaultsInfo returns the process's page fault counters. +// PageFaults returns the process's page fault counters. func (p *Process) PageFaults() (*PageFaultsStat, error) { return p.PageFaultsWithContext(context.Background()) } @@ -530,7 +530,7 @@ func (p *Process) Connections() ([]net.ConnectionStat, error) { return p.ConnectionsWithContext(context.Background()) } -// Connections returns a slice of net.ConnectionStat used by the process at most `max`. +// ConnectionsMax returns a slice of net.ConnectionStat used by the process at most `max`. func (p *Process) ConnectionsMax(max int) ([]net.ConnectionStat, error) { return p.ConnectionsMaxWithContext(context.Background(), max) } diff --git a/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go b/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go index 61b340b63..55c31962a 100644 --- a/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go +++ b/vendor/github.com/shirou/gopsutil/v3/process/process_darwin.go @@ -10,10 +10,11 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/net" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" + "github.com/shirou/gopsutil/v3/net" ) // copied from sys/sysctl.h diff --git a/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go b/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go index 779f8126a..a123ccf9b 100644 --- a/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/v3/process/process_freebsd.go @@ -69,7 +69,13 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) { } func (p *Process) ExeWithContext(ctx context.Context) (string, error) { - return "", common.ErrNotImplementedError + mib := []int32{CTLKern, KernProc, KernProcPathname, p.Pid} + buf, _, err := common.CallSyscall(mib) + if err != nil { + return "", err + } + + return strings.Trim(string(buf), "\x00"), nil } func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { diff --git a/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go b/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go index d5b5bc329..29c447390 100644 --- a/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go +++ b/vendor/github.com/shirou/gopsutil/v3/process/process_linux.go @@ -16,11 +16,12 @@ import ( "strconv" "strings" + "github.com/tklauser/go-sysconf" + "golang.org/x/sys/unix" + "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/internal/common" "github.com/shirou/gopsutil/v3/net" - "github.com/tklauser/go-sysconf" - "golang.org/x/sys/unix" ) var pageSize = uint64(os.Getpagesize()) @@ -100,7 +101,7 @@ func (p *Process) TgidWithContext(ctx context.Context) (int32, error) { } func (p *Process) ExeWithContext(ctx context.Context) (string, error) { - return p.fillFromExeWithContext() + return p.fillFromExeWithContext(ctx) } func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) { @@ -120,7 +121,7 @@ func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) { } func (p *Process) CwdWithContext(ctx context.Context) (string, error) { - return p.fillFromCwdWithContext() + return p.fillFromCwdWithContext(ctx) } func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) { @@ -134,7 +135,7 @@ func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) { func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) { // see https://github.com/shirou/gopsutil/issues/596#issuecomment-432707831 for implementation details pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "stat") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "stat") contents, err := ioutil.ReadFile(statPath) if err != nil { return false, err @@ -202,7 +203,7 @@ func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) { } func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) { - rlimits, err := p.fillFromLimitsWithContext() + rlimits, err := p.fillFromLimitsWithContext(ctx) if !gatherUsed || err != nil { return rlimits, err } @@ -257,7 +258,7 @@ func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ( } func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) { - return p.fillFromIOWithContext() + return p.fillFromIOWithContext(ctx) } func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) { @@ -283,7 +284,7 @@ func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) { ret := make(map[int32]*cpu.TimesStat) - taskPath := common.HostProc(strconv.Itoa(int(p.Pid)), "task") + taskPath := common.HostProcWithContext(ctx, strconv.Itoa(int(p.Pid)), "task") tids, err := readPidsFromDir(taskPath) if err != nil { @@ -314,7 +315,7 @@ func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) { } func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) { - meminfo, _, err := p.fillFromStatmWithContext() + meminfo, _, err := p.fillFromStatmWithContext(ctx) if err != nil { return nil, err } @@ -322,7 +323,7 @@ func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, e } func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) { - _, memInfoEx, err := p.fillFromStatmWithContext() + _, memInfoEx, err := p.fillFromStatmWithContext(ctx) if err != nil { return nil, err } @@ -380,12 +381,12 @@ func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) { pid := p.Pid var ret []MemoryMapsStat - smapsPath := common.HostProc(strconv.Itoa(int(pid)), "smaps") + smapsPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "smaps") if grouped { ret = make([]MemoryMapsStat, 1) // If smaps_rollup exists (require kernel >= 4.15), then we will use it // for pre-summed memory information for a process. - smapsRollupPath := common.HostProc(strconv.Itoa(int(pid)), "smaps_rollup") + smapsRollupPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "smaps_rollup") if _, err := os.Stat(smapsRollupPath); !os.IsNotExist(err) { smapsPath = smapsRollupPath } @@ -481,7 +482,7 @@ func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]M } func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) { - environPath := common.HostProc(strconv.Itoa(int(p.Pid)), "environ") + environPath := common.HostProcWithContext(ctx, strconv.Itoa(int(p.Pid)), "environ") environContent, err := ioutil.ReadFile(environPath) if err != nil { @@ -507,9 +508,9 @@ func limitToUint(val string) (uint64, error) { } // Get num_fds from /proc/(pid)/limits -func (p *Process) fillFromLimitsWithContext() ([]RlimitStat, error) { +func (p *Process) fillFromLimitsWithContext(ctx context.Context) ([]RlimitStat, error) { pid := p.Pid - limitsFile := common.HostProc(strconv.Itoa(int(pid)), "limits") + limitsFile := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "limits") d, err := os.Open(limitsFile) if err != nil { return nil, err @@ -602,7 +603,7 @@ func (p *Process) fillFromLimitsWithContext() ([]RlimitStat, error) { // Get list of /proc/(pid)/fd files func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []string, error) { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "fd") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "fd") d, err := os.Open(statPath) if err != nil { return statPath, []string{}, err @@ -642,9 +643,9 @@ func (p *Process) fillFromfdWithContext(ctx context.Context) (int32, []*OpenFile } // Get cwd from /proc/(pid)/cwd -func (p *Process) fillFromCwdWithContext() (string, error) { +func (p *Process) fillFromCwdWithContext(ctx context.Context) (string, error) { pid := p.Pid - cwdPath := common.HostProc(strconv.Itoa(int(pid)), "cwd") + cwdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cwd") cwd, err := os.Readlink(cwdPath) if err != nil { return "", err @@ -653,9 +654,9 @@ func (p *Process) fillFromCwdWithContext() (string, error) { } // Get exe from /proc/(pid)/exe -func (p *Process) fillFromExeWithContext() (string, error) { +func (p *Process) fillFromExeWithContext(ctx context.Context) (string, error) { pid := p.Pid - exePath := common.HostProc(strconv.Itoa(int(pid)), "exe") + exePath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "exe") exe, err := os.Readlink(exePath) if err != nil { return "", err @@ -666,7 +667,7 @@ func (p *Process) fillFromExeWithContext() (string, error) { // Get cmdline from /proc/(pid)/cmdline func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return "", err @@ -680,7 +681,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return nil, err @@ -701,9 +702,9 @@ func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string } // Get IO status from /proc/(pid)/io -func (p *Process) fillFromIOWithContext() (*IOCountersStat, error) { +func (p *Process) fillFromIOWithContext(ctx context.Context) (*IOCountersStat, error) { pid := p.Pid - ioPath := common.HostProc(strconv.Itoa(int(pid)), "io") + ioPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "io") ioline, err := ioutil.ReadFile(ioPath) if err != nil { return nil, err @@ -737,9 +738,9 @@ func (p *Process) fillFromIOWithContext() (*IOCountersStat, error) { } // Get memory info from /proc/(pid)/statm -func (p *Process) fillFromStatmWithContext() (*MemoryInfoStat, *MemoryInfoExStat, error) { +func (p *Process) fillFromStatmWithContext(ctx context.Context) (*MemoryInfoStat, *MemoryInfoExStat, error) { pid := p.Pid - memPath := common.HostProc(strconv.Itoa(int(pid)), "statm") + memPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "statm") contents, err := ioutil.ReadFile(memPath) if err != nil { return nil, nil, err @@ -790,7 +791,7 @@ func (p *Process) fillFromStatmWithContext() (*MemoryInfoStat, *MemoryInfoExStat // Get name from /proc/(pid)/comm or /proc/(pid)/status func (p *Process) fillNameWithContext(ctx context.Context) error { - err := p.fillFromCommWithContext() + err := p.fillFromCommWithContext(ctx) if err == nil && p.name != "" && len(p.name) < 15 { return nil } @@ -798,9 +799,9 @@ func (p *Process) fillNameWithContext(ctx context.Context) error { } // Get name from /proc/(pid)/comm -func (p *Process) fillFromCommWithContext() error { +func (p *Process) fillFromCommWithContext(ctx context.Context) error { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "comm") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "comm") contents, err := ioutil.ReadFile(statPath) if err != nil { return err @@ -817,7 +818,7 @@ func (p *Process) fillFromStatus() error { func (p *Process) fillFromStatusWithContext(ctx context.Context) error { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "status") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "status") contents, err := ioutil.ReadFile(statPath) if err != nil { return err @@ -1022,9 +1023,9 @@ func (p *Process) fillFromTIDStatWithContext(ctx context.Context, tid int32) (ui var statPath string if tid == -1 { - statPath = common.HostProc(strconv.Itoa(int(pid)), "stat") + statPath = common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "stat") } else { - statPath = common.HostProc(strconv.Itoa(int(pid)), "task", strconv.Itoa(int(tid)), "stat") + statPath = common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "task", strconv.Itoa(int(tid)), "stat") } contents, err := ioutil.ReadFile(statPath) @@ -1128,7 +1129,7 @@ func (p *Process) fillFromStatWithContext(ctx context.Context) (uint64, int32, * } func pidsWithContext(ctx context.Context) ([]int32, error) { - return readPidsFromDir(common.HostProc()) + return readPidsFromDir(common.HostProcWithContext(ctx)) } func ProcessesWithContext(ctx context.Context) ([]*Process, error) { diff --git a/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go b/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go index 88e2bff53..a01f9ecfc 100644 --- a/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go +++ b/vendor/github.com/shirou/gopsutil/v3/process/process_posix.go @@ -14,8 +14,9 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) type Signal = syscall.Signal @@ -108,8 +109,8 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) { return false, err } - if isMount(common.HostProc()) { // if //proc exists and is mounted, check if //proc/ folder exists - _, err := os.Stat(common.HostProc(strconv.Itoa(int(pid)))) + if isMount(common.HostProcWithContext(ctx)) { // if //proc exists and is mounted, check if //proc/ folder exists + _, err := os.Stat(common.HostProcWithContext(ctx, strconv.Itoa(int(pid)))) if os.IsNotExist(err) { return false, nil } @@ -121,7 +122,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) { if err == nil { return true, nil } - if err.Error() == "os: process already finished" { + if errors.Is(err, os.ErrProcessDone) { return false, nil } var errno syscall.Errno diff --git a/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go b/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go index 4f10a67bc..ad1c3cfc1 100644 --- a/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go +++ b/vendor/github.com/shirou/gopsutil/v3/process/process_solaris.go @@ -30,7 +30,7 @@ type MemoryMapsStat struct { type MemoryInfoExStat struct{} func pidsWithContext(ctx context.Context) ([]int32, error) { - return readPidsFromDir(common.HostProc()) + return readPidsFromDir(common.HostProcWithContext(ctx)) } func ProcessesWithContext(ctx context.Context) ([]*Process, error) { @@ -199,7 +199,7 @@ func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) { func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []string, error) { pid := p.Pid - statPath := common.HostProc(strconv.Itoa(int(pid)), "fd") + statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "fd") d, err := os.Open(statPath) if err != nil { return statPath, []string{}, err @@ -211,7 +211,7 @@ func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []stri func (p *Process) fillFromPathCwdWithContext(ctx context.Context) (string, error) { pid := p.Pid - cwdPath := common.HostProc(strconv.Itoa(int(pid)), "path", "cwd") + cwdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "path", "cwd") cwd, err := os.Readlink(cwdPath) if err != nil { return "", err @@ -221,7 +221,7 @@ func (p *Process) fillFromPathCwdWithContext(ctx context.Context) (string, error func (p *Process) fillFromPathAOutWithContext(ctx context.Context) (string, error) { pid := p.Pid - cwdPath := common.HostProc(strconv.Itoa(int(pid)), "path", "a.out") + cwdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "path", "a.out") exe, err := os.Readlink(cwdPath) if err != nil { return "", err @@ -231,7 +231,7 @@ func (p *Process) fillFromPathAOutWithContext(ctx context.Context) (string, erro func (p *Process) fillFromExecnameWithContext(ctx context.Context) (string, error) { pid := p.Pid - execNamePath := common.HostProc(strconv.Itoa(int(pid)), "execname") + execNamePath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "execname") exe, err := ioutil.ReadFile(execNamePath) if err != nil { return "", err @@ -241,7 +241,7 @@ func (p *Process) fillFromExecnameWithContext(ctx context.Context) (string, erro func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return "", err @@ -258,7 +258,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string, error) { pid := p.Pid - cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "cmdline") cmdline, err := ioutil.ReadFile(cmdPath) if err != nil { return nil, err diff --git a/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml b/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml new file mode 100644 index 000000000..dc6fefb97 --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/.golangci.yaml @@ -0,0 +1,12 @@ +run: + timeout: 5m +linters: + enable: + - gofmt + - errcheck + - errname + - errorlint + - bodyclose + - durationcheck + - whitespace + diff --git a/vendor/github.com/shoenig/go-m1cpu/LICENSE b/vendor/github.com/shoenig/go-m1cpu/LICENSE new file mode 100644 index 000000000..e87a115e4 --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/LICENSE @@ -0,0 +1,363 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. + diff --git a/vendor/github.com/shoenig/go-m1cpu/Makefile b/vendor/github.com/shoenig/go-m1cpu/Makefile new file mode 100644 index 000000000..28d786397 --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/Makefile @@ -0,0 +1,12 @@ +SHELL = bash + +default: test + +.PHONY: test +test: + @echo "--> Running Tests ..." + @go test -v -race ./... + +vet: + @echo "--> Vet Go sources ..." + @go vet ./... diff --git a/vendor/github.com/shoenig/go-m1cpu/README.md b/vendor/github.com/shoenig/go-m1cpu/README.md new file mode 100644 index 000000000..399657acf --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/README.md @@ -0,0 +1,66 @@ +# m1cpu + +[![Go Reference](https://pkg.go.dev/badge/github.com/shoenig/go-m1cpu.svg)](https://pkg.go.dev/github.com/shoenig/go-m1cpu) +[![MPL License](https://img.shields.io/github/license/shoenig/go-m1cpu?color=g&style=flat-square)](https://github.com/shoenig/go-m1cpu/blob/main/LICENSE) +[![Run CI Tests](https://github.com/shoenig/go-m1cpu/actions/workflows/ci.yaml/badge.svg)](https://github.com/shoenig/go-m1cpu/actions/workflows/ci.yaml) + +The `go-m1cpu` module is a library for inspecting Apple Silicon CPUs in Go. + +Use the `m1cpu` Go package for looking up the CPU frequency for Apple M1 and M2 CPUs. + +# Install + +```shell +go get github.com/shoenig/go-m1cpu@latest +``` + +# CGO + +This package requires the use of [CGO](https://go.dev/blog/cgo). + +Extracting the CPU properties is done via Apple's [IOKit](https://developer.apple.com/documentation/iokit?language=objc) +framework, which is accessible only through system C libraries. + +# Example + +Simple Go program to print Apple Silicon M1/M2 CPU speeds. + +```go +package main + +import ( + "fmt" + + "github.com/shoenig/go-m1cpu" +) + +func main() { + fmt.Println("Apple Silicon", m1cpu.IsAppleSilicon()) + + fmt.Println("pCore GHz", m1cpu.PCoreGHz()) + fmt.Println("eCore GHz", m1cpu.ECoreGHz()) + + fmt.Println("pCore Hz", m1cpu.PCoreHz()) + fmt.Println("eCore Hz", m1cpu.ECoreHz()) +} +``` + +Using `go test` to print out available information. + +``` +➜ go test -v -run Show +=== RUN Test_Show + cpu_test.go:42: pCore Hz 3504000000 + cpu_test.go:43: eCore Hz 2424000000 + cpu_test.go:44: pCore GHz 3.504 + cpu_test.go:45: eCore GHz 2.424 + cpu_test.go:46: pCore count 8 + cpu_test.go:47: eCoreCount 4 + cpu_test.go:50: pCore Caches 196608 131072 16777216 + cpu_test.go:53: eCore Caches 131072 65536 4194304 +--- PASS: Test_Show (0.00s) +``` + +# License + +Open source under the [MPL](LICENSE) diff --git a/vendor/github.com/shoenig/go-m1cpu/cpu.go b/vendor/github.com/shoenig/go-m1cpu/cpu.go new file mode 100644 index 000000000..502a8cce9 --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/cpu.go @@ -0,0 +1,213 @@ +//go:build darwin && arm64 && cgo + +package m1cpu + +// #cgo LDFLAGS: -framework CoreFoundation -framework IOKit +// #include +// #include +// #include +// #include +// +// #if !defined(MAC_OS_VERSION_12_0) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0 +// #define kIOMainPortDefault kIOMasterPortDefault +// #endif +// +// #define HzToGHz(hz) ((hz) / 1000000000.0) +// +// UInt64 global_pCoreHz; +// UInt64 global_eCoreHz; +// int global_pCoreCount; +// int global_eCoreCount; +// int global_pCoreL1InstCacheSize; +// int global_eCoreL1InstCacheSize; +// int global_pCoreL1DataCacheSize; +// int global_eCoreL1DataCacheSize; +// int global_pCoreL2CacheSize; +// int global_eCoreL2CacheSize; +// char global_brand[32]; +// +// UInt64 getFrequency(CFTypeRef typeRef) { +// CFDataRef cfData = typeRef; +// +// CFIndex size = CFDataGetLength(cfData); +// UInt8 buf[size]; +// CFDataGetBytes(cfData, CFRangeMake(0, size), buf); +// +// UInt8 b1 = buf[size-5]; +// UInt8 b2 = buf[size-6]; +// UInt8 b3 = buf[size-7]; +// UInt8 b4 = buf[size-8]; +// +// UInt64 pCoreHz = 0x00000000FFFFFFFF & ((b1<<24) | (b2 << 16) | (b3 << 8) | (b4)); +// return pCoreHz; +// } +// +// int sysctl_int(const char * name) { +// int value = -1; +// size_t size = 8; +// sysctlbyname(name, &value, &size, NULL, 0); +// return value; +// } +// +// void sysctl_string(const char * name, char * dest) { +// size_t size = 32; +// sysctlbyname(name, dest, &size, NULL, 0); +// } +// +// void initialize() { +// global_pCoreCount = sysctl_int("hw.perflevel0.physicalcpu"); +// global_eCoreCount = sysctl_int("hw.perflevel1.physicalcpu"); +// global_pCoreL1InstCacheSize = sysctl_int("hw.perflevel0.l1icachesize"); +// global_eCoreL1InstCacheSize = sysctl_int("hw.perflevel1.l1icachesize"); +// global_pCoreL1DataCacheSize = sysctl_int("hw.perflevel0.l1dcachesize"); +// global_eCoreL1DataCacheSize = sysctl_int("hw.perflevel1.l1dcachesize"); +// global_pCoreL2CacheSize = sysctl_int("hw.perflevel0.l2cachesize"); +// global_eCoreL2CacheSize = sysctl_int("hw.perflevel1.l2cachesize"); +// sysctl_string("machdep.cpu.brand_string", global_brand); +// +// CFMutableDictionaryRef matching = IOServiceMatching("AppleARMIODevice"); +// io_iterator_t iter; +// IOServiceGetMatchingServices(kIOMainPortDefault, matching, &iter); +// +// const size_t bufsize = 512; +// io_object_t obj; +// while ((obj = IOIteratorNext(iter))) { +// char class[bufsize]; +// IOObjectGetClass(obj, class); +// char name[bufsize]; +// IORegistryEntryGetName(obj, name); +// +// if (strncmp(name, "pmgr", bufsize) == 0) { +// CFTypeRef pCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states5-sram"), kCFAllocatorDefault, 0); +// CFTypeRef eCoreRef = IORegistryEntryCreateCFProperty(obj, CFSTR("voltage-states1-sram"), kCFAllocatorDefault, 0); +// +// long long pCoreHz = getFrequency(pCoreRef); +// long long eCoreHz = getFrequency(eCoreRef); +// +// global_pCoreHz = pCoreHz; +// global_eCoreHz = eCoreHz; +// return; +// } +// } +// } +// +// UInt64 eCoreHz() { +// return global_eCoreHz; +// } +// +// UInt64 pCoreHz() { +// return global_pCoreHz; +// } +// +// Float64 eCoreGHz() { +// return HzToGHz(global_eCoreHz); +// } +// +// Float64 pCoreGHz() { +// return HzToGHz(global_pCoreHz); +// } +// +// int pCoreCount() { +// return global_pCoreCount; +// } +// +// int eCoreCount() { +// return global_eCoreCount; +// } +// +// int pCoreL1InstCacheSize() { +// return global_pCoreL1InstCacheSize; +// } +// +// int pCoreL1DataCacheSize() { +// return global_pCoreL1DataCacheSize; +// } +// +// int pCoreL2CacheSize() { +// return global_pCoreL2CacheSize; +// } +// +// int eCoreL1InstCacheSize() { +// return global_eCoreL1InstCacheSize; +// } +// +// int eCoreL1DataCacheSize() { +// return global_eCoreL1DataCacheSize; +// } +// +// int eCoreL2CacheSize() { +// return global_eCoreL2CacheSize; +// } +// +// char * modelName() { +// return global_brand; +// } +import "C" + +func init() { + C.initialize() +} + +// IsAppleSilicon returns true on this platform. +func IsAppleSilicon() bool { + return true +} + +// PCoreHZ returns the max frequency in Hertz of the P-Core of an Apple Silicon CPU. +func PCoreHz() uint64 { + return uint64(C.pCoreHz()) +} + +// ECoreHZ returns the max frequency in Hertz of the E-Core of an Apple Silicon CPU. +func ECoreHz() uint64 { + return uint64(C.eCoreHz()) +} + +// PCoreGHz returns the max frequency in Gigahertz of the P-Core of an Apple Silicon CPU. +func PCoreGHz() float64 { + return float64(C.pCoreGHz()) +} + +// ECoreGHz returns the max frequency in Gigahertz of the E-Core of an Apple Silicon CPU. +func ECoreGHz() float64 { + return float64(C.eCoreGHz()) +} + +// PCoreCount returns the number of physical P (performance) cores. +func PCoreCount() int { + return int(C.pCoreCount()) +} + +// ECoreCount returns the number of physical E (efficiency) cores. +func ECoreCount() int { + return int(C.eCoreCount()) +} + +// PCoreCacheSize returns the sizes of the P (performance) core cache sizes +// in the order of +// +// - L1 instruction cache +// - L1 data cache +// - L2 cache +func PCoreCache() (int, int, int) { + return int(C.pCoreL1InstCacheSize()), + int(C.pCoreL1DataCacheSize()), + int(C.pCoreL2CacheSize()) +} + +// ECoreCacheSize returns the sizes of the E (efficiency) core cache sizes +// in the order of +// +// - L1 instruction cache +// - L1 data cache +// - L2 cache +func ECoreCache() (int, int, int) { + return int(C.eCoreL1InstCacheSize()), + int(C.eCoreL1DataCacheSize()), + int(C.eCoreL2CacheSize()) +} + +// ModelName returns the model name of the CPU. +func ModelName() string { + return C.GoString(C.modelName()) +} diff --git a/vendor/github.com/shoenig/go-m1cpu/incompatible.go b/vendor/github.com/shoenig/go-m1cpu/incompatible.go new file mode 100644 index 000000000..d425025aa --- /dev/null +++ b/vendor/github.com/shoenig/go-m1cpu/incompatible.go @@ -0,0 +1,53 @@ +//go:build !darwin || !arm64 || !cgo + +package m1cpu + +// IsAppleSilicon return false on this platform. +func IsAppleSilicon() bool { + return false +} + +// PCoreHZ requires darwin/arm64 +func PCoreHz() uint64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreHZ requires darwin/arm64 +func ECoreHz() uint64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreGHz requires darwin/arm64 +func PCoreGHz() float64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreGHz requires darwin/arm64 +func ECoreGHz() float64 { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreCount requires darwin/arm64 +func PCoreCount() int { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreCount requires darwin/arm64 +func ECoreCount() int { + panic("m1cpu: not a darwin/arm64 system") +} + +// PCoreCacheSize requires darwin/arm64 +func PCoreCache() (int, int, int) { + panic("m1cpu: not a darwin/arm64 system") +} + +// ECoreCacheSize requires darwin/arm64 +func ECoreCache() (int, int, int) { + panic("m1cpu: not a darwin/arm64 system") +} + +// ModelName requires darwin/arm64 +func ModelName() string { + panic("m1cpu: not a darwin/arm64 system") +} diff --git a/vendor/github.com/tetratelabs/wazero/Makefile b/vendor/github.com/tetratelabs/wazero/Makefile index 8e36cf8c5..056794288 100644 --- a/vendor/github.com/tetratelabs/wazero/Makefile +++ b/vendor/github.com/tetratelabs/wazero/Makefile @@ -1,10 +1,10 @@ -gofumpt := mvdan.cc/gofumpt@v0.4.0 -gosimports := github.com/rinchsan/gosimports/cmd/gosimports@v0.3.7 -golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2 +gofumpt := mvdan.cc/gofumpt@v0.5.0 +gosimports := github.com/rinchsan/gosimports/cmd/gosimports@v0.3.8 +golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 asmfmt := github.com/klauspost/asmfmt/cmd/asmfmt@v1.3.2 # sync this with netlify.toml! -hugo := github.com/gohugoio/hugo@v0.111.3 +hugo := github.com/gohugoio/hugo@v0.112.5 # Make 3.81 doesn't support '**' globbing: Set explicitly instead of recursion. all_sources := $(wildcard *.go */*.go */*/*.go */*/*/*.go */*/*/*.go */*/*/*/*.go) @@ -18,20 +18,15 @@ main_sources := $(wildcard $(filter-out %_test.go $(all_testdata) $(all_testing # Paths need to all start with ./, so we do that manually vs foreach which strips it. main_packages := $(sort $(foreach f,$(dir $(main_sources)),$(if $(findstring ./,$(f)),./,./$(f)))) -# By default, we don't run with -race as it's costly to run on every PR. go_test_options ?= -timeout 300s ensureCompilerFastest := -ldflags '-X github.com/tetratelabs/wazero/internal/integration_test/vs.ensureCompilerFastest=true' .PHONY: bench bench: - @go test -run=NONE -benchmem -bench=. ./internal/integration_test/bench/... - @go test -benchmem -bench=. ./internal/integration_test/vs/... $(ensureCompilerFastest) - -.PHONY: bench.check -bench.check: + @go test -run=NONE -benchmem -bench=. ./internal/engine/compiler/... @go build ./internal/integration_test/bench/... @# Don't use -test.benchmem as it isn't accurate when comparing against CGO libs - @for d in vs/time vs/wasmedge vs/wasmer vs/wasmtime ; do \ + @for d in vs/time vs/wasmedge vs/wasmtime ; do \ cd ./internal/integration_test/$$d ; \ go test -bench=. . -tags='wasmedge' $(ensureCompilerFastest) ; \ cd - ;\ @@ -66,11 +61,12 @@ build.examples.tinygo: $(tinygo_sources) done # We use zig to build C as it is easy to install and embeds a copy of zig-cc. +# Note: Don't use "-Oz" as that breaks our wasi sock example. c_sources := imports/wasi_snapshot_preview1/example/testdata/zig-cc/cat.c imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.c .PHONY: build.examples.zig-cc build.examples.zig-cc: $(c_sources) @for f in $^; do \ - zig cc --target=wasm32-wasi -Oz -o $$(echo $$f | sed -e 's/\.c/\.wasm/') $$f; \ + zig cc --target=wasm32-wasi -o $$(echo $$f | sed -e 's/\.c/\.wasm/') $$f; \ done # Here are the emcc args we use: @@ -123,8 +119,8 @@ spectest_v1_testdata_dir := $(spectest_v1_dir)/testdata spec_version_v1 := wg-1.0 spectest_v2_dir := $(spectest_base_dir)/v2 spectest_v2_testdata_dir := $(spectest_v2_dir)/testdata -# Latest draft state as of Dec 16, 2022. -spec_version_v2 := 1782235239ddebaf2cb079b00fdaa2d2c4dedba3 +# Latest draft state as of May 23, 2023. +spec_version_v2 := 2e8912e88a3118a46b90e8ccb659e24b4e8f3c23 .PHONY: build.spectest build.spectest: @@ -166,7 +162,7 @@ build.spectest.v2: # Note: SIMD cases are placed in the "simd" subdirectory. @cd $(spectest_v2_testdata_dir) \ && curl -sSL 'https://api.github.com/repos/WebAssembly/spec/contents/test/core/simd?ref=$(spec_version_v2)' | jq -r '.[]| .download_url' | grep -E ".wast" | xargs -Iurl curl -sJL url -O @cd $(spectest_v2_testdata_dir) && for f in `find . -name '*.wast'`; do \ - wast2json --debug-names $$f; \ + wast2json --debug-names --no-check $$f; \ done .PHONY: test diff --git a/vendor/github.com/tetratelabs/wazero/builder.go b/vendor/github.com/tetratelabs/wazero/builder.go index 0aade139e..f64afabdf 100644 --- a/vendor/github.com/tetratelabs/wazero/builder.go +++ b/vendor/github.com/tetratelabs/wazero/builder.go @@ -322,7 +322,7 @@ func (b *hostModuleBuilder) Compile(ctx context.Context) (CompiledModule, error) } c := &compiledModule{module: module, compiledEngine: b.r.store.Engine} - listeners, err := buildListeners(ctx, module) + listeners, err := buildFunctionListeners(ctx, module) if err != nil { return nil, err } diff --git a/vendor/github.com/tetratelabs/wazero/config.go b/vendor/github.com/tetratelabs/wazero/config.go index 5172967f4..56a32fcf5 100644 --- a/vendor/github.com/tetratelabs/wazero/config.go +++ b/vendor/github.com/tetratelabs/wazero/config.go @@ -7,16 +7,18 @@ import ( "io" "io/fs" "math" + "net" "time" "github.com/tetratelabs/wazero/api" "github.com/tetratelabs/wazero/internal/engine/compiler" "github.com/tetratelabs/wazero/internal/engine/interpreter" "github.com/tetratelabs/wazero/internal/filecache" + "github.com/tetratelabs/wazero/internal/fsapi" "github.com/tetratelabs/wazero/internal/internalapi" "github.com/tetratelabs/wazero/internal/platform" + internalsock "github.com/tetratelabs/wazero/internal/sock" internalsys "github.com/tetratelabs/wazero/internal/sys" - "github.com/tetratelabs/wazero/internal/sysfs" "github.com/tetratelabs/wazero/internal/wasm" "github.com/tetratelabs/wazero/sys" ) @@ -649,6 +651,8 @@ type moduleConfig struct { environKeys map[string]int // fsConfig is the file system configuration for ABI like WASI. fsConfig FSConfig + // sockConfig is the network listener configuration for ABI like WASI. + sockConfig *internalsock.Config } // NewModuleConfig returns a ModuleConfig that can be used for configuring module instantiation. @@ -835,13 +839,20 @@ func (c *moduleConfig) toSysContext() (sysCtx *internalsys.Context, err error) { environ = append(environ, result) } - var fs sysfs.FS + var fs fsapi.FS if f, ok := c.fsConfig.(*fsConfig); ok { if fs, err = f.toFS(); err != nil { return } } + var listeners []*net.TCPListener + if n := c.sockConfig; n != nil { + if listeners, err = n.BuildTCPListeners(); err != nil { + return + } + } + return internalsys.NewContext( math.MaxUint32, c.args, @@ -854,5 +865,6 @@ func (c *moduleConfig) toSysContext() (sysCtx *internalsys.Context, err error) { c.nanotime, c.nanotimeResolution, c.nanosleep, c.osyield, fs, + listeners, ) } diff --git a/vendor/github.com/tetratelabs/wazero/examples/basic/testdata/add.wasm b/vendor/github.com/tetratelabs/wazero/examples/basic/testdata/add.wasm index 3a9da803e1d5c06411164861ea5230667f03b9c8..259ca4f00afac1d80527d7efd4694337a266b4fe 100644 GIT binary patch delta 2112 zcmZ8hO=w(I6u$Sq--%hNY5*raOBmQr1-3o{ifKNlgXnTph+WtmTw_GfKq6dog=tR+&34wJ}< zRZVp%Rb(YmX`2w_%~p_uzH6dJIittFeNlFWw#Ac9U3nc1=*UCePY_;Qzy}aF|+xhfd?;EA=?7KmYX}#eqvMzMfik(WYwCcezG2c zwWPX?nd(9X;MB=MZH#0Jj0+%P+)-iVF^rCZ5ilVvKiBxt(_CWyDL{$vX5q^4mKa{6 z*@(heQGRYleyrN$&r}?AuuL9> z3BsefI@KwOZK58Do=(q#Q4L8A`%$G!Uy! zfng_!v$K_<)X`%HQ3rzg+9juVn2TcYYk58G$chbw(4Yw2*xRoY+3)VxkD7PoXLN50 zCm6LMpwGBKwFv>OKDHn$9z@4cfG*6+)yX=y5@t4pqh%6Vdqh1uRBbXt_`|ahj7iOB zh!5nq8gB4#D7##3q;qI7ro*TSCd4ren1QX-(@g7$!=tTA00n$InTyxWT$unblB@rb zYuY~oCl)sl&%lKdcnQRD*%IgD_y`S;Dn}}cy%hc0@vvd!Eunx|ErLKYX?ca^ncTs7 zECzP8ls!Mtn$D|=N>pCL=<+CoXg$niK&8zxh*s2t*SF9Khl2fFWcJ~}a2l0jby0$1 zur|6bhjTG>xfQXmOB@c!wRs0z1}V9;T#*FgfS|C4f{l=6aJ4pS76B#~hL}8J!wvR= zOPgc9E2)I#k>V-0$A^%=+Ms-iU5xSI!#&;vBLRw${j{>Dp<+(qG%RoetI_COv%yVk zI!IDo{8sr%J58XEh{^{gghwpwOlJ#uru0mWl%2Q|@|H9c2K2 zHU80KT#?I9d=1erT#?1kQgz7~Ji6GbvHGou*JLjJAt}gLTLlA9ty1uCx0SP{!M6M} zyE+(mH`xe4TrvX^tG~^i$qh))^P^{gk6d1`oX$msCrPfMv7bE{+$+Ou=g<}(OA9p7 z8`;Z4e+8Eudu4ukLH=M*WUthp8yQ|dx6(Vcyf9hFx%rh-Cv@-nSM@JtO#P3G^Jf>A z=g;grcjELyPoF%wzJGQ70N%z1|EFab$_b)qyKhppJ delta 1999 zcmY*ZO^6&-5Pm=XH`6^klg+ppnAvP~XT(uZd1XS>#ApSr=zk08eMV8sB>Z*EG z_0`X}Ti)ApfkIix;(#hHKC*RYJqlH_v!;0xykCaSA3gd%7o9MyXOm zJw!N_t0Hl9&*nTy@A_ zXlN3o$y*^c;$%Fkk-ts=jS~wEL6H$VAY41+nXUMTT8%u4(i1;Ml5&*lM8+{EHc(N9 zEPE`snj*Gf1(%lU7=H;X7HJD`d+bd*vrdV^&kJ0w)G8pqQdH;Lr`KuTX#lVOcOMY?=V~iVwgV<}Q{Ic&-l3CC?OCEY2O5`JsNMbM=%Hh!K6VDk(!|L&tZrC|5fjk4|j| z2d7yO*bhKp+6RFZfiOxuPnJtCXXW(7=5`A*yb_QAvy$l@qF25&(d%PGfv{oE>)2@XLZ~$@tl_yNJ z50B`Dh7SwPgNopX(EWft!7oDzi;$9i4Mn~!hyRt^o5@V7Ddb5HE90^AdEJrYKVll?J@qj&D9%27sS@mfepXJb>u#{kc71}C9f8krNO1tBaF5a3EVO4J zTss5d|IYv~Iky_W7{91G2_X;ucN`G(`-P7MO9Z2`oY~O)X-^f zRo1sFtDCq#Cfdbo2lV-ZGe1k~Iiw#J$VvnAI&-*4K_m z)?^c;bVm*m-@aAH~-B( z0ODRn|3INQYRFrS6h%x3N6f ze)^&I$ybk!kE|ZvT+zj)V@D2NzR~_#wkPkamX}T~uPz=~ diff --git a/vendor/github.com/tetratelabs/wazero/experimental/experimental.go b/vendor/github.com/tetratelabs/wazero/experimental/experimental.go index 1d917af7c..63fd564da 100644 --- a/vendor/github.com/tetratelabs/wazero/experimental/experimental.go +++ b/vendor/github.com/tetratelabs/wazero/experimental/experimental.go @@ -12,11 +12,30 @@ import ( type InternalModule interface { api.Module - // NumGlobal returns the count of all globals in the - // module. + // NumGlobal returns the count of all globals in the module. NumGlobal() int - // Global provides a read-only view for a given global - // index. Panics if idx > GlobalsCount(). - Global(idx int) api.Global + // Global provides a read-only view for a given global index. + // + // The methods panics if i is out of bounds. + Global(i int) api.Global +} + +// ProgramCounter is an opaque value representing a specific execution point in +// a module. It is meant to be used with Function.SourceOffsetForPC and +// StackIterator. +type ProgramCounter uint64 + +// InternalFunction exposes some information about a function instance. +type InternalFunction interface { + // Definition provides introspection into the function's names and + // signature. + Definition() api.FunctionDefinition + + // SourceOffsetForPC resolves a program counter into its corresponding + // offset in the Code section of the module this function belongs to. + // The source offset is meant to help map the function calls to their + // location in the original source files. Returns 0 if the offset cannot + // be calculated. + SourceOffsetForPC(pc ProgramCounter) uint64 } diff --git a/vendor/github.com/tetratelabs/wazero/experimental/gojs/README.md b/vendor/github.com/tetratelabs/wazero/experimental/gojs/README.md index d28debf31..b608b576f 100644 --- a/vendor/github.com/tetratelabs/wazero/experimental/gojs/README.md +++ b/vendor/github.com/tetratelabs/wazero/experimental/gojs/README.md @@ -15,8 +15,8 @@ wazero includes an [example](example) that makes HTTP client requests. Go defines js "EXPERIMENTAL... exempt from the Go compatibility promise." Accordingly, wazero cannot guarantee this will work from release to release, -or that usage will be relatively free of bugs. Moreover, [`GOOS=wasi`] will -happen, and once that's available in two releases wazero will remove this +or that usage will be relatively free of bugs. Moreover, [`GOOS=wasip1`][2] will be shipped +in Go 1.21, and once that's available in two releases wazero will remove this package. Due to these concerns and the relatively high implementation overhead, most diff --git a/vendor/github.com/tetratelabs/wazero/experimental/listener.go b/vendor/github.com/tetratelabs/wazero/experimental/listener.go index 8e27e88a5..7c1ce6fb2 100644 --- a/vendor/github.com/tetratelabs/wazero/experimental/listener.go +++ b/vendor/github.com/tetratelabs/wazero/experimental/listener.go @@ -13,14 +13,17 @@ import ( // iteration. As a result, parameter values may be different than the ones their // function was called with. type StackIterator interface { - // Next moves the iterator to the next function in the stack. Returns false - // if it reached the bottom of the stack. + // Next moves the iterator to the next function in the stack. Returns + // false if it reached the bottom of the stack. Next() bool - // FunctionDefinition returns the function type of the current function. - FunctionDefinition() api.FunctionDefinition + // Function describes the function called by the current frame. + Function() InternalFunction + // ProgramCounter returns the program counter associated with the + // function call. + ProgramCounter() ProgramCounter // Parameters returns api.ValueType-encoded parameters of the current - // function. Do not modify the content of the slice, and copy out any value - // you need. + // function. Do not modify the content of the slice, and copy out any + // value you need. Parameters() []uint64 } @@ -32,9 +35,9 @@ type FunctionListenerFactoryKey struct{} // FunctionListenerFactory returns FunctionListeners to be notified when a // function is called. type FunctionListenerFactory interface { - // NewListener returns a FunctionListener for a defined function. If nil is - // returned, no listener will be notified. - NewListener(api.FunctionDefinition) FunctionListener + // NewFunctionListener returns a FunctionListener for a defined function. + // If nil is returned, no listener will be notified. + NewFunctionListener(api.FunctionDefinition) FunctionListener // ^^ A single instance can be returned to avoid instantiating a listener // per function, especially as they may be thousands of functions. Shared // listeners use their FunctionDefinition parameter to clarify. @@ -43,8 +46,11 @@ type FunctionListenerFactory interface { // FunctionListener can be registered for any function via // FunctionListenerFactory to be notified when the function is called. type FunctionListener interface { - // Before is invoked before a function is called. The returned context will - // be used as the context of this function call. + // Before is invoked before a function is called. + // + // There is always one corresponding call to After or Abort for each call to + // Before. This guarantee allows the listener to maintain an internal stack + // to perform correlations between the entry and exit of functions. // // # Params // @@ -52,36 +58,304 @@ type FunctionListener interface { // instance or parent of the result. // - mod: the calling module. // - def: the function definition. - // - paramValues: api.ValueType encoded parameters. + // - params: api.ValueType encoded parameters. // - stackIterator: iterator on the call stack. At least one entry is // guaranteed (the called function), whose Args() will be equal to - // paramValues. The iterator will be reused between calls to Before. + // params. The iterator will be reused between calls to Before. // // Note: api.Memory is meant for inspection, not modification. // mod can be cast to InternalModule to read non-exported globals. - Before(ctx context.Context, mod api.Module, def api.FunctionDefinition, paramValues []uint64, stackIterator StackIterator) context.Context + Before(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, stackIterator StackIterator) // After is invoked after a function is called. // // # Params // - // - ctx: the context returned by Before. + // - ctx: the context of the caller function. // - mod: the calling module. // - def: the function definition. - // - err: nil if the function didn't err - // - resultValues: api.ValueType encoded results. + // - results: api.ValueType encoded results. // - // Note: api.Memory is meant for inspection, not modification. - After(ctx context.Context, mod api.Module, def api.FunctionDefinition, err error, resultValues []uint64) + // # Notes + // + // - api.Memory is meant for inspection, not modification. + // - This is not called when a host function panics, or a guest function traps. + // See Abort for more details. + After(ctx context.Context, mod api.Module, def api.FunctionDefinition, results []uint64) + + // Abort is invoked when a function does not return due to a trap or panic. + // + // # Params + // + // - ctx: the context of the caller function. + // - mod: the calling module. + // - def: the function definition. + // - err: the error value representing the reason why the function aborted. + // + // # Notes + // + // - api.Memory is meant for inspection, not modification. + Abort(ctx context.Context, mod api.Module, def api.FunctionDefinition, err error) } -// TODO: We need to add tests to enginetest to ensure contexts nest. A good test can use a combination of call and call -// indirect in terms of depth and breadth. The test could show a tree 3 calls deep where the there are a couple calls at -// each depth under the root. The main thing this can help prevent is accidentally swapping the context internally. +// FunctionListenerFunc is a function type implementing the FunctionListener +// interface, making it possible to use regular functions and methods as +// listeners of function invocation. +// +// The FunctionListener interface declares two methods (Before and After), +// but this type invokes its value only when Before is called. It is best +// suites for cases where the host does not need to perform correlation +// between the start and end of the function call. +type FunctionListenerFunc func(context.Context, api.Module, api.FunctionDefinition, []uint64, StackIterator) + +// Before satisfies the FunctionListener interface, calls f. +func (f FunctionListenerFunc) Before(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, stackIterator StackIterator) { + f(ctx, mod, def, params, stackIterator) +} + +// After is declared to satisfy the FunctionListener interface, but it does +// nothing. +func (f FunctionListenerFunc) After(context.Context, api.Module, api.FunctionDefinition, []uint64) { +} + +// Abort is declared to satisfy the FunctionListener interface, but it does +// nothing. +func (f FunctionListenerFunc) Abort(context.Context, api.Module, api.FunctionDefinition, error) { +} + +// FunctionListenerFactoryFunc is a function type implementing the +// FunctionListenerFactory interface, making it possible to use regular +// functions and methods as factory of function listeners. +type FunctionListenerFactoryFunc func(api.FunctionDefinition) FunctionListener + +// NewFunctionListener satisfies the FunctionListenerFactory interface, calls f. +func (f FunctionListenerFactoryFunc) NewFunctionListener(def api.FunctionDefinition) FunctionListener { + return f(def) +} -// TODO: Errors aren't handled, and the After hook should accept one along with the result values. +// MultiFunctionListenerFactory constructs a FunctionListenerFactory which +// combines the listeners created by each of the factories passed as arguments. +// +// This function is useful when multiple listeners need to be hooked to a module +// because the propagation mechanism based on installing a listener factory in +// the context.Context used when instantiating modules allows for a single +// listener to be installed. +// +// The stack iterator passed to the Before method is reset so that each listener +// can iterate the call stack independently without impacting the ability of +// other listeners to do so. +func MultiFunctionListenerFactory(factories ...FunctionListenerFactory) FunctionListenerFactory { + multi := make(multiFunctionListenerFactory, len(factories)) + copy(multi, factories) + return multi +} + +type multiFunctionListenerFactory []FunctionListenerFactory + +func (multi multiFunctionListenerFactory) NewFunctionListener(def api.FunctionDefinition) FunctionListener { + var lstns []FunctionListener + for _, factory := range multi { + if lstn := factory.NewFunctionListener(def); lstn != nil { + lstns = append(lstns, lstn) + } + } + switch len(lstns) { + case 0: + return nil + case 1: + return lstns[0] + default: + return &multiFunctionListener{lstns: lstns} + } +} + +type multiFunctionListener struct { + lstns []FunctionListener + stack stackIterator +} + +func (multi *multiFunctionListener) Before(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, si StackIterator) { + multi.stack.base = si + for _, lstn := range multi.lstns { + multi.stack.index = -1 + lstn.Before(ctx, mod, def, params, &multi.stack) + } +} + +func (multi *multiFunctionListener) After(ctx context.Context, mod api.Module, def api.FunctionDefinition, results []uint64) { + for _, lstn := range multi.lstns { + lstn.After(ctx, mod, def, results) + } +} + +func (multi *multiFunctionListener) Abort(ctx context.Context, mod api.Module, def api.FunctionDefinition, err error) { + for _, lstn := range multi.lstns { + lstn.Abort(ctx, mod, def, err) + } +} + +type parameters struct { + values []uint64 + limits []uint8 +} + +func (ps *parameters) append(values []uint64) { + ps.values = append(ps.values, values...) + ps.limits = append(ps.limits, uint8(len(ps.values))) +} + +func (ps *parameters) clear() { + ps.values = ps.values[:0] + ps.limits = ps.limits[:0] +} + +func (ps *parameters) index(i int) []uint64 { + j := uint8(0) + k := ps.limits[i] + if i > 0 { + j = ps.limits[i-1] + } + return ps.values[j:k:k] +} + +type stackIterator struct { + base StackIterator + index int + pcs []uint64 + fns []InternalFunction + params parameters +} + +func (si *stackIterator) Next() bool { + if si.base != nil { + si.pcs = si.pcs[:0] + si.fns = si.fns[:0] + si.params.clear() + + for si.base.Next() { + si.pcs = append(si.pcs, uint64(si.base.ProgramCounter())) + si.fns = append(si.fns, si.base.Function()) + si.params.append(si.base.Parameters()) + } + + si.base = nil + } + si.index++ + return si.index < len(si.pcs) +} + +func (si *stackIterator) ProgramCounter() ProgramCounter { + return ProgramCounter(si.pcs[si.index]) +} + +func (si *stackIterator) Function() InternalFunction { + return si.fns[si.index] +} + +func (si *stackIterator) Parameters() []uint64 { + return si.params.index(si.index) +} + +// StackFrame represents a frame on the call stack. +type StackFrame struct { + Function api.Function + Params []uint64 + Results []uint64 + PC uint64 + SourceOffset uint64 +} + +type internalFunction struct { + definition api.FunctionDefinition + sourceOffset uint64 +} + +func (f internalFunction) Definition() api.FunctionDefinition { + return f.definition +} + +func (f internalFunction) SourceOffsetForPC(pc ProgramCounter) uint64 { + return f.sourceOffset +} + +// stackFrameIterator is an implementation of the experimental.stackFrameIterator +// interface. +type stackFrameIterator struct { + index int + stack []StackFrame + fndef []api.FunctionDefinition +} + +func (si *stackFrameIterator) Next() bool { + si.index++ + return si.index < len(si.stack) +} + +func (si *stackFrameIterator) Function() InternalFunction { + return internalFunction{ + definition: si.fndef[si.index], + sourceOffset: si.stack[si.index].SourceOffset, + } +} + +func (si *stackFrameIterator) ProgramCounter() ProgramCounter { + return ProgramCounter(si.stack[si.index].PC) +} + +func (si *stackFrameIterator) Parameters() []uint64 { + return si.stack[si.index].Params +} + +// NewStackIterator constructs a stack iterator from a list of stack frames. +// The top most frame is the last one. +func NewStackIterator(stack ...StackFrame) StackIterator { + si := &stackFrameIterator{ + index: -1, + stack: make([]StackFrame, len(stack)), + fndef: make([]api.FunctionDefinition, len(stack)), + } + for i := range stack { + si.stack[i] = stack[len(stack)-(i+1)] + } + // The size of function definition is only one pointer which should allow + // the compiler to optimize the conversion to api.FunctionDefinition; but + // the presence of internal.WazeroOnlyType, despite being defined as an + // empty struct, forces a heap allocation that we amortize by caching the + // result. + for i, frame := range stack { + si.fndef[i] = frame.Function.Definition() + } + return si +} + +// BenchmarkFunctionListener implements a benchmark for function listeners. +// +// The benchmark calls Before and After methods repeatedly using the provided +// module an stack frames to invoke the methods. +// +// The stack frame is a representation of the call stack that the Before method +// will be invoked with. The top of the stack is stored at index zero. The stack +// must contain at least one frame or the benchmark will fail. +func BenchmarkFunctionListener(n int, module api.Module, stack []StackFrame, listener FunctionListener) { + if len(stack) == 0 { + panic("cannot benchmark function listener with an empty stack") + } + + ctx := context.Background() + def := stack[0].Function.Definition() + params := stack[0].Params + results := stack[0].Results + stackIterator := &stackIterator{base: NewStackIterator(stack...)} + + for i := 0; i < n; i++ { + stackIterator.index = -1 + listener.Before(ctx, module, def, params, stackIterator) + listener.After(ctx, module, def, results) + } +} -// TODO: The context parameter of the After hook is not the same as the Before hook. This means interceptor patterns -// are awkward. e.g. something like timing is difficult as it requires propagating a stack. Otherwise, nested calls will -// overwrite each other's "since" time. Propagating a stack is further awkward as the After hook needs to know the -// position to read from which might be subtle. +// TODO: the calls to Abort are not yet tested in internal/testing/enginetest, +// but they are validated indirectly in tests which exercise host logging, +// like Test_procExit in imports/wasi_snapshot_preview1. Eventually we should +// add dedicated tests to validate the behavior of the interpreter and compiler +// engines independently. diff --git a/vendor/github.com/tetratelabs/wazero/fsconfig.go b/vendor/github.com/tetratelabs/wazero/fsconfig.go index deeb7d7d5..099a79173 100644 --- a/vendor/github.com/tetratelabs/wazero/fsconfig.go +++ b/vendor/github.com/tetratelabs/wazero/fsconfig.go @@ -3,6 +3,7 @@ package wazero import ( "io/fs" + "github.com/tetratelabs/wazero/internal/fsapi" "github.com/tetratelabs/wazero/internal/sysfs" ) @@ -122,7 +123,7 @@ type FSConfig interface { type fsConfig struct { // fs are the currently configured filesystems. - fs []sysfs.FS + fs []fsapi.FS // guestPaths are the user-supplied names of the filesystems, retained for // error messages and fmt.Stringer. guestPaths []string @@ -139,7 +140,7 @@ func NewFSConfig() FSConfig { // clone makes a deep copy of this module config. func (c *fsConfig) clone() *fsConfig { ret := *c // copy except slice and maps which share a ref - ret.fs = make([]sysfs.FS, 0, len(c.fs)) + ret.fs = make([]fsapi.FS, 0, len(c.fs)) ret.fs = append(ret.fs, c.fs...) ret.guestPaths = make([]string, 0, len(c.guestPaths)) ret.guestPaths = append(ret.guestPaths, c.guestPaths...) @@ -165,7 +166,7 @@ func (c *fsConfig) WithFSMount(fs fs.FS, guestPath string) FSConfig { return c.withMount(sysfs.Adapt(fs), guestPath) } -func (c *fsConfig) withMount(fs sysfs.FS, guestPath string) FSConfig { +func (c *fsConfig) withMount(fs fsapi.FS, guestPath string) FSConfig { cleaned := sysfs.StripPrefixesAndTrailingSlash(guestPath) ret := c.clone() if i, ok := ret.guestPathToFS[cleaned]; ok { @@ -179,6 +180,6 @@ func (c *fsConfig) withMount(fs sysfs.FS, guestPath string) FSConfig { return ret } -func (c *fsConfig) toFS() (sysfs.FS, error) { +func (c *fsConfig) toFS() (fsapi.FS, error) { return sysfs.NewRootFS(c.fs, c.guestPaths) } diff --git a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/fs.go b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/fs.go index 7bfc30a80..c87d7699f 100644 --- a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/fs.go +++ b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/fs.go @@ -2,32 +2,23 @@ package wasi_snapshot_preview1 import ( "context" - "errors" "io" "io/fs" "math" "path" - "reflect" "strings" "syscall" "unsafe" "github.com/tetratelabs/wazero/api" - "github.com/tetratelabs/wazero/internal/platform" + "github.com/tetratelabs/wazero/internal/fsapi" + socketapi "github.com/tetratelabs/wazero/internal/sock" "github.com/tetratelabs/wazero/internal/sys" "github.com/tetratelabs/wazero/internal/sysfs" "github.com/tetratelabs/wazero/internal/wasip1" "github.com/tetratelabs/wazero/internal/wasm" ) -// The following interfaces are used until we finalize our own FD-scoped file. -type ( - // syncFile is implemented by os.File in file_posix.go - syncFile interface{ Sync() error } - // truncateFile is implemented by os.File in file_posix.go - truncateFile interface{ Truncate(size int64) error } -) - // fdAdvise is the WASI function named FdAdviseName which provides file // advisory information on a file descriptor. // @@ -97,22 +88,16 @@ func fdAllocateFn(_ context.Context, mod api.Module, params []uint64) syscall.Er return syscall.EINVAL } - st, err := f.Stat() - if err != nil { - return platform.UnwrapOSError(err) + st, errno := f.File.Stat() + if errno != 0 { + return errno } if st.Size >= tail { - // We already have enough space. - return 0 + return 0 // We already have enough space. } - osf, ok := f.File.(truncateFile) - if !ok { - return syscall.EBADF - } - - return platform.UnwrapOSError(osf.Truncate(tail)) + return f.File.Truncate(tail) } // fdClose is the WASI function named FdCloseName which closes a file @@ -154,7 +139,7 @@ func fdDatasyncFn(_ context.Context, mod api.Module, params []uint64) syscall.Er if f, ok := fsc.LookupFile(fd); !ok { return syscall.EBADF } else { - return sysfs.FileDatasync(f.File) + return f.File.Datasync() } } @@ -211,35 +196,103 @@ func fdFdstatGetFn(_ context.Context, mod api.Module, params []uint64) syscall.E } var fdflags uint16 - var st fs.FileInfo - var err error - if f, ok := fsc.LookupFile(fd); !ok { + var st fsapi.Stat_t + var errno syscall.Errno + f, ok := fsc.LookupFile(fd) + if !ok { return syscall.EBADF - } else if st, err = f.File.Stat(); err != nil { - return platform.UnwrapOSError(err) - } else if _, ok := f.File.(io.Writer); ok { - // TODO: maybe cache flags to open instead - fdflags = wasip1.FD_APPEND + } else if st, errno = f.File.Stat(); errno != 0 { + return errno + } else if f.File.IsAppend() { + fdflags |= wasip1.FD_APPEND } - filetype := getWasiFiletype(st.Mode()) - writeFdstat(buf, filetype, fdflags) + if f.File.IsNonblock() { + fdflags |= wasip1.FD_NONBLOCK + } + + var fsRightsBase uint32 + var fsRightsInheriting uint32 + fileType := getExtendedWasiFiletype(f.File, st.Mode) + + switch fileType { + case wasip1.FILETYPE_DIRECTORY: + // To satisfy wasi-testsuite, we must advertise that directories cannot + // be given seek permission (RIGHT_FD_SEEK). + fsRightsBase = dirRightsBase + fsRightsInheriting = fileRightsBase | dirRightsBase + case wasip1.FILETYPE_CHARACTER_DEVICE: + // According to wasi-libc, + // > A tty is a character device that we can't seek or tell on. + // See https://github.com/WebAssembly/wasi-libc/blob/a6f871343313220b76009827ed0153586361c0d5/libc-bottom-half/sources/isatty.c#L13-L18 + fsRightsBase = fileRightsBase &^ wasip1.RIGHT_FD_SEEK &^ wasip1.RIGHT_FD_TELL + default: + fsRightsBase = fileRightsBase + } + writeFdstat(buf, fileType, fdflags, fsRightsBase, fsRightsInheriting) return 0 } -var blockFdstat = []byte{ - wasip1.FILETYPE_BLOCK_DEVICE, 0, // filetype - 0, 0, 0, 0, 0, 0, // fdflags - 0, 0, 0, 0, 0, 0, 0, 0, // fs_rights_base - 0, 0, 0, 0, 0, 0, 0, 0, // fs_rights_inheriting +// isPreopenedStdio returns true if the FD is sys.FdStdin, sys.FdStdout or +// sys.FdStderr and pre-opened. This double check is needed in case the guest +// closes stdin and re-opens it with a random alternative file. +// +// Currently, we only support non-blocking mode for standard I/O streams. +// Non-blocking mode is rarely supported for regular files, and we don't +// yet have support for sockets, so we make a special case. +// +// Note: this to get or set FD_NONBLOCK, but skip FD_APPEND. Our current +// implementation can't set FD_APPEND, without re-opening files. As stdio are +// pre-opened, we don't know how to re-open them, neither should we close the +// underlying file. Later, we could add support for setting FD_APPEND, similar +// to SetNonblock. +func isPreopenedStdio(fd int32, f *sys.FileEntry) bool { + return fd <= sys.FdStderr && f.IsPreopen } -func writeFdstat(buf []byte, filetype uint8, fdflags uint16) { - // memory is re-used, so ensure the result is defaulted. - copy(buf, blockFdstat) - buf[0] = filetype - buf[2] = byte(fdflags) +const fileRightsBase = wasip1.RIGHT_FD_DATASYNC | + wasip1.RIGHT_FD_READ | + wasip1.RIGHT_FD_SEEK | + wasip1.RIGHT_FDSTAT_SET_FLAGS | + wasip1.RIGHT_FD_SYNC | + wasip1.RIGHT_FD_TELL | + wasip1.RIGHT_FD_WRITE | + wasip1.RIGHT_FD_ADVISE | + wasip1.RIGHT_FD_ALLOCATE | + wasip1.RIGHT_FD_FILESTAT_GET | + wasip1.RIGHT_FD_FILESTAT_SET_SIZE | + wasip1.RIGHT_FD_FILESTAT_SET_TIMES | + wasip1.RIGHT_POLL_FD_READWRITE + +const dirRightsBase = wasip1.RIGHT_FD_DATASYNC | + wasip1.RIGHT_FDSTAT_SET_FLAGS | + wasip1.RIGHT_FD_SYNC | + wasip1.RIGHT_PATH_CREATE_DIRECTORY | + wasip1.RIGHT_PATH_CREATE_FILE | + wasip1.RIGHT_PATH_LINK_SOURCE | + wasip1.RIGHT_PATH_LINK_TARGET | + wasip1.RIGHT_PATH_OPEN | + wasip1.RIGHT_FD_READDIR | + wasip1.RIGHT_PATH_READLINK | + wasip1.RIGHT_PATH_RENAME_SOURCE | + wasip1.RIGHT_PATH_RENAME_TARGET | + wasip1.RIGHT_PATH_FILESTAT_GET | + wasip1.RIGHT_PATH_FILESTAT_SET_SIZE | + wasip1.RIGHT_PATH_FILESTAT_SET_TIMES | + wasip1.RIGHT_FD_FILESTAT_GET | + wasip1.RIGHT_FD_FILESTAT_SET_TIMES | + wasip1.RIGHT_PATH_SYMLINK | + wasip1.RIGHT_PATH_REMOVE_DIRECTORY | + wasip1.RIGHT_PATH_UNLINK_FILE + +func writeFdstat(buf []byte, fileType uint8, fdflags uint16, fsRightsBase, fsRightsInheriting uint32) { + b := (*[24]byte)(buf) + le.PutUint16(b[0:], uint16(fileType)) + le.PutUint16(b[2:], fdflags) + le.PutUint32(b[4:], 0) + le.PutUint64(b[8:], uint64(fsRightsBase)) + le.PutUint64(b[16:], uint64(fsRightsInheriting)) } // fdFdstatSetFlags is the WASI function named FdFdstatSetFlagsName which @@ -250,17 +303,27 @@ func fdFdstatSetFlagsFn(_ context.Context, mod api.Module, params []uint64) sysc fd, wasiFlag := int32(params[0]), uint16(params[1]) fsc := mod.(*wasm.ModuleInstance).Sys.FS() - // We can only support APPEND flag. - if wasip1.FD_DSYNC&wasiFlag != 0 || wasip1.FD_NONBLOCK&wasiFlag != 0 || wasip1.FD_RSYNC&wasiFlag != 0 || wasip1.FD_SYNC&wasiFlag != 0 { + // Currently we only support APPEND and NONBLOCK. + if wasip1.FD_DSYNC&wasiFlag != 0 || wasip1.FD_RSYNC&wasiFlag != 0 || wasip1.FD_SYNC&wasiFlag != 0 { return syscall.EINVAL } - var flag int - if wasip1.FD_APPEND&wasiFlag != 0 { - flag = syscall.O_APPEND + if f, ok := fsc.LookupFile(fd); !ok { + return syscall.EBADF + } else { + nonblock := wasip1.FD_NONBLOCK&wasiFlag != 0 + errno := f.File.SetNonblock(nonblock) + if errno != 0 { + return errno + } + if stat, err := f.File.Stat(); err == 0 && stat.Mode.IsRegular() { + // For normal files, proceed to apply an append flag. + append := wasip1.FD_APPEND&wasiFlag != 0 + return f.File.SetAppend(append) + } } - return fsc.ChangeOpenFlag(fd, flag) + return 0 } // fdFdstatSetRights will not be implemented as rights were removed from WASI. @@ -341,12 +404,25 @@ func fdFilestatGetFunc(mod api.Module, fd int32, resultBuf uint32) syscall.Errno return syscall.EBADF } - st, err := f.Stat() - if err != nil { - return platform.UnwrapOSError(err) + st, errno := f.File.Stat() + if errno != 0 { + return errno } - return writeFilestat(buf, &st) + filetype := getExtendedWasiFiletype(f.File, st.Mode) + return writeFilestat(buf, &st, filetype) +} + +func getExtendedWasiFiletype(file fsapi.File, fm fs.FileMode) (ftype uint8) { + ftype = getWasiFiletype(fm) + if ftype == wasip1.FILETYPE_UNKNOWN { + if _, ok := file.(socketapi.TCPSock); ok { + ftype = wasip1.FILETYPE_SOCKET_STREAM + } else if _, ok = file.(socketapi.TCPConn); ok { + ftype = wasip1.FILETYPE_SOCKET_STREAM + } + } + return } func getWasiFiletype(fm fs.FileMode) uint8 { @@ -369,10 +445,10 @@ func getWasiFiletype(fm fs.FileMode) uint8 { } } -func writeFilestat(buf []byte, st *platform.Stat_t) (errno syscall.Errno) { +func writeFilestat(buf []byte, st *fsapi.Stat_t, ftype uint8) (errno syscall.Errno) { le.PutUint64(buf, st.Dev) le.PutUint64(buf[8:], st.Ino) - le.PutUint64(buf[16:], uint64(getWasiFiletype(st.Mode))) + le.PutUint64(buf[16:], uint64(ftype)) le.PutUint64(buf[24:], st.Nlink) le.PutUint64(buf[32:], uint64(st.Size)) le.PutUint64(buf[40:], uint64(st.Atim)) @@ -396,12 +472,9 @@ func fdFilestatSetSizeFn(_ context.Context, mod api.Module, params []uint64) sys // Check to see if the file descriptor is available if f, ok := fsc.LookupFile(fd); !ok { return syscall.EBADF - } else if truncateFile, ok := f.File.(truncateFile); !ok { - return syscall.EBADF // possibly a fake file - } else if err := truncateFile.Truncate(int64(size)); err != nil { - return platform.UnwrapOSError(err) + } else { + return f.File.Truncate(int64(size)) } - return 0 } // fdFilestatSetTimes is the WASI function named functionFdFilestatSetTimes @@ -434,7 +507,7 @@ func fdFilestatSetTimesFn(_ context.Context, mod api.Module, params []uint64) sy } // Try to update the file timestamps by file-descriptor. - errno = platform.UtimensFile(f.File, ×) + errno = f.File.Utimens(×) // Fall back to path based, despite it being less precise. switch errno { @@ -455,9 +528,9 @@ func toTimes(atim, mtime int64, fstFlags uint16) (times [2]syscall.Timespec, err } else if set { times[0] = syscall.NsecToTimespec(atim) } else if now { - times[0].Nsec = platform.UTIME_NOW + times[0].Nsec = sysfs.UTIME_NOW } else { - times[0].Nsec = platform.UTIME_OMIT + times[0].Nsec = sysfs.UTIME_OMIT } // coerce mtim into a timespec @@ -467,9 +540,9 @@ func toTimes(atim, mtime int64, fstFlags uint16) (times [2]syscall.Timespec, err } else if set { times[1] = syscall.NsecToTimespec(mtime) } else if now { - times[1].Nsec = platform.UTIME_NOW + times[1].Nsec = sysfs.UTIME_NOW } else { - times[1].Nsec = platform.UTIME_OMIT + times[1].Nsec = sysfs.UTIME_OMIT } return } @@ -668,6 +741,23 @@ var fdRead = newHostFunc( "fd", "iovs", "iovs_len", "result.nread", ) +// preader tracks an offset across multiple reads. +type preader struct { + f fsapi.File + offset int64 +} + +// Read implements the same function as documented on internalapi.File. +func (w *preader) Read(buf []byte) (n int, errno syscall.Errno) { + if len(buf) == 0 { + return 0, 0 // less overhead on zero-length reads. + } + + n, err := w.f.Pread(buf, w.offset) + w.offset += int64(n) + return n, err +} + func fdReadFn(_ context.Context, mod api.Module, params []uint64) syscall.Errno { return fdReadOrPread(mod, params, false) } @@ -677,31 +767,39 @@ func fdReadOrPread(mod api.Module, params []uint64, isPread bool) syscall.Errno fsc := mod.(*wasm.ModuleInstance).Sys.FS() fd := int32(params[0]) - - r, ok := fsc.LookupFile(fd) - if !ok { - return syscall.EBADF - } - - var reader io.Reader = r.File - iovs := uint32(params[1]) iovsCount := uint32(params[2]) var resultNread uint32 - if isPread { + var reader func(buf []byte) (n int, errno syscall.Errno) + if f, ok := fsc.LookupFile(fd); !ok { + return syscall.EBADF + } else if isPread { offset := int64(params[3]) - reader = sysfs.ReaderAtOffset(r.File, offset) + reader = (&preader{f: f.File, offset: offset}).Read resultNread = uint32(params[4]) } else { + reader = f.File.Read resultNread = uint32(params[3]) } + nread, errno := readv(mem, iovs, iovsCount, reader) + if errno != 0 { + return errno + } + if !mem.WriteUint32Le(resultNread, nread) { + return syscall.EFAULT + } else { + return 0 + } +} + +func readv(mem api.Memory, iovs uint32, iovsCount uint32, reader func(buf []byte) (nread int, errno syscall.Errno)) (uint32, syscall.Errno) { var nread uint32 iovsStop := iovsCount << 3 // iovsCount * 8 iovsBuf, ok := mem.Read(iovs, iovsStop) if !ok { - return syscall.EFAULT + return 0, syscall.EFAULT } for iovsPos := uint32(0); iovsPos < iovsStop; iovsPos += 8 { @@ -714,41 +812,21 @@ func fdReadOrPread(mod api.Module, params []uint64, isPread bool) syscall.Errno b, ok := mem.Read(offset, l) if !ok { - return syscall.EFAULT + return 0, syscall.EFAULT } - n, err := reader.Read(b) + n, errno := reader(b) nread += uint32(n) - shouldContinue, errno := fdRead_shouldContinueRead(uint32(n), l, err) - if errno != 0 { - return errno - } else if !shouldContinue { - break + if errno == syscall.ENOSYS { + return 0, syscall.EBADF // e.g. unimplemented for read + } else if errno != 0 { + return 0, errno + } else if n < int(l) { + break // stop when we read less than capacity. } } - if !mem.WriteUint32Le(resultNread, nread) { - return syscall.EFAULT - } else { - return 0 - } -} - -// fdRead_shouldContinueRead decides whether to continue reading the next iovec -// based on the amount read (n/l) and a possible error returned from io.Reader. -// -// Note: When there are both bytes read (n) and an error, this continues. -// See /RATIONALE.md "Why ignore the error returned by io.Reader when n > 1?" -func fdRead_shouldContinueRead(n, l uint32, err error) (bool, syscall.Errno) { - if errors.Is(err, io.EOF) { - return false, 0 // EOF isn't an error, and we shouldn't continue. - } else if err != nil && n == 0 { - return false, syscall.EIO - } else if err != nil { - return false, 0 // Allow the caller to process n bytes. - } - // Continue reading, unless there's a partial read or nothing to read. - return n == l && n != 0, 0 + return nread, 0 } // fdReaddir is the WASI function named FdReaddirName which reads directory @@ -781,92 +859,33 @@ func fdReaddirFn(_ context.Context, mod api.Module, params []uint64) syscall.Err } // Validate the FD is a directory - rd, dir, errno := openedDir(fsc, fd) + f, errno := openedDir(fsc, fd) if errno != 0 { return errno } - - if cookie == 0 && dir.CountRead > 0 { - // This means that there was a previous call to the dir, but cookie is reset. - // This happens when the program calls rewinddir, for example: - // https://github.com/WebAssembly/wasi-libc/blob/659ff414560721b1660a19685110e484a081c3d4/libc-bottom-half/cloudlibc/src/libc/dirent/rewinddir.c#L10-L12 - // - // Since we cannot unwind fs.ReadDirFile results, we re-open while keeping the same file descriptor. - f, errno := fsc.ReOpenDir(fd) - if errno != 0 { - return errno - } - rd, dir = f.File, f.ReadDir - } - - // First, determine the maximum directory entries that can be encoded as - // dirents. The total size is DirentSize(24) + nameSize, for each file. - // Since a zero-length file name is invalid, the minimum size entry is - // 25 (DirentSize + 1 character). - maxDirEntries := int(bufLen/wasip1.DirentSize + 1) - - // While unlikely maxDirEntries will fit into bufLen, add one more just in - // case, as we need to know if we hit the end of the directory or not to - // write the correct bufused (e.g. == bufLen unless EOF). - // >> If less than the size of the read buffer, the end of the - // >> directory has been reached. - maxDirEntries += 1 - - // The host keeps state for any unread entries from the prior call because - // we cannot seek to a previous directory position. Collect these entries. - dirents, errno := lastDirents(dir, cookie) + // Discard the bool value because we validated the fd already. + dir, errno := fsc.LookupReaddir(fd, f) if errno != 0 { return errno } - - // Add entries for dot and dot-dot as wasi-testsuite requires them. - if cookie == 0 && dirents == nil { - if f, ok := fsc.LookupFile(fd); !ok { - return syscall.EBADF - } else if dirents, errno = dotDirents(f); errno != 0 { - return errno - } - dir.Dirents = dirents - dir.CountRead = 2 // . and .. - } - - // Check if we have maxDirEntries, and read more from the FS as needed. - if entryCount := len(dirents); entryCount < maxDirEntries { - // Note: platform.Readdir does not return io.EOF as it is - // inconsistently returned (e.g. darwin does, but linux doesn't). - l, errno := platform.Readdir(rd, maxDirEntries-entryCount) - if errno != 0 { - return errno - } - - // Zero length read is possible on an empty or exhausted directory. - if len(l) > 0 { - dir.CountRead += uint64(len(l)) - dirents = append(dirents, l...) - // Replace the cache with up to maxDirEntries, starting at cookie. - dir.Dirents = dirents - } + // Validate the cookie and possibly sync the internal state to the one the cookie represents. + if errno = dir.Rewind(cookie); errno != 0 { + return errno } // Determine how many dirents we can write, excluding a potentially // truncated entry. - bufused, direntCount, writeTruncatedEntry := maxDirents(dirents, bufLen) + dirents, bufused, direntCount, writeTruncatedEntry := maxDirents(dir, bufLen) // Now, write entries to the underlying buffer. if bufused > 0 { - - // d_next is the index of the next file in the list, so it should - // always be one higher than the requested cookie. - d_next := uint64(cookie + 1) - // ^^ yes this can overflow to negative, which means our implementation - // doesn't support writing greater than max int64 entries. - buf, ok := mem.Read(buf, bufused) if !ok { return syscall.EFAULT } - writeDirents(dirents, direntCount, writeTruncatedEntry, buf, d_next) + // Iterate again on dir, this time writing the entries. + writeDirents(dirents, direntCount, writeTruncatedEntry, buf, uint64(cookie+1)) } if !mem.WriteUint32Le(resultBufused, bufused) { @@ -875,66 +894,8 @@ func fdReaddirFn(_ context.Context, mod api.Module, params []uint64) syscall.Err return 0 } -// dotDirents returns "." and "..", where "." because wasi-testsuite does inode -// validation. -func dotDirents(f *sys.FileEntry) ([]*platform.Dirent, syscall.Errno) { - dotIno, ft, err := f.CachedStat() - if err != nil { - return nil, platform.UnwrapOSError(err) - } else if ft.Type() != fs.ModeDir { - return nil, syscall.ENOTDIR - } - dotDotIno := uint64(0) - if !f.IsPreopen && f.Name != "." { - if st, errno := f.FS.Stat(path.Dir(f.Name)); errno != 0 { - return nil, errno - } else { - dotDotIno = st.Ino - } - } - return []*platform.Dirent{ - {Name: ".", Ino: dotIno, Type: fs.ModeDir}, - {Name: "..", Ino: dotDotIno, Type: fs.ModeDir}, - }, 0 -} - const largestDirent = int64(math.MaxUint32 - wasip1.DirentSize) -// lastDirents is broken out from fdReaddirFn for testability. -func lastDirents(dir *sys.ReadDir, cookie int64) (dirents []*platform.Dirent, errno syscall.Errno) { - if cookie < 0 { - errno = syscall.EINVAL // invalid as we will never send a negative cookie. - return - } - - entryCount := int64(len(dir.Dirents)) - if entryCount == 0 { // there was no prior call - if cookie != 0 { - errno = syscall.EINVAL // invalid as we haven't sent that cookie - } - return - } - - // Get the first absolute position in our window of results - firstPos := int64(dir.CountRead) - entryCount - cookiePos := cookie - firstPos - - switch { - case cookiePos < 0: // cookie is asking for results outside our window. - errno = syscall.ENOSYS // we can't implement directory seeking backwards. - case cookiePos > entryCount: - errno = syscall.EINVAL // invalid as we read that far, yet. - case cookiePos > 0: // truncate so to avoid large lists. - dirents = dir.Dirents[cookiePos:] - default: - dirents = dir.Dirents - } - if len(dirents) == 0 { - dirents = nil - } - return -} - // maxDirents returns the maximum count and total entries that can fit in // maxLen bytes. // @@ -944,21 +905,27 @@ func lastDirents(dir *sys.ReadDir, cookie int64) (dirents []*platform.Dirent, er // // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fd_readdir // See https://github.com/WebAssembly/wasi-libc/blob/659ff414560721b1660a19685110e484a081c3d4/libc-bottom-half/cloudlibc/src/libc/dirent/readdir.c#L44 -func maxDirents(entries []*platform.Dirent, bufLen uint32) (bufused, direntCount uint32, writeTruncatedEntry bool) { +func maxDirents(dir *sys.Readdir, bufLen uint32) (dirents []fsapi.Dirent, bufused, direntCount uint32, writeTruncatedEntry bool) { lenRemaining := bufLen - for _, e := range entries { + for { + d, errno := dir.Peek() + if errno != 0 { + return + } + dirents = append(dirents, *d) + if lenRemaining < wasip1.DirentSize { // We don't have enough space in bufLen for another struct, // entry. A caller who wants more will retry. - // bufused == bufLen means more entries exist, which is the case + // bufused == bufLen means more dirents exist, which is the case // when the dirent is larger than bytes remaining. bufused = bufLen break } // use int64 to guard against huge filenames - nameLen := int64(len(e.Name)) + nameLen := int64(len(d.Name)) var entryLen uint32 // Check to see if DirentSize + nameLen overflows, or if it would be @@ -979,7 +946,7 @@ func maxDirents(entries []*platform.Dirent, bufLen uint32) (bufused, direntCount // In this case, we only write up to DirentSize(24) to allow the // caller to resize. - // bufused == bufLen means more entries exist, which is the case + // bufused == bufLen means more dirents exist, which is the case // when the next entry is larger than bytes remaining. bufused = bufLen @@ -993,6 +960,7 @@ func maxDirents(entries []*platform.Dirent, bufLen uint32) (bufused, direntCount lenRemaining -= entryLen bufused += entryLen direntCount++ + _ = dir.Advance() } return } @@ -1001,7 +969,7 @@ func maxDirents(entries []*platform.Dirent, bufLen uint32) (bufused, direntCount // based on maxDirents. truncatedEntryLen means write one past entryCount, // without its name. See maxDirents for why func writeDirents( - dirents []*platform.Dirent, + dirents []fsapi.Dirent, direntCount uint32, writeTruncatedEntry bool, buf []byte, @@ -1042,25 +1010,22 @@ func writeDirent(buf []byte, dNext uint64, ino uint64, dNamlen uint32, dType fs. le.PutUint32(buf[20:], uint32(filetype)) // d_type } -// openedDir returns the directory and 0 if the fd points to a readable directory. -func openedDir(fsc *sys.FSContext, fd int32) (fs.File, *sys.ReadDir, syscall.Errno) { +// openedDir returns the sys.FileEntry for the directory and 0 if the fd points to a readable directory. +func openedDir(fsc *sys.FSContext, fd int32) (*sys.FileEntry, syscall.Errno) { if f, ok := fsc.LookupFile(fd); !ok { - return nil, nil, syscall.EBADF - } else if _, ft, err := f.CachedStat(); err != nil { - return nil, nil, platform.UnwrapOSError(err) - } else if ft.Type() != fs.ModeDir { + return nil, syscall.EBADF + } else if isDir, errno := f.File.IsDir(); errno != 0 { + return nil, errno + } else if !isDir { // fd_readdir docs don't indicate whether to return syscall.ENOTDIR or // syscall.EBADF. It has been noticed that rust will crash on syscall.ENOTDIR, // and POSIX C ref seems to not return this, so we don't either. // // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fd_readdir // and https://en.wikibooks.org/wiki/C_Programming/POSIX_Reference/dirent.h - return nil, nil, syscall.EBADF + return nil, syscall.EBADF } else { - if f.ReadDir == nil { - f.ReadDir = &sys.ReadDir{} - } - return f.File, f.ReadDir, 0 + return f, 0 } } @@ -1104,6 +1069,7 @@ func fdRenumberFn(_ context.Context, mod api.Module, params []uint64) syscall.Er // - syscall.EFAULT: `resultNewoffset` points to an offset out of memory // - syscall.EINVAL: `whence` is an invalid value // - syscall.EIO: a file system error +// - syscall.EISDIR: the file was a directory. // // For example, if fd 3 is a file with offset 0, and parameters fd=3, offset=4, // whence=0 (=io.SeekStart), resultNewOffset=1, this function writes the below @@ -1132,29 +1098,13 @@ func fdSeekFn(_ context.Context, mod api.Module, params []uint64) syscall.Errno whence := uint32(params[2]) resultNewoffset := uint32(params[3]) - var seeker io.Seeker - // Check to see if the file descriptor is available if f, ok := fsc.LookupFile(fd); !ok { return syscall.EBADF - // fs.FS doesn't declare io.Seeker, but implementations such as os.File implement it. - } else if _, ft, err := f.CachedStat(); err != nil { - return platform.UnwrapOSError(err) - } else if ft.Type() == fs.ModeDir { - return syscall.EBADF - } else if seeker, ok = f.File.(io.Seeker); !ok { - return syscall.EBADF - } - - if whence > io.SeekEnd /* exceeds the largest valid whence */ { - return syscall.EINVAL - } - - newOffset, err := seeker.Seek(int64(offset), int(whence)) - if err != nil { - return platform.UnwrapOSError(err) - } - - if !mod.Memory().WriteUint64Le(resultNewoffset, uint64(newOffset)) { + } else if isDir, _ := f.File.IsDir(); isDir { + return syscall.EISDIR // POSIX doesn't forbid seeking a directory, but wasi-testsuite does. + } else if newOffset, errno := f.File.Seek(int64(offset), int(whence)); errno != 0 { + return errno + } else if !mod.Memory().WriteUint64Le(resultNewoffset, uint64(newOffset)) { return syscall.EFAULT } return 0 @@ -1173,12 +1123,9 @@ func fdSyncFn(_ context.Context, mod api.Module, params []uint64) syscall.Errno // Check to see if the file descriptor is available if f, ok := fsc.LookupFile(fd); !ok { return syscall.EBADF - } else if syncFile, ok := f.File.(syncFile); !ok { - return syscall.EBADF // possibly a fake file - } else if err := syncFile.Sync(); err != nil { - return platform.UnwrapOSError(err) + } else { + return f.File.Sync() } - return 0 } // fdTell is the WASI function named FdTellName which returns the current @@ -1265,6 +1212,23 @@ func fdWriteFn(_ context.Context, mod api.Module, params []uint64) syscall.Errno return fdWriteOrPwrite(mod, params, false) } +// pwriter tracks an offset across multiple writes. +type pwriter struct { + f fsapi.File + offset int64 +} + +// Write implements the same function as documented on internalapi.File. +func (w *pwriter) Write(buf []byte) (n int, errno syscall.Errno) { + if len(buf) == 0 { + return 0, 0 // less overhead on zero-length writes. + } + + n, err := w.f.Pwrite(buf, w.offset) + w.offset += int64(n) + return n, err +} + func fdWriteOrPwrite(mod api.Module, params []uint64, isPwrite bool) syscall.Errno { mem := mod.Memory() fsc := mod.(*wasm.ModuleInstance).Sys.FS() @@ -1274,51 +1238,54 @@ func fdWriteOrPwrite(mod api.Module, params []uint64, isPwrite bool) syscall.Err iovsCount := uint32(params[2]) var resultNwritten uint32 - var writer io.Writer + var writer func(buf []byte) (n int, errno syscall.Errno) if f, ok := fsc.LookupFile(fd); !ok { return syscall.EBADF } else if isPwrite { offset := int64(params[3]) - writer = sysfs.WriterAtOffset(f.File, offset) + writer = (&pwriter{f: f.File, offset: offset}).Write resultNwritten = uint32(params[4]) - } else if writer, ok = f.File.(io.Writer); !ok { - return syscall.EBADF } else { + writer = f.File.Write resultNwritten = uint32(params[3]) } - var err error + nwritten, errno := writev(mem, iovs, iovsCount, writer) + if errno != 0 { + return errno + } + + if !mod.Memory().WriteUint32Le(resultNwritten, nwritten) { + return syscall.EFAULT + } + return 0 +} + +func writev(mem api.Memory, iovs uint32, iovsCount uint32, writer func(buf []byte) (n int, errno syscall.Errno)) (uint32, syscall.Errno) { var nwritten uint32 iovsStop := iovsCount << 3 // iovsCount * 8 iovsBuf, ok := mem.Read(iovs, iovsStop) if !ok { - return syscall.EFAULT + return 0, syscall.EFAULT } for iovsPos := uint32(0); iovsPos < iovsStop; iovsPos += 8 { offset := le.Uint32(iovsBuf[iovsPos:]) l := le.Uint32(iovsBuf[iovsPos+4:]) - var n int - if writer == io.Discard { // special-case default - n = int(l) - } else { - b, ok := mem.Read(offset, l) - if !ok { - return syscall.EFAULT - } - n, err = writer.Write(b) - if err != nil { - return platform.UnwrapOSError(err) - } + b, ok := mem.Read(offset, l) + if !ok { + return 0, syscall.EFAULT } + n, errno := writer(b) nwritten += uint32(n) + if errno == syscall.ENOSYS { + return 0, syscall.EBADF // e.g. unimplemented for write + } else if errno != 0 { + return 0, errno + } } - - if !mod.Memory().WriteUint32Le(resultNwritten, nwritten) { - return syscall.EFAULT - } - return 0 + return nwritten, 0 } // pathCreateDirectory is the WASI function named PathCreateDirectoryName which @@ -1415,14 +1382,7 @@ func pathFilestatGetFn(_ context.Context, mod api.Module, params []uint64) sysca } // Stat the file without allocating a file descriptor. - // - // Note: `preopen` is a `sysfs.FS` interface, so passing the address of `st` - // causes the value to escape to the heap because the compiler doesn't know - // whether the pointer will be retained by the method. - // - // This could be optimized by modifying Stat/Lstat to return the `Stat_t` - // value instead of passing a pointer as output parameter. - var st platform.Stat_t + var st fsapi.Stat_t if (flags & wasip1.LOOKUP_SYMLINK_FOLLOW) == 0 { st, errno = preopen.Lstat(pathName) @@ -1440,7 +1400,8 @@ func pathFilestatGetFn(_ context.Context, mod api.Module, params []uint64) sysca return syscall.EFAULT } - return writeFilestat(buf, &st) + filetype := getWasiFiletype(st.Mode) + return writeFilestat(buf, &st, filetype) } // pathFilestatSetTimes is the WASI function named PathFilestatSetTimesName @@ -1606,7 +1567,7 @@ func pathOpenFn(_ context.Context, mod api.Module, params []uint64) syscall.Errn } fileOpenFlags := openFlags(dirflags, oflags, fdflags, rights) - isDir := fileOpenFlags&platform.O_DIRECTORY != 0 + isDir := fileOpenFlags&fsapi.O_DIRECTORY != 0 if isDir && oflags&wasip1.O_CREAT != 0 { return syscall.EINVAL // use pathCreateDirectory! @@ -1621,10 +1582,10 @@ func pathOpenFn(_ context.Context, mod api.Module, params []uint64) syscall.Errn if isDir { if f, ok := fsc.LookupFile(newFD); !ok { return syscall.EBADF // unexpected - } else if _, ft, err := f.CachedStat(); err != nil { + } else if isDir, errno := f.File.IsDir(); errno != 0 { _ = fsc.CloseFile(newFD) - return platform.UnwrapOSError(err) - } else if ft.Type() != fs.ModeDir { + return errno + } else if !isDir { _ = fsc.CloseFile(newFD) return syscall.ENOTDIR } @@ -1653,7 +1614,7 @@ func pathOpenFn(_ context.Context, mod api.Module, params []uint64) syscall.Errn // // See https://github.com/WebAssembly/wasi-libc/blob/659ff414560721b1660a19685110e484a081c3d4/libc-bottom-half/sources/at_fdcwd.c // See https://linux.die.net/man/2/openat -func atPath(fsc *sys.FSContext, mem api.Memory, fd int32, p, pathLen uint32) (sysfs.FS, string, syscall.Errno) { +func atPath(fsc *sys.FSContext, mem api.Memory, fd int32, p, pathLen uint32) (fsapi.FS, string, syscall.Errno) { b, ok := mem.Read(p, pathLen) if !ok { return nil, "", syscall.EFAULT @@ -1681,9 +1642,9 @@ func atPath(fsc *sys.FSContext, mem api.Memory, fd int32, p, pathLen uint32) (sy if f, ok := fsc.LookupFile(fd); !ok { return nil, "", syscall.EBADF // closed or invalid - } else if _, ft, err := f.CachedStat(); err != nil { - return nil, "", platform.UnwrapOSError(err) - } else if ft.Type() != fs.ModeDir { + } else if isDir, errno := f.File.IsDir(); errno != 0 { + return nil, "", errno + } else if !isDir { return nil, "", syscall.ENOTDIR } else if f.IsPreopen { // don't append the pre-open name return f.FS, pathName, 0 @@ -1698,6 +1659,10 @@ func preopenPath(fsc *sys.FSContext, fd int32) (string, syscall.Errno) { return "", syscall.EBADF // closed } else if !f.IsPreopen { return "", syscall.EBADF + } else if isDir, errno := f.File.IsDir(); errno != 0 || !isDir { + // In wasip1, only directories can be returned by fd_prestat_get as + // there are no prestat types defined for files or sockets. + return "", errno } else { return f.Name, 0 } @@ -1705,32 +1670,53 @@ func preopenPath(fsc *sys.FSContext, fd int32) (string, syscall.Errno) { func openFlags(dirflags, oflags, fdflags uint16, rights uint32) (openFlags int) { if dirflags&wasip1.LOOKUP_SYMLINK_FOLLOW == 0 { - openFlags |= platform.O_NOFOLLOW + openFlags |= fsapi.O_NOFOLLOW } if oflags&wasip1.O_DIRECTORY != 0 { - openFlags |= platform.O_DIRECTORY + openFlags |= fsapi.O_DIRECTORY return // Early return for directories as the rest of flags doesn't make sense for it. } else if oflags&wasip1.O_EXCL != 0 { openFlags |= syscall.O_EXCL } + // Because we don't implement rights, we paritally rely on the open flags + // to determine the mode in which the file will be opened. This will create + // divergent behavior compared to WASI runtimes which have a more strict + // interpretation of the WASI capabilities model; for example, a program + // which sets O_CREAT but does not give read or write permissions will + // successfully create a file when running with wazero, but might get a + // permission denied error on other runtimes. + defaultMode := syscall.O_RDONLY if oflags&wasip1.O_TRUNC != 0 { - openFlags |= syscall.O_RDWR | syscall.O_TRUNC + openFlags |= syscall.O_TRUNC + defaultMode = syscall.O_RDWR } if oflags&wasip1.O_CREAT != 0 { - openFlags |= syscall.O_RDWR | syscall.O_CREAT + openFlags |= syscall.O_CREAT + defaultMode = syscall.O_RDWR + } + if fdflags&wasip1.FD_NONBLOCK != 0 { + openFlags |= syscall.O_NONBLOCK } if fdflags&wasip1.FD_APPEND != 0 { - openFlags |= syscall.O_RDWR | syscall.O_APPEND + openFlags |= syscall.O_APPEND + defaultMode = syscall.O_RDWR } // Since rights were discontinued in wasi, we only interpret RIGHT_FD_WRITE // because it is the only way to know that we need to set write permissions // on a file if the application did not pass any of O_CREATE, O_APPEND, nor // O_TRUNC. - if rights&wasip1.RIGHT_FD_WRITE != 0 { + const r = wasip1.RIGHT_FD_READ + const w = wasip1.RIGHT_FD_WRITE + const rw = r | w + switch { + case (rights & rw) == rw: openFlags |= syscall.O_RDWR - } - if openFlags == 0 { - openFlags = syscall.O_RDONLY + case (rights & w) == w: + openFlags |= syscall.O_WRONLY + case (rights & r) == r: + openFlags |= syscall.O_RDONLY + default: + openFlags |= defaultMode } return } @@ -1906,9 +1892,9 @@ func pathSymlinkFn(_ context.Context, mod api.Module, params []uint64) syscall.E dir, ok := fsc.LookupFile(fd) if !ok { return syscall.EBADF // closed - } else if _, ft, err := dir.CachedStat(); err != nil { - return platform.UnwrapOSError(err) - } else if ft.Type() != fs.ModeDir { + } else if isDir, errno := dir.File.IsDir(); errno != 0 { + return errno + } else if !isDir { return syscall.ENOTDIR } @@ -1929,18 +1915,15 @@ func pathSymlinkFn(_ context.Context, mod api.Module, params []uint64) syscall.E return dir.FS.Symlink( // Do not join old path since it's only resolved when dereference the link created here. // And the dereference result depends on the opening directory's file descriptor at that point. - bufToStr(oldPathBuf, int(oldPathLen)), - path.Join(dir.Name, bufToStr(newPathBuf, int(newPathLen))), + bufToStr(oldPathBuf), + path.Join(dir.Name, bufToStr(newPathBuf)), ) } // bufToStr converts the given byte slice as string unsafely. -func bufToStr(buf []byte, l int) string { - return *(*string)(unsafe.Pointer(&reflect.SliceHeader{ //nolint - Data: uintptr(unsafe.Pointer(&buf[0])), - Len: l, - Cap: l, - })) +func bufToStr(buf []byte) string { + // TODO: use unsafe.String after flooring Go 1.20. + return *(*string)(unsafe.Pointer(&buf)) } // pathUnlinkFile is the WASI function named PathUnlinkFileName which unlinks a diff --git a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/poll.go b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/poll.go index 057d76e3b..1d8ec7f94 100644 --- a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/poll.go +++ b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/poll.go @@ -6,7 +6,6 @@ import ( "time" "github.com/tetratelabs/wazero/api" - "github.com/tetratelabs/wazero/internal/platform" internalsys "github.com/tetratelabs/wazero/internal/sys" "github.com/tetratelabs/wazero/internal/wasip1" "github.com/tetratelabs/wazero/internal/wasm" @@ -50,7 +49,7 @@ type event struct { outOffset uint32 } -func pollOneoffFn(ctx context.Context, mod api.Module, params []uint64) syscall.Errno { +func pollOneoffFn(_ context.Context, mod api.Module, params []uint64) syscall.Errno { in := uint32(params[0]) out := uint32(params[1]) nsubscriptions := uint32(params[2]) @@ -162,11 +161,14 @@ func pollOneoffFn(ctx context.Context, mod api.Module, params []uint64) syscall. // If there are stdin subscribers, check for data with given timeout. if len(stdinSubs) > 0 { - reader := getStdioFileReader(mod) + stdin, ok := fsc.LookupFile(internalsys.FdStdin) + if !ok { + return syscall.EBADF + } // Wait for the timeout to expire, or for some data to become available on Stdin. - stdinReady, err := reader.Poll(timeout) - if err != nil { - return platform.UnwrapOSError(err) + stdinReady, errno := stdin.File.PollRead(&timeout) + if errno != 0 { + return errno } if stdinReady { // stdin has data ready to for reading, write back all the events @@ -232,10 +234,10 @@ func processFDEventRead(fsc *internalsys.FSContext, fd int32) wasip1.Errno { // processFDEventWrite returns ErrnoNotsup if the file exists and ErrnoBadf otherwise. func processFDEventWrite(fsc *internalsys.FSContext, fd int32) wasip1.Errno { - if internalsys.WriterForFile(fsc, fd) == nil { - return wasip1.ErrnoBadf + if _, ok := fsc.LookupFile(fd); ok { + return wasip1.ErrnoNotsup } - return wasip1.ErrnoNotsup + return wasip1.ErrnoBadf } // writeEvent writes the event corresponding to the processed subscription. @@ -247,15 +249,3 @@ func writeEvent(outBuf []byte, evt *event) { le.PutUint32(outBuf[evt.outOffset+10:], uint32(evt.eventType)) // TODO: When FD events are supported, write outOffset+16 } - -// getStdioFileReader extracts a StdioFileReader for FdStdin from the given api.Module instance. -// and panics if this is not possible. -func getStdioFileReader(mod api.Module) *internalsys.StdioFileReader { - fsc := mod.(*wasm.ModuleInstance).Sys.FS() - if file, ok := fsc.LookupFile(internalsys.FdStdin); ok { - if reader, typeOk := file.File.(*internalsys.StdioFileReader); typeOk { - return reader - } - } - panic("unexpected error: Stdin must always be a StdioFileReader") -} diff --git a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sock.go b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sock.go index 462824642..3dacf3df1 100644 --- a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sock.go +++ b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sock.go @@ -1,6 +1,12 @@ package wasi_snapshot_preview1 import ( + "context" + "syscall" + + "github.com/tetratelabs/wazero/api" + socketapi "github.com/tetratelabs/wazero/internal/sock" + "github.com/tetratelabs/wazero/internal/sysfs" "github.com/tetratelabs/wazero/internal/wasip1" "github.com/tetratelabs/wazero/internal/wasm" ) @@ -10,34 +16,172 @@ import ( // // See: https://github.com/WebAssembly/WASI/blob/0ba0c5e2e37625ca5a6d3e4255a998dfaa3efc52/phases/snapshot/docs.md#sock_accept // and https://github.com/WebAssembly/WASI/pull/458 -var sockAccept = stubFunction( +var sockAccept = newHostFunc( wasip1.SockAcceptName, + sockAcceptFn, []wasm.ValueType{i32, i32, i32}, "fd", "flags", "result.fd", ) +func sockAcceptFn(_ context.Context, mod api.Module, params []uint64) (errno syscall.Errno) { + mem := mod.Memory() + fsc := mod.(*wasm.ModuleInstance).Sys.FS() + + fd := int32(params[0]) + flags := uint32(params[1]) + resultFd := uint32(params[2]) + nonblock := flags&uint32(wasip1.FD_NONBLOCK) != 0 + + var connFD int32 + if connFD, errno = fsc.SockAccept(fd, nonblock); errno == 0 { + mem.WriteUint32Le(resultFd, uint32(connFD)) + } + return +} + // sockRecv is the WASI function named SockRecvName which receives a // message from a socket. // // See: https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-sock_recvfd-fd-ri_data-iovec_array-ri_flags-riflags---errno-size-roflags -var sockRecv = stubFunction( +var sockRecv = newHostFunc( wasip1.SockRecvName, + sockRecvFn, []wasm.ValueType{i32, i32, i32, i32, i32, i32}, - "fd", "ri_data", "ri_data_count", "ri_flags", "result.ro_datalen", "result.ro_flags", + "fd", "ri_data", "ri_data_len", "ri_flags", "result.ro_datalen", "result.ro_flags", ) +func sockRecvFn(_ context.Context, mod api.Module, params []uint64) syscall.Errno { + mem := mod.Memory() + fsc := mod.(*wasm.ModuleInstance).Sys.FS() + + fd := int32(params[0]) + riData := uint32(params[1]) + riDataCount := uint32(params[2]) + riFlags := uint8(params[3]) + resultRoDatalen := uint32(params[4]) + resultRoFlags := uint32(params[5]) + + var conn socketapi.TCPConn + if e, ok := fsc.LookupFile(fd); !ok { + return syscall.EBADF // Not open + } else if conn, ok = e.File.(socketapi.TCPConn); !ok { + return syscall.EBADF // Not a conn + } + + if riFlags & ^(wasip1.RI_RECV_PEEK|wasip1.RI_RECV_WAITALL) != 0 { + return syscall.ENOTSUP + } + + if riFlags&wasip1.RI_RECV_PEEK != 0 { + // Each record in riData is of the form: + // type iovec struct { buf *uint8; bufLen uint32 } + // This means that the first `uint32` is a `buf *uint8`. + firstIovecBufAddr, ok := mem.ReadUint32Le(riData) + if !ok { + return syscall.EINVAL + } + // Read bufLen + firstIovecBufLen, ok := mem.ReadUint32Le(riData + 4) + if !ok { + return syscall.EINVAL + } + firstIovecBuf, ok := mem.Read(firstIovecBufAddr, firstIovecBufLen) + if !ok { + return syscall.EINVAL + } + n, err := conn.Recvfrom(firstIovecBuf, sysfs.MSG_PEEK) + if err != 0 { + return err + } + mem.WriteUint32Le(resultRoDatalen, uint32(n)) + mem.WriteUint16Le(resultRoFlags, 0) + return 0 + } + + // If riFlags&wasip1.RECV_WAITALL != 0 then we should + // do a blocking operation until all data has been retrieved; + // otherwise we are able to return earlier. + // For simplicity, we currently wait all regardless the flag. + bufSize, errno := readv(mem, riData, riDataCount, conn.Read) + if errno != 0 { + return errno + } + mem.WriteUint32Le(resultRoDatalen, bufSize) + mem.WriteUint16Le(resultRoFlags, 0) + return 0 +} + // sockSend is the WASI function named SockSendName which sends a message // on a socket. // // See: https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-sock_sendfd-fd-si_data-ciovec_array-si_flags-siflags---errno-size -var sockSend = stubFunction( +var sockSend = newHostFunc( wasip1.SockSendName, + sockSendFn, []wasm.ValueType{i32, i32, i32, i32, i32}, - "fd", "si_data", "si_data_count", "si_flags", "result.so_datalen", + "fd", "si_data", "si_data_len", "si_flags", "result.so_datalen", ) +func sockSendFn(_ context.Context, mod api.Module, params []uint64) syscall.Errno { + mem := mod.Memory() + fsc := mod.(*wasm.ModuleInstance).Sys.FS() + + fd := int32(params[0]) + siData := uint32(params[1]) + siDataCount := uint32(params[2]) + siFlags := uint32(params[3]) + resultSoDatalen := uint32(params[4]) + + if siFlags != 0 { + return syscall.ENOTSUP + } + + var conn socketapi.TCPConn + if e, ok := fsc.LookupFile(fd); !ok { + return syscall.EBADF // Not open + } else if conn, ok = e.File.(socketapi.TCPConn); !ok { + return syscall.EBADF // Not a conn + } + + bufSize, errno := writev(mem, siData, siDataCount, conn.Write) + if errno != 0 { + return errno + } + mem.WriteUint32Le(resultSoDatalen, bufSize) + return 0 +} + // sockShutdown is the WASI function named SockShutdownName which shuts // down socket send and receive channels. // // See: https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-sock_shutdownfd-fd-how-sdflags---errno -var sockShutdown = stubFunction(wasip1.SockShutdownName, []wasm.ValueType{i32, i32}, "fd", "how") +var sockShutdown = newHostFunc(wasip1.SockShutdownName, sockShutdownFn, []wasm.ValueType{i32, i32}, "fd", "how") + +func sockShutdownFn(_ context.Context, mod api.Module, params []uint64) syscall.Errno { + fsc := mod.(*wasm.ModuleInstance).Sys.FS() + + fd := int32(params[0]) + how := uint8(params[1]) + + var conn socketapi.TCPConn + if e, ok := fsc.LookupFile(fd); !ok { + return syscall.EBADF // Not open + } else if conn, ok = e.File.(socketapi.TCPConn); !ok { + return syscall.EBADF // Not a conn + } + + sysHow := 0 + + switch how { + case wasip1.SD_RD | wasip1.SD_WR: + sysHow = syscall.SHUT_RD | syscall.SHUT_WR + case wasip1.SD_RD: + sysHow = syscall.SHUT_RD + case wasip1.SD_WR: + sysHow = syscall.SHUT_WR + default: + return syscall.EINVAL + } + + return conn.Shutdown(sysHow) +} diff --git a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/cargo-wasi/wasi.rs b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/cargo-wasi/wasi.rs index ed6cf1e68..3641e5394 100644 --- a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/cargo-wasi/wasi.rs +++ b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/cargo-wasi/wasi.rs @@ -1,8 +1,11 @@ use std::env; use std::fs; use std::io; -use std::io::Write; +use std::io::{Read,Write}; +use std::net::{TcpListener}; +use std::os::wasi::io::FromRawFd; use std::process::exit; +use std::str::from_utf8; // Until NotADirectory is implemented, read the underlying error raised by // wasi-libc. See https://github.com/rust-lang/rust/issues/86442 @@ -18,9 +21,8 @@ fn main() { main_ls(&args[2]); } } - "stat" => { - main_stat(); - } + "stat" => main_stat(), + "sock" => main_sock(), _ => { writeln!(io::stderr(), "unknown command: {}", args[1]).unwrap(); exit(1); @@ -43,7 +45,7 @@ fn main_ls(dir_name: &String) { println!("errno=={}", error_code); } } else { - println!("unknown error"); + writeln!(io::stderr(), "failed to read directory: {}", e).unwrap(); } } } @@ -59,3 +61,29 @@ fn main_stat() { println!("/ isatty: {}", libc::isatty(3) != 0); } } + +fn main_sock() { + // Get a listener from the pre-opened file descriptor. + // The listener is the first pre-open, with a file-descriptor of 3. + let listener = unsafe { TcpListener::from_raw_fd(3) }; + for conn in listener.incoming() { + match conn { + Ok(mut conn) => { + // Do a blocking read of up to 32 bytes. + // Note: the test should write: "wazero", so that's all we should read. + let mut data = [0 as u8; 32]; + match conn.read(&mut data) { + Ok(size) => { + let text = from_utf8(&data[0..size]).unwrap(); + println!("{}", text); + + // Exit instead of accepting another connection. + exit(0); + }, + Err(e) => writeln!(io::stderr(), "failed to read data: {}", e).unwrap(), + } {} + } + Err(e) => writeln!(io::stderr(), "failed to read connection: {}", e).unwrap(), + } + } +} diff --git a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/cargo-wasi/wasi.wasm b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/cargo-wasi/wasi.wasm index 89df2534fffb1fb2009bb270afe1c3cf83351da4..2ddde1064d285a9000aa3393cd087ad96e738ed6 100644 GIT binary patch literal 94484 zcmd?S4Y*y`S(v$h&fmS~Ug^kIQemlhpA!wpjfGX9wkwB;mP+gx$4Q|4%|ORa6PM)P z{8+L^q#bH0iIbWnErz(kFaZo?h=BwGV_FXrnhTgt7tb;^ep7am%;dcB&{Y zP-9orxZ^c{>$Z#68~%+~-E#7_SG=lNxj;j!ZG~68=47#UfjT4VeCx^AoVx9Tt*qSs zic_z?DQcm!|N|P_B~ytXCA(g zzw)(jxZ}2BaDg7zsqr^nb;qe!oVsYAyQs$OJY&5}m+FDiTVDT)*WGr((XQNn@(r)N z<+eAz=2TJFkCwk$4(e*ugG`HYS@p|ZyaC7O z)g?t$4EiHF8Q4+L^G{K%`06-brybx705TMHNl8`LL;f28@36eRd^7+0JlHc>ftk|T zvs=Y@_`G`Xy4zm&hLeAjE^YyzCr=gcDaW_m^14^N=JmIne#2{CRlK`g`E8m`<@inI zZ!VE6CoTs>6&1Fn9w z{F^WPE8qIx9RBbBZh775ulUM0-c|mE-ztBjd}n#tjep~Bd-b)m7ypy;H_LmUhi1CJ6~V6R*us>TpvGkO;tqc@v~>|IxAK!@ReqqMjPq&6Y1kW_FF&Jzhl-9<}%k73yP6l|ISc z2EUK_8$C5WZa)^cCAGMDJnFPJPqi;R5jE_!siR>ke!6}3WIT%($|kB*=~MBnZKTeWFJrO_|CQO?5Jrcg*TkpPCgN zDtIAqWIMe>)o4~+-?rQg(w$BHttSA4$!*F8s7FoFFxItk(_=2D6-aHHt505C^?2Ib zm=z6B^-^ic8dZns!4}Zfo7c;x6rfZ!l~7Q3^CWFor%tqYCsMg-6KU;qnw-dk=$}p_ zo-+W!a9Gvp)T3m6U!G3YIrruK-dVZOm{-mpbM>t!W`mtay~1GfNLQc>+uUHx!_8Tr z`pvLef!3OS9(uFdJJzhGH=f9-o)&2Qs8{ z_h2(gC}#eRCqT&*YM7Swu?pflR83|Tql66iMzso%#!V%eMCDltCGr1_vvNN#GR%ex z20bl7Mc`uJRN|xkwOM@wO^F@|L1{q8H(mz2LYX640XGbvm*{Lp-$m}5YC^GI^I)Y%cq}yddTaS@&4#EBweJlfAYeOGzkiqB`kUT@+g7A%eLg~?kJJQ zPo>?b86~_>oP<+Sc?!ZS(sMRW!{aB@fsHW&VR=qU>8qGl{9h}kxdf0ReSt)HdXvAG zU%&qp^vUyXzPfqoH@%lJ*m7Do{aJ6_I!x5GTC179`E>T1J`fe@&&!nn8gpD;zn?1o z{q!b~%w`ETeXTy3A*zuAgM}1WVQ_hRK*HypRHqf7NQRKX5+NeNZiFcK5p+qBk?&{t z)S1l6-kGL^WHK3#XH|@-ei10@byAM$7iG}TzUhFsxmcSOk}Ox-Nfwl3l9j91R>siY zoDyZ1OoQSi6Xk+rmuNd^QG%8wpztM7rUL{MEZY6VxBCNHz6W~kssO(?Zv zD8iOymO=+!Z0e0DvvQV#iYYMDibN~W22ixZKYGi`UBMJrj#144JJE_dPzD{`2n@q! z1iv-|!GdA}5EWwv#HtyPQP+Jl>YB`Uoivm7c4;j*oX!}XtpH>hm8X%;sQ${;rdZQWLv@SDBTS1Pgn7p+FfoHB?hbyOp z&O}4Zp;=)@ECRW8(-t-uM7?=pV>%d%_?vlUkp3hKss4Nr8hYIr>SlmG1^o2^B+NmH z$ODFy0R#MMTG){zO=m(I02SPp%c(!u&cs->(<7bTiE^O>COm)C!A?$?)r7irf#Cw0KL_IaB;zGmM`0{V6`wfB}9D~(v9{^ zkWoBHk5VO!<)i`Kaf@|64Pe2jwG;E7+>8d_Zv?q%_X$S`yK}XF1{Xnw=~~Gdn(n05 zP8N0+9wA1;Vh5!g8rMD0*Hnj#H7rYruWb6E)SEu^hsJ+n({DTNcby_x>P}$Aq&n%X zoRSkLQ*`bKgaS0CIJ*t>)&c>sv~$=LH*K3c<`a@GTi$QYiDUjUGeHrdQ(AH;8P0q> zYPE&TKwT*_6jJ#;WEaY9E;W$FxXrxWiFt`F4`xT~BVgwOxCBvUi>R_i)P|g(B|O?h z^&<;(C}ILeVjG3{4gJgw*C^ARM}(@iR{v?%RRS~|uYXKeOo`FwttNUW~duOFKknje>&7U#-&;zp(rc@urPkr!yCvK(26?2AT z!`vZkLgVwBr>I);oKWcRhYrLUN{lM!`As@y^zUR)4Zn$|^^}5kMl=rs*6fAZP!n7( zJYkGW4%H5}xXv8|dRDf0y=05SMoYH%6b&@eH#^XbjuQ!)F!pYOrgb+FO0cF!hq{8$ zRnWWco2ZVFL2XU}BaxiqXDw{-q#cjFg&p6^c04XQh?*9N2}lgo>ta=^jvfa3R7(|W zTz5+=Lu-BJ3$r3fD*C1aX1MK6wArfyb4O_m6SvZssX-*S6A9>9$RPuI=^AXMEXBF@ zYX3%hA)*^F`hY;pqD;@bp!}3ZmgOgJq)+|+R&hmTbO~*&g%mfVD5qqEG%j{jesdK^ zt%Fb`h^i74j%pxW1LgGa*5vZOMhXy$!%VONE;gT)9aSdTPO6CM&e>lgSr9_i^GLQj zmt^TMlPo_Ynh%o2gcJ8YN!A(EG?QeBzaY9K&_BKVh)h`~S>_p?A<6bL$yOI4S^d?P zWDPn5InPP9pGg+qFb~JUX^{1TWI+lfTV;~PoRnm1W}=>l5PD+2l4Rw0NEXgw##)jM zzrJqgDNhIZ+6UzJlYiuNXOEzk6uib_$+2~S-jV( zH@dR9PP`NAxwA2dwL+;}i;h9GE54ihJkgG2xGy`JJBaogf$oTQmhP2gxLayOm4*Y^ zdV6ceH9Fo7{O!r{R<2AjyB>>a4LyI3m4;A>-=qdzpzRQlLuXPGG;u^%*^ z`Li&dF{vUvyMysuX5$%o9IGmrL=J8(oUjO#0eOIe?Hzq(KUW0shH@HYS%>+|#xt^? zyUuv#4&zyj!T>$Ov^AhDS0&E1q0uAJgxVki8i+)?mNqP%E^M=DG)fm$iwJ0nO0dx7~vVuq>jFRjEgv_W>E8-#4%XNe&^1lCQ04E4sG*1j_pu2~pZ+gvl;-DrQ_ zD%fs4vm4gy03a~92=eV-xNgyKxNgz#HrMU^hMCAb1OUgQWDyJ6V@^7PV-y!6I3BSc zaAAUD0=5%eMk{Kec?D^C3Q)>r``DmjcIm3~Tsk!H+^KU|b{Q7(F#OzX zAwycB0I>fwzL0x)JdRGTN0goK)Zv*U;HqQDw^Hd8Ze3w4GTb_U!mUGibT+cD7-Yb? zkKXACnr=H3bM|Y8G^dSh|4>|pCM)=OqeJpI#|;f0(z4NHf{0DAUpYGd*|l=Oje3Jf zOLa{B+?!#zt8MVuL)-YCF*^cV*3ey?D;c@4bN;C($Lr|R#FC2P0sP+d2;80+oOIOS`J~}Dv19qR7*6xO||UMFtirhSe>Y9 zX-TgmG+^JE&@k{Wq*_`+dp4>iC@=bW2FeT7q7&>QYeYnHP$nF9!#w}WcwC=Z#@QXcK^NO_dEs^whDgDSg8*_i@b z)gp<6YH6u*r`NO>vTD(8Xk#y=S8NLxYN)niIIEVq{8jeBvxEy#KnrC;PYiU;4i~D0 zj#|}1Yze6ZIc--hQL;_7M9D(6;JLGMAF8E7wHVVtL09Lf7Tgj;FU9$)48CwTFCGGS2Q%so>ABl*)P@1r5=*gGJ6oD|ygU zDECRAF~Y~6wT%f&kA_VVRZOK}WtVKcSp&8dF=0g8btMQNUso!0beYsq?Y}b+Ot0x( zRZdLI=%szeJR+V?m|iNzO72bjp(&+;r^}mICpFT}Bo;4@Yck!)@}OwSl=jY~4}4;) zI9$*i+HUeQc6TqQm^haFAG$xw8bOh_aMt5G(AabZ|dc7kc0PI#ZBugjAQM! zB&snEuYcU)7zYvb<#Awe#W*UMo!c8YnXY3D6UqZbqZVrsKpIcJ zVO9Y{;A?556$4cDU+mEffywVFj`L%0EYo`@h;RC%fe zy_-fQnaS5lQ?W2ZH4z#?c|wZ-(X2vi>eM>D2}*dQ{1XuR?noGSn#IYzB-2u%(S>Ks z`v8@n3CT%x?8LB&mhG|l>Cxpb8P4H}1HoQz)(l&(nRVFoC%dDCF=W`gqS`y%6EwCm zk^S*Un?3KFPMST(o4emG6h@OJ9)YAVL$zzjnC@iURB;*Rwy0P72w0`H zBjQ>9hZFfR3?iM?spTg`FxVjh6Mph~!B2f=Vo5FxnJeW&Kln*Tudb+%=%&1pkAH6^2hH#>&#jM{t~yZq9K- z>ST@sp7S|wB$X|39CuW6!o%puKs1Z!_MGFidE(t?$8mO^S*`D)HTZ8b9R>am&GFAP zW@ba4NiJxUb8sAlLvsfpK7RInc9h4PdmSW1CTTL)SJbh-6+*qrL=8n~${yQ181e?H zx*&sf{E~ll1~Ao970E-|z1V1L$O&yvFp;XwU3FELEJ7%I?mxR#O#Zs!=}=LmKl-~HVIE*NUMQ~Z!)m@OivAPI5u-!Eu zRu|@k8cM~~lo$}1NFmp~!KT5yX^ksqNPnu_}6f7rSD0*HUd6ErFp0B;8zPn5xW3tlosd6`1e&j9O ze4Ia%TWOg_uc%*sP5q5L{TPPC)zz!G0*SBX=j>e;yc%n>yrv@1p-Oxw*x`znuC8v6 z%a0da-YwFYME*Vz&;Zlqe-Prc@b&fUz1-8;@|yb93wWrM&c102!;YQ;9+E?@DvIk0 zO}+pfK$uNPLV6|y zJ~xQw^g&)tgUQ`xE?|kWdj|t_S|Y(=G8;j1s=0$uRh;S-?5tRSftc2Kj>#!*?kN#} z<9Dx+V6D`LWTvJB7Y)cmVsb&22^l03Q+aBWLGTvk)n`_-faT^6B3aWqUgyr&U2mzT zNG9?=jSCuuTq?p`H;QIMhqDNx@z}T!`o67A2X zPMSs?aX?-H$if-PRSCI1+p6`muSy~`!W>xJ?lnolNUrkQ1EQ+=Z}>*!)CnYpbVmC1P|FTl^va6JV)9Rk)Ds8dubWw7NtG`O3m(I0~v4$<}{o`+`d4shl^m!xC)Mot6-kbfwd=Z8`smNF|%_ z%61c8=_Wi{lEP;ZEgKP@%qA@kaTXPIa$6ANqTk-h_G+`seMidOydInzYx#I5E?-ku z>zyB$rY6!EVAG^Ke{w=uxN4H0p+KTq5<2*d8;U2BMp(NQU~TFyjY$zp%kI%Tr_na` zPAAZ)Y))nhAke*#m~#^y*mN7oZ=z|#^H5dWG=oHjbO54BJhOdEiQsSt%j5!%fAMz(%Y>FR~}1DdWnbg*_aV%Twfg(~ybHu&$d9 zkkv}tej8k-E*p2aWjTsJi;M@T1T{7@PvG3;sQx@%IN*0<8pw+EJ>J)tB z4TtMW^fK?{(=()f{VjamK>qow1Z_$OdT}*!byjJdcgTLoZxBO4o*Ee2XZtxoE{j!yn4Ip}IH#7i)4bA6Gogj;(=0vjOh<4EdgapD$s9&4Xs45>90g8^jSrDAYIYpFF3*pqXmBkN?rIoVZUK(bhj$;2ljTAhS4J zjJTF2C>cnr@W6-|$>?-=yX#8!5D#l{%kt z@65ueV`Ty1o_eR#r~lbj;q<1-DTt#oTY6r!?-Zjd8O^6{hQ$dRc&r#phbv%o74$)G zAkQRHej@pd?fRF&8m<&rf&J3fNf7ydsFGhJ{*%-3(5kyB*p>F>0&1u7hV?9ze#ma-!OAq~S_He}R{D#ZL&94j>{zhXSD_S#W z#TfuDmh7(11dJRqQ4lsf_+U*3bk5C>N}oWQ4|T0kw?oZ^LtssO0Pw-j4mHDk3H#rg zu#Gh}3HTypy0V})p`P4Ngg|p`L?sBD%C2wD1o>AfaGq}n)C(lr5eZU!4yl%NShLfA%G-8jw zS8g0CXe0nh{f#RM8gc1xkBzKHBkNY7k=@bAo(-m!FeI~-CkTde*S4*}18uv9it_3r z8oi?EUsKR~Q(slAUstT>db^JntOGfLyv+}5I<&}6x7fH%WyU#!*#r_h5{=<7UD(#K z74SL(j^WPDFaxfIe5ru%4#0P}fUgJOm(q!i;K~sbR$w-z!=(=Wb z`BfcPU>qVA?vY*qq8PGwNe~WNY9y-R-#AZmcNc(i2BbT?fN=l>m>_M(pc^d{dU*jt z6rx^XQVTOQvMy0pjR@u+#!%qWBkmVdmA1Iz56d?gwI`TU%;8hh5oqbB&v1Ok5b*(? z!V7U7x;nKnU9rGsYcn7CXrZ>I$uF(mM83uomhvAuD=*_&2w^Os= zDblhq9YO;^aD83HlAUDJptRHJ={J35h&i8sH&~DDy;dcMoW;A)#y~eh5?q<(8Nc3^D5!ji{?eG(T=s$izC51K!)p1(8=ccum&`kst7d> zu|T%HWARKvEI~e|*PIBsYKf4mmI%3OiIAESA+Sq?WtP2}2$vcGF@?Ui2%HB7>hU}G zR)aIOX&E1dmBPY(Vhb~uKh7+OAw*eJ$F~0i6~#*-oO`JTf8scJm6SH=9_o@=x^sc`H_=nPy-;H7M zofcs8X^55llw(@BAHSRxYY=h<*l^DV>E5^V&aTOGE(0&S*vhWZt1u=zFcO8986F?fhmt;bg7fa;PFXdV_vPBAj^m-jx?5P&L)CY(4hte_*u(w z$34ShD&H1N&(Ht+|M1C2-}TeKnZ9~IaS5zYhrm{gorP;u|IvmnMy z+=Gs|(|u0_FDc)>%trydCl`j*IOhhai1?rKjqn~*neiosA&O0vm|Y}GhyfgTaUR1E zIC(W@INeQ0kaDc`j*pk$Hd}i+ew3xS7wyB@dNXd;zj{{fcY${u#1fi?;{-CtgUV(N zRsi8Gg|zadf=Jip&8NPLfw7qx6sEK9;`;9Y5$xT{lNfS~g7z)9VM7NI=3mZPS)$L$ zyJ(e20V-D3mdDf~+~nnRTm;swAh$dP2lIq9{Ae|~e(BX-u8zc&3+7kGRm0UGDLefn z0tZs2*|^L?^Sun&LMF@0T=;-jEz2fvoRK1~qF4nDT@#9!mQB198)=RfFANnEy|sco zQrd=?)16Fw5pW(-gL53p2PL^Fxn*$KxuxSy6|^k~b}QVYb0J+BFGfO(h`&*cq8*Ts zOSi>hXgaXnfXcXv3bF?lU!H6Rv?*2cYZ^j1d0PhXIOg?BfHP~57js2O=_~oU=SR2b z1!hh!#6Bh8U~-2OUa|P5*FlXsVdQPH?G>$lsL+H;aid_il!5>l^eN zkTCH~YN~IrItSRa)4>e1x<)co*RM5W(eSH+T=Y)$e9%8XxRCaYCIZ?ig20 zobccEgDw0F`CPy!3&1gN4Lk+lL>d=>yIP%}Z38@uO+(Ai9&irHSQr`sPBstd7<&VO z!)<4!WctjOPj=eCRX;skY&cS}-;VD?^YJZ)4pBx5YfRCLbt-py^PV5;X4cBizG#zg z`C)Ef49gPMxS(bu}w$;@1pLS>8{#>&X$j zOlwiV>Pu7{rb|wxvuB?wPS`qPp?xPehH|ABSFP|KCVyTq!~IS<9*QRp2Oln0a~v>y zF|;8^s!%WFN7;DXR>Kd`t=LmeG)tTP*o)VDiik*6!!XLV43*|ugQ)f4GcSp1R9tNk z85oP~m1#ij+MW``B0lzQpdvL&m^4Kp%0=^V4+bwuo?TQ9p?UC=SN(>Z-snUo!&QZd>j{B>Y*c3&X+L(J zqU9=4oK}eu=RRi0H~#gB0It`dr&(9d7~mv~##)>y(ksS=qhDNn1Ot7nHWMJ2H$O%I zMNG5DC~)I1OM0+p4NF~?j8JlOws)gpN}Or_Hls~8?_!G%o85#H0nhUiSLcC1(8}y! z9z6008t$jj?aUnL%7X@7izzfahr7+31>kfzlg?4JVL5}(?Um`Fd3){Dl}qy`qlmF- zsDKDpvUTc`YLfk|Exj-7kcxDe=`gr=hSdg?S7|$ej{)+%KEw|*z>zHez$H`te6;Nm ze#mtH5`M^~BaagLnD%K$#{`~rSn25?O|eaQ1gP~*hy=903Az&Bq({AS1NQ_IHM=L! zmktWEbRV%Hk~$7%lfWZaDQw-7YdBabJfSwNE_Z-&WAGNI1Pseo+Koh|Gxg3^CkL6D z5R-ZrdL=p*RYR@MCYb_kFW<=?{jPt}*^2Im-_v z(U@Ki_u#FpO}?-?mjBuCKHBByz${iAj9${}ba&Igs{A4scIZcs^5wl_$KQOmJdT(} zJno-ea{TAte73r)xy1V`{PP!1?mzyaKmPtdF7BFLI;HrEdh&9{CBC>GEec&BGw()Y z_!2I!Di2Qg04>PF+YbE9a!%r|W{v3lq`8!CT-6~pvEQX8GAI`2dnvrPZK;Xc3AS@p zITG>hawChOdfAvL_$85{NLo3CaU>RXt}4lHG<>^ngM9@szcMpV4=Wwl6=hqUa_7vc z8l?yDiFFW08XoXc4+_S-;TeFb;$6FpHYX=}ycY-dPUb<@7o zvo6vLTgvLKYt!s6j=3`BByFDRmD`zB@R?U z#h=l}!NI}VXorTfq;*f$4f*gPX7qX9!XnaOqGeFbD@)^>{ltQK-n z)L@5%m&FQRDy1G`89MKDp!38JN-CVs%xi`8hg-4~4^f;#Q)qWo%SD@z$VfBZJd7&2 z>W1;OtPo>B;8}~vwAc>#-SPH3vCC?eOq-K_!yJJ2F{CrMo|r>$^)$*0XU38Pn+-eZT@Im#^jm|7dd5n(vg? zBZ-ik2fg9_bfbtjN|anCYBC1;y&*PAZ&BpUUAH8}nCYRp-$oZa(gpBvpxbLiuF;GWzRCO0P94#eT z`zYi2{U9oGQW@mF3rwLdMV`fASOo^P55&x~aG~;d(l!y#BFyD_}UbMs(Y z53gNPf%W=P%>_1kf!O1ObY5hkZP1lC{1|Xv;brLUf*V)uf*V)uf}7$7sl(K};FgE# z$hJ2^SGBUnl_@aN?=a$F!tC*fUmdh)aaIl&4YhVvMTtmd1FC>!%ep)r9IPS1A}8 z4(WbaC|$4TG-mN8@ZRWL)w?4=01)oDWsWk0xlt7P&JV_)?0cvcYe3A;^8+Gl9+=_s zlHIZ&BU8E%7Z#Iu~C8DFI10Eg3Q4{p|R&_Rm#I1zfdMz*S2H)RYP^BBcU_4#9^^1xt-!8*8jlO~ug) z00I`C#+_%LNfiE)D&4VWU^(M%Rz&=zo_trCeao2R-b@wqEZ@N5Gm8e?O&BCzayUPb z+mtk~=#!X2Gw)hMBFFgfGG)H#8ng^HV;DhPjEH4aiEEUOG<;s;9O9xJc0$m$1jWdj zwdkc`Np8Yi1>$Wq68DZtjDSQ?*G!$FER61ugo5CA;t(mG5Xnz40ny$TryUavJNR)9 zVx+~nZ~_5qr02o8U;%{eV!+zQ4uDtY93gc81G*!!NLvW#Z@FOs+iV6my138(9D_?M zKx8Z9pBb0^_LDmce}u6w{x#*UL;X?vUs>}Zr0!<yy48pORcP4@zcJFjTxp$;f&W6GGAgFJQn1FO_aFk>ecC&qqN zM6E{#%7)4kE5|j*iuU6VAy*ABa~0tZ)Hc;|LpA+LPfZW~b1-nYaLZl8d8Kh&#DI6x zd*=XA3+FjLU?fVM4$f}^0Bi!}#_4j{jyqW&@alZLizr)QB?8`Sl^nKjy%GY$%?m4A|-58HnfqA&9kPg*r!qU9RI3`f0eot ze@x^n9}KaSrF*p4rPXXM@3vCn^pukNv#oS3O8Lsswo-bdE}w(hR=OIcd(SB~l2M-g zmc-s4c6Gr9nh)kG5?Pp4=|S>emon(mKj5C}XHbl>zM>qMn@38LOQ5?9^%<2a(&|x2 z6C@lhR^{6Nat9Cjmn;~(7qo@Xx9uiJMaJ(70|hpNAECY~apW()USnE3$?yhFzl}qu zHY0DYmLn?|3EQ8EnDw_1Ke6CNqbKNr1ErVuvnL(;ryD9Sy`UH z_!71aqzduv%*b1WmGx!`2J7r)9%TE4SI8dsp@fQwAp#3$OSkl(`B}UeIE0WH^Hk6f zY~0@zR%X#jFXKxF@_0c%^R4}IRr`X45bO)yCctZ7j>sGW3XIYt;I6I?LWKN~OXMB< z{QMbZaxwrj$tw?4>n#$<1)vBh(i^b@-Hv%6M9M@*>5e#xE{sK((;(yl4IuQM*G+3s zK?4yWh>WXtftn>VF^;gBmb4Mco`edr>!jvxb1`yMxk!B@7#$QZjDXJ$K;Tv^0m1Ap zfKc+GYjNhyTLQ+w4iFrWbpvDEgf%R}Jc!C6vP>%?+!4Zx)|?62#dWZP7gvSVTAyl& zbgbd4rYHSyPQ#_RfI?(qyEpxhpNNaJcv!SZ)kSlVUo>YzR@)qx(HvTl^gWx46%JN= zol<2}PFo^&WwcyEF#Jmc;#w;)kSr-Ski3KjmU)cX)S=B;g~@Cprjb9}W>TH1Vr9TJ zfj@!~kBxBXAVX3JSmElVQp~p-C1aUt=(=By1mVp=e866{k`z5R+9aq((TKcd>>myi zwHe2Uyx_vUrMQf6MBWh%Bd?hJU2Y-)@J)KmU&6G&KIpmdtnW}=tE#A z;3Ch47kM_?gg3BC6`AM&vEVv8d{tu9t*~R1G4kCN_)){x7=(24_In@rXmJN#v$@%u zIA&+=IKikR*tp}vPSt?Q@Y@x9pLSh4$3De0Q-WF>)yJ40P+p5o2uKu9Gm1ktG4;ke z?*0{CepMkU0NkpyNK`CKAW}0T`WDkjoIxUB9u0W`e5517O5qjaJW|vxn_v?XzJNWO z(c~%@UL*6zz!PMZo<}_cL^S&U99KHP4kwo z=aW~)ONu>izEF~Rv)5&L+SgblNlLenIf_15RLSwYXt`1EBXZ41x_C2vV-@%(bI^@Q zEE*mdG!<4_^rJ(u(3tT+w}Z*o&mjgEGVnPV%DbyBHV%YFn?C7^TTY++5IK~STbaV2 zf7@1(o|m3_2lwA;%=6-dVGaPwfOn3E&WGg)LiEh4O$jPH*3OL6CK@Z~iK$wkQMzv9 zrbDX`2V(rniU@T+!Y7H9F2~S}q2vy19Ix{l)(bY$bF#Yo@{P17U%lu14d$xfD7X^v zkY6lfU7N2UQ4=*4Y@}y$RkKQ(b!3*LAulNfy9mOAv%#Joq6)ZCfHkW*8gDnl5aiEk z*g(e8Cb1_M+GDC6f(6gaCk5VR6zH!O%cV4$dW}YgvoYQr6!I*HK2tP zSzco2S5AT9+~mC&1Oe$z`6}<9A^R&^m2KPQh1)Jao3>F2@A*VHBk>!)6{3d0eECKW zxYrs&Oi6lY>0G?04 z>=H!$iqk-^aaK;Q4qN(p>QV$@Hg1`#SgLXL42kT586J`G2@c(6xdo8o{P~9cxy^_$ zHc?O;Fi#}Y0IEa-2!p0wbYZhn(10IN+P3I2&`yK++0f5git$I~NgV>3Te+Q;9%hAs z#!c>0IkQ7|-NMQ_-7OYY>ac~fWVa32eX&wQ$VWrxUA;Im0+_I2B*ZCl67e!!3lixY zFoBa%(?lwm20fX)8j-iE8Aq`Ob-H&w|)UP zu?pyk4zja1)0(%6F|W}K+p=3>w9;Aut%0x-27+Wvjch!$Pq5AI;HZh#5iOA@rk;k2 zf_X@X2Gc4GlwQ|I28~jn)oek93Lz#htYA&bz(V&Pp3-^4Ldz`=%a<4q1|QAPR)ocv zVLy1_3`dVNPebe=n$^=BeT*;JjGT9;1JI2&Ux0#8w;#imk2557J^4qB~A96~?yuo^@!C(cJnAAx^i+S_TFU zt+=|bhcLV`f0ws(VcmSzc41w^7_lHzbd11ZA5y{Wtjm%0*taIbED10TBrV$Poa_7YM@C&m&a6xT=e4gwqC@|TeT=Sa3%} z^M^49RN(^7$C23D){X<@a$0TOWK)f|dUTrKI|BDhl(ZDouJ`lg0-E>|E|VJ5X-Dji&}4O zbYC_=R)n{UI7AlBhFkb~u`b^UknO(^z`5~1j$YPXOrLplOGQbhHVu(q3YgNxLV zhPISjHAxUPmME4G+8~pMRDvLca9q;CMv;icuw_nz$s!V#dJfuxiVDSiG5*+q zQ!8=|CGRyowmie>CtAxI7on~O_-9cPsWXl7f15#7nJH0ub$N9xeYAbYW0EPooG4rF zpkSZJwugM9jJn%M-i21(sE8QV`Mt6;niq}Z4#m;4I7FKfy^V%5Tng#Pi3maADwuNH zv$oNFp;t8t@zjp9o6zlq1V1`Q0c96!8pz9|#ev)?Ax+q?3{y=0f9$TUB0WDnbYJJP z8vV)*u!Q1h*roh_$E8r|tW2YJ=>gv{wMYDG+L@nsIrGTKLwq0mYQ3n$^g%P}!S+4vAjDZNXdHWbC_iF9q*svvPe+e%&D5a_Nv`FZaEGC|X#j%- zuA`YZYB9Y)^dFZm$RSy|SB7BgG=R{G!oX1!Mr1kz)xwDE5n>0k7!jtag#w(X1)wu7 zoTQ8iYqV6EC#nj>Lg9v#^R!g<=c?t$e%xt^b935Rysw+Z$r+ky;}lg6QoO$nQtZ@H zo?yjtJHwGI{O#@Z{%GBv1=BGT)!N0(Y<|O^;h*SVNTD^7m|z6cqDE3+Fr5*Q=Z1HQ zaIzstNyOq1FI$mZlZeL}(4@5}MWG>$AoVK6@kmtU1%yTvVWUPZv^^3hib%SNBBO4p zA4NC@QKWWCgD4_{Es97*t`(C)l-Gr|%yl;m52|G`rgB^mYtgvic|}Y1zK++7yakpd zUPi~G)(q~`Kk#=jVH z)<>2zOO~T3B~Xn3yRgB;EHQMyG2q=!N#!=g4JH7%9!+|OMNruY*ep(5e3{dO5ffQ}}t5}eatd_ls*K^k%1d2c7vupKqV=wFT2s3zi^PapxM!4s-A0mK9$ zOG-iP&=FI8w;w_mg57uO%PGLMUptoD`73 zo8g?M2lDlF7tOF>Q{j{l7if01zNwMM*>1^WjbSsJZ0v?W8r4;k8zqQ9NWNJEI!=9N zt>Ohp28!)RO%}=AB)+B_^-^C~GnP!zzplBF9~pX*u5@5c;ui z2xGv!at>}zLdF?z)b7=QllxsL!{AdN47hAS2@nq8h+5I_J^^wR zJpYAj!Wq4;y9j5f`F(0QV?cf9*7${gmNy9WCtr=|lMf9#M-V%zM0285wbdCOxrN0h zf#ux=y18gI$SziZu(ed1xJ;qCk=JCl1spjL+aMCqY~v>@R)mpz(^yhUkj7`m$b?u- zL5^|R+NB1)D@K!V(fI^o^FtR(5Ryp3RJV_@&E^$7eK^-pH+d+z9!i;3+VX~sGY;R= zeGGXhnc&SC!levboi`+#I=>N>9214w9;|Q2V^Rv{6~DlyqXrxBe7raR__Y`AbYCX( z*Y?h@_RX&jbWQO>??l>na>g{)k;N<-Sgr z-;^;w{=cfSR8&7jM01F5#M}xF(Gll~RQ9|#61mUb$SxrX2!XE+dtE+FOjk|uy9=?&Q zf6MO+0By(?>8q<-Wws%aDOioYhE)u9=-QGyQM!9}Df*OKJR0GO96U|sPwIO>&quaLi7>0V#UuV1nlgfIH9E50!nA523><_+V((Q8v7 zh<3#S2*2!)FPS@1G)+l@5IN|8rzbu5+B?z@ANLNMfxE%!`C}FxvIU9zjikyZ{o-w; zRIa}jZ!>Yqtfl6)O}8~T@2>+OH*v{nBw%_fx8k>_AW+PGl(sAZ``#0RW+({+xX{5ENI0V<|Tx=yo+!KCO@a8?! z?8O`Zvx>l5LgiM+myraRJ0L7a1F15H5)M(&2!MP))*mu=ZqYN%#@na_UVcEw!^51`IXJO!VjgeqWR+? z$q)Zy44~W8qloXgA>U%rQ;zFVBhvuw?lU<*)+h^EOGv9NVl|PM*cwitF02)X zMBAhyrxAx~m?OaeHLcQvzp$k>{-7{KP5^i^B{jm_E2+E#vjuxN1Ht`?@qei1PF!n> zx0*!G&LUl!aw^@-Q#%7_0Gmb5uW`-U=d1xJX9(+KmBp+Q8_%nxfz!JEBo9`=-n?Ca zmB{u(Jbh@V=2JW_VUE&WKTfi285>@J`e?C6;C8;O39j@UmJQst(txSL-h79`#m8~Ok_Kf%VZV`=&Vj9KLR8<8K z*n3$j`m+5d)1iOqOuVbv~`90D#Hm&^;tn5$VhaZfvNIb;s zjAhEG2uVRoEM{ygO^^8cIS+97V@YpM0c(l4IF=)N`(vx~{QM5sU4_YKMAMVT*~R-9 zRizE22_G8NRPa2fKL>euvJ++O`)&L!5SDm6t_xC5`lxu~>TuB%=-M)8T@Iu;_wv=D|S;VIwSp7oEh) zoVt^rpMw{@5K%G4sbh^1DKZ5|q2>aBZ7<_8V+ve`{jruREr-%qVi;g6b}aKg+Wo5+ zjkitK$Tc3ASjJlwG#j!~&7X?#R@Jd9Ytypp7w0XJ$M5-#;%gy;V(M4ZLv7--W7Fd< zZPHRYY;qYsK|u zz7zNJzjM{sqsWV}xkvA#yH6C6gG(Do$v%nXq(D;6M9q8bU9e@$4JxkY6q%(Kpo48N zDj8}Fk9ij^%QF`$D8A9G#+N|@1?h|Na3%-1jWpkfs8Uv}-7eD|Te;@hHbUEH4K$=Tg&plU(nCyMyA7mFk8p!j4G5_T9x6sJ!aln<^}cC` zydm7zSlmNVVArE4`pg!H<1@tR(O;xjeZ9O1lhV8aks2UwZDvkAAgQ`5JhJc-xl)DW zD5|kNuK|sHB|neRn1a|D|i(I6UdT<$~u?@V(0gSW@Xd%LUJ+;QN;g)+o4txnP}wA6hOr zNWpuT3%)2FNA3K-+o(W!)-4R&dUIxG3?RsB2rAV#XSgf zvjtzGHCxQ=&1OrKh1tS0Y$I3#4e7zHv=n9wSFPECgQnTy%hKePz^(^^angbs=N~Lt zC-@+(bwZ{X+6`Hmvk~jgH2L*vZkKOc*cZ12(r#B>R-O(8)x(l5w4$Er9RXcTuIG~M z*~%Q6U?abe%T>z~ALlgOVE4p04$y>WtHjAKT$x}Xdr{ZVV22PmAv=Qfa6jQr76la0 zxPZZ@bk!bwgYh8GJ@k&Q1Cpr`KukLuVvF>i_oMV6irgz{B_HVSVPoDCc^sF+mGFe+ zrwpR|*79MXydFbFP5dg|x3twhDC1GyzdaQ@9XkJ^-aASthe!~m*xXesOnWG-R*t%# zsSjy|IJ2wtrphB9jXEg#vA6+v( zigk24b%i>lxM7Ey4hSaD{i1ES$C2BYCbE*>pk25+i=z?0eJvx-G{qcTigdCn-P+H7=9rBaCVMRib3!ue!?MCX!at8KBh5Y;*k~6#WLj6 zjK>+k;1D##nt*^*v!^Y!1;RJL{x(6+Mte?{gNpGVmh)yJe1OvXQDp*?!WTpW!JfKo zFUu)KnM1J>x0TXePBa2^u9XrV*JkuNQ;<{y9kneHYKr6{eE&^0i9$0z$jL>>?m}M3 ztj8L_;=HzWc9fGTSyGgfz>Oa+_eYLm)j)KACN6%Gj?q@oZO1XA6R1qNU)^@Cn+0pA=VLS%?mTU z6BP@C>qhKCLKKJ%vQ!;wchBB*gY5*FGLKqC4aE_hT!E8E3+0!4k~pY8X%GOG4yo5q1hA zr#CCx5##Md_gW|mYJ!8P7oJh*G)d?n1zT?u+J-9-15R6hao~o)9U%N-mXjJ`5~sr{ zwA)-#=ai#Guc;f#JXyNc{cLawehyRr1w8u{Nm2P+w%F&St~~@knQN|Gd&v4%9+Nz- z-AH$J=UKhC$|gzHp**Cawa%SG3F<^b4^H5!bYL?DoExZV!6r++YsB(q7SmNluns2@L z-zTdcst)mfbwzb0kIaC4>hib5Z}Tiuy{0K8 zLL7aIDgbLs1t$H_+qYOSpn;Ei@oE0JxA6O_d1`Bj`Nkkpb*w&C8GMVSMerFYq&qzD zkda-;-_ZU<)&swL`E)BfVOquMaik34_AO%nUEII7i1EX&oB?B^Tm<5o3YNf2?}#!` zic9RdkqXYckunhqP%bfCs%gM1nFPWAB7$U@R+v1KP0%hvF-CFQ<^?4bZ>M3J{`mjw z@j;$g_RD%Oy46i#8m9fMNFl#@(mGl1Q_z?Hag%jjgbBD)QpHqj9k5^I?NFpuyWJf# z&Q~e0exnshG*0Q)s!=)tCuJC-*m}VXKrQ1ytOgCVa9N3<&G~K-e7`tRYzu#QI2rnZfq(YVwLV-OnmHn&v|w6lF=548AKPL z4F;oN^geCGSp29FCdS3b_f%Q*Luw(?RGVnWY^f{M_NGUEcZ-2S;!6&DxMwjCxl=(I zLf`6-?oeGzD+EnsG#o9yfN5aV#H+GAA=BxdAA#MjQ3dXsW)0n{*Bi1cSPDArM-+!H zwNk141rAB8g@}V!LU1=tF}vFUcKq@1UmDRo=V5jzTa5ghGABE<%20e{Xc-}r{r~@J zaq=<-qD~wC*&pgx{FgJ-=XFEQG%s24i|^e>*~J9hlZ$>qyX}Sf*ebUdM)v#sLwcB-?Pf?!P}cMsw-<)1k|l<)W4;PN1c6zhmPw=P(n!5mRWpK0r-23!)@j+XVT*hwWX{7dEV9O;_-PwuyIN`C`1qmQOAljS@5Xq3jtsg($N>)&TwE+%725o?&mty8Dy0@*O#SD^GhVoCS$&*=yw(E6X*2p<|%D~r#aGL6}x z8cNzTIQn3A#Tzr`G{hJGn!36(-$6I|CzHH1Crzk$&Pa7GiY{T|nXUj#)67teC#!`t|kk+~ehWY>wCY zzknB)N>5i~ICzQA$+N(@F=CU<$8cEW>X7br6VTS_Nj@;@g#EQjyat*jfJ8hGN6YJva{2nnLfMghi zFha58-!GTLR&3Km^E*iqyfS=+Mn5ljmECyAwLR6x;8i|(e;&T_!v}C~mG?M3WB95+ z4`0bx=Y+5FIgtpRdHAZ!dClLVbEhWAP=7cF$b+oq%F$Y&P?yN-M&&M~kcY zF=5OIfmc^?)c~vn2!U4|!Bw%^2I4Qe9G3nKkO!>e3^pr1fE}6+v#O`9L`GZ}c;Tvr zsaw$!hUn4={jZmFO1Bbf6)Ddl$}mQeyg|GR6A+?^fR%?CFQir#QcL;9D~u+USd<@# zB#L=`0ycANG1nivF)!u{=&(ov12RVu;)H=PMxNMi6vZhB`6@rshFpG)+Qs-^mfK_g z)NuJFEW5qwUmL{nV)_rc0kaO$U5{C$ zm3X+oVlj;*6*qXd&Jw?L7YH|4$fg#7&@m8T%4hIibl_(z4IA5&aik!h8}*F z49#aSpk^7Gb>xFQ!dYa&k37KlI7lYPjfwMp7e zL#Rx{e-Q=OL<(!tndOoS+PGYCH007YiQcr#nRvQNNk;ez#?<#WFTyVKgNBk$Ki39h;pD zUPLwj_@pIR*E8d!Pp)zXZ?Ba$7!0QD)Uvs|kR27GF_fs|k6p+%q%tIfSAjG|@lY-J zC|fnob>#9YD9S|!Z)}&#YKj+j@&U6QR%hk#pLTHV7VFQ~;QqHVXS8ina0P>2Wnb<6if~a;gPT6k6nJ>uQ;EwY;GM>S%G7Q?p1ejYd4H7PEJ^5U^ z4GZNb987f#JTGbEP7_nAe+^Os)?gEEXqOSHZ{2;vWr&4^vc+!xnQ}Y>C3Ffxc2>3W z($W**ovT_+6X!`~?ff#fP|d~o=UR!tnnIV+4=z2(ke|_JQ+uji*fu4HzV!6yk?H27 zSuH2)P~lLqGCz}+o3(rbvG_sdK0_ghS%640bj0`$oHWQ8M!;Jq85<$>#VyWw%HVu5*xvX$d{RAE+A= zXmZSi)w=CEFgy~{`Dl<{&(ndX#XO@9Jb$a9LK&rIZ{zR25On{k0efdF_)O&&Ya(n~ zfMO`)-1K~Q6_B3ayGVLI(?y>9tVqw8Sx@8COhshY!?xVufZTH~G|b4fN*N-UvxA7` zLiY}d7J~)_XH)4Dv)oFd+W<@|BlA9DvSp6R z!X++a8>6AR@d6TNv(L?=C`EXLRks`-%^}<@l|S4fse_89O zKuw%$z*#$pxt_o;;#{bJ^Wt2E(YK~*zj6$Oydbo^8b?adI78Kj($1ly_yjTa;!DT6 z#66b+rfhXb{2fO)$MJz29w=O)R({FPC#3s7u_fGb#KatQx)xsk(C{cW;Iydb%uKG* z{VYY0T2c}05KLvF8YTq%WLG}o5)k-4G3)Y(TkPSF6qA2U{5^y;-y~vpkm8g_$S5BF za(*1}gkqs{MG3^*EM5p8#jhDC~0-Nqfoy8@?40{q*QBxeCIr&DeCs zN$Jk87ufi!@MGg^P!y?kR;5|C21AXBiCt@8o2(4DjT zeQx}1O3vUr>rvsC@m)JCFLTZIk2#ZhmuYUi!)8&%KsKNY=i=kwb7BcE5y#DUVE zH@x5b$a#4GdZ<0i3G)%!;4h2{ZJJ*AY$>y2)s9$Ry^YY>bnzpywegG)=+C-gwI@=nt18;DIYuE@&cYMQj!F zygK)%kYIqlU7?B}^e%>i(SGp|PC!3GMuC)^5IG$(8JHRf?Nr7o{aBcuc)?FU-`g$G z$oaldw{;zLd1fw3>Fo?{UZVAwu-D*+I0ItErpz$KuheD`6f_Q zNxKQuG3HI6Q5Ks(c~)SLv5xE}P|Dj)pj;g;8qcmM8!EbGQVC~53x*o7rh7iTB^KRP z$g`zQpj>xHRK#M8x!a4%@wrjK6t!q99T+q8A>|Om>=?yR&6XgT?4g&a*-qWw^q!9d z5_Vqn`12>_(Rmn75;?jsouG*C_kJnZ#utUOE88I1j zfs1f=+F)zMXY}5V;MyzlJcx02iR>KtFwXm61X4m@E(c1 z{b>pFn>5DTxD6o!)j%XMXj*scN{q?@(ODaVW-{8$7pGv?4u*F`Fup1P6`h{?kdX(9 z;wuX6C(tJkluW2m7%?9RB--IdRcR#F?nLnTm099JrbUR*FVd4EEAl?6jV&a^xpKw< z(pAT|NDqX)KHg%djkuFdj)|vKq0aSwY<6x|Xn$Uw@XwC+Q&jCfJk5h8Pb(733l%tSFcIui=nmMURAPB12rnIIXA z0J6fmQUb0lB*lChUYzpBkdRQ$;()^t*ola-Ql!gIU?~*o7LV{7 zrNODDcan0xEZNnpsEM>1aB!aWZ#QkLN7c0`81Rh$k_cN6&K#m`z0NixVdmFmYUR67=EXYdBQMGd3+Fh(uN%^|}S!*tMxISGp|@ zk?cowa zPgEE+lQxX)r|(b{CXpS=;7KM7W$cF@Y4S@E5{Nkaw!L%#&BZ05}mIhPq)^#q@A&|O+^M=ZWNI?)?E_x10y!?(x~`_G z9@=?yhMd4Cho*9S$!mI`dRkNG1@lg=w@Q;|kgU%n{12NP@jQ42q zmHfch)I8o?Q(w!E`%$?(!UJ^JA%2ji-<*HGHvhbYpC{Hposjld_?h1 zrwpsZ;yAEa-xaM|4zjcgZ2Xl4VVT~s7b5*nEz|k2; zMPX!dLqMMkqmH73Pv1NjbjIaVB=7e>=iaL7PKQpE?|ZNFozz{<`al2u{Li@}gcAR7 z89xA>xp+~Y&hRGe7jXTU2(PiQ1ZT`ZJYkat*bN#>5uk$J{WV=<)to*8F?_*L0|aX6 z&0htm6=P-}<}p)d7zz*q;Pao$feB1;n0)-Z*lf{UzQ)vC4Wp(RaY%Hu1gsHLxdavf z|8!TdgJR+{E->3nBcrYYU;Cc?ATa-{`aiLMC+!BZ5T&vY?^yB|N}@waix=FmS-E zskYO+cahe~=92)3gvv0>_(HizR6a!lZSlQ9q?rJQ^qRSA2ooUAh13#E&X{Qy`@V^3 zCbR-aLSGo7F>SJQHVHBk)|db)13c*a*=uADk5jo5c~}&B_~72~!H=U-l5g06{>`zd z9Z&-@L@+Y8A)byf;*$%l{Si{Oqn*%0=pS{BofZ)K37O71gE_4NVUe-&gu#d z>H@0LGTc)9(%B#^v>KKOoqdku+5rh#qQjwz!NWvD(CfpMS#~JplOqU=gJKqVa=(`Ie0Cs?rvrG07tG@T~hfMBKhZwOl zN}~?F@ZO+9xNh`>0M*()s0V|j_E~L=kMI^S7_7zi-8sq{o*u`Jk^gv{+fF=?2gF08 z#YoNp7vN$0q*nxir_?A9Jbe)zVSDCya89Zh@W5D>VESl5vh!L5kC2FBck;D;F?NTy zo%cW*0eWKRzTo$YR5t+=PzBQ?1BJo_P#1ogGvGj9M~Mej;1LFpdP;-*!$q0@Om+(y!%x{2WbV*PS z*c%|w7op`YX?+BVss_9}Q-P_=5HQI!XVwJ@v5vr@Lz4=g)`4+ji|17Kp+}U3JG`@l z>w3_ySq=zWsD$7$u_XdyBv5>>!RNSv`fTm4@$Hpp--A$0&`Sz72tUGtkd!{Q#$O}b zV18E|aUZa_5Rw5~3R4iNVOLUum1O&iSV8`^CORU7hQu0WE9BVzL>~edNc(3R8?ytr z?gk7M>7z8X4XTIP^yuai^0KA+pgS@Z3vcJK?xJD-HMgLftRvtEA#*1J>!Y$l3cQAe zvOyvtnv+!*#-jvbE1mBWNqZxe7tnhiaLHntPoI2Fq0|>nBsv-BhiM1gNhxNkIU_f^ zBnYM!GjA>b8VoI3LjPDN8R-uz80Y$vnK7$SwyROl`i6vj#{2b{Ps60}c2R7|xB z+J|v~ssWbdH7Pd5ooxYg0xrO$X?WY{CE;4%%}+co^i4%mEgZ7(^2P7rC550)^zt@h zj)YUKFK6*;!>0r>p>uKSJYs5?HTbpV$VD_?mnM$ErRx$JYu`6O5shL!Un&_hc*z^Fk&tw@$9b!F0Rf`#!P!^V*ELlSHx3vM8 zA>HT`GkgySvwbj$&~K&n(t1>Jln(!cxiX3lt`bHic&RQR|I2aIv`RQGhWD?s`&S$H ze@0k0)V_veiU(!lnyZh)^VCi?#T%;VVMMvRq(OHqIndq}qMGJV2g84|h))R8$ChxxzBUBd;u8_{nrU_Po>8n!A4;Sa39|#&9I4<-SSK)U z88d+|K=ZAikk$A)6ef<4j^>Lfv7hS2Ou>Cevx4&%F-h=h;d^1M)~+`0%)0;_0wHDx z_()Kg^0(nZm(-d8v==A(!lz4^m+^!Qk;yV3=D)Ru1jTgI(Y)+iB>2TA=FnjPhC=`! z(qzs_>UGc&ayv56Ay)&`=&_u@$G`AJ0s06z&VeRH@cTG5oLu;HO<(B=uYoy;RqOlG zv!rcOTpFT-wqd65NB|4rF>7RAUdA4h0=<)6k;iH)QxyQMS5TbobdB}lYe0?4$2ZCX z$XKt~_ks|%&s)EJ($)tWt@D1+sd2m?v<9)2JNp1}ObCP*X(EABpSTa81uiaZCDtD} zsDa|-payaD6)uEAfG;Z64%cgu|a zHn_&(0?p`?Uz==32OBWu(B(czntHN!ICRMyxs`+)(RSZTVA&m{)KO?7uF2w`&iEJm z56)wpM%?-YhAll=LTnT|{zZhXJGj^bd%KTq=M*}prc#~FTByvN)H_6`lYsZpBthUT ziGbrFbb{NizrbKS7-;jtqTqK9Y6mBPL?@Cb@yU%##!Z<7=LR6U$+Q)+0AcBo1-J@7 zcR`{M)u1O3L;Tb~GWZZ8g@zGx(Ar5F>YUX3B!j4^q_iF!4D#afH$M*C zV{l-)Au7YCHDMH!BxYVKG$_OB#j%wb0bI5C56hKjQ-v~6mTWZkp*x@lx)W}_rXtMA z%nT`JBl7iVR0cW0JA`kT5;WMCN7!=~^G>06?A&OH&S(_@8U_&dxK%3BQKlqo|9qTe zdLS;D3yJ7vY)45oBJT(ZaTcH<+oDXk{C(37`^LB5m|Ttd6<~PvD&>gX7Z31=4pfyI#WNIxSk0g2+0= zq6QmVAIa?#YHDODV727++xjRmGYkD;1|LZyF5;!mwW-#-9jTv6%r`BqC#ZErs?fPO z69c3{mGnGN!!Se8oV)0dSCX6{0A`HfJ%k}_C`NP=umZ#4Vk8IX3gU-+0bb*joCFce8^6& z#B<HBSPSK?jE_ici2;Ly{s#9ww^D^rEo`T`>)wj2(Xb2r`L{BKeV2mzSClaPzn8UP=Bt-!k@keIBL_lft-t>MJn-k)sGF-t{10{9|K-HZb;M5k$&_s$GP7zqsRZ zLcR9__4|HB*Ca_GE&dzVohrZzdC<|RV->jXrgsFd7hltNGp^}1WMLOr3gy|-cNb-# zsK>k6+fHiPiPj$eE#(ebM zi)$Ri!E_Tu>jB+KO=up%0l9&F4+En8bB|$yE+DQtTD~|0#<}4KKYHxfAA0A1{rm5U#cufC{cn2sEwA4H z`yaBqhko?Om;TT1ZvWVuZ%9QkZ>fmDQ|dQ%3~UCA1F6T?ih>|SgCyZM5~M>`wb)&$ z3Uh=`A%SObJ%Eo3LcMgLR6bOao$~OoRdVxkyC5jYL+`QbDo}lnH8kY8^1v>yS|6(A z^Yzl9iZ!xq`G8z5$yP}o*j%X$$Oo;VI?hKz{v;Chp#v#wZ$7R!wcMYH>sd$@Z^W}| zJRfcwZHDE}#%_H63k)&4S`Q@g%Zq`ub5a>cV;*)3K) zr&g{U$;)^tb_(OOU#dTA!bVd%_LEk=Ezu;Qm~sW#gWsT44p! z%5l$E;eItzH8_$_pX(z-jLrt-GjT(756uhyI%H=9fAY0Fh?J)Ki+!*{Z_Z7Z6Sa~waH zRus?k(?&MkGgP!IR^>h;=f4b~YF;m1z#)P^F0e*9JY=uKPYi1Q!5Do|{pI@On1V zddwgFjjz90?g@)w{sDZdtx_E<4s*CZjyec;MF5}h8@N`i9g$1rn(UYBC3nQD3>T|a z!e`ej6+O2}@!*hty*lnm)vFDbtF=~KEqS#=<;sE9M=h0DcDVxBQ-i@%&$V2);#I3M zxG5S4?I4G(`9)vg@@`@$MMKF+J zX#}EU#Hv`s9wsn+Oqf7a=gN>Q98=!lRm!DuqhAcitDbj&gl)Y{SC4pyJ*Qr4RKcFPfDOUasg$eL)vkB2h|Fwo z7=OhpQJ+y66oez}aW(8dwL@>wN_`k}hqu5T)^NGBzd3J=BUb7oKokt2J~F~^re5+6 zk3jlh^j--N@Y&Rmh{ffwHw>{|2HjLRORAR~FoON%O7RU;fLQB}DzVWqJS__vIDjeB zi6(+XJYg94h-nr~T!-|W!}W#83r<-Md1WYbVP6aKvT~I-Brgx?b6Z;{({V1vFV!Dn zDyX1RKIFN?3+a#E^&(9`&!lFQiF$8G9VGLvhoW{Se#86!#Qltx`=`KD=sw^nBfy>- zcrhtCc^S{Yk9w&5ukcGcUs%tdP_7O4TyL46CtP$0^V&O^Jl+`NI+^7jv`P-OPy`+h z0U4^Y?Hws&jxZg?ii}C$UmFxQp&ZHCu>59}Cw|*3-(TKM#lzCz*kRe5Q1&e39p5Vu zW)JDAJsd>BBgjWO0r5zxdput~G*||$aTfU^@{%q=dBZ-figVpzEuMw*PWsb%Nb8aO za%C9$UWjCZ0>?1vbfi19mg&R&2BeMSo^QhaW~43So}Z8Vtw{Yyoc4zyqW}oGUh`L* z!kuV`=8W1I4})^G$9H?c7(J5g0rJ}=_|2I$v=~cf)I%9%*sz*vrPr2lH$o&fP z5^VksiR6BG|2(bPat*xh7O%TE+6zN{!sZ4vGWRX=!%7>!}XeXczoYjixrQ( zV_g(V9i5Cm??9cT$1=`DEQ6#)4Qd2v874#vE7-nwn`|Gcd4g~^%96fD{Uf}72KQjJ z=$MWF&<)4SlMekNo|C--k>KU!-DOnndZ>E{GNIzhW$nTH&Se$_yCYZqQdS<<~? zQ@K4e<~5#&@0a2|(b)KLvdS@?oA93SZ7-M`@s;uU7-oX`?nmAsUX*<#mq@75ueDz}7??T#*v+*bI#`5sW}@z( zRVgwt3O4K(t0P0!5ui^4Z7^xQsGr6V!eR%Im~4gcekbmUx3$V7!ZXSf%Aw20-Cu$G zE0Ojgk;VuWSGWr4YNS>e6>#6)1c6T+j@{<-*3cpANVUKew`I#$$?Sq=jqog#a~++X z0`Y+Wo{gFg4U%p%QYk|yKn>W>EA1Xr$xf6d9ut&xpq*nHfXl04RFFC~aWUZ*lv|B* z6WSw9#$PNIYeljNSf^G65*p>6MENX!LtA8TQ`OiA<_o^S1wFx+;6`ZxX?wZ0g>>be z4PAK?QXa=8CNUbmJRKBZcr3T3!a{+XbBSl?HJ`zGo5pgu6Ek&3q($~nniAAp0jtU8tA z2<8w9UZq^$KPZFFok5v205Z5BL|Jyo;u)Rr!h&Y-OZ>;NN+nog@Uqn_)#5=9_Lb#a zTL(&V4PgZNWaJw!D;lut?(S(Z33>>rt36Ex;x3dYU7mCRnu7^>L*)=tSLi<)5{5yh z6xd9=@FL2GKAMoHk{)u>{*?J#E}O~cawGCm`_)>7agRcUiPd@q`pIR;LwZ-3mvlsu zpGjys)1YBW!g}zdDc~~^glWx(JnY9f;zCAHgdI@Jpin`bp^HJQN|SQ1SguzAK^t0@ zJW?)JA^u(XGtkZo)Qh{-%tgaF;85`mT;dNy^3Wt;nqVoDMhhsk%*gjqo@5No7vUH6 znXW034odgbZ-NWy2_%nG!8P5JtfY68mwanf7vVSQ*_4;&g=7cSN6+XT<)=Dn-U#mV zk?0xaA)Scor8elA^3gTbFT{aYNK25?NE?xMBl$>&k=}&#PNe&hK8f@g(l?R*H_{)F z;tAL?NarCPLb@I4KBP||J&N=+(zlU*ffP@63Nw(FAZ3x(B3*{$BOOG#1?e872a&#j z^c>Q6k!U1CwjNN0dAcA(CM_+5dN zMam;}_rT@4yY7%GA@pO7VL#lEr250x3TGb(L)cU%S0fkk0{7T4RL8Obyc)1YNCP7Q z4z32Tz0eflfxAoC(QqCSiQtA?11KX`>tJz=0fJ*RTtoG!5thV zy%?_{AC6o*GD7{3xl0nR8Q4waawAuY08!I)Y0xm5?iis(Ji(>Jyi(+$Z03TW3hojp zn_vv}Qp16Ug50x29wC7V$X3q{%D4Kvf~tjvTEL*l9AiRLO99h>T7xM7oV-d4=o&7n zv6-3sP#`r3D;ur;L4kCdrUy{qdJOaM3H?1gg82-mAaFR5`NfMhrXYYHpWo&T^^bA( z346T5@OIKHk%LPhHG(Dvc74!L2&&LcC4_2%JjP!o>^?GVm*KF$$q@u5(W+!aGlGM1@RKkH$?S@J<%M=2F;T~(6(5=}vb+AfB znY?Uip@CeXPfzAP)3O5rEkMZwbrB&zJdj<_$Y*CDd1P`q5G6q9G|2`M-tn-eCTxKR zj(K6Jd~tYW$Rj%lFVKy^y+&9LWdhP4t|Fp{emI?LMZbt@;TAxPu0U!V6L?I@RXy|q zPj^%iEzjVE`;|j zi$r6IEuhR2w=!DaF$0dz19yZ4T&Ovq-3)ltmcwltgY=0GBGEreqpb}$wkjNhS!n$Wq1{EsZ=Zmc`; zORkd+xCcm_hYMDxuR3Qu^P0;8tt@^zYZOy@Z8{?4i8;%1kYSJ)*);5Y0wn45&KBgDZ z4yl}1qC*;fx7UX@lcC=_PuJji>-_=Thy6JPxGoRJ=#(oSTi5i5Yr$e=cQ@*~ZV7k2 zZ(z#+7u9R52VKIu@SNZj{$_Abe|h+D!s|zZJmGJ{*Ah6cUI^a*8-61wdyv(@;eQC% zu<5+Rw0=a~*Ct0sH4i%uD>#r(AbChdtjXY>XT%e@dr=pDgauvPgju_G$y&%uXV9yj zXnhVWWBQC-DefPvEgxu?QL|sm%L42x}i&SFX5NSoYAR`GkR9nbwfAxoS_)1p&4l-V`L58FbvbknTn~Jnwd5;X4ceA z!!*rY4qeQl`5dawp;!)&#=_xxjO}lbZb0&_A;^*nf^{$_z=Qetoe#T%Op)+@2JXrA zaRTVra!?Pv&dwmQl*^WKJh}sU=OKmnAHy~AE-V#5ONNzO0b^l!8X_uxL$*4rl5m$V zE6I1EPBM2Mz;9Qh4q74PHGCh>iHgGaygYx$T7t$^<5-VE>_&J6WoUe7oXuU_h(rB< z`X}`L=Bp5MY3VipBIEv|^e6N^@(hap=d2UwrdEOfq*^_~`J!?T4}&1SM{~IkgfxI> zL{s6rD{)OGy>MlBclTAy_6nv6Y=S8)P)@B1XDf(3StFB#U?RKdda}HXid5z0G<^f8 z<{0WHlk`^nQoWzRFPW{M#c!P62fV=c_Ctk0R1Hn*GP+m}mlOCEO(yw=2L$2gC`0D% zAMs1{{3?EF-orYmA7i*)(21}Q%DH^b!~7G%D_8;@KwhGQ1Q^vq{GN~(@h2=~hb_L6 z*34mi3(B31{Dk{DQg~11KFM$)j!o}kREi}MQZm^lwZ~G@)M%$TT{ zcglj;!sKFcsd!EFfb?+WG=pR4x=8wk{ZTi}Em;BfBUysh1qZ^l8dcy+`J^Z=s zi)Z}pTi*VG=#;6`&seTz@|(BxU$A|L>+SpJPt9MDNVcbD%+_=H`#m@>f^b|NYAG-Fx2i-tL}rm+gK3-S_iAPnN9D85K4)3l%x}G5+s@s4FS+cBeOC`So`0Zv z`1%{(dhY`dKl1qV4?SEefBv0UcU>2YL{~@rh}hFTdTe1towgvlv~5vrWo%P)>Wa|^ z;!C4Tqsx++)b@=>jka0s$vJB_=ORwBO_>#25}6+p*PGD`V?ELKL|bCLd~UR(O^@Vb z^AgdH#Lj*rJtdv!PPQLCXV--*lPhM;J7>X+*=^g=z@{m46YcS>$#dK4sSWE^#Mi{y z;}^%pSZ5?Q`Zjyf)@1wWhp+D1oNA9xIWr$`*H=YnkAAw>-QBUZt$oYp`CF5_r}QV< zM}N1aePQJMej_q9*&fd&+K=jU6Kf(1E)l0`Q*L~(Ur&ub`POaDl$(^!S+_lK?EHH^ zeJqz)5#1L*r+rKNve=o&9=X!HFq%tDUr#9U?mr}N`u2*p5B>CLdYZT}J~f&=ddpj) z2VzqqZHdlz44mIq>mB`Fdo?*SbITiMbj;|uv~BL_-yS_b@}>>bX5O@OaXdcyt(CEL zOT>}Yk$F++==#Oe^D*)0^DB=1uhHKx-xh6;N;gj5v~BI^7kcAjbZ=~aMmjomRn+ac zqD8()Y{k4%XiiWcG>QE^&F)WqPHCA+pC-P5rUebJLsk+m%` z`qi`BZ;In2l~^numlE-0qHTKng4EoOc~d&4c1(+QM$S0n%(hwLY-sOuBl8mT#Rbyh zS#o4$WOb@rR3fURiT6n#ksgSCH2FvAPq9BsuSSlyeeCd&x83?7<8h{CyF`71wo=_kj9C_`u?zh-U!1y|klcD(%L zXFmJ%SDtX#5WZjSdN>pL(1`o=fC?cNW6{;{XN_}q8DxAm^ieeLOIpX=Yg zBoF1+RKw|)GdKlRwZKK;e-OrJIT%6-54{j0}Ehp+v?52r3Jl@}~5T>m!@J$%Dw zADuOO(c&%VZ{I=q|2H@M(^KF4*7slj^=~WH+iLZ9ozvZO-@~7J?2FHR=ZEiE|L(h# z+ZKQ0o6jEKzT=836Ih!(x969?DwU13=WW=0`yIRY*T3}T=fD2Kzy0*pG~m#l@*JW7`w+6PG5W`0S3I(T$PSU{BNI(>n6eg=ZJ!;pjDIkA5k3?2*X4__04n zE>FyAo6|-JcTK!KJ}-WGVr6Vg`>H5#Bci5OMd!s+kaH!>~Kn=q3r zW5PR@=7d=v(6-y|-g_ zRJ|v9^t-x!sJJ7NRERcGEUoH1Ko z+#wGv{?)3xSFTXxRpk%AxJtTzVD+Lu4Ri~y%K8V659oguf251;ON^yceq?-fs+H@R zb5BlLU~T=cMfYr5pRsnne9b)VHhAV^-M3k?FIwj$sxHYBB>=ZrVmxK+KXNimEUzy6cwTW}0 zVjDzZY-OZ3xnhne8z>M>0*?~y(n2v$#iL1NX_w}Sl9YqYj7q>;agh|k-ZJvp{s)!b2DRF6==tspkIwj4OqLEH~ds&j=;xrMkk1UiH z;oo{mOe94q)h2?P#Jbca9>nLJ+r)U}djJA@o1hw{WV~GxmBngQ!F^0z*4BY7KFAO; z@e&0i`J^P>6%nVv`G5u^($nh&@d@k&x>X#Ig?LdCqGG!&A#8wj3URI!6W=Y(J7bD? zPI7LlJECB0l60=P5s;U#qcDjRY161xl42P53Mnc6lE5ay80*AJIcoW__;)cOf>B17 zMWW(ApngHx8QGFjqt}W0wB;CQdqhQ@32|*?X-rJ6!}gC%8-$5ih!7|N6!HCHBsr5o zRupH6QxlQc6Grl|3Tm4_?<89P12KV2p)LrMKGx`p-q&2i9Euro@0x|Kpq4kp(Ewl$Y@?<`0kfNl#pp_mPZPjm1o6D+#dt1s zOS2Ih8;Qn}Nhz@?dMCb^9MzKIRB={JoQ7Jbvl?TrcsI(djRFFR;e;?S`m(UiIs)yI z(JGGM`wytxDY9Z|VfbTnI)%48QSu9mZ+2b~g{>5_md}H86vBvQH=n16g=)zfsScKF z1-8ED9a0g1QQ2QbKJ26zRC1QC`$}53?40T5GUE2ruZh-x!}?U)H$2T#vsOmY4cn8> zKdt(Fw?J{S=$H+A(pPQQhS>_sQjJ{jmsA9oJ?gSxtvYEY_{#&P2po>o=lKrUEVx*DNr zH2sW`_K+M;RdcGFSY0T2d(SE5 z^^%jencprbpsp{Z5|E}mFTNgsiJ=wO|f!mOZEJmr)RS1*#<&&^Lg$7gcY36(+-gW zyDw1WVqp-mBPa;Zl9pC-if^kq#mf3~)LyuF$9L7U>-!rWP3u`RXBxHzZzVH*=QZ~5&B^##uqSyN<^#he*x`bHcC*c6 z+rTzxni_8zWYO6MXwjr*`EU{XrUgEpbu@PgudD?vpru;yp$F)2-E~Cd2uZpAdIFUN z;M%(7!N&*>Wv1)YrjalSu13?=;jVNY?X2AaWiULq>sX=0zLR`@r{(s!78Y^Fqubb# z03Fd6-%vC=t7ia0CzDRAOV48i$66_ujsP{Th$92ZvC#l?Gytp!VfV)$QoKPjc6GzgDm_~pV-9y*<@2~=l!;z#sQawxO7Eo@v_Dj@4i@m5x|_ou zJuoKA*DPJh<`mAx19*kB%5DqX)(hCUhDCaK@iVq-WL!OMs*n^UjK-1NCgNZ~rn&=s z#aj9hF;dO6K^uma$>t2h&ZM<9z2_ioPQJ8B1FRa>=f*4r@JeggPv~WGn&IVa-SyM0 z0LID)C}wzs^`lVNGic4X9IP$qX3o&lnq#Y(^ILk#3IwdT*?-n+hB)=KMi3+MIq0dG zjH;N1qT~QDtYPd52$~^9Ap2MxJ+T@%UHcJIKW<3lWw4vgTG^~>L+ABuJ7egX@f7SL z+QIb#;M4XXnl)ebfh@k`Ww6T)@%K(zGkSvL*}W6_vP7f4#@DbS#F2rtvL*SWlEh?ihr1_(IZ z#*xp5fC2S za~i6kb-`Xf3R0LTwhxhf%}$=Wwqt0v4b2;?+A8!*Eq&pIO>#u%o0{q_>k!pHc0dg| z0%3;nqj!q#Z)-5#iRdrnONx_owVbCZ4$4B7T+|&%${;+3_-v^N>AD{~ zD$$AxRm;n%S=~xIep=VJ_qXbR0l#hdRhvLz427}phV-#L*RY`LWmL&vX(!AuN2Kt_YN_VJX-69T=Gz7~uRU_xx&{tgBQ*)Qb!DHa2zbt<$suq_~ z4x&C_&S^kk%T|os<*y&cWgQ1GDv0^eY}W@NUU5MS#!ak~ZNnDj%2q@RQQSqbMJ@B) zjO)N8_IyyLW2Ud{pR}&MBM7E$)MYkk45gKvDJr2M6;7SuT9&Uv zfv{Bvwm6LPLL99^qZ;Vu5C-A4M8gG^5RlLJU0p?7Pe%8$CfrxnnwA+Er=IR^*aiV3 zQ8h1}gBGIsIS27dhOP6$Eh3OzLXJ_m7#vc8O=Kfd38;jqBxo?IzL*F@MpG#JAHbI<9f>#L^W2Li6e=g^dM5FRHNau|$aDTwBRG6ikLb2FL!7X+fG zJOVMyLYN?pDaNU{-#t8DXB{hhpsA)|p`?As&Z?H<55~!tPdIE&U4KJr%^WTDn5LMx?{SSDjV*#Q{iU3-L$7-K|oaycLx83VGN%}SqP6T z1c#Gx(_YT?)Y55`^&IF-8VL`_&6=Lq3DhSPHrpk%{ki0X_Pg=5L}><1%iSM zu&xdK3Je-8LY<2a4x=1kg!6iQC@pCp{)f}YR zI0G^@9N?6tx?Zj}sa2w69NX6*7JW-sUDK`y42bo50(CX5Y6fg#IPaiF!$LhcNqz?b zktW8F)jfDLO#RR#`QiJ3GLg}9Ab2h7=MGPj-!svFtdr@aCE1>G1V`DBvt)$4Y;L7I z0#;JME^NnZYP2T~D>N_z#ihlWwT^sQgN~QAR0k6Q>FTPg^@d4$1!f6bNjEjD0@$9f zT(`B^`YH060>>L0XsW|RfWH)eeMfual_wn^e-TQKT}*=XVk>t;+XyA4g2xSi&#KL@&3`lC zy&kOV93iRdWsi!1hW=UzGzO5=eFN)zFm-aO10~1SkBLdFU$GP8ZWPyZn38jqtjXFS zT!u}Rfz9$*kzj+0b<$QdIXKpI^(OK1#uWZl-dOb1f-f{}IhyaNX$n|=lNhbql>=`U zC!Zrl^=P$LN9?kLfM)$~MPtPQ!Pc_WZYsq%1jy+_#-hEx;?yFyWT-pwK~3-6CG~`aqRdz5rRQhhsq;){Bqz zJNTz>6<mxa4woyYD7ReTubKd;(-uX>5vTO zH<{2U0?l$Kd0|h>Eu!YKst3okjmQR2ihhTw6Y@iIPzf0=id z!Uzh3+)=Dy_0q633u_TsECK8PWAffW!G^;RI}%hAT8ol-kH|f96_`vz(1*EoaKdU{ zMzei2?K(O%F}MNVE1qQampe(o6xfo-U{-Yv*xy(=wje&Tx%Y{2-oX3C(^-dTHFyoz zf%y!Ff#I4NtbBh!oZRAN%$u)h5cnDvuV-Q*PsL6VXeC&r%zRM1I>3dKs3t9{;Dl7y zN^+!>koUvDq@XgxEp%K_(w1zTLeG0GSVV`KEDNP_+c{u7GpZ#X80wAh*tP%O`h(#mIN@nhKh9< zELhr>kEQ(Fy<(=!|dlWd|U_!d`?hjRLxZ22ljH=f0&$n(z@bd1ul!Y0l3@K z#)nTLVOt`_ED&baaj~%o>JXN!?h~irV8Q*^nMY!&?A$NLSg6lO#I1pXgk8H3S7Udi zjUURGb&G7yb{t#7DmWH_z}OxT*9BFvaWgo*W(7LV9`xbY_hIL1j+*(XxIL&Km~Whs zgqXT~z9qKqH7hiLQW~~Q0ZwW*?HCV=+60R)Pao0*my$+j){qexv9XzjHp4~{)D(WoU5^P+=SPJeFb!|M2=c8a4g_?pF9;fxmg^+ z3lF!CXcZd_?VrSs0CyM$|MTSI)!}%eN=UK*)Y_*eFM{ByoDUxbOnS?5E$3gvji)x^ zG1Ti}mB@7z1k1q0!&2p^#SNj3NA^gttT_qLushLmv3n6592*XO`!k{+R`Pl&ihzOk+~-fHuxG+;ZJF@vWU!EzHXdU_8=--Zi>I?H>-(ygaeM_{0mm_N>3vw@Pu3tD<~$M6?(>XVRdATuTBm@$3)zq zk99Y!8fF0dXT%_)vsElnBpiMLANFsucRFtoQdrhc9j%Ph%xEC0Kp?Pr8 z80m~-Wb|iW2UiG-(LxV1SjPir^gIK;1xS_W#8?3b>D8VWJGpU<$dDky`0JwD+Y;P? zQ|92t!jY9&2*S}Jg(58rYOaE5QcNhh7W}BjH%_4pT;3WC4&Ad5=C67F|2%~<23&!b z2cfCK?X4KvH$%xeb{?7?!z?41Np-;-Jyo~OZ;6P`MvrMx|1WhX;gmXVYq!MrAs)lZ zsPJ%mp6z5k_uJydC)M;>2gX{3@KgexEpeW>8_bb^9ec3Sh*(lI-~7(RgT+K0#KvP3 zuzkeNS+Lr%LIj_$D~z<^rCWCpr79)K2Cd_~XEC}95!6CQKun&y+CCD2qKwyZHQTLp z>oL*{owL<$L+e&nm*|KCoaVBuaVWoxjsEG?ioRM=m&Xs`RFrx(u5_!pZbisV!x9+8 wSpi+aAsJpZvT_i1_5PtUmR71OQ+9pmz-q)l;xOx#$to1~)d)NNzepA`qW}N^ literal 97804 zcmd?S4VYzBdFQ*=-urx1om17Pn^sF2WuHTjHjz$~D**=0wN~Ho6-3aPn=#4E1KdcW zRSI;|(=u}%x`0Me$%M&}hzU_9F##h+GBO#jL&j23NhF4hIuh+9OfC}4@MK6re7HA6 z?(hG;YwvTa>J-g2_#`)%eyF|A+H0?mcfH^5yVlMwx$-R`%d+sUaLmQUp+kqlp^NkS zZ+3Awlv!zZamh1&1XbYA)fZ>k#VwUl=vN+CC9WC&tMF>op0Qe2Uu~_n?T3mxe#h(e z9fgI}%0E-|pa0fNu6)x)S6+6>6<5CT@&gxLvH#M8Z@ToY-_yNh|BqjJ(T`txAPbw+ zn70~NzUg0H`poraf9wqx?Z5PrH@x9Z`?I-C+Uip0t^40};L@zONsXB+E;;bVi!Q(7 z(#x{>O{(-Rz3kwd_FsP4Gmd&|UFqlp*Pwp%&6i(!Y1ZDP$2n^J*c+}qaLIvZ>~o%K z!1bv0j+v+jv@W{rlDAx%Wt;RpbH)D4fApeDuX@vgtSG)1emAs>ybK|m$wHR5X3FlC zR@N%>P-f*IpKXP(HE-v$Arv8$+uEU(hb-h-pR51Z&RcoOe|o1io3-shmbJSxWoU&q zm2#e}`L9*bSl%vL?XqZr+F2{>W!-K*n-_f^gwXDWyl7jOyx6msXY6mzQ{G@KWyuh& zj1peTi=xAS?V>C@;fioQ|5`=Jwzg-WhPbk_n)Ny-6z#WM`j*T0|BF0pUj$h9AINSC zy^Ah-%O!8R?4pC0zv&Ixd&A6wv=>9~aJW5uD10pZQrK~Q_%GpW;r;wOcr9iBF?{cT z2(SE1xIg?)dw!YUcLK!U3m@n25vu*?aOM^NI-Iiq;xB}KzY)Iw${WLPhXcPFelGlM z_^ohH_|0%l82x(qcf56dxGDV4Z@c7s{^bvy`!5#H`QLvb?7l8s7cRg2$FKfs_+t1+ z$6xUFaH8&hGAvy9mGEHr#qhuU)1MCiNBFPd^Wl#0gSUjA54*k=ek!bnfBwF3SNJvh zc;hF-^ZrwK^GCwJ5C81PUiLMr?)-s&bzk^gIP0wsgtPmhJ^Popm%kf6_wvv?bV3#f z%cI`TEMJT(f4rLQ%CosFW`lQxc-wzp&6Y>4_*l$l?PwqLCkdbf%>i&?^NxU3hz*%y3~&+ zADQ@ZBg3k!i5s|!hp132R(bpYzm~Y(qO0{$mHfQPeg?O zRJ=PqyThK@3!$rADfyQ65+Fv*$8K&v2_&Jbjs>?(!(auwSD;O#S!(^8uLp z{RFeA^twSf-rs;^S$cv**u+Dri74uX2roy36}% zJ3p{5{n{79vYLqfgK@CWC($|>yF6zCRLwN4{9r68X?}-;F<1nM(@dS>}M0o<4$h_`$LoD~Y$%3rk)kPN|wVJH@JkZ)H$80E|oG~900 za)#8aa-oS;9tALo|IZzT9lXdiD{h$dFo1hKA=JW9$j428RGdvy0uP8Fra;H%9t+h% zO)x&aB0_LL6M6o~n)*w+kzuiVG*bAf^K?R>hK)sj_oH$ps*jSfVP>2BS#K-+FWD zF2-bcnxiBKLy%FLL_E43}BM~c*j1Nj>IoTOTz8G)w zZb!nAcuV>LbVqE8~MsK=Gvf0dET7fL{n7DXU~Ox2L@WTmn-1Yv{ZTx8*v);S>nsk zWWESKF;ub5`;e~f^MOuUJ3ux=QyL@ufhqaG7=Av?)RAeZhfF#!DyYxPso!2^NXPa| z03%SGJ=cPRiQ(}Y7mOCk3(E7JYoby|0a7d_kkNi>AcQK=l9;6~fK7v?&@WKX1^UJK zMu0D#zJ$ipGg#FC6Sz$6yVZNBf^c6y46BpQ*DQBya=9H~(1unT+&gOyHL70dK0{B^ z5UK`5jAe%ytqP5VjrF^BE&ayO$R5N-hmJS?@oJ;itIpjF%m}y8!hC?If2-Ox@V*M* z#x46aL&%=H9V4g-G&GgF0;g*(c35-SRONO>9+0}S4fv{jch*PK1o=YMG9h2Jz&|vA ztEyJ&v{iQshbd|XW{avtPy9-hK$$q#)Ip3nnOPI`mIeW`q&2Lv^VX~#>j_GSMEgm- zSk#r3F^n)7lh7eBon}6ga$}x>_!9MtS^0bLFoa#hHQ>$I+`L?~eIc7qW-9byv<)K; z04gLvg#@T2QGzt%?lP(Xyg&wqczx9sf=L84V9a5Q6jrEu$$o%Jlg#oLO&-~cCQ_1R z!6L4E5pZ?U&1p=kO55lKV<-lCM^<08Z`jIp^Rz4}J@0}-rOc)bz1~&!v!qn=s6WzM zrlQw27p76>rV(gkDrc9v&~;xjk#`n`9oldE>$WnipUM9Ti66x7+LHO0UMvZyhAlV# zWt_=0loAajFto|4rpBUWn_?oVUnB|JLDs0@UHNgKXsrsGDr`Vxzy{@PE|}_C>#t*b zk4bgnAa1WZG|oFa9F!IM8PkI|pPDbIeQ89C{AS_6KT9ItF1?#vHaiz zt6{2D3q^qX!2N2>OetHe8HSD!AWv3Qo|Y(|u%r;|we5=#qv{4bN_qkPYcYTib`(v^ zax$dr3cvJ=URVuDg5xzFQ_h7B=o1@sa~XR~=vnFJ#e{AS8BOTsLnKgFw%T!3cQ3Ay z0dubxXjs$>Ar4lRbSTphyfS=$?2%OlP?-CuE zAlER1O@Ly6UM5#A(NUtX52d-Hoy+`^wju3(q!&iGe5Bo}Z#rOwQ+EQJdKJT*%8jAL z#En@Rc|qJ9X6Vl3K!P%!hR)<%oO|8vScL%@d-;t8AbPvMC35a*w~5${4$ zotVqrgfy0hWIwuAPDvMToJ|#ejfkVxPB0QcnKaKd^MmA9m%Fhar55!Qx_ z?x)I{mCv;1DuQ%v{7;}P0HNvzl+D+pEFC(^a_Q2%p)4w#U|$MlwSrR3gtGW!HlXac zYfi#bCQ+7kMrH_QTaL2%W+~ zel^Y&Qw)u7uU!p)WzC}WYB5IhXwHtHqNHTdP}(R6R@Jz$qcJ^$ZjBs;0m()(6?M`u zF#Wjg>>Ust2XWQh!`XWw@fNJ%s%G!_ey*N$R z0Yle}rgQgPXt+h#h$uCKGTCR@ddtuaN6fr2(KJS-Ebk@vz&=NWM1#`^399YN9Q->$ zNb=Bu*EInd?c?WtWHkfJXN)x%=_ia9KQID9z)d9}(SuYFNT@SOLZY2#BB9RFNGM5E zIQ1H!PNRn^nfj*YbRBDv#v8F#K4-AjczKbOk{W9h&UOuFyTaK_IO}yy9WfcTkn|u! zKB!6R2z5|7q=Ym$D+I1J5_>$xSp=au9vYm*stC^Pjjfw5p&DbHg`!jKG0v{@`i5G4 zWibx1!tV3M?=|-N^263wu1;f5^7dK7wy>?Q%4i(x;`x6XXbG-O3^IEF?s}9 z21`3(CB1L;L+22)LuCVn6p4@~QZ5@P5KOqPO$A2PFoOr>7-+(S+&YllPL{~I6vJtk zhK&ci%4K7RS~C-SM1PR-%%8FHj7nwh+9}F&aOD|(Y{3>(B2BJuMwmIy7`Y7v-P`(d zJ68bU4S@q-sSfMu$}_y5U$yegFO+9N6apx5+ZGIMvMPSBB`H19VNGn{5e1|$N1&jF zg{NcP%v2(@rW(C~$42G3Y$i3qVRK=tv3Hmz3xs1!9G3R!xJG*zvFd=Wly8@_2+R|z zGGUmfJrj1cWXC9|6ANNZ@POcoh+~2#z)Iyy&i}REhPhj0%(di{Oz#tNFbjb=ilJfh zyrJOKrkN>NYfLlDU2DH-6=)~R?CiP124D~zJN>qdO*d=UOgC$Ijp??r;bsa99E*~m z7P!Zn)Ck8cHbXcb5g*tb;aGsR2Q%n1>R5SL3aMnlBkifC5+Xm!ot-&a%tqm%E z`^cw>()mW@6AT>{o(cKZiucwe@`<}R^3ncOj}F!$9}H$AUQJ>^7^5Jo)*$Az z*Tk&c?8bbk7346XAQv%EMGCTMlO7v`4Ayf=hU8q5i(+HOCBaXAfqOFP=qTyOa6q^d z^O^{^U}0IwINXAfXC>osOR#VYI76tBa0}e>0CNhH`mvmfZqnr&OgbcRW7KI{>e4ji zj@h{`;6W{$8v38H2D3`V{+!J*iz!AOmN^VAUxdE}aVInDGWjCStkcEJI+#bTBkL78 z88Ggxce((l;YHSyU!)O9{gaMt&_(Aq=(>QnHxz&rkbCYol=G05gT~81r1DeA2|Uwne`M0jnw%tXo0_Cc0=ovZhQQ@-nI!OhQo3vuMDi$1lP3;An> zT)Lp&QOV3)CvB5qrh@`Tkg66fYxt>Ta%yHX(IP3b*6SxlOH*iC1@Pa7Xt9RZh?Xf0 zgKH*@B@-oD66)26#@MGL8VcTKq9q~Pvk@(ZdDh2KFwaDbj9>*_%_HJY84tlG%q!4q zv|#8pO;xEtb+nSo^5Y3Erq>)zv^XAZig{B+OO1K(jD&eiZYt(com}PLTGk5| zBRJ&(h``Kpg!)aeV5f-BLt$d&cIlgLwV7OjMt_CgKdUhijS2(+8f$m5Xk7)>w&yc!oh}x%N&cYRnoI_sRP9OBo8EgCW=68aZmNKJIl_2QsaPE*Ti{QUXs@dxYM*V@;@MXv5RUo5SX1}n zvT~o=;AKydq_V`Q-Sp9faG~ka7QPW2;7?2Dy3oib3=Z40KrgvE`f3d0&0pkFzX&w@ z{x;q8>n7xZ;H~cXHxcp@c&09(zNRx$9$6j2eu|u7s~J4`(~LHFr(EhzZM2g(GdbE= zoGYBw>})AnJe#CaC8qGdbooV?AM%Ab^vB2ykM|vD1t=y+E(K zGb2j7Gm5i2BPY8n&&X^(yR+6A89r&f(LN(nrVe+VGctSy@}=-o7wOUXP9#cuy+7-O zuJa`=V0;@;R?ruv2&_R$ll=g45-KJE)36@*(7s_enxZZORbE3&Ww0mKA9eXksKGd# zlV^)Y$y*>3f|X#dCuPbv`vH*Uq%1Udd2?6Tok0a20RagM+P0v|I9c0>15ec^NQwcu zbu9-SW9%>jf*z@3px-5C$`g>K9)cCxT&&PXBU#k}{UB&y2K?xoc~>n_QY)@<#~gJ41X;Qn~cwTHX= zaCbOCZ}!lrf3t_iDyBYEfI%uh{#PaT%BnSf6^K#}#htnbN@{!a%u|n5-3N7cpCPSgWwLAKz%rlQbH0i0FM+6K$f7vsQz{U!JH@1 zOCbQ(<{3s~@B}nsD=S?q+$5zCmJyx4TI6bHcYYT{Y;m9crXwN8V0U3Ev`xPiYTSzUx$=`9h84< zZPAx0MqM;f&4ZbAL4CDUL}i3R-rSY@)7^5N=7eH%{+tnlxoyc}lBbfo%Glr{FT_Bi z1x_XEBw!uQ}2gQT=N@J~^eWko)DFIJf6)h`0dtIX`%Bq&7 zfP37^24T9tv198%O(&zRvZg0eGpNrbh1zNKn#sD3m=uE7=j$ zC1;bLcpmsOc5cJu%$G35*Vt+@Lx8%3CQwSQ9Nt+N&eFauPI5(f9}~XD^{=VEtUSr` zQA^BNe5wAGI0ZBjhD18yCX-doAY=ft%Xqa{^`&xiorMI{uzZbZ9Vv->grP?J@-TV>)9loiUGF(5|GKlcC3uCYq9-rpnUV^t?>ZSx9jYsr&X^v)A)HJ>QdM zugLV=AYSNV&lMhlysILuA=r^G@=xKkR;*xN`l-cSo-c|lkaKV9Vu`At>Cy*_t%0~Ijt1syOMzfx&skJG=fX_I)WHo3(%Q1v{+x?F zx6qd=I7CFscW=vQ*cHpBx5uT-?5S{C_ph>;r*L=QVcng~9VXMOsnLoj)4@4hd2?U|k7kq*>W{F+ zH*kSv{!=cix9Qc_bI0XEt4WUZsrki}kO6h`Ý@quh<@ZzeqI~xp5b4EK>>Wm5$ zHsnsMS4yNbN%(NKwaEH-^B>l<^@k!cs-CE)r)hx#npVYyX^{wIOq{-aTHCqvX$|6C z{yy}Yoio?6pRA&RFn-LRQCqp0lGlT+bO8uXEV`!^1C33XH_KW)#9Fk8WVgp7I=^H) z%`o@fiN(%rycqEV-tv4|lmQHie|$Yt*%fbj&uTWfAy5$DU?fQA#>i;lHq@wmqKQKc z5}C@Dgm?1h{9xO$7$Nhdn!7vbChYZ2+%h;-g5;(`N*p&g7lZ!|A1oZ_j7$M21?{6e zG!#8~3mIrdHkv=J=vMQ$_s}Qy#nOTryE7C)Nm!cbo02G@lNQ2mM>B5GP)B>bSPzE7 z-@zR6PJaqvfcK;}W{g?S41U<{DD(hRlVbLo(VU!Booa4ycNq0?{-6M$<#YzyhUhw; zUrXAY9`*9)|V79LOm>>Y@8gOR!S9algv1TFO6zKcrPb3={rdg4uEK@&YUV8@2NW$- zSk?L72mk8BfB9D*dC$*%|Lb57U9mJN?yxKaf!)FW#aS5$IWDw@!(IbDj*EP$aRxWS zgX$;G7YC7L2GC#xS<80kLk3Rlk}CiTuaVle(;KO{v|+#EKf2q_-N|;hz}-o9S8=y1 zKKAw1jOAg>b{oa#;{(7~g_sMv^};Xd4jfc~E$W92-tMfpat|7)&Rlc718i9zOno$y zSK+|K9>^Ds)$(d$p>*-Ew{<4t+=V{L#Nv%V4;5GJCDFXrmG;)P05qB=0Fm`P!(K=x zW&@`LlI~7UN~0I7eWq4R`IYsg3cIrk@}9C6%T@{o7na2!xr(V4gLekO;-2g2>1FY5 zjai(B5d)@w%*8q6h1|i_U(Mx-4~m_i<2692_$v0h#Kq;oTkJKa-;NKm7x-b;eNaJW zl`p%og0=mF41*Q;P8+@{idEo1%pS%)h1nb5N9i{=D5xy)$|4-Aa^o?2X&__4WD>H9 z8+U?Br&Ur)-c&Y$UQdARu<- z8y-KKIh+D3f%lKa4np!C$1f%b@9LR+s%2JMP`JO^}F67#7M9P`VmQtrVt{S$Q6EkqdP!I)t&EfEi0039&M8BP^#Y>+E#BySm{HA9>S9k#%?qn&lH z0b68>vt2{2ElI4Q%!c?X{Hi=Tejl2BD_-O&(Cq_NcfZxl>zX+=;kE4p`>p;JvSwtb z^eIr2g;hiYKfs2*$FqHEy=dOq&lpx#?j@~4TQEzu){-Mw70XLVeSe}YZrW;NBhNHv zjl5*!Os9+&%l0Yb6@HNlu%RP5)F2sRJu?k%|Nhi*aPexCkA}fSql68&#N_DOe&M!R zk~eJe90kN=$1zOwcWu5cfIl~sWAU@pE-Gw$3M!90F|5yEV38%bwzZ#h7#wiqZivIV z1CGATN^}iJp6a@!U?pwp?wJM%$sxyGa>#L)9CES?WQ(!zjkg+OI9uBYT@}I=>4e}% z%Zxw3uN5TjjZa=lTP8$MWOrv3c_6IkSvzFD@@B0vWMCUurZM9kI!Jq5py`9!2J+4geWVe7JTcH zoD6k;Yg@8Ds`j~CETE&lwI)W6-jo)!;Pokwdf#e?EjqCS8yTHgkm!y&>{HI-j9FP) z@_EIOG`l!wcR&>4>S;?oE8(-9)2mxXTL7=z-U7fZch9pI=9wsA2`E?%^?G{RXJYeb zWG~`^qIDdXSs5+N_KfTWTu_Ri&m})K+sb9m9APeUXjsmx;f$|eo&=lOwrxCE3`zq# zZwD*E9sf$4svSUyoKq;e;4uaYS_Mj|_GPFR+v9LA4duieFv<#*Z_q52)|7?RUJekU z&m{ZRoV0P(8g`3CbjgzSYR4mwqF^%Jj9;C4fRop%PwTMBndSN8XNnN=Fy+6t$~e3R z*?L6mLpK!;e>lJ&W*1->X(w*RV7;?a`%sTO%nvpk#3M&^gAQ`!W4b}BIPwKFKT-RU zdv$~Qs~uEG@PqNj&#Y!zl{g@MKwD~>f`tS7LS z%7>hRFkV3~x5!3%Itu$?39{_N4)vQ`1Hwxo`8Re68>CQ2;on4WvYb&kC<;bDRM-WkR(((>p&NYNJx+Muf-!C zGLYSCwY^pw^<6EAgGh*e;?S#=sO_&|wB*YbYblN{LV)MHFEfV$wuZAdYJhTNf}PRD ztN{yvFha^%Fu!MzMdHieYSF@fQN&UXD2CB5$tqk~?t0Mjtl|(t1bn!2B zPkG6`IukIYn?MdFO_laT8`y210gD$D;0OgAgpHul&7QlXnw92;z+8?nVGhI)TxKdm>m&k!P}jHbJuX?3xRnS@{YxBLCn4Tlck-!i`QT7X zuDk~n!-I5l?5Sawf<+>%{4V1jDe)P1WKzaYAyX$jcEn)Dgj$z1YRgzx5Z zxtKXpD*b(Sa00F>>l%d* z&2TU$?4HuF)fXuwmy&!ZR6LR0x!dS~k!E0lou|Nkf7oFdC;Kq)byQLSV8_+Az10o3 zkLGCQ*nH9dspSP4=5pL}~hbwCA&Q8>y@7lj(?>&G0zQ4{6k6)B*Z!;#^9UjB& zp0IPc)qy8pqCx~C_Tf~sNdNh2OEsvr)8ba%=`Rfco!C*wd_dSm(R^W@YW5W&$Cvbq zz*yYBRO|^|<6N3xUx!7>p~OKDSOM|{O1@AiKE;Ajn#{&ab|z;B-2di|>2E0^j!PEmNAh6gX9_ieWeXXYGdW~yyABu@U2AFy6sTf6dm zveQS~_Lf>b6y8@Ne*(8bK1Y;!Ssg9;9DC+-G+M>yh|vTcKq#=_GA`ivqYBzI+L`=Z z+qqzp4!ES8S(RICbwolg6(?;Z$G@Z`}S(v;p%xT&SAhMUa+`q?i6=`GN)+{ zP@B}$2h4CcT-sp9ibD=HZ9w$lpb_w&XssxB_`XJKjZ8nv@{p-?!F_oHa^x!%PU zVJDY`^kG#wXShwe%p0^qxCu@y-Y5#Kx(rA|FdwSinayuTETBW^!cFV`j=+`S-KQ(X z_i~N5&=(EHJJ12KX?B9VmWP9mLLQni3i%71Wnif&B%l6q0F(E?poDs&5e)jhA|YW& zltreDKNIP~Mlw}Ed)P9lh67I)G2MWSQfmEe_k-9kNCWK*fww!$;-0gI!htRUDzqmv zjoGMaPfVxpX$aXc$lu1>VD@W845hXth&|)z*&}wq6XH)Q%TU5=cRC$SLk>mC#^3ZdE=R5r*SLy1+C8iX{JetY zU~O-s=w^y^e=DSTYJQXbiZ>}_bA#XCp!*fQ_&ENom#gkAB6jl?@?%v$xZWESo8abt zS~9B=J>9*eTov)?4-Qdb10tGj&wD3t^4hGuh8IvvnInn;q_ZetDMW+>8fN(->`Qu- zMXw#*$a;>a${qmGSq<~RR@OYddd@wRU7Y?{;Am-c$yuwG@w%`0n$Jb#1{MBfCfqj}zh&ztpn&olR`7as_4 zaM>~930K4i7+riB<*aCYNjlmnT-oI~$ndDFCjCsCX-OP7c?GNF^*BQ>7fJ$H-UcB2Y1&U z&osCPd1{0E+I-$QRLJf?KlZ5g0?cMVYYt@t)?zV#hJU!cy7Ohoik!7TT=6%RBEhhu0KIrt(=OO3bkG%fP(thA=Fy-esSU`V2N$2$@78m_kTX9yiadjy${IL|a^ zfp%=jd0@q80Fs;_0|X^Cvm38{moY;d%RL|F{!R@DUdU_!igMU%+(dhoni^8@PKlp} ztbt4y?z>A0-aU($q$tLWH1%OlCJY6wHys!*b2ZXYST8xh+h!SnxfT=GX7pk)9(iO{ z3(gj7-I?_mAM!F5xLjoIFdbX0ozyiF9Ec0!MURyhTQ;knn02R1cQ~`=1=Ve@ud5ZJ zF2*6t0kWW283&LW-x{mxhEUyjAA>gCP)uQ^D@X@3zkc- zoJSv3yu(2Bim=`0V<#TifE`a;ListWi;#uFOwF=Pm>ZcV5DEDK29gA!^c44?6PC_Z zfUstau-aOS3Q7SVIN6Fe-p20H<0=v>WNTJu&UHCb7CaYC8R68uDmdYwv{;v(TO>BE z(OkxRV8oLjVsV&qSqFu8CMs#ilM*W=)8$T43ByR}wu?Io7?37g8j08=5{_kx#s}e; z@$kkuD>`C%W=nP(0;-W0dw^NMJt>pX)75@;4Wyea3C)H^AXsk z$TH3?=_RwM4+u!^@ZXSFuUt5VXTnB5wjJD5MShsWLAWRzuzog%*&dKM_&FEC@R{Y6BKQK4T9J#%CU%ZV&PiJJ&;N&^< z8rYly&X5sDQ0uk6wCgVWz~f~^%dA;zgier9biz5lEd_n;O_lI-@q#%(=pZ1C8OU5P zhf(VwF#o#ZUwBrBZ5`V>e((dF%ZgqtKoFhiD4e6Evt9Rbh21_^?SoTD*1@f#R z+idTi+~v(E5?C2S16GO>ST$;<#31y7-041I`m+&}9WgOtQc+SxgOv@CS9lY7BHvY6 zDdMW&C*~Z(k%pl=*@$L$vArTo69N;oOrc(Mo#tY(Uy$HD*H+ynVGWtl$_q5q`?G~G zkahL|>5;`wI)?B}X5%BozwN?1#R~Vp(w=DIZO<3B(D^cL^|d$BIRYy3!tnL#=(D|!IZ=byId}axD@HXjjV*vyN*i7APy^28?~n;W zELkID^zLZTtTd)RZgROI2R|amPKjui`p;sEI;8l(KfxvUiTF;tKum098?wlsR}y&xx*HLvCkUoFj3KsFF);B$x`Hq;WsL(Je4GT3QZ zXs9>L43T>BN`Vj-@3J2TJ$bK$v05fAr2<>bTIsP|&}rmUmMdR+GK0}TN>>?-iA+Vr zlqegg&KPQ4T;@+zdrZ;!Pb?NrD^52CHf$xr4$!Y`2})1LLCRfn?1#!uwM0h_YAFm} zHZl=OPqia23*wg_#6Mi z0J9HF7{ZCAE`WEe5|)_GN01q|D}_AVH_e#LD_!yAWId^t2CvfCPk~MKkv&kQn6W6$ zj`ebYs+#5l!h=LSg?#I2S^UdGF@ics33j3s!?4{PLiaqN!;twmV;^CWoh2xA1ZU~Z z<5`=K1>|5T4>b`0rfJdE8cNKJzevW+RQz>HglCsZ-bs{*y&}NqMWy}PA&&wZkAZkY zj28ALR5Fc$I^N3VF5D9pik{FvMu6eO;$*Fa`TK)=Uu_|(T+l&0X~z!u0ux*ZY?Ea) zw`*jr?);l#UDnX`1CvQj6vKjOHm^pk$VD<@(DJEU=uYqi zO2c3)T4yMlW>*AJ`JPN?X|My@_DzLd{QQeYum8o4@>{aOVGLi0l!Q)XoQdf|Zf4M4 zQlBSWNQ{a%UMt0(KDC$-yXf@nGqPRW6(FuYAEU%6i{rs`&fyNi?+jj!e4r2W*Qmku z?cTY*T@>5YZfeq6Q$zVPHgx~9Z>V_2h8}&^4N2h&V9*UXpDiP(h&MkXFrC8el_EQa zXAR9&s!oDYRg`xo?Pd%?;MWLDNVJHj@KDN*d}Pj0n@Fi78?QGE7D;Wa7OyAk0zykg zGQNys54Ebnq{J#kVc=sHA7toasevQp#W`e#_Klb^kH z{=i?8x+W~(B&rwET#+c&u_+O<(=m@+yJe&n{AMtjN>1Y92I(&D0Le}+Zh%)_L-8Gm z-)8t0OwXs@yPCz9#QT00r24E(&)ivBK^B3{ywQ;3qhDVY10^6M$Y{aD@%VriknY>l zsGn>=xbrZ0~uZrISQa){&eqLxsPWLCOne-XA{G zG)qS<54TE*n~A$Al7>cpDQGyuo;}$H4ApJR!n2N{OtOyKA^`;@?1~jWlw^c)dd6{; z6I@jdZTlysc^DAdke3W7I~RkylxfUe$~5LKWg3eRiC8K0pzZi3jYvqy);8kws%mf~ zk7?kts380P(>(1s*MOzchYV(lb_){P-v*(4-hS|x4H^-&1eUua>o@y z!ZArZyR%9Z5mUx8tbvT>fG6N6-ITI$NgJ%%4jQai9f{2akJ3TX^k@_7lpcJD%#JZ1 zm(+z}X3-t>RtLsmO^C%NQ`VB218RvUzS9n{7*CR)=-+z9a-4;NoZSdOW#B707vfL- zW2{ZItm0)HbLaZ7ZA_vjzLi6UCeRp?ie|%x5-W!@Lr-ufSFVOLK1#r7eXN@c4)Tf* zx^0*X<^V(Hi48ep3VrLM>e07t{wA%DR#l5}saEgHGlX<(SE#$sePxZYjqp)g{!dr# zcD!?px`>E-=*OK=1XnuC1S%=&=*SbcfEywa8^oWYjl^J;9exAuK)Ot=g#=heNkkUF zA9rV2oRt9xkuCEK|AaAU;%KG?tgVtCy-IQPD&^6uw2oe-ee^1w4OJkIR0ge+$0oRu z{oO7ECq6u8p8*0$sG|fh6rhdoy7`U=vMVui4_yhf(LpeLGAy}>1R}mRB43*wcwATR zsB&j*WlS0zS}e@Die3V3<(adXtWJI`7(rM^OEUB&5i5m2d$etahsCIp_>?C2#OLAp zpORpZ`|t4m{Q9(hq2yyw*s@DB!c3T07bmbdMD2|bqa)boDk;QlDJZiN3T6zp2QRI{ z_mJJ++grX)ZghWLp%=&uEqK{OwW3$Cq`i2ylf(sVdR8PPp6uA$#*!JlPRa{`X>Avl ziRK3{Lk>eeefOmgt!8*ts**=Uwmo2|WP|d2IdIR#$?iJVQjxu&QzjPg9 zI~Fjo*v?)5)^&*Z4Lvy_9=?&^=2AZ@EK=+PqZH7~f{@zM`@hOCEB_(tth*1{jfojz z{(_bAw4wrSQM|B5bV=t@D-EAt-Nd-$0P^b_ zbc=cjY_38eP8mU1GXj|Scm&vfthZ7QN&+;ybu6H)H66oZ3UXRW1 zA?i96gVY55q)$&YYM>Z5 ziuz!UCZ9oSRQRn%l`*Zj8+j*gD6!95-?_j!rd7gdRWDK-qJ_d|`_&zxH1z3`e+i`sjy#YL$M7~3-n}GVucx7sMo4BRSuyK}Jj(=g4Lg@&-eg1(A_3*dR%aX< zrIKjGvRDFKO{j5Qa*Kj?NID+6RV?&0;|XM`Q)$X3epu>}+?LF5oJxbyXF198UbmNE z>!UC@-NHR5*fE z1_4a*c3z5PG>gm6^B+sX39z+A28aWz5Ku5Obw{9`=#1{z zfqRVKow5{hD68zDpO+OpW_Kz-37~_{c+%vm5n^k#XDtR6)PC(F{sO=}TNiEKODd zc%w0Z4mob9^VQ`pWfp=jc*n*RnYz>*@KDuVO43@Fl)IUZLl^nlG#MtEG`9HdH3|8D z2_t)V#uqfXT1Z~}xxgjkOKpn+P*wK8`?M4QI$uyLru-V(%Nhc4WraZXN`}3 zW>uuoK6i&eu}WBVg=7(N680&hPOPhRv^epa7OiqU5_scg5n`fEuqOh%Toj+xdQU`$ z3DBDQY0+VZB=r@i0v|`5K6q`+gb_Yt4RHpAbDKD`88IGbwjEbfqs(wO8>lV})GB&} znGqjtSi+KmZQ2Eqqqg?(iGO););^R18X>P?RZ`pqcA=iuMhS#{)wMFdAAlSbUiRKG zlhx3D?yj(9+^8EoBl%=YI!{{;&#Ja)%%FM9Fu)o^se&VTTd zm+pe#g`4qz{1SA8HfQWahAJbq2Y;vs#6dPZ_<|m6o$}xldaz~6gS$3+@IF1*Hsy_< z*sPCh^Z@tXhEYBF0UjVkHavJ#52nrI_w~Rg3!|Kz`4{y7C)9?fKC1^<3L75Wv)LOT z+3by9)PrgB_$fV@2Hh1sm|Fl^jck013 zY=5sF95ZDe|5^{GLHEvox52T8x7?P-naA)lab8Z5>QqR;eX8)%HvJkAV;gQbZB ziFHdMV2ZEi!T`RX%Tu>YQD8*k&{EN4V0hGw^8%H?ignu_2WzaV;%UhvE3;2$Ck02u~Oee!R9tItGmLX{)9V1QhZp-0HxYDGY_(NXl{$ zr;xCX_RpZ22$rR`%A`vXEMnPqrwms@FHfzm@+#F8zlslj3aWTHzjtve)Tg<>n?Dv~ z@!aTqF=Ae8&;lB^$%#dUqlTG)w9+2|kEkV8vYlaM4k*SJ;%(Ont!j^6<+;=q#>|J= z4!F0#zoaBFoIXHND5V%khkPE}*)QNSbNphj(cVUj$~hDN_`z#PjH?vMY>?hX$qxbLmz z)?%j2g&~xl6POq`5HjoER|s@bHgq5Z4Y#B%6RmQ6VZ?YmgWs+Jf zOUW4tdeOg_%U%qM_(}AFkw>C(yR-I)&>_TjCZpn1gLjFtUlu>c#r&I&_?yWGhNbCf z`Q$tY*)R8NybB1dp^(*mPPb_L%$f(wgm#tBv+feCOxP;ShD23w-b$ z%}>VCi7V-6N0BMb4!Y9>JGOiAn~a@~EjyyV*P&!K?oND+TXS`AYwcW2U0!)Tm%rfp zN`}`VJbh~ZM$Np#yx@!tC+?ViJ?6x?*pjQW6W8^UI@G>L2C5-xb7egwC2!RC_Z?** zHY6QBc%cG6k_!^#y3+@nnK*aae0e%oc1Krj%R_%>Q6JfgD-nl}fDP|8uLf)ZfVs2D zS+co3h8=VHt^C?G=JKOHjDcKhFa*?uZJCBdAt_yGG-yeTB}zGhxWd>i$Zr0Dp`3E0 zJbJAi{@Y#=ICB*QE8>gIqc(#ok%A`THj)fVbU-#hr_JdbsdRSI{Wdej{RS0_-WUt4 z&#-{ei<$_9!eqBpFd!BJ`J`#Zd)^HheJV(#7?YMYYk>@!$y6q%_JEF0v^zdnVxUUuZA`7CVy-Ae|0B3NTv{xqXkvlALAVT*agq4ad5wNC*lHr$N-cBF8ntZCx={M2ikh8aMf9IB0UKt8V9MDf5 zDnhBN1|~Eahdd>U($NBnum)D~u2N!^9A43*X#>iVHRV);YG!?s&04DlbhQA(tYAo* zr{RD%C?wRvbC8sp8E|Isori&laNQ*a|T4&W<|gOYe2(A&E?!? zRZViqY#FZuk1eDktQQ(v^IBbI?~9kdm`iGXZb!OT<7|{rN3aM2F`AZa1L-+@tj28v z#HMDQb{}(Si|;;$>)Hn1zmaXwYHS01ZEhRD6g`WD0=Es?z-O&(K(2u5n{7Z&h;O^r z+Ctk#;FDXAIa2`mI8VTFrof2mu@#y1Gq@w=+-*$Q)LIyCKc3vTEXILe20OB_DQr_( z8e&5E`YMO+|eo$ZJUR(3iuctZ{f-Dz7qa{n4ke@|v$Q_+`?KREEo(H-t8Y zzhRX$CkjzsSPy^9`4vsY7piHiAq|a+%ChG|qOmS`MqrlpYulT_!m0~C$r*zj1-6z1A;>6T z<%nO7I*R^f(T@1aIpQniDNluK`X?)ZSnvFmv2jbj%1UXN%&|{L>ka{gYXHhyQTCL6z z8`>dRSv_=S?B{i|+T2Y!k*m;&T%cv`MuCQs<~DI6SD_QR6!%99E_5Q7EDY3N9cjir z5qvw53swVf)2+_qssv_%mjpQ3f-%4WdBqOgqAGhu?7%HdAP(H(^c5|jP+irGr=no- zI%JBfF8SO0{hX*pM7(Hz(haB!vPeYE0-%*|ab|Y+;84I~62rM-QQhdA7t~ecDSmyz zj4(lC_m;O>^>lhYn`Wy%8UV(aXY0{CDu(nVEF*jb5H>bZph43}=yRDMrP|S;g>`MMiTcy?4945d%L7iaz$9Ro3(thG^-h(!z{Ea$KimzcmMC z);Y-WMux&@W59gYy=~WJuydUDLC+J($MFe%>s3i=ZNRdEios>^Nq@w~a^2a+@_aGg z;B5=xq#r-UBc&y!ZwpYmX+SQ?5g?W`M>-|DhQD%m=#MqUZzTK*efSeA+)Je1kM^;F zq;WB1jZzaB&w?Cn6>5;i=;L9#69dm+ZUzhq0EdI>N-=k}w%)aR1ZW#BY{(_9({r@b zz_(uCmeO;+k%yLc+Vu`#m=2-sq1cG9H%Gmx3KBCV!3sz{9{Gb++sZ;^{BGsh5LU}} zYx#bE%aRp~B1-tQj?vWH(3R9~XbmY`vCq`7w|-*ACI+XbB1#oUp|7T+=N%M@#)`(` zS74R#c=6E?hw)=yXRbPplR$VqENat<%oK4UTmTb8M!m`Qq4C5F)=P(yseHoD6nTwK zZiKJ+AJX>}tdlMnvqZ@l4$f=x_|P8$1&|aOTeZlJcFy>f)_6z|htSfqmmxi=SE(7UU6n9 zSwVd&%Ij?SZJ*Qtbhsa#%?*Yb^OmCyO-78TMt$zSP1KhLNsu2d`0X{Jenmyv!DRMX z(2)YnO;fJ}?Hgw)XleVDs6cZz)0=5)_CSj{$J=fNJ+$Ne`XX-~%CCl@0rr-%-|hTp zATL)kmzMho*={7SD0>X-3pC0@il3BQ?bH0JW_CoBG%iZOL+Nlgn`h&J)f-FWje2+8 z1Jrpr-TM-#7PFqw;#*husJf;1t!aHhr^{k~=~!Z-&s0)26r#r58`#g3z5vX?<$Pj} zn^Tto!jl@iv+9hDgV@zRU$f-r@vD8Xc}(7s`w-|KMMZpK@@+`l z>#y3|II)~BHSc3CtZlIAuO5Imv5muB_mQihF~m}OoP>e|f|P3vi7`Z~Zm|U}Or%)AF1qhZj*k`pJ#m*-K@c913PLvS|k1EgZy@TCelK7xEa0R^!s9ddM z`Q7(fu&Qs}s6)frjK>=6$UZGBr(d7;o?tal_PG=18K@cVp{G}Jfgn%e@*u4VgK{yO zT~=8>uhS6&0>Umh4ZPPBU3Fimo0Ln)_eA!Nze4glFbD^+_xzX7P0zCU>93Evl}8e% zU=g|_nab}#OwFvKV^>sU;mEb9S#yzz!-zCpE}HILN1v_^H_si#i{3Y9k)$ldLwH#O zt0T5VUpjTjs8uCG6wzB*m#}XsPlgZKlRB>F20K(rtX@vT@vCeLtk%DFPQJ)LnW5}4 z9TrF{9e9M39?eaU#$QEY+x;W8xS9Gb6eMH)*$_^Jqpq8I?sWs3F;0Rx#vw21ef+fJ zjo?AZ=2c!0$JFNe4yt8yu8Ey7AStGI5^@0o^LaP!Thvwgt(!m^m~Bw;9a8bG@kTJG zBeDrW;uZ`83Xmj&wm7s#8i!E8J}Gap8-}E`HHC3-fz&x<;%+=47QtVOS^1{m!X??a z)r4N6DTbxc&N_IgdV&!G@AUtS2q+ch`~2-8Mgn>BxG>p)ypUpO%M>1gyx9E4ko zT`5-cAfSf&jlqipp^6d3fknyDOjwN-P(}0S`1~h!D9U%9NODuOWQc-Pe0YqQ(yD}n zf0G@G<_zQyV%E@Bw=nSJoLDTEq{DcmWUk=WIX32VEg}SyrvMX9-Q1ffw16EZ`e-V|Da zb6KcHpsDquxf)QWTJ>GEnyj#;u28?x0J<*lCMHxX@&lw=1r5c=Gs^AQN#==$_1f_e z)4&SEyAl;J&3P-=pk*6MPr~H;lN@g?OXW(E5X1kuRz_lSK{lflE49m33}++=YLuA4 ztAQBC2x6a-P({qJ7a6?BFI2hmhlYDKW02~2%tHJv%3QSkfM>fbsqC5Mqn zZL7y;dVd;D(%t|;f;&ul@H-4g+|*&C2Z2V7FZq_mq3NVa)xRfqg%oz5?XBk6tG0O)HBR>GOHJ9y_TKb` z>>sOL`|@5PaB^f5j(!BhGHqCel~GsquKriI;~6;ZN(q{_S);)cDnmNGuuf+8&HQv!O0zz(`wUW zxoOL$A;nqY11_a;3xI9S2n4P|(yZ>HM9YEqh(wV__pSoG8U*pBggpj2@lJ|R@9rEo zOWb8%9`nW$L?9a^#Q*vs-w2q23t$TR%49*H;H#4bM<##3jN%_m7IY|hXtJP9!5>W) z%uw*~WI>mLMb_%u(>?lLb2|cw(~P zC2?2$W>a8}`q2AiqS_T{5H8KcB4s-+AVd7Sym_p2)?D_z;BJ61oMur3@r7(CY|g<; zNPzR#Pz)?cK;o)CX{GQ$q4k5n@T-X@Z8?uW>n^S-d7(K>K*P;;rB-{u67B zXRLP48e61d)Ba9Vv(IsNl7b8_-pF`7FJax!QbU)_?0rJ6)JC#kN9uGx2!k9XXik|L zuoC{+30JZSFxQx?!W@vO9sI26?gmQiMu#~XGa2ci1$lHZkZ6HWhtmeTgiBgbJlH(0 z+DH86wC~vVWNXh^)xHv!7F&nAYqt(FAT}6F#ZZlDn~SMoo*@Q-kJI)Uw@5~_aXkF_ z1Pl5nZG>%Jkh4!DfB^_M_M0*d)FYx&kT%&SFglU4baBmxUw-@?yb+FQ84SILa^DJt z!Lkkomsyv(Y<$4tCReBWcf2tnEP^gO@^-rWg)q0dr z&zUivUB)G5gH>tg=hW&{F;=H6`mA-?RGk76ga1_nhtb>krBqR9V31nHBW10yS4F=4 ze35A|H1mWfZ@SAF={)u=6!WPQ|Nk(7FhrT8hepc9RPr)+LQ$$@=bUF z<(rQ!l>)NzKtW6J)WIsHm{ipSRujtBgN+hA0Kl?b0d#4`6c^M@333L^P{br8zBOM` z7p9GaUa{l-<15q^P9XWE2FVo+CGm?Bc%r!orMMa>_+y40S9vnbButbGx+~R;Cu5UP zUm%v!1l~4#5^YDJ21(h?@0Iq*-sonVWuf_S*a^cEZgCjwRlug=w82f9cw&<##;=2x zKBHXH-nKQ{Hz3{DVi-yw_;>TXY#j53j5xAnL({tn6i`^;^n2iIlstl57eEO=n1#40 z(|14p*YHMHE&1so-W^8P0C#IfQn|iq1pn2~U`u3~m-g!Kxer@Rz-xmSFje;-Q?#J8 zp~4;TMdN^nhntT;8xo4-fTu(uXfEuiro7zk4tVa81KzTEv>THThVSCikpo^0NF85b z*aA6j_B2qkjD;VKpPl>UXD4e{lp}8H%bGOr4d_P+rKOCLOkRyZDElQaOW-Ok_7pGc64KonzA&Z??d^kxbVtH$F%Q0r-n%q)jr!g2W(TJ^Y zfr){oQngy21dY=DuGK8w%OCApcy9wlgf-L)p~H>GUuQ6F26IZrDL~Z%h^L{^3Ekr+ zS*gBZgITe^LzA-v4OF6`1z91Ll&xB4s+N<vWBUk?@MujmuwPw zk$nz)w0Jd7mDrY>Ek$0Gbq#0L?i4YT_+<0>kKFYcXKbzByA*M>FDd|tE<2S$M$% zK0pIuE?R*vqlS;qyf@??pLyRZ7C8~0Gw<6Mk`sR)BSx_4f*c%?UtM)xJId|M`;J_) zti5Dl)|`27D5O!lytI#fwNI0eg~F+Uu$;zZxn+Y{1c2@i)<}NjveCwSgMuXHOJMBirZE>%bCmp}~uFlot9PL$}rg z9LCP)W8%C4#)Q-#qgJcZ?|H$(qQZA`BlAd{ZDG9W3F6sg=TK!`EI1VCSsdC4=Ska~ zFBQ4ryujug!ILqPtQ6WY5MIHV2IK$#zSJBnG7&?AzyDMHq5uC(b!R=*pGe9cLI%>7 z?hFc#Fd-yMMCp7Jg2bqZ5e(J4ax1kwAPyvj#eKnbuX)q@nrCG46hknC$Hi1$sEbF* zO?zNxz(c6cgYOd?*_|zzw@oyMU9RrkVH{v$XtQ{+@fP2UH8PKm-#%hvt6fxo*!9D&odp^&Gj2{je zw2@hgJXScV(foKiBVnFMR$N&@6&CU6)}km`yz6r$>_71Fmz`@l>7V~)ezpAmeNXh3 z;~(|>$A9|@KiT1;{-?9ck+VtC(C%de!sFK+IJaj7 z%MjoXY}eBVsSm`5KCwzbBVhf1l$%k&$5YUrA`39C_%uiO@y8u&c#x!XQErS6oh)Wd zNjt?g1}SR!;D_CSTQL_6Tf|z^fKFrhQ)OlKfo=`C%ib#7Q^W74>9$7`IC;{y-~)J^q4%} z%&n<3d3@?u1e+UVt$C>YCf!oBqAL@MA5aqts@L1Fr*60YrR4NSJw!QP$wF|p6c_HdE+ z(%rZE*0sW=T5@+BaynIxMS|pb#^jp#LFQni?)e1dSEY%Q9q!igar}0$>F{@xab@#u zq-JPny6RcqM*45veC|-G98#TNK~T;uudXy|eNqnjCNVcKm3pT>ww*JRp)|?kmWFfg zNblrV7mHB%QU6sSsd>2(ernh@#_Xl5Gv~IOi($dfMW8nw!G{N)<6+Gkfr>pE@X-r4 zUu^LqVt!VfeF$QbH=rj-!$Iyc+Pu$fkz>Xp4h;11_fuqn>Q(3qE0KNWB|#)PvGb$_ zB-NnWVg`eM(ik5}Gur-kIl9^F#4&O{x-G+jiU?rL>dEqGKEj;*7(ou3Ba+$Ml?}+2 zpnO^1W9(r_;A5e5JBh8m6SMAcD}>5THsV8|V7hmUGQ-vjDvzKw5@F|yPF{kHe0*h3 z;0x&U1V84*DF9{%1a%@}H%a3!ps~J)64Q2Xc-@>%vSnzqd<>}?@Y!!nvWzXAbMuge z<(Nvv$@!;6KW@aFmaCv6M6nJb|JVAm)Dt&j&s_C<3`{8s-(~Jdrlu{5@}t*1zm_H( zoBDmQ_m@HBm&V&}hmdc8kbNk77|O36!5^*@hm94r#fo4*>bX9k$C_(=NR!_aZ>lG6Tugux-jU)BCbBYswzoHs z&J3m+!iqyc1Q!Cx%*aN-S6G;pWgjWew4N=dqzMPA@s+epTgi9T-Z5n?^Sk-Zi4vsk ztLz+xz+)WGydG*%!2^2&xU5V1x0P@CdFH*Z1~*6H z#PWp`f0vIJm}$C&ATMJsnc;VA`49J8aXznWr3A?3uG)jdTFb!vrSkHM@!2B zE5x|S0)q)dzw*lPVIx2dYc_9(>@M^Kkzgjgu_Nn*4y?*38;30|AQNbO3V(2Ip#Z-y zsXpI0&+6GJ#=7@f(#h=jQMm{i%z76uqoLF9w2K!8pP6%9nk&HF;E#1w23*Z#f_nm) zjCo}%65!WPhLLMBET6O!$-pR8a_wY7Iz<7Vx!wKMh5M_yC})PnVFR7K#2`ZQSBG@6 z!e;*Jb(3M=TH{oR}SG3B7VTmV83dax26Ek_t-HlzpZFSyx)q3at+~g=_BU3%%MQbH>;!*z*+?}=4?jpk1;Nyfqcay zqvG|A^T_yF{7rY&jGt%#(idx=%*R8<3cxF*BsHE?Gq>PZ3N42@)&?pmdpbl^OpJ5} zRxG9W>48=qZAL)nxq!fH1n5nlvPV7M@e~N?Rn{zq9H3#jOvRH`YJAY1xD|zIK!xUs zY+j&f>)?-iUl=bEiaz$7P_6=Yx=E0bXy$=BRp^6ceuTO;LN*BY;P>J0;!Azz$xphK zf!zQ!20O`*@NPlMJ!8CJACYf7W16v+Vv27JufILo;2e{_Gr1POTjcE~0-_l)4fJ_p zI9vsCl7B!a%mruiq z%A#WlpeNf_Q1m`_idQn2j}}}+n-kLj*hw5if&88bF3u3Qs8Hk!&o)=-ODQaI2_~^SlGA&JAS6 z42BvrvnQJ@Uz<%v_e$w;HcgKvvgmZV_hC_!kO^LpQsb!BZ~{x=67lQX47OxiriLc9 z4c};A%9GK)(x;fKw{de^re)6n_hBBhVa7@TjyebPG!~1T$kI|UOH09IvTSXxatg`6 zgi6T8WXS-6k}z3Y+l!g=Ya;8B#jSHPt#!}I%#?SF+f5mey&KmL34F2Pz$NP8d<8^Z zKc4((DWO{6O-Eym`)HIQ+KlGi&tfzwVRRBW-ukSXXd;PQ*i z>=H*){)vn-!lWh3>gsZ~Iv8aRINA+Qk_z-?x#%|{-4Sp1COo{_`dd!+fD>i^|P7DWm^=?Vz4L!LvC)XxG#bfJRA8efFz2Gh$0lSDv=733a z6gb@uhWZA5;gsfEk`JLnXq848Kb!e?@-lwv+#QKodsK<4;^+LaLD@BVcbY<4?#dy% z%r!_vi#~FUq>^(T-(p<(E@S zo3M4~o3MQ+zwPjs1Fkgh|6A93m0TUhR#BIhA!?mlhG@Fu`~}-EUBp{ItG?xZ;-d5| z%6GC(1=ftrD(>tP2Nd|;CMh?-N>PXXYiu|RY9YY?q1hhNdJ7{SPy@`f>^IxeVaA#y zv4YNrKjYn74HPi>JSb*;Uu-rDovKM;l6fmGmsj3x`|4 zjoHpq4EL7@w!u7IT*pzm#zuqp_f09*cCbXU=Zu?6cM;~Y+ze26)OxlOGbpO zOxbmyg5n>h;ut2Bivj;dbc6*u zmF23j;fdEwk&3_XqmaSnMjiUGUh*8|rkWjm!LXWYU_P{C?a-P|qX!{VF$uh*oIOUgK}akE+Sx|0f)JP#qqXJnouBZ7t#ZE zO)@O^^`R5CNm~Byab@||bB$BLWnD{J^Bh^RAW<7yQ_J}fuq;7PY6^lTf*wx>uCJg2 zN)1YU_6|Z)Vv=&ZacPMix;b4TvcOaLn+ssEGo?5rPSlvxV;nGBmTqg4di(^w&alPs zV3T|qxA*#7?kkr1P|Pf+nm#^E4CCriar+2tsltAb7H7wDY!7QEGie7VGThBL9r$Qp zWlPoqg!)|=ky-CYWK4+h4s+0m8JXaO>1pc&T{*-gWQPI7^qNgQU@%!hZz)$Fy`B9o zz1KHxs#={+ln*fBQHf$2zqTMudyQY4X(i06DWCU@*x%@U&3!}^K6+TpLNvsMv8#2l zhJ{-7Z_7d>ya6mpAH0557hERk4vY3~BCLa#WW7t9j$BE4>`w2f;h}3gl8Qyg zO-JxKp8*{e@kVtdZduYve=5+o93(fp=PRDEFj5P45rT(m=41S zt}|$gPg7v4^&GXl!Xne;ccA5zxcD7t`Ihh4nD6?IwQL91uZ8nJItn4LBeiEm!_N^` zJo;N3uww0K!DA^LLT9jNExm5a7#dxp#^E1aPaV$D!8N76|_Mg&d zI4DACGy~jNxwKkfKtW$;UbFq6Vwd7EJesN4XqEF4k2|B@NoXvk`xMboWwF}%r=Ggs zH>~7=Wu2`DZI5Sl-wb7=u>V- zd~;ym0o1L>vwddVHgE0c$PfScG>IyJnG?~XolBc>E^SiPePU^Pt@&MT>_z)8=j_g+ z{xNxN>4%P_ZPiE8wm6cOF|`Kg%@IHGb7Rlqi-st+^%=FO{4FeAyyBcxtIvN#PO7zY z6aG|J=8N%wR$J*ak3iB)VBG4SK&Mj>WId4lvjl+SB8QL)cP&6c#*tviMVn)339r1> z`oy7EYnzioRj4+kK`mFHfNjESaq2?OI_JY}RYnZNPP)|*yTkq%Ab?oVTaM^W5YMMA z)lY|Wlo{5C{F{GG{VEKFZd!g){7{cMzhmO0+gvBz_Wh*WTqoW31q3#uT4w@;opcLE z@Ill1q+8S6Svx)^g96RA13QV1ThulEAP;i~QHT`T-4;Ql9kl3s+(D{z5N%jlL+Ip4L0wF*WP-+X1kknoKh9p!%5)ueWAc-AH zuim0=)Lqq7b!#ypZUK(*zJwT$@rH+Z!5Hj}$4P9**4UU}n*g4{OB^RA9(&Bpcx;@E z6VKp;|L@%UUR8BVLXz!#^KX4u^_IJyd+yoqeLm2sq78JyRS+71dN@9SU|%vWK>Yk? zq&ls~Ux2C==Lyo|8vVnEi^?z2yr^dC`6_;Xr5-G&k}&d|oE$QTL)|4P1y$UPb6DK% z1lP-9vOG6{QcIrd$rtnljgZvzZRDV zR8`PkN%^Ro<)8n-Q9}qj4VCYG15mp`LyG=`CFP&WYf&ADR{!5z58MFMAX{j06+_h~ z)Z18Uvg9ek3Kw{P0V%z_vfL7wC1YeMFLf}a5KARn`y#fK?G(vnxAQ>X?v}WK+AfyN zxKx0E*{zuZ6tR4%R4TDKa!{yT4V0G=4__7wrsf#ZsWPxKH9W3Tejg_CWDX}$W*C@& ziZ;1wJDg-N!eXu#2Byt0LaRHERzKe9=)ybI**f9~kE6yD)^4^o<{b31bK3tT7)ne7?bQM> zr;25KI~v5P4Cy zHDdG!UsbRMYffH?B+>W7&si@=%8?KLW7BCN63>4v;0S7l{YvF%c1hSJMO~e z2ikYSacS^)h+Gzg=P)`kyz9Mf2tG92`eGMoD;PCj?2=EO17T6&&ZB($nnhib$#j$LSCd2enb@IV`9trd77$}U&G&Fg3Cj4ERUO9 zXup|UEr}|#w9Ta6?2ZMaQNf)}xZ^3}d*yhKK@{2!Kmz+y0WJ(BKfdYm)4E_f7 zwk)?C6kLAv0S0y7eGEi>X+cF~hyo{0*hc{eH6neT6*m^o53x80{!ki|!XhxO;#bb{ zR6{q^7twsiBVSMRFXbC;{-qwhbcs>WB^f;&uKeN~Wb}LW^Bedu7RG zZ{?s+xqL}3N7SX9Av?jN1dc9#ennKijI#|G|9rePlw&MQftz?&2JRq+MOKQsi{DX> zsyp5e{IPs+L@p}+?`?gjUihoW79Nrw0{~VRGp44Ej_|8w?fvEc+MouHW^i}=YzpEh zBu+SI`7`f1D&d-3x1E4e87u>m8HFlzcmnn66;U`e2*)eK4wTshkOFpBldAqWu|z9dqF}(}=XcA@GikD?YMx93ze*PTY}o7;{`G=h zyF#MmQZ1bUyEUohur_gp*N4=wgb4Kbx}jR^-Ey3@2B-wZg;5j*&y_ul+HS|MN5}?K z7LUe_fnKd|ncPSY=oBniSnX0n2qvU9bo<NQI}Ql z#w5m%$l}2m+=dgJh_zwY6hIA6vU!LvHBwS-^ic)X=jfQhIfMdAlQfDy3&50zIWSX+F6@y0 z$OKHa{3U#SV0C~LaS%uVqG?5oyD7)4fUNHVrP}LH$BD}pqj6l?6!i^o^__31x(AI< zZs6+CyQqq7U&dn9t$g1C{aPW8B1cl^AP<4RqK@Sceghng4lJPKX8A$6i3}|0TM|@D zzok9hKM}Nn$ho}aVQ7GPM5&b@eXv}~zr4F!pPMbL3s&G~!@r8bv`<3TA ztmd;E*VaE4p*bn?hU^X0Ax`UwSwg?;)I6E7GL0)Hedg`ui92Yyk5K>c?Z`_&M^tG@ zQJFIk%@E~jD<0B*cGViMSo-)T7`}xWe3bs_w(&5>>s}@5VxEc)Y zM{mR0wreEbhITQyFvyDBP@sg_9e7UQFN@o(j({wRRfmp+xz;? zrWQS|>VcYQPW0_tc)aHe`z{lz0c5Y1My?i^0xB*C9x(;%oTa7^LHflME*`*|tB=s5 zs{`}<1Zfnjd+Mu4XMX0s?<|3WB0BP)8a5ahWiYh)OpLm*vvJs^&;T@mbH+w*j&WyXds z#K$NY%clUb$q1=i0FH76$7iQ26c}MpX`0mHBMN&`DZk3#(~($cg)&RA zAn$vgJIdDGaumr)eb5CpM!LwDLR$x8BJ`>i5-5<&MX={oNyPDxT6%J}sM;bSC@M{1 zr>9@=7U>itk2776SaD#4Aciala+U>qWKv~GZJiU-Fkk|22MB;fLxZOr_)RH75dEqF ziqyiHc=S{`WuV-;Bg$bwWS)RC7&CGEyx%;hi`?>jQ0f71jV;n0XutN%gtccTT(0PE zyK2vjirAOaHL>s`TVoX!Z^bMZO}IQE2gU*|<(pBwC0Z7tRRZNC&__K+B03%J@DL$>;N!qslH9#4(9{zH!^zfH)rH3yX&K7ZSC|Nch z<8!HWSt1(6l;U^PznncYL8p(N>MZESr9--L>ChG>D}llHa~y@9ICJ>b(f@z|9i5G?+ai;VQ@FJkCh#w34=FfZp*?)J4lQ>i^EKI7?Vt3J<4zVhQ z;41~0QOm*a%J(E49K>iL%taYOsWy&+&vs|VgkH;kY&Kph6~>hiQs7&z;q`*8bP!8` z+Wjm=;_^KSr9dfNFHkrrC?}Hf!xvnsoaeZoRqxe_WwaXfN7;6uYBEsuxWyQRO!Kt- zFRzeUJyo_uCTCU`Me@L|1Ci8#i--Eoq^;RD%6T$O(eJe1TEJ^6&?&&dyj~v)Fo0&4 z`jVh>UI;^w{oBHNK?5!J>$ob_#Ydkw3K0BWidj?kl+k^Ga7a+bw;m}>VXn)cp}@de z$RV=*6Y6@Y;?%OqOm|9!`7J7&ansk+h)@izrw75YOTUZFWg(^H&<)Xbg4je6RAe^b zT?6a;I`3}m`$vx zU7RO9X!xtf(<@@39PQdMkC{ow)BiT@zWD#B-S_>~Z$4h3A+3)L^o_U7FPgSO zCHsZ8GF1@Pmb)zQ7ppJNl7~9Vzj{(S0U8S4%L9=zh@S;Ng@Fo3)+W#at~9JW>DRKp zZwUQTSguGG?MM@ZuvR&c3^ZV0~6KTs}Y!LQ%|$@VK{tyVf3O=8lbY7qsc5!kyFIU+;rv_>G5>Y)eI zpmvqCroo4^5EUQJ0c6AFhg*=b#xBUEX|HETnG5R7bp1!c5Q{TgG47xad)aZNevV&H0bg0oZ3}e9P z;{Um%K2mT$z|}%h!<}%g$*J1@TK!-xZr8`ht(sGc_YP4GLEN~EUz13GEk4?` zCMOSr<2M3`@)bV;Ec<>mvc|m#wD|!ujC%v6f46ptg(h`IfvubI+JzKb)-G{6Py^53#-|58yE6cdEo(L8~uD1q!UM^2^)?9R{~mcN>#>^}poT+aQlxdrdc9_u^zLl_p1IZc8P5s?h*& z%U6Kc@mhT{K2dKrM+J122RP%CBQ8nuUfhfW4+h{cjQEJvj8|Q^7I)m{WTSrAb!PWM zmkQu^ATprv`THTmh|(X8F!9NHe4kr$8`h-Dyp7&56|@%Ly0H|mj!rfwEE`xI8nKu} z*D)TZo;>A)`u4CWWNg>&*|oc}p?vvOyRR)@zA3<>Q=nM0yY1Ev2=rD*2h_T~Fs#>A z=Nit;=>NgSD4iELRi`{pVW2>WJPvipI+Zm)yP47YaFAUtR3!}>zMnF(Hs4A*gR}*w zll;9}`LR(jLweC@j*O1$xqqH|WDT1jl&tfqnhlKi)f=O)Wr?U2Q>V`j{}Pf2W{kVz z^~T|;ntN!%wShKE%8}P&I)HKWaKmlZry3NI8}(E*M-N=NYaRwu#^ZNP)xlHuknK{L({x>GuYqK8)vB*n zXF1dx);>3`FilV9Yu!d&)+mFYnhb^@lNwx))+T`1gw>EC0e0548?U*O2kVXfYOJh} znlskfow0g-LWVb5b4D9LSHL$mIzBoXU+xa=8;Um%k1GgBz7?|GR@ZA|hgD_%fG8aF zm9C9Wjq8e-F|}~r@rlX9EMhC(dM@j^2^Oawm4l36IS#Pbbiz6S$rm^V4`I7gO;?(<>$RG~AOAvzYQaRnlAyK@8a+}6 zUpnqP3elK5Ipf}=2?z8WAB9R$t>e~4nO;2xY1^w$)f|X269J?(zY&@$DN7os|ID`H zLjk|e@%$=s?`R6Un8~Ar)^x7@0{8Ld^`>4o@fE@P+}kstWUT%CN?XTSuOgb%Wp&<5 z9^vs#XyKXs2KO&;zo6s(^Uxl-_i5z>TmWp`Cqz?38{;|Zk@EkQUy8Qs`32=f{?M|{ zaeCtOvbnul=2!+nmN8n+0jp+93!^NHF&3rJ_``LG0Hk8H5oZnWn;bC;loNR(D1Q;< zg$4)ra}WZTa^I%$dRZMDsjC$%RPsLR5E(~kW04fdM;OQC%bdmnxBgX|q%6N)0 zBC82~>@2gE`*oztW<6ieeVMdj*7M7`-$>d-(kpo!=E6|pQP73q0KzIf;78) z^Ki``uGegrI*w9@!0qiMq3fOHw{X9e6y*6j*MdKtd9LLCs#$qtoIC5I&3a8O97R!u z2FpSgng<<3%I{zc+xKjXR}W9JRE*2|2b2sc?FbHzaSu7P_s6UJH`#!Dmk@D`X`YKt z!5Vc-@m+OlcU&qTgJ3lfOCW@hhgBjS#Se~7j-YMK;OJ`wSbJIC4Jg_Hw^6Ml%(R*q z>U|&e-yrS7Gw3%mR=iF&Z>)Y0k_%ITMl>v*j!#XxhmM7Cvm*LWy*Au%RSsFFgL4Lq z3#n6JJt%eif?*(ML6?J4TG*)|=110*$bZ4T$k&pN6`eb)7;RQ+2)YRW z4^xkli>9)NrFon8u5!ShRd>g_6rV9a=R*S7*CM5n>onO z6Ym8^(oaNG<7Uz=B$4Li{#Md$q|Q7Q?)Q@Xv9|_(a6}}ZiAEiQ+!XSx35w>aGEMaH zD1A)%_3@+T#p1WORg0GA)orO{jUBYWUd5G{uUIvss+P>zKQLg3PIiL+sCkj*J4^4R zjNo^h_K(&^Cr3rTS52?-8Rxy^i<56pTdbTxr>eZW9I6bV5N1B(ovq4s$g?{{lHD;i zxx>3!Nw9lb66~hBw^h_aEu)rw8Fd>n&hC1B8v^Q9Eue1p1X3xp0SOc(Ly4nuEzhK8kwxWNi*DD5D7wj)M7P%`cljddE-iX)hO}KT z^7~E5ox4TuWGsHiHX?QUms>^X+$Eysb}f@h16!1w*=}kZ;^Vb+bqB&@`{_m{av~|x z_$HAPw>Hb2&)PTFi)6S#sAySh|C^LRxIqboJCO(dwl~58%ZP(iSPmpXx!+pb({y=w zc_0J&7YJ)*Edu%#>}hN1TaW-dZrde*tQ*us1=qSt{M*?Q|28V=kJdJe)Hj>l0sCPw zg$;X6q2`A1&u3^p{S~go)^aQjR(1=!Uf)0J4nc#PU>`I%DEAG@2oF0!In+39^N6oo zt7P!nWTlC^)hhqAUp}bs`~H134+B-%4dYX14qzTPjQ_!}(3-YPx3#`YM7lttL$wa%x&8$M%64=@0BW(- zD3DL+mB?%&?;#!_F*f1{Ewq>#!gotUG>j4QiY@Debq);;cc_%Zf^p4Zzec9(EtD5o zTX=!+DBG$@3usPLjppb97uCqJ@0bFwHAjD*{BiP~UVAN8Z~U6_Im!p^H4Z9CLjIFk z0P-TkLhZ=2@hmMjWB5?SsnSp^c&dRwG{QTP?M~Q_x<Y6bU$HU7>2yX=vQNgk@`mv>ziU%NJb?Vj!1w{E{;2O=iI65^X&h=m74JTO|HY65L#?3qwfB4!w)uu#i= zA^LWlu?BLHNUg)l!lNW$!!tLSP^=WxzANSFc;Mr3za3ez(!t$kVhT zGMC6rA`gw$z^f)SU(6Gd9X%Sj7z1YyC|nNmXUQwL-Odunj9A+T0%7}aulo{h%@Fci@E!QHmNs@IdvV`=#&%YKNk?S)_^8Vj4 z$ylUsK^xMh+)E#%f6_0}*Q7skElK1dc_(?rCMj!IXsp0f@(K=%C?$2uGkGWZrA}FM zGUuWbKNuS@-b|Vz?IrCYT}DcgE+#D?{i6HdHoZXo&yc=IdW`fS>5Zh{Bh^SZlCCCg zAgv~yL+T;D+%;glNcuAAO{6U(;`q@PKM{Kru~atV z$-@)U4{ce4*?8z=VzLo)pMi+eHaW^L+9o}tLuA7)rmT5l(QW6#zK1Ci!5zXhRco1| zD5%YiV&gNE{MKn*qC<1-?;K)LmVyH3dHW^!&DGXzL8ipRwCLgfUEJ zNsOe1NUbt4*i-z50#Gq!%5G}}!f||t0oT}dc)VIiaNsfaS+P#4$yfFPWp+h~HV}EW zSy#jmZL^eN>baAi&k|$kYalcl8?0lb94TR=^f-aiqcR16P`Ia>7IbU3Egfu1Q6)=s zw9rDXz^EM8_RqSFFkv83v$}lYLTm(|z5Rfg1_ zrWudhf}V7weHWm(XN}9!lp0zu)e`bY)LIKO+wfHbSvX>DHiG-kRdl?SS=0JZ=R)-D z&4Lcv&*D>|_JDRN;7MCZ2ijh3_|K$Q?T77Y4~*oXHiU4WtmY1+=zI!NvGf$yYfpfo zbikH7!nhi$JvxF*Kn$E{WK8$v)`V3Z9Ye~*?urn#`Dn+8)t;i4}aPGyKuMhXw)#B z&@W6knhCun^lWH#cw6MZMn4$(Rb)xDJNoI+RnfCThm31OYr?+>|H$}C_^!y)#v|dw z(Pg2UIUXL2d?K>Zc-ef+xF@{V__5g)xj%ASWTkO~Sv22ed^!4{d3k8F`A<>AURbx7 zH6)FaZYS+0bv_r7ClD3ezSV|xu!4UTk>6(gw)i3f!yWmL#DS0RFm=o8$h{CmqMoZ9x@5M`&e()FTixRX;2-%P5_ z6*6x5qY7i3bnLjjaq-f=Z>cuLIgCrIIj0_K(b-1rxNV5xm_~SK3~H6-Iyxlq+deh6 zN$e_}^Hb+}=lultfg|-4Ah}{_$S|g9M^u7DGL_C`bNNEis@jh01>?8t4OjW7t)@Nd z2dTWz@7pBhUPIcT!VRvTnp8a;G``Jyfn)G%pd`D8#5E_RwJNHAvxH)d3lZkSdS=Dr zf#hCi|L(ppLk<*-^k>Oy}fZI50&D3_pa*I59PWPr@lASj)=z(^DAQa zXZaNo`pbU%d$~SQo)^g@{gR4;e)TWYb0YngdSs3M9_cR9?~~&4cW3Xa-c|g>hlYCZ zTE+kIyVMOocP;N-zN+_THSS=Izm9UZ9y6)n^l)uTJkWR0rik;R&WU)RIFv{vl8ICz zoya7ziCiL|C?tx>L^7F7CDX}FGMmgL3B^bjQ;AeEl}e>knN&8FOXX9AR56`MC)25P zI-N;p)46m$T}T%*iA*w+%A_-yOg59tJYlBgf%gVG&I#ENb1tK za6=`oj5=;SzFfN5q<-m9(4Y5Fmq6gl{K~k#&Tp)v?&Ctz_fh|fyh2F2plT8icT8TQ zhE$N3@{Wt>uA#qdh4$Tv%|Qf*;9eHVa*|<&qtRF_)D`RQ>Y3lWr0?ARMRNw`_Rot9 zgwHtR%$|kj*$7$Zh8J}$HkX7hSQrnl46p7RG85rsC}n;$^zqOmkxz90-_Xm^e+m6- z_?4bd9y_rCRQ?|j$CKmEDSfAz_) zef{r#^y62I$ow-_Bs2NarE9lddF#Dz-yK`mqt2GgrMWUAk%W)+=vw z+u+4Bq{N$lV*e7e`|Ak32ee z`V-L$dX6j(pWAIlh9j9sSJ>=|bHY4+6^ZHAX^DeB!$0N62IQ>-g?oWjm#qR!>@Qqyyd(P=u z(7&Mn_E>LhQS8R9mC?<;t0MgoGo0*O6S`!Bw9-S!=C|G)=6c;}n{@ZBH&lh6IZr(<0`xwY%A z`^V?L8Ch^nE`QziuY2UN$NwVx!WnOPRzme2m_;w4?(y?qPL&J{}^ z`}lYNx+njRcYds^_tJIV=-b~lzh3#$&whSW^?(2Rm0i2v`{2;<#mo1+|3eS``-eaJ zu}^;P3s1!Q`p-JAblIkBKJwA0|LQ|s=Pnw&aNT7;`RUJJ`RbFA_-ih_XnDF&+H&Q# zoxAp2C%CuQcD?=0LwCLIO%Ffv_@|CO_t@jL`WOH3w!u52;mGQ+7dD57rtdy4oSe5L zvaIL)=*sBE$lOb&ABioCEQ>7f&h%}+{7AlMVQ=?2mu@PC?e3n$!sycQ;;6a45V=q=~^GZIMUyf3zwpcx+48uJGbW3bJATy-MvRHy7sD--Ipv}bkULpXZLKUfsJ#{ z?dpwf>AtvUs&B)(OJbKsdt=wc%;-QkI{oJA`CGbsr$2Jr;HJLb*qk# zzQ)_U(oO>Sh zruwFzc+)m}&b^6&g>Qf4?kgVp^Sg^(mqc!fUDUg|cX{;8yFYcadsU>^HGjRJ!~?(T zzW3Xg^nCayN7D1m^I~%&-ACT?#>oEYoN!Oqz`OQd(KESb`k#86-4kbReyuEp>wC_f ze#4O~!mr;j@2q=wUJ#2-e`{rQ-BNR6b$C%EbY%Sn^Gi|l$a9z6{okhldBwI!ZzOcj z{EgezPJek#%#7@bF3yCG%v}|6`mgJqeyniboK=w?Rzz(2z4v@KGCw>gd@xes>vQJ3 z{z!qrE$<%Oeq?w5dGsaMJ(sLKUDMyVu=n2B32C@b%PV3%gp5m+h{XGf;2H>A_i(NB zf<2R7L0u?|Uu9~dGFf*;rKups%oNh@6?zXNy(bbk-WlC%+U^ ziM8b)&wps!`i!;nrQ096W=DPLweSDJL)RM5TD#nDKD5jD-qPL13xB`ou^(F3|MW*o zZ+z~>hi;4;KfCcI^K~~F6NIv_M(zpm&)m|NIBURkp=Kd=BEQBwfAP(IrJf%1oQT=O z;*YKjuj#(z95bG$K%^V0)zuq1&n!vtNH0i*wdFB=~Vp6%; zZC+!By864TW~isHYinpR^_gaVu1Sm0K66=*=|#*KoeG^Bii8LF>`EvUGv}GWK73y2 zeEzKunO)sxsISL_cAHb7LGwU366!Hy;lBY0^tMZC40XqPLuTTFWF*0T)Lh=v&lXoQ zgbTc+V7SyB3cV-H=e@h6!Eorw^@jNs_LaTW+#5GyqalM2X~jc3LvVTeer_mgJ`h@T z#vJpa?sNNw!U@I}3SDeo4&*~@>+a?l^fa}GLQ%$jNvPZWnSjkilNumQfm(iO{!!Ej zGs?*FaK!v$>Ni3=!<+k(kvq-YycLYIH=Lx-E^}>oS=8)a$59lS9+r<;2@5Cziurys z+?oGnmgt|Xrs`k(YI#_!_Lo^E+^yTF6DZkS1p8a-y{m&`mE zVZMX*B4)gIc}&ezEEFCB;0Q|OzIGv9p_bRiXaJalZPJu!FuR#(RIbd}JOhSin3qMa z;khvsIvc4x9Eo;!hq}&>+|N$+NUGbMYc7nM^Qd*csxj)AAEM0K2oUHR?=tpIzl4l9 zq+^yZLq-!L#y0CP;;CAkM)~<4Bh!lXX8gsu1I9bth**xz``o`ZjVvHxVmN~B#o=cK)YXXV^N!rXrPHHl|FsIQvL zWm5&)vOUMk<=tfH%G0XPb1D+Bi!GkMRbBQMq_bI6S}&8#x#80rC3UG_Noqo&P3EkO zlg}gzZox@Mww_k6CalSkirC|+DwnZ6E1yVbQ%UsOVk)}2Qo)9$LUJp|2YAJgkrI%{ z(x;xi1=p@iPF{%7+Nex!_wXs@^&IreN$F8f;*<)AL(DJHn?0=(OlCzewQuFgi(w14 zD>%a@`@5a7ab?<^6LZEqf)3}-k&rS*Sg}Xg`ZTW#OEr(HVq#z>c!mv1rIBo^h~>x0+jhbAs)g#gYgI8^ResDusU$%QrIH`D zP%24S1d~KPQrs>SoLnN|SWdo*)oD?3#zfZe+)UCtuTdYb5KUZ=j=Gq!stI-%CGweS zGQaq|_E2~Yt-!vOO(rtgeA-Q0OR^o1oH;kdm$HYWVM#}d=`2W5ETowyw_41cw+)yw zKp8(5^0Q0rb=!uYLqOentDpm*Ti~I#YB85BxS67zbTXvs`LF5dgvv-JJAsJ~ds;qi zryR>mTySa-r-#`>K3`3yJSUS&rQ*7y9axKj*uo#;W9yxF3QZuI=B~SFG*`{%syQfW z#!6JZTw$pdAfqfDWp62!L>RnW78us1025_D4EvnKUeAQcodph*N?ZLaAV8R)u#=>X zanOdTfNWSHt-&kWpj09yxGs{V>=9_!uTXpA45YOM8;f>2Z)LJoD_wZaWeVuvmS$_< z1y@3oC29rFPN_6&uqn^RNSbi+>6BeaR+sJa2df&ZPT>+|w@InA({jp=h1Y2IBAPk3 zin@#>(s{PIWiw7Ln~u5Frtpf6aRY(zrc$t&PZpEaf|bjr zJyyDP@s<{P2HT=arPjWvQfb4Kr-s&8bG?v=v8m=rh1Y@~cA}cJz>lI`ELeGK`FRz^ z(U24q{!kw_(2i2+I@ew^RajMC*IG9nB*lYG z7c47{ERuH;Ug{Dd&jbyuOs!GIvKC4n2W7l0rfAnmxXDbSn9td(QW}E3Dg;TET_0lC zVuGM~Le0H&-hqg@MK_akt!i=gdLPYd^i&hCHqEN&2Q%@^N>^=2yqk2ZZZ@CE4P7y- z)lN+eQpk4S5j@*4Ibx_FGK2x_pPG<)OcwG^CX@53j_0ME{IKRoKInpVt!^t?JM%eG zHff0{lC$$3VqDQlzy*aN&O&sxzII_gw^=K=%*TX;+g>79u+s=^blyrhN#X`uWfhtP z#7)3Yfo!?}|G|@BS=DUXNu{p!mzBa(VSBirq97LuWagy00G}v{#EQ`zaN;zFbIV%t& zltU%>MMfCihyRvx1t*cTq2ifTx|+<|*-JP0xO`j^Sy8}(6jX=q;9>{3+WI?3+2sjON{fmrdFEG^mv*6sl{B9YATb3I(3sQ$(h; z7f>qaIjLk3|6AHdm?^C5oXq1bph5ygB$0KBG?YtQ?q$35h|m#AB?5Kr%AL zyyfDuLup!nV;i$)bVALj&+pdkUN;LaGgpmfc}2(0S}9P_c3@BGM7hO?TSA^6J*pSI zzYDse9}4ystG12D(JCM!T8_8j>elK$1^#rfC3q6OqtMz-<~;V9vvR8GLN0gth#qPO zpHxm7Uv$?YBTz0yjCNXw$La)0wb+O%1y8IWy4u|{0m@HW``t>leu$1+XnMthozJBZ zxw3`i#?zrS=^{!39@=a*kxxOWHl0r4Y#MBL3U*EyS|**?d^&~GN!vq6ww-*|%A}mc z6^S($?QV})VZcmTD{p5LMOIfnkt}#A+uCw698P3Ytmta72n~cJWVW8HfXnpfa@AB3 z6mrr9>&lZAK&Y`0<5^g^t?_JM<*&%&@p5(-ba3{Oq>FpGU?as;iv=%H-IktBE$h%t z%|StNrR$9#`RDS*R4U=ZiL7Gs>K2J@VR;9c3Ajpb*o;r$nwbH?YFIK zPtZE8kUO35h%zV?yu62wkaBjtYVLyQcwWLv6_Kr=uDgHBzM^L4s%{<`JC!TKRrahu zm9bZF>{lj`lIg!o{DK7mDpXV1Oe*1Ax3yD)@)ewxIlVpi$60i4%Bm8=kwSE|SbCZ3 zhh}#MiF*{;d>;pf&@`mewsPoy`J9u-0CmHL4j$E^+d85~RVIZ?A+sapB}H_nBI>ZL zyj{(SZ7u^Ca_)`4J2ruy#=65eVW-_Z>-?q|YYX?m%_kXF-m3yfM0bgBN?Yk$?B6Ll z*GA4vF71lwgoIs1BhTErwF7p?7lrmr5X-%V*eGT{K3ZrALy0OBy;v<23)wt8D0|zL zC#`B52fnnc>JY5b*#se7DKN@*(s|FToV>1?-Rh{z%NHyRrTGG8DddX8-qNWE#+t>W zGgNcvFFCk{YuicdcZU|)ge`n5ol3e8aGoV)YYzQ^Fo(IZV`4o!QmHzszPe8I& z9FGt{0)5tObq>uIk7jaBJCjRr(v5?y2Q4b&?7K>1Zik5ivh5p>APqtdX3}wxN{KfN zh((Fr975`*ykym_j+~TfqkZKqFY9LE5?R;Ij9%J-h_htYT`jH8Cj^d-RN+>w6y_)7 z`o!%qvB_cGl2vP?#HWrUGtAQ3GG5lQv4C4P!UG{=V-98*EEpv^eL4rQ3h-Ju zR<(BWB3a~5j7gql+m1&>T78QirkXI%4;jbsTAQV&-+AW&rRopKIWEfjm9P?sphUh^ zp#x6dn>eKvqE(=*RRvN-hMe>=*z4{%jj}l_2M&K0nBkTlc!PEa}sz-sz`$l#_LpZ>NLt)cz~+eJgTvSu`K5u*w|@! z3${jds5zQB&c-gc$Xr?J1cGd$T1*@~jUMFPd>Y)&WRs5LV)Q)Z8-i3r9jsF87J7!0 z4jC=hGI5nG#_VCA0;#vhk-9P|R$bP`R+Y2}Z_K~;B>9P&%w|)mYPOh2<&u_t=SlJx zlE6NhPhhjJx+s^wcar?DH%xbVFN49;rGdLnlHY?5y4Zo!iGo|j`2G94e^ct!=@G~m z@g-KhbTOC4uwl8cOZq~Mginili(CoSa~k!DN|W;>pb4IM(NK6)aA>xWo;FWjCS_w_ zMrBW9MfWh=9WmDjQo|&2&Q9EQSUF!+{6e!!B8MVg=h5B0{N3giKAHwR=UT;kkb^h9 zIv?=znGDiwl69K3(suS9^EW0@RyvhHb7KLa0&u?Cy=FHqGj#yp>rG$Yn-E*Q0wCTS zPFS#AJ#=9-z5u#OEbM@JgtbH5E}^;DmZ>=R2j-0}4)j}@Y^gg@ELKxUFnMhBnRMED zgBjthqy6`pD>Q-bU<2xsA{cc+3=|I!4Yio4zVTG1I*;`~n@M2Z5DJ`qlbO&ipINT% z4ri~Iv{{-3LYs?1tP^iGm5*zcc#^{uKk2&t=KLNea6j|>=hh(!)Pb$A!NhgK%#LHwIhusO) z2T!4hmru(kgLH=Yi@cM4pLv7s>~Cf}mGFwni1sU_*`r`*Om?mqrwa*Dkn!{e&FQe%OgwU6~?=7+Zo3#e9+XUs|Hs1F_aRvWU={RwxhF} z@X-0~WCDjm8dKDV%$Uyjka;>5|IrR*61!d=e+*V_jGt^Q`S5Sf(s04%vdN5-Ci(*B zf%Wgr+g=?nJNU+N*JS5{6hthzNF0z>3rP&;QT1U{bQou9;*ZVk9qX>`S2@<}p+!%v z>32dQpK_3cnHAX~Q>}i){E~UXzOV5K5vF5tTm)x5>HM91d8K|du8vy3DU1_v_9JAa z4v~Z1lM)Gmj)ONTXoevwvIT|WS5~CBPb5x3?pp#t(ZU+z;A|@3+$2onqh@AJwazx! zmH}K*kJ%osD&j{9zaV}e45&rtV<*R5r3a#<6>#~a*a_BL0i!U*nR{KF%c3J<$EzD%7NugTu}zYCvgF&|BhGq zjM?u`gX;8uJb9BSz^;oLjiU}feVf&#S_< zv9J7@xgn4;L@Dvt*ld8#QhTxQW{JVVE?8ue)9F7qy`Ylcm8hakqPQwi{n!|Yp5bQP z?B~p{n`?q)^8X(q)&^H64TanV=Qwee6c?+R5x`06CW<+!2V`*(~aAA^T;sta+Iq z2%vV<1&dgTDu}miFP2>d%5*CemBh@FEGp|v7EAnB%*#$(2dwef8eq!Az|n_l9?xkUG^f*xQOvMeHYik6ilTqpU}-$YF443BVa*TGmLhPIrWD%wv5B(3hB zyRMIbZX2&Huj<*=tbf}gEm?)l#lo&6QiA2%* z+R2L$g;lJ2nEuc}*uLw2{p3Zm2zSU~g%pm2k~bW zi9q#;=XR^#KmK5uumfyRrT_w&3s1=9on#WOTQEj?czEs^v_ zzf3fzytvNl>fvzIme;Xlb|^8Fi>j|moR=KR<%g2-<*lzv#5uqqy*iOvoyf0<9puEA osb(xOlq?PJo)SjCR=l5Uv+A1|7xPqIGgkT1J{YlC;$Ke diff --git a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/gotip/wasi.go b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/gotip/wasi.go new file mode 100644 index 000000000..50612cb87 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/gotip/wasi.go @@ -0,0 +1,162 @@ +package main + +import ( + "fmt" + "io" + "net" + "net/http" + "os" + "sync" + "syscall" +) + +func main() { + switch os.Args[1] { + case "sock": + if err := mainSock(); err != nil { + panic(err) + } + case "http": + if err := mainHTTP(); err != nil { + panic(err) + } + case "nonblock": + if err := mainNonblock(os.Args[2], os.Args[3:]); err != nil { + panic(err) + } + } +} + +// mainSock is an explicit test of a blocking socket. +func mainSock() error { + // Get a listener from the pre-opened file descriptor. + // The listener is the first pre-open, with a file-descriptor of 3. + f := os.NewFile(3, "") + l, err := net.FileListener(f) + defer f.Close() + if err != nil { + return err + } + defer l.Close() + + // Accept a connection + conn, err := l.Accept() + if err != nil { + return err + } + defer conn.Close() + + // Do a blocking read of up to 32 bytes. + // Note: the test should write: "wazero", so that's all we should read. + var buf [32]byte + n, err := conn.Read(buf[:]) + if err != nil { + return err + } + fmt.Println(string(buf[:n])) + return nil +} + +// mainHTTP implicitly tests non-blocking sockets, as they are needed for +// middleware. +func mainHTTP() error { + // Get the file representing a pre-opened TCP socket. + // The socket (listener) is the first pre-open, with a file-descriptor of + // 3 because the host didn't add any pre-opened files. + listenerFD := 3 + f := os.NewFile(uintptr(listenerFD), "") + + // Wasm runs similarly to GOMAXPROCS=1, so multiple goroutines cannot work + // in parallel. non-blocking allows the poller to park the go-routine + // accepting connections while work is done on one. + if err := syscall.SetNonblock(listenerFD, true); err != nil { + return err + } + + // Convert the file representing the pre-opened socket to a listener, so + // that we can integrate it with HTTP middleware. + ln, err := net.FileListener(f) + defer f.Close() + if err != nil { + return err + } + defer ln.Close() + + // Serve middleware that echos the request body to the response once, then quits. + h := &echoOnce{ch: make(chan struct{}, 1)} + go http.Serve(ln, h) + <-h.ch + return nil +} + +type echoOnce struct { + ch chan struct{} +} + +func (e echoOnce) ServeHTTP(w http.ResponseWriter, r *http.Request) { + // Copy up to 32 bytes from the request to the response, appending a newline. + // Note: the test should write: "wazero", so that's all we should read. + var buf [32]byte + if n, err := r.Body.Read(buf[:]); err != nil && err != io.EOF { + panic(err) + } else if n, err = w.Write(append(buf[:n], '\n')); err != nil { + panic(err) + } + // Once one request was served, close the channel. + close(e.ch) +} + +// Adapted from nonblock.go +// https://github.com/golang/go/blob/0fcc70ecd56e3b5c214ddaee4065ea1139ae16b5/src/runtime/internal/wasitest/testdata/nonblock.go +func mainNonblock(mode string, files []string) error { + ready := make(chan struct{}) + + var wg sync.WaitGroup + for _, path := range files { + f, err := os.Open(path) + if err != nil { + return err + } + switch mode { + case "open": + case "create": + fd := f.Fd() + if err = syscall.SetNonblock(int(fd), true); err != nil { + return err + } + f = os.NewFile(fd, path) + default: + return fmt.Errorf("invalid test mode") + } + + spawnWait := make(chan struct{}) + + wg.Add(1) + go func(f *os.File) { + defer f.Close() + defer wg.Done() + + // Signal the routine has been spawned. + close(spawnWait) + + // Wait until ready. + <-ready + + var buf [256]byte + + if n, err := f.Read(buf[:]); err != nil { + panic(err) + } else { + os.Stderr.Write(buf[:n]) + } + }(f) + + // Spawn one goroutine at a time. + <-spawnWait + } + + println("waiting") + close(ready) + wg.Wait() + return nil +} diff --git a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.c b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.c index 65779c707..818b8c330 100644 --- a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.c +++ b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.c @@ -1,10 +1,13 @@ #include #include +#include #include #include #include #include #include +#include +#include #include #include @@ -70,6 +73,114 @@ void main_sleepmillis(int millis) { printf("OK\n"); } +void main_open_rdonly() { + const char *path = "zig-cc.rdonly.test"; + int fd; + char buf[32]; + + fd = open(path, O_CREAT|O_TRUNC|O_RDONLY, 0644); + if (fd < 0) { + perror("ERR: open"); + goto cleanup; + } + if (write(fd, "hello world\n", 12) >= 0) { + perror("ERR: write"); + goto cleanup; + } + if (read(fd, buf, sizeof(buf)) != 0) { + perror("ERR: read"); + goto cleanup; + } + puts("OK"); + cleanup: + close(fd); + unlink(path); +} + +void main_open_wronly() { + const char *path = "zig-cc.wronly.test"; + int fd; + char buf[32]; + + fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, 0644); + if (fd < 0) { + perror("ERR: open"); + goto cleanup; + } + if (write(fd, "hello world\n", 12) != 12) { + perror("ERR: write"); + goto cleanup; + } + if (read(fd, buf, sizeof(buf)) >= 0) { + perror("ERR: read"); + goto cleanup; + } + puts("OK"); + cleanup: + close(fd); + unlink(path); +} + +void main_sock() { + // Get a listener from the pre-opened file descriptor. + // The listener is the first pre-open, with a file-descriptor of 3. + int listener_fd = 3; + + int nfd = -1; + // Some runtimes set the fd to NONBLOCK + // so we loop until we no longer get EAGAIN. + while (true) { + nfd = accept(listener_fd, NULL, NULL); + if (nfd >= 0) { + break; + } + if (errno == EAGAIN) { + sleep(1); + continue; + } else { + perror("ERR: accept"); + return; + } + } + + // Wait data to be available on nfd for 1 sec. + char buf[32]; + struct timeval tv = {1, 0}; + fd_set set; + FD_ZERO(&set); + FD_SET(nfd, &set); + int ret = select(nfd+1, &set, NULL, NULL, &tv); + + // If some data is available, read it. + if (ret) { + // Assume no error: we are about to quit + // and we will check `buf` anyway. + recv(nfd, buf, sizeof(buf), 0); + printf("%s\n", buf); + } else { + puts("ERR: failed to read data"); + } +} + +void main_nonblock(char* fpath) { + struct timespec tim, tim2; + tim.tv_sec = 0; + tim.tv_nsec = 100 * 1000000; // 100 msec + int fd = open(fpath, O_RDONLY | O_NONBLOCK); + char buf[32]; + ssize_t newLen = 0; + while (newLen == 0) { + newLen = read(fd, buf, sizeof(buf)); + if (errno == EAGAIN || newLen == 0) { + printf("."); + nanosleep(&tim , &tim2) ; + continue; + } + } + printf("\n%s\n", buf); + close(fd); +} + int main(int argc, char** argv) { if (strcmp(argv[1],"ls")==0) { bool repeat = false; @@ -95,7 +206,14 @@ int main(int argc, char** argv) { timeout = atoi(argv[2]); } main_sleepmillis(timeout); - + } else if (strcmp(argv[1],"open-rdonly")==0) { + main_open_rdonly(); + } else if (strcmp(argv[1],"open-wronly")==0) { + main_open_wronly(); + } else if (strcmp(argv[1],"sock")==0) { + main_sock(); + } else if (strcmp(argv[1],"nonblock")==0) { + main_nonblock(argv[2]); } else { fprintf(stderr, "unknown command: %s\n", argv[1]); return 1; diff --git a/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.wasm b/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.wasm index 181bb18157c46e00609c753b90b3001a16f91eea..255a198f097f84776b119254c961b1b5fe43aadf 100644 GIT binary patch delta 23148 zcmeHvcVJXi+V?&8-g9S?Nx6^!fdqI?Xn|0Igir*@jS>Vz6ct%@&4v`r5K@Ptt4u(| zf(m#+v0@h$1dY8QveL{`#tB*r1<*2yYKh?`vo%dob%N4l+)%; zF5YNe`k}R9Xto{4kBI+9;%y}Zc6{Z=$pcdy?q|%#1;aP48*W`Kd-_7;Y<%&faHzJr zqNS#?+J8*+O;1fUs_R+|35q_cjBc%|S!_6H=K2SPKhWfgO z#TB)6^)-gUEdF9MUDIqZi~JVRCnM6@ShcvKvZ|`4DF%|UW=>r9wA55BGg7TJVzr2b zBBo)bm}W|vXbkj~Tjns%0i5P}u8K!MS4BNCU;4R&OPQx;UNQ+oNfYUHD zj8LX)rdVJ~4WZ9WF$@#b;OG(Qk1#mva?l{M+t*(s^Q@I=I(Gkfl_sgHkQ zt`?5r9_lWFL?d#95OK5AEcJ{6^T0KG+KhC=19eHza4%_VYct%d_*EJ1UHnc)y2ymN z5i;D{{d=vu%#W|}qxMMk-6pU{3rr*5qLBBcZsmu|(+#r7AmLu>-)9ds|Gvq8$3ArU z$E>StCD}X9KYN0uTjZ39bCeUoyD=}_hb13<*_-oZw+1Z-w>P<9^?l03)sJQ4cqUp4-e~=7_*HrTcycSw?7-M z5j=uJQU?zVC`wElPS(R?F9;GzDN9pJ#pd>VQ%8zP3FAbM^LblI=_T6BVG5O~7bQ2k2yI1HY z&=wS!?$w$Pz6Bp-pS{ZeJTqtdmE4Owe8O=5D+n%aZWnB_3lajTpf{2ZgFw*p_m>Z;$M1r7Lv>br4BoG6? zZt+w4%~kiZh51&%3<3y_mYCXtK&O9tzdW(izqH@fo<7qmD-AP=4wCzz|6#vrZeXrN zIwm-Zb4lFepO8C2+~;4ETW|jT8vlpf5$5Ns{9$<|;yVA-yspbE-$C> zepZ1*Oe7RfSt6=L8Zz7C3}SR53;hrBDp~Z5{)hFvmizNuHTB=PiAJmw zNuYxzQ0ot-DZkpPN%ab)4Z;+bG-wKzG1y}Urh9Alz>J3j$zGh7AmKi$o2G{MFx-zB zc&7QiecR67 z6D)s#0d*|s_;ReZM2gzi4X;H5W9#g3MfWLlFUXdOY6WIYC7}&3e zqp<8+o*Nwu!`h%YvK5i=FUucR*+r6<)MO^o_Lnp*^xp*(3hGL1&58 ze%avN;&NXMnb0T5FO-S!G?QM^(ro{@A%n$Uf5nh-!uGch84$mm9m3^=Re(?$gYkx{ zB1D1YWFw4Vq(spQ1(OW#aiX3v+2CqP(Hj;3miO5z1l)a^g{2#1hDw2BfWTA+sa)Ca z?-<7wD3l$T1f1v396F-MJ{=UiUb&-YTj#n!0Iioz66UA>BK62> z0j^es9TrdOunH!s5Yh;2GDxLL-c0n@@o3hdQe5j2*cZ>XD`BT zGuwR=QZtN5KZpe_>)GpnGIGiQEh(K79us)H*=u{$!qf^CeRU=rKI)x(os2xGSny0F zhiMb@HQVbM?jQUkMjv7NtNaT_4>C8d@^_BT5r6WZ8vV9-$G>F^r@+9X0pgwZ!-_r? z;`R37hYT>q0sqKi!fTy=y`WeD-mYI?(63(>t3e0Y6VPTO0NMdzte}{|EU!&ONnmO? z;1`bvXZ!r|M~bu@)t`EE$b{wwpq%r(%R4aM6%2Y?+W$I92=IM1x%U9=9MpsR zdp1^Ovwhf!@3Hc;yf0SyLk=bPEym>cjjAjpVV<|eKjF~R#UK3_4_z$o_SMuO;&s1r zN+Dh^nlcpqcTX7x_>WVL_!+i!>Tim!*R~A)FIMJ5@*wY~4y?CLTY7_U9adcIuVTxx z;7CP7%8W9YgP%PI4;t>pjG9g`Y(_JZQW5bly8Xq6O->EAwIrfc3)B;g;cUSmjUmhO>w!Z-{xxs`ksgr>z0&1HR!_8&kKL z(STa}#$VOGa{4VM>>GOIYP=3Oh64z%;Pr`-~?V?XfIM zr>w<#$eU&jiF~fzA#{7+teYStI$J^Dg|jE-y~{37vm?Rk;^kqOX{miv=8NJ4Zk~z&HV1D&itD-r?68@-+v<}n{u?6_vRb|G08L@=$~|S z8k8?O`XTfVnmY*ajJZR*4Q<8T0`y)tx2T^UR2P2~U^XlW{PEdb7MpbLKt1Okn2Mlk zrA^12&N2J!m<9Yc{n#La!P}L=+Y`atSHWA}JWVnqcx#zA%S7aN&l|w0^!B{*{MPHZ zf!tYg+&ih~bNusrd3!eb1CQ^e)&=Q+Em|^*2x&oytl%6v;dnjqopJm$PRfUlABa@) z|9E^WhVa!1iTwC)f|08S^zaEBj1Jm?zZ5v>9k8O*Thmw0F9f}s+Py;Fna}z6{rs-3 z;{&Lmj7u)qb7o=gaD=~F1 z;g}g63`(qWpZFh~Ja%B0-3}jPc;VEWDZ?w~MX0^_l*=st>57Zv=W-y*;>s;EaIK>& zIKM}kI6J@RS=8ekY}hD-odYJb7Dx%9zVovvtE}zJv(KTPYxI5&35E>Xab|wc2^O|; z)RVG~-$5+nEG_9QaA-*okX05xfp41}azPxSH2+V($>^m|xM8Tzj=Hz;Ao87b(>E)p zhJs;8zr6B_!%cnCGq_HJZfrFo7?ujBSv)C*vBm}wnaq`pJ&bOVgBCBf;WX3FURcMQ zvG~GKIUj4sCU($R_{hQvZMYx%`xd@#p1aDwvTD7!%`dDjh`+>FbY2j^Pqlft5aEu_ zlU{H@x=~<5HwY9UcNgcIK}2|SHrdG3yD5at4NlaGr{(14jJvTF;E9a4X4sDLSqw05 zA>s!`bAHf)%{3pvv$5fVNIgbuA&^<7mx-Mfb0l|hp3qyOQAQ^3G0cwqz;@#Z97p+%cK5RY-=n~5$?ZE#Lu$-;LTMsP=oD`{jYZ#8h~d#KP;R+_@0 zu8X7X$gFOvHv9>DveU@yNT6!B_tct1F zeZ~(jy43t;m4EG`UL)RPd_SHpp`gGlR&!~t`(eEuL}pMvq9f-}FjUvvK2BXugePK~Mx`ZZO+%2Q689@j@@ zoZWBH_DkXWkE5aE9lqOmt;Nl}j1qQc{?ydQgvqu$~EFSrF!z*7dHwSS#<15%d9XpQy^g zZXhSgYN@`|H^JI3!J3<}Bad>i>+6?`6Ou{&OUxp#UCSEa6{&&f8W>eX1F-Xd&wsEk zH+#QK$&8DYB5tk3p?@XA#r`LCL$HARZgisf!Jiq;6F>U3(H5SZiL*~BQU$>ZuktyP z+er|}LR~S9Q{$;vmC$%9DOVGqZX!*f ziOp&fO-iU6LnFB8gqrLXs6(Of(5RY1Q`A(9;4s)Q4PDcss+3BVN0VtP9fp6N`$-$J zRFwf)rb`Mt8g)2Wj)>FYYC0XE%4s^4&r&lW`AC{UM>eaOx;SSB=FWn)+2EcXRY%cL zY7Wh!Iqpwd=+R)AOGne(W=?Y^Kd57KEX2>FV`*NO9RFBjjsxa+I*yJ9<~Xh%J_npY zCnViJKjDuPX}(%OCkB;Lu1g6_h#N4xM$b+<;`4a7Zy@c(YHRNX5G|96QQ z>OM?q>V84@3A$gjs0TFfJ>Y$i5f7p1zk1fBIHs9>f`Hv8TGiu%9u(>cCRI-g0`R1m ztDX{s|Bs7i^|YYh33?jPGq`wD&kA}*(6eYhCy*S^;hF?V1?kTVY8UDSLC*{Iq96b- z!lIXiXQ`JNMK6Qr6}DsctAbt;>NP>H3iY}m0I!R3^@gCA1ib;O{jBIsLHh;0iRSNF z(eDFAENClcS0j=cSr-!L`8}58w*R)Z!E(3RA=#ybCi>qm8_eZ1aQQMWnO?eNdQ|gMJNiD1jyP%%1vm_aS3twdQF;QUH-ZYAx%3isl1~wy?{d^A=o%G8 zF^)zhhEa(Y6-Cup8jBJfLx;GZ=_DQpM|LZ}BfFKKE(MgJ;eEAw50~s@&>xEWIgZR0>i;X4JOAhEf_;7O+$T_q9Q#iD@Q2`bp#zwM>L}tr?Z|SRHQ}a zQ8j~RbY?c&YRJgmkT~5x>$E}fq*Sbwd@(%5dy4N(ltdGsFs1Q|pN9KGp+fk@rk}#i znC(L<75+_OH9}!uuTmqFs?yL%$84Y8tTF&*VqVW|R`|FCw5|>}ruL-5o-BIGu_}vt zs%*+qy(pV{l`C9dVQ%kDeVUO8If-}+)fe45Bbrq%^;LP0m>XzER;auP<*5N68At>C zrqg?4+ocB4proq7S{2X1YA6i}Cg5^a0D2w&W;KFFbZ9C>_ed(Fk=FGcl&&i8QGk!52aB zn|bQ(&^;C1hw+Ttj9GZ9V!urbbbI8f(g=qeB!^QO9p0>t0Emf~rZ=l{Q0iSF2fM(G z>tiOSVRo^aNk^(#G!wJ$ESg=ejsn{pI*R5rtE1`Ygzg(H%)lni<&1B;b~RxlcIX%^ z@sI1|J{GuR`C$SG46Au??{PGbXJAaa$I}T%s`(I#$(BxRRtwBhuI~kG_-eh@{|dX5 zFIWz5$+U!%yg#hwG&|W#!%U0`nND&4sx|!@vQMR7V{3A%`VCdkZ;n=#kiC#9X<@Uf zg5W9^yj=^frs|&wuEDmVmf|MWM%5x(q)zil)lm(dMs@C&T0s;dqAcPOEn+b(?hxU9 zpu6g+-u;?s@j1MO>NaG%g^7~4pV$yhfrdWveM(k9hH&8n4JsI^?h zVEp9B_{2$7;liJkAcMqWoNCR%am*VySK{FdUdDrYIf&J!g6f#lTI!V!Bwfi>%|zWvR;gj?zR~7 z)a+s;Y50&_AC>vI#plJIp7TGg#bCo~%*#EWvHq@SKTPKl?+PP)LgJEEe&K+(Y z;EOoi&Qoyaiel3?fZ};Ld@%M+jnzl5304jc2ZUiD_KK9sr+oJZRuK$o5U^OoX>b&4 z_z(@9l)I6=vA(c z!GMp&ntyCF4qfv&)&~g7yh+DJvC<#^^JL#GE#BTAolJD$9l(PLonRf1~&ANHi$(^GKu ztMyH#srVGY(;v>^ion3;^e~#1IGsRaDRh)Zk;oplr!Kaq79AeNY2*kbav73XACUSX zHF3ukk90ejAeXHmm)}^;vjyj}m5>~akn?y?Pz7Dmn6ntRox(fWf0M+#SG78lIEzK` z5ue|U$Q8xncE_)5?cKg_#R8H3H$9n6#@>Fi`*i#8GulM@=elbJmY@~ry7#vq3-Mk1 z*0Xkr{Esx|Q$Ys=eJX;dW7KCj8zUz^!|B-lzP&lVOW@Nn9@(`fU24*`CWMS#wOfd9 z+rM0mPawYaH?J8c{@MP>8c=?#CGN54UW@ivpge2solG+3yuA3o*kIm3qnxtUKXB!# zzO(2b7JX+$)%V=|r*8fe%^xfT=|^s=pDg;(Qvb3Dz`v{+>L8=qZ2G}ct88ks)oPmn zthQ&Uvu!$P(b;yhTBGsj*eqbJO#s%$?YZh)-F=?!KHnw)=i4*Y1^ARht>c#qZCYp3 zg%EI&O(4F&ri*ZOc(IMyc)d**+q53I4K_jk20$B`=@OeZ+H?t;z75CucJlsWlTF`S zYO_t7Y;~y}CqS3N%FAr5l3N%@TflTVuAkKvHeGJ3D{Z>MR#({s;3~UZU2W54HeC&( zYgo}%o362GE1K7`qH6<1ki)Crbu8w3o369f4K`hGs~c?sa3d7n#LPG2w)`fWZU*-) z%zaD3Orf?h`c|8^*>o$gw=wp%1olE5&)Zon-EJo`WIHH8vmG?D_0y3tb1?zaiR{Xjin z(>*pl0Mj1S_=mKBhiwAzFoODs?%l0>AGHaOD67 z4pH65QGMK|eKtJ~+!HoI{u6+nWUi-ddeWw+(0rO5@^r!>hI+=Powj<`re|#RoJ|0p zgOSg3P+wpay#SsUc{nfG^rEd^w&^8Xy@L1ydIeE^)u!iddKFZ!v7*;)dd;TS(R_my zy%8vaAdc#Omh+}f`)&1mo8Gk5TQ&iB3mX5x%zw1$4>tV~%zt9$KP9Xb>TSlpW7FF< zy#wq4o7e3F2{fJ@K|R0AV(HyvRNsRDh3y3%KvX~E=AU)* z&uD(cCVtFK^@&X%+v-!B0DKA)KV#JAHhpBPzhL~I+v*FO{$kS?!2Q*x&uscDZ2M9Z ze5ECPZ4-d65!Jux-oNYKZ)^ha4Wjxj59=TN@*RrUrtiT2y-gtg76pZ%{*#0HgH8WL zr33e)O%VShpr7K*^)H)#vgu!FA7p1;{ogXjVYJ?kW0AZZ<%7fR^4P^KGkOx6&@ zQN4)eTrBA#sn$!nSgH+@0BnH9jm&+Cq>Yj;0k_ZGKDc@BCe$XzZkDu3(q>>UW$dL1 z>}EYlU&d1DGMOmVEua9+7S`{s>K4_@CBk@xq{}5;A*1R_ZeFFESD|?|n|KX3)mBN@ zNOi3w0N29A>lk&tq^qU6LDKb7-6#pbjX>Qb={iX_!L*w-{uV7@nbWPf@lvbdQ8$DNspnqmlf>|6hRIL^>-|0pQPVO^|+*cQavFFz!OmT zBs0gKlJumcr@;L*b3dIhQ>bSc{j8*CBs~l4bBuj1fxSXU^?4Rc&nKh$0w_T90%(H8 z^hJsN=1Y=Zl=KpU_cAwM(al%Te3dPG4dZ`Ns@EmGCe<5~0K5Uy_A~BHNv}%vdr5Cf z^_C<6ZvpiON&6-J0T%sHh#=H=z2K75zif zx03#W=69^ z#m$4dc@WJuerR=-1FTx@(5kqj&UOgU+0G2LhH>XO)aIzQ4xQtua~%S3E>Pz=w8o+H zoMv^t#$TW%taAv!I%lrBQ1@P>doOkfz{So?wVrRdH}K0whc-C05&V}p1mg7$UE<^_ zKkmTon;h~T+63fghai75pi7zSGKVg8=rT07IPk_6C%K8a+@XI-b%jHhJL*b@09*+p zuX5n_s~JUCgXbC^&Q^!6an!XAZFSUj4gt8%DOcA!bd^KbJI!%*11q}Gp&J~!5llC+ zqMHIm5X5f38K2bB&HMn3_tm6pEy3O%O-OjzYJ5jYg-J$KyU$+_VP+Z53T1|y>?*?3 zspzu1bnP($vMzntm*eiEY}&c`Av}Se+{=ZZitG^pHdv5KYlXxg-rXtjdzGR568r((fKK5 z2ldaivvJ_WCm-BrmKB|M3%H0$vM4jk8vi2@kCYb zEnagpKja-Wnq6&#C-7(#ge=C1R(fw5{FEh>;K|El`t$byadP9&!|~0SP8)3Ki})Fv zhINQY4Marz>6?bf1vFV}@eRVM=dDqAYy%BQ#J$fs{3RlMC=^1FgT>h{)B*+%YncEWq zi6n>5{@`rr=+Nj?M8)5ClvtPs5N3OOKS{GxxA$= zR%6sw*0&})`1`{Fs!hqrIbzxwHL=S2ww-Lt0af(`xGL8)a*T!Tn_=upclB?Q@FleQ zH~Dh_F#jfhz68v_9Y0WG@NeSB1&$xX?oQG<(yOGh=H4B$6s(^zV2Zas8)*@`N z+%$~-2EG)ne=@o_#T84T|fi2*;4+!&FrYexu58bG;5{Ti_%79$+ zE2bJ@OKY6)H*C+2Pm)%=o4$|{*nX(APGbhGe7dxnxuK1pDXq2K&qypqB77u{ zlh*2P+EWd)i4pUqb#gZ?nCH%CMEpc)ZSTesNys``T92^colJJBv_9xYWhKgw zAs&`iJvX#t9+lRjj>cos+Q1EM%(IAnN8@E_rFAr3m6nm@iHp~zwV7KwVfIVw3T|A_ z#=Rviubb0)8KLk)z?^{?TAy1fPXK-xuz9UK3~wP*V=rLrN-Op7I>YDzP4-_5d+X!q z6mG=aIOP!@gZs2&AiXyp8rKnZA3`(D+*tepBYV6Mw2HoDrk?MkWu(uqH;j{jg*0<3 zBpYIA>Rn3=V?S)r8Y-D}6l7+XFm}}5K!dx#qXh+NHQXA_IJ64h=JTK!GbyB-Ir)q% zT7{O8v98H5o(2Hf*48L1nE=^o72Gx9QB5+x*)Vb-Nvl7BNk)Jq?_IWXL_&RzW*ET? zP?&uj;|dp|m08eY7}X~9qu=Gg+9US`RB6w5v=FDJ<%Y2?>Bdu7OMmtjH05Yb{S%t9 zwWj_r1TtK$X`t3rw!$#lz{um*iYTEd{JemE+`WLuFj9X)T(SQPhWtEw#58EJwF9Rm zT$ZEjtn|%5OSlE(Lbr?_!_G2{y@8?T)*j4$6l=T?gAsEKOm1j}-{;oR31RMCtY6Gc z1+u5fn2Kd>VC?Z3Uf)fMLWd!$J4DrV6II(O3RH_aB`yEe8kY0|UOx=RWNvL`6=yjBfep*4iIU&diExa z2+RNkb zr^VPt@5ShJVZjf0zaF%yuhBjyyx|!i>nX;`x}pcm_KjQxs2A4VXlDBKZL&&SgFXwaWGS z$*4BN;A(pgb;7mMelA9c-&Uj;r`h@&S!3eoYrpxAinUai|S=^Y2W{%Rd zeY56>hzuzDan}TRA$O?88OE&xlN&nxQJk8~Gf|?(7dGloh#xZ2`3>gq7FX0QX=-eV zwT|&O?&cHWozB&DyBW6ad|_1BmP29#XSQv#*G_S zTv$~-ws`D>>V^2DJ$H}gP2&GVvawzDW?^G0o9afNX8c>~LD{wZCx2r93GIKNywIn+ z!~fpKLH^3Su|4>ALn-u+xhLg6Aj^)`Evc#akH)~7L;jcd+C7$4*8eAiF6`U7w6&(H zv7x&4f2SeBAO54zO|Dog(+}S_wqMkoEv()oL))cv!s}(q9LGA%oGPpw|G4{x)YLFK zmt@Lz8FI`aJshicmdtRh0R-}xw49BORXJK_SOZCBe;_l$qgl*UX@wU#R>f%9-?8$6 zaXygp8tYVZh>*gu29Gv-BNt%^PZ`z_|4;W#b$HgWM*4Jr|D0JSz9S)BtAwPp0WvpO zv&>n-D)EoIfB2Ac)?gh^5N29P2F} zA@hBJ%Mj@-1?EOzEXR7Ahje{B+*77F)&Y=NAWL;N;+OzHaJa9DBN)j6^VDs<|MLM~ zrU(291`G%TPCyu10@4Hih2A8-8)X>1aUSr4zck=Y!GOQ`F~)Wg{?2O)v?uhap(RS-a&bY+@#t3Wi~z@V4O z)E&^e9hp8Gw#H<}2Qm#lPJttMynW$_Jp87_tXEdff={fSg2Ic;;aQILBFse6ZHKDt zd4S+Rm=7S4YR{}prdk~4@^-+wFEDo^xSw2U-h^)hJ^-r#!el@)6ywIwWOulhd&5(Z z!&_y_4oqD^X!_{T>dIJuFLxt^TckW$jegG2y zGq^}YviAmV%oS2H0;36Ub*#rQ)Lz!3Abc#~Nr2!1Br`T}|2W+M6n>Cx zzDD*!8adYe0nbz50SF#I(#1^tAlj=DRqGjaL)CK zY#tCWFX)GP&kBFX!+qj+1?2crhXoL-042=33#xiM)=TJ+P^Fieom$V!pxzlUCO|L( zVm0W8nxGqM0Ce%<4$b~5*mnf%@dONhK+F#W_=9fn1L(qkyXMC?ORU=i{sahiK+KMQ zum{~>2hfH6R?WU2?6(H&`{Mx&e)KXw5a16;zz+cYSv>7-3s~L+2S9KDl5#`fms=ni zIr$d4MmzXBCpQPgXfp_6#>fp$_(R9KY2^oCvi>AiJJz%tRzAgZ!`lLnbn=q?nM_UW z?OS6lODgLcD)?HqB5@Dg*^#&m_K$odFMVl4Yu%y-+`6`&*4W}Nd}PePiVEKFRW#Pt zS1!UH#YnVktAh@I{Ug1yTkFoi2FVEaNygH;hS=B=|BgpWBUSY^l?_Xqz|`cg-aW2| zQH|TlMuT-54K>S;s_}n#B)`8lMPCwYsN<%%mj5WEpSL^TTDY{|-haSZ~dpIEf zojoBD@((^X2vDjS)_v)Zh0GMDOTj)@UuCEI-ebjPq!4`({WmSy=V^za+4JXr;xc^{ zdeixayrQw8rm?m*gSk?hS{kb=YF5<6GNEjg>1wJjfA+EmQ}yrotCu}{=!h(-sH%jZ zs#s%7YnETScT_yvsc4N=w#0h%s9CZEI7nSm0|4>u?N-KOHA|Xe6}rDNR@27`NOJ7j zmYSNrA>6n#M?Z(9Hdf`zis`T@FH%vVL$s{1uDX9_A{8oIkQj??>Kj{YD7zzn5I@)#V@{Ri1X)uHK4}QL^ZRuYC%f_2L@PK%gEBgC{PDoxzzubf zs{aHj=!Rs(J8Agujt=c&jSkkZoCJXm4gcBEr0N2ZsINlZ6tqWTgkCoL+mn=E`kZwV* z=Ae&r5Z$V#(~J2XN3QWsYphpGeN96NfR^f|O%pW1lBS9N#C-$JNqzid_Vy8z{pNi+ z;!yvBef`B0f7`x+@u>-))YmPns%U7eT3%gI%U-FB9X2=^XctVEj=&?8v1up;_7?(B zDs{}gL>Rm9B?u~GW!k9IS`H5-l*Ern_(@aO)y5jDW7BP>FLweJGeQaOBNO4&lx*Tm z9%1;Er- z#gGWCzY4?TnwFNvmXkt&8tUUU4JU_|SGB|%mn=NRS&n*MvhddqigHC${i)$)wM{LU zU27{MiTA3;mYUy$ni`ubP=%FNQ)Tr+CqPxDwA3uGYhX82<4^JGNC2)0C!tzo8oY)- zr(1Oz{^l+|Y+IC7Q4#0aKJa}*U96(Dwdu4_Q)^9qO;xPU3Ercb5CJxPzSr1VUsKbx zIHd!uXU{CFX{oJmT)srsHZ6@+H8@RrfQ?c+qsivrG;3UIiw%m_RwwxUFeY0u{+gzx zAgNlm%&v?z)-4YuhP)!AXP)}j(^G==0s%iG0C@`iZK(W+ij$_#n|r1M;JE3>pB2XY z%;Ny9bOQ!9bxB=4){l75!+BH@tbT1G(G};uV2NBM5}GjB)goOBNv=(23!B?(1VUNa zdRl#~ZrnKx*SDV50(h-JPAyr=-RE*Qz{Xfz@p%H7SF-}kS9Nu5toD%e8CP4kB39d4 zcY#16)z-yVU#_@K8i%zKPc@WcNB3>iCU delta 12571 zcma)C31Ae}-G6V6J+hl*LJmUCHw%G4AS5INuqgo)vvYM`u+ZIb_2B4ehWMEfB*Y>$4vH`5A_Y3 z^o_%_%vdaTZj8rHH*j|Js{!3W1B7+rC(yCNzQXOz4UQvN=tLNH`37D z+}g_wAP39uxSyMV@} zfTro1#thTr33~imik_0fn65L;!%~<>*EPB@4PT}+&I2hJK!Rzh%$t_3`E>|bUXP}; zjFb$2hUV8&Q{@Z#QKwq|6wVwTFzRY&)~9@Nzt-+yR+V*10Ga|bIge?zTCKxMwOyO{ z#aSwIz+B@FtPSyaoLSe=)n?Y+bQdg@rw1S^n6+It8ux2^Hp?7ywEdifcw4E)Lb~ue z`_w4pt50P@7ff*LO4(!%*PfR0QgiaiJ!GryTw(0I`1}dF8VOGwUvGN?xU=I^S-@c< zL6CnkOA7~7+qy98;6>axLFqMMM^<}mex+RO8K&*qEYJ4XWA7wCZEwKYdONJx2Ha85 zN}(-CGci!(M+4$=c!t>DNMv##p@YcN}BNJ}f$5YpJR!2=#^ z3CaG&XPXAFWNnUwPy3IGqJ?WzU=PKWvtPmu)tp$V@C}rp?O90;<;+AqK#AcB< z4)wzh;>|-F1p?&Yc3EUq@*CtrYe-BIDWuIx)le(Lx<(E8tW+J!H0ydArWyh*>w}(8 zX=uZWW3>$fOb(<6oM)MJEe+5}zxYoe6e({Hqb51=5&x7Y(fE=o(np|H+^(uJz37Uy}8-S*RRx zcpEA(kX42_r~*HiN9Fa#o+H&EjaGn{37kz!K&kcu!M3i|IzFK}Jn9%i%MT@sVS(W92z112hK)VO*8nl-K(p}YA+JLT}=rtM~rBuk9^QR8Ff>hXg5c6AA%DP|vF@L({MrWe!Tt#wf z0j8E*Rxp9zE3YYN*Ph-ijlxmd!MLm_tl^vG^1{j!2QsA^4&HAe<>*G_tyBxPIcySh zjqFkc!48McADBa%IC1a`{w;<1BnRWiCOgPc6Qxqo5tY#wxSqfYKBM~gb2oF})4ym7a2 zuEiY86qK~|h-Pr&A~D9oZ&7tHNfD7uvxk)2tn_2@0adD5Zk)+@;U+}j{jv6x>>CxQ z+Ceb?(7lSX+0Gla+tuO3XgA>2gKCJ43-Ch(=fN$tWPBsvvwyFnP2|&|duKjQG-`QN z8#B*(fX0DxY*}s?m<#dRHYamUh&kplP{%0Tb!(9{+J|gf>Lo83UGXaA(K(>5+;Tfb zafn2YDyi2 zWj!FPhM&VPkoOJW%deK*BPQg#8Ao$)gy}&dRf8acpegr`7{(u#zaLSB)5YM@qS)1x zl8|Q>Er&EChT-O^(FAr;VNPN`;c@(J7zSNkjg!#NO#dTTE!OJ#M; z_9Ge);3%w9Pg{==jhc+xDgbvulDkVsWjsnG+dO1a{;9M&4;wjmHu7Y`l9^?d)N=J@;|4$FdW^!y zYP8zq%>N&GMOiuDD)*KRA;yDcqjR4j#(wH7uYfRw8ZY(0Is&NoH;kGB}i~s%(PxmYV)8L zykzHLxw2wPkB=lOMvheoBqDRmyXxlw+`S%5k{^5eR6SsQYZY*%l z8=yFA33TH9JySU!pOA34Jw*8JEMeK1!4#yt6lnpQ^&-V!XOY`xskToKWjb%gRdiRbvCLHE|u$@YO2_y&X6HrlRL8noSEH&S!4@AU+e3* z{KA<8d!=v~KN}2kMSeksQ+8JYzVT=F%C(+Bb2zW5zJ@?v)u$)K3#;o}B$>m9tE2%EEMZ zX>B6Y`b%7HpDDEejmu|ejwHUn%q-FV7VjT2>v_HC8{!w{NIkAWAg;AJzP6FNiq85r ze*c_1G}yoMn682*dhOR7zW(lERm~>Hy<|+)We&nSiXH+5Sl(c?om*-A3qfE^T!WA!sWjoUkdEd zMHP96 zPbwth8z-r?=KGVTQ>RQ_QjF5eWlQ=}c929K+A>#G))gQ;w{t03gGIjbdD_XugF`M%^abg253Tw#QA67Q72%5&pJRMVP{JXj|kpQuv+Rb zyIt0Xvj$y8y8u@1p^OPStBcuI z9m6xInj4`(b^QEL<~d@}dTiaoi{luUgkCg5hRCRkpMCy%k-1K7>d=uP*v_*k=5*effvV-bkC(=`~N61CZ*@LxOI^_x0!txn{TK#)EO7vI+KJiKRI>y;S(v~#B5(s4~PJr#(Y68w?tZLPx7~n$$eX;DRFF4 z=Q~V6X1y)vx4fo(5tk*)ui)F{1ItTGchRc^I!~e;?ECDMQHn~wyQ<8^@RMk^BV2_ zxZKp0J?eF$=TUsv;E7{_SYRD=krbf4P%Lye5&3dg+3~+Vj|?mU{$#O4oNOh;73Wg1 zG_l>-r-)M$Th6ICQ=N)Kn)8H`Jk1gIGN6{V*-2*b;H-LqoqY=gtrGs=I{*{|+6 z)}c~HzU@Vsyz~gPK`HT}Vp_s9c09lETdsnXgn~dqK@g|Gph(HLQ=uRg=Y8iBr8v#8 z>~x^g+iXju2}>lEX*Rkmp=?k>StgXp%ATC&@04r~A{Y$W!EJUfre$tYRL9OcBq5rY z5Y12cQGlslAoB9g|mQk;)hgh#cD%_6|Gb?vZ3JylE+Q>~AcifJ%CT}%_xd+b_KOTGT4N{s_ub;1#Khqc&KiZTO~ znPP^RnV?XU&Jwdqksa#Idh%t5uxE>U`)D!So>M7~7IW(DxiEB$m@AIyv5!Uk$C9aC z!k!1W=C#@L#r$FLhaSPKH|6!wUmGt5`8)lcs~$6Aai4u37rVH9KNt6LyPpdH{d|tS z8xITi16=Ip;sM@cKggl?L7ae*S4XoSA{p@zkJ@{m zzRG@#3;f^3XWNhC;B4>Z;&Cqa@?QH19E2hKD1`SB9o={VOi; z|CeBYiHqmCc!|sTR}C$AnA@*%@f&Wx#sz@ap!jv}==K|2JS;E2YBqnk|E!-~t6O_@ zuX$MOmP$J|jM{c~Y;{azyQ#^=saO{|ZJ0)b?Ob%|5F8tD0L?>(=8HU$-(wdblLd(m z%@YBd`Zz~Js<6#25=C|~qy&bdjoRK0iDD75-c=1X6qy(%hT0`)f7SX&qxCsjKbGu$ z=%(&>UQq2c3jAg0?6Sie?L9>q4ayiXT8ufY(a`0<%FE`893!1To=In~}RL@J)!{X~?csIsMx2iEA{mRfCd@Yxi>gyZ)E2+lHH5b;Ah$LI36(z_~+l?$gDCy4Z(u_Mdjs zeZ-Q!r6BeRIgCR+((+eb{1wsfrrpZ^8{QM*+0Fh|cMSXQy7*QXf7jdW?`ZhF8h(%A zKXl0blZN&Wy7;GV#|;4>Zp^mN!&A1s))4>D?eh(>*09$Z0>ClIMFa(${GsG3xQ8pTw z3!4nF(GZ(JyV4LB7~)Dml7y}@gfzre7+!54l~)_oxG@U+8bf@i+t(W68pFQM5CE=& zm)9GZ3O5i*+yJ2)DW01Qaid{xHpESay~Pj!wixyH&4#$%5I2KqD;c`Q5L*p#3x>Cn zp<9)q0QAry;x+?o(`|Sm!kl~1kc*kU%@9a7u7>p<6(bKSwiDNOa24QWj}J`WPN>@n zrS|j!`wqhq_ML>i(`d8rGQ?em+lJx}qyM%$7xUO3NFB~MR-4f3@OGt+SxHm{o^gRP z4nyt3b1$(ShC_oJz)im}R^k!J##@__dPV;kcR$Is&*F0O zj#sqL<1&4xq}#Tg%L$o!&vm%<-*L|-p7Dd<%hdv-VSl7OQr_@Det+XG$zwk90K0w2 zQ}=`VOg|rI0}WW<0(BJ^-GP_XSlEKdv}a%#^5R@*I^?NO;3#pX@SRz=kDaYv8Rg&M z^t6S%&JV1|`ixTKaGVvPWTowe&;dq|aWH~MyM=|e53hlc2b?!_5jf<70eeBY>HZM| zDpFh(LHXSMBV!sY=@$rJ-PDWL;qNy(1~$jJC$OI0NDHqB;!TGOtPDYt%~P+fv^ws- zhA=B-SHo+WK`1@x~aVbAZJ79D?Qk{_#{kzPlJi|JiWT zcQ)S2aXDspQLcfbImPRxm&jfy<`>yGK6_--?m1NZdv=fX`PK>V&bo>VHy(K7XfL&?M&SQim^s1WlHuUA-LPo|7NS}0$7G(W$yp_9?yIazCG3yb!y zim;Z3_Pz+4@64C;AM2JcKUUKJ^<(uO&iW@jwO)%&OtTonAJ?Ge4}ONvKEI{D1k>kb zjOm;F{0=aElb=5WrtiQf1u%UR9}6&jlOGfv?T{Q#W2^!L`X)cMfa#n3ECfv7bUNM89;XX-D|K*dsT>hIBDF3Ha| z^^r%&j@gXKVJ6UL$)S#TSIn&(NF-$N{9z92(E3G=y1U=#_! zVAca9UiJzsq^@pbtQpP&ZQV}j(bXDuGkT3S7;7 znDA4NcCGkc1HU_B>9wmETa}SW2hHzY#5yP8UTzMtCP!K6iq;J^slQsySUdQkJ+ltz z7(a#rWT~&8!`NDv5L7i?lyJgVM7mC(5lao7&)72 zrg$uBZtEy;cPeRfGHEao z!)#j#=4A4K=`su^%mm8)a798wvXlE;duwN;I|a?e#v;?4^Y7A9>E=T*7`|NY`jFpAUoTD@S6xwAR#iQ5!uZPSnsJgJ7@FSF9PW!m%U6)#kFu2oXU;kP zzwxBCc6NpTo2H@i;WsRr8b4xd(`%JKLFEUkf0A039&PQ2{6C!d{y@f0E0Wy@(|(d; zsQmswAgixC(&Xj^ov%@k>p}UqgOzz5+A&)CR~nwDc-rdNxAk zMtz=die4pWy)|<99MZ2(6dwI(UkmA)q#cE8y>G7Ohe|_((t|6cd~1}4z-_Jaskfdt ztGQk+`XpBcNUTda%^tXV>g^alt;XUfnw<+)5hQKyg zHUTcr<2pcc4+Oa9;^E%gOn&+P;MgrL`@4_?2vdL(?%e`YIUbxjsqx9ql^%UF>>&3a z09Wq8j{|RV#W5xj;zThwdVC*x^c!OzKuG_X&GqQl$DX6s{RBUu8AkKqS4N83f{K@i z`=Y(k)hrzDXlU&WH}o!VqRVPVt3}r;`Naog3;R~}MVh)goBP61JX&EPV|}e>VJT5O zviZZ>)Nr_)HRIu;i$RP0>cfz%`pC{}4oA=IjxhW>HQd?I0l>Y5!x6dmqcW_-#) z^P_Uk^~9Z3jT@u`>lqT^-@&k!V^*IE+1{ zBiz)0-_bw4pbekrCQ&P zGCeL!meJB1iDY}>GD+lkNNZQqU^6`HjMivwAW@vvU9HVS(v{&>DpDVLl9zorqLM13 z@cBtb#M{)~)fXwqN-zS^(hMh~Bwi?A{yZmEly`{M-5XKFWZ8<{P+K9C%&AB_#NHQ) zth5iarE(j}O)zvfL|24cTH9Tfus75?oYK`D=^QpF9HU&eh7bFVa>)Q&FESWG7KSI? zI8=lYWr(0!`g#j;1>{^f4Z^e0!v`obJu5 zy2pCF#L&@QAt!xNTva*P^{~CQu?ensQq=7f$GCqZG&J@Rp-Nu%MIo=2cYjelW_%)Y zCEeN8vO=_^c-O?5dZS$(jSD?%FpD}GkMm$EoYCEWyl-_&cW-NF zv}IAiy@#8+dLt)zySuun_fOQj8=4n;T+&JY-pCqM3gIuo{8q^Ye6lYIEk!#aTTLs& zO)FN0TN+y1PsvPFIYwn}?QD&P`}(?1^>+6~+9OTT(>(5dSvpie46l~D`r0Fr?y!FV zJl$xBcC|Km6Mi;&)e73)*W_0KRj1hnsj(y8`kCRSvyNZT;sLN|)(OjfxX)P>1GvI+ zCCETWYkPZZU#mfwHYBg1Z$*2wwQ42hv2R5$z;@KGV-+DgfCSVPZLRJ^eIsW?(O%6h z(Ux&tptQ7}5pC&f?MATxuIlWgQ4bcAmiDfOXkTlzr58eT)Cg3J`=A-U1oHF-oQ?GLMViMnp2^Yb Rc*t2=Ik38q{C}_R{|Cnpumb=9 diff --git a/vendor/github.com/tetratelabs/wazero/internal/asm/amd64/impl.go b/vendor/github.com/tetratelabs/wazero/internal/asm/amd64/impl.go index 264a03026..8479d81c3 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/asm/amd64/impl.go +++ b/vendor/github.com/tetratelabs/wazero/internal/asm/amd64/impl.go @@ -1,7 +1,6 @@ package amd64 import ( - "bytes" "encoding/binary" "errors" "fmt" @@ -12,35 +11,37 @@ import ( // nodeImpl implements asm.Node for amd64. type nodeImpl struct { - instruction asm.Instruction - - offsetInBinary asm.NodeOffsetInBinary - // jumpTarget holds the target node in the linked for the jump-kind instruction. jumpTarget *nodeImpl - flag nodeFlag + // prev and next hold the prev/next node from this node in the assembled linked list. prev, next *nodeImpl - types operandTypes - srcReg, dstReg asm.Register - srcConst, dstConst asm.ConstantValue - srcMemIndex, dstMemIndex asm.Register - srcMemScale, dstMemScale byte + // forwardJumpOrigins hold all the nodes trying to jump into this node as a + // singly linked list. In other words, all the nodes with .jumpTarget == this. + forwardJumpOrigins *nodeImpl + + staticConst *asm.StaticConst - arg byte + dstConst asm.ConstantValue + offsetInBinary asm.NodeOffsetInBinary + srcConst asm.ConstantValue + instruction asm.Instruction // readInstructionAddressBeforeTargetInstruction holds the instruction right before the target of // read instruction address instruction. See asm.assemblerBase.CompileReadInstructionAddress. readInstructionAddressBeforeTargetInstruction asm.Instruction + flag nodeFlag + types operandTypes + srcReg, dstReg asm.Register + srcMemIndex, dstMemIndex asm.Register + srcMemScale, dstMemScale byte + arg byte - // forwardJumpOrigins hold all the nodes trying to jump into this node as a singly linked list. In other words, all the nodes with .jumpTarget == this. - forwardJumpOrigins *nodeImpl // staticConstReferrersAdded true if this node is already added into AssemblerImpl.staticConstReferrers. // Only used when staticConst is not nil. Through re-assembly, we might end up adding multiple times which causes unnecessary // allocations, so we use this flag to do it once. staticConstReferrersAdded bool - staticConst *asm.StaticConst } type nodeFlag byte @@ -218,20 +219,23 @@ func (o operandTypes) String() (ret string) { type ( // AssemblerImpl implements Assembler. AssemblerImpl struct { - nodePool *nodePool + root *nodeImpl + current *nodeImpl asm.BaseAssemblerImpl - root, current *nodeImpl - buf *bytes.Buffer - forceReAssemble bool - // MaxDisplacementForConstantPool is fixed to defaultMaxDisplacementForConstantPool - // but have it as an exported field here for testability. - MaxDisplacementForConstantPool int - readInstructionAddressNodes []*nodeImpl + // staticConstReferrers maintains the list of static const referrers which requires the // offset resolution after finalizing the binary layout. staticConstReferrers []staticConstReferrer - pool asm.StaticConstPool + + nodePool nodePool + pool asm.StaticConstPool + + // MaxDisplacementForConstantPool is fixed to defaultMaxDisplacementForConstantPool + // but have it as an exported field here for testability. + MaxDisplacementForConstantPool int + + forceReAssemble bool } // staticConstReferrer represents a referrer of a asm.StaticConst. @@ -244,39 +248,52 @@ type ( func NewAssembler() *AssemblerImpl { return &AssemblerImpl{ - nodePool: &nodePool{pages: [][nodePoolPageSize]nodeImpl{{}}}, - buf: bytes.NewBuffer(nil), + nodePool: nodePool{index: nodePageSize}, pool: asm.NewStaticConstPool(), MaxDisplacementForConstantPool: defaultMaxDisplacementForConstantPool, } } -const nodePoolPageSize = 1000 +const nodePageSize = 128 + +type nodePage = [nodePageSize]nodeImpl // nodePool is the central allocation pool for nodeImpl used by a single AssemblerImpl. // This reduces the allocations over compilation by reusing AssemblerImpl. type nodePool struct { - pages [][nodePoolPageSize]nodeImpl - // page is the index on pages to allocate node on. - page, - // pos is the index on pages[.page] where the next allocation target exists. - pos int + pages []*nodePage + index int } // allocNode allocates a new nodeImpl for use from the pool. // This expands the pool if there is no space left for it. -func (n *nodePool) allocNode() (ret *nodeImpl) { - if n.pos == nodePoolPageSize { - if len(n.pages)-1 == n.page { - n.pages = append(n.pages, [nodePoolPageSize]nodeImpl{}) +func (n *nodePool) allocNode() *nodeImpl { + if n.index == nodePageSize { + if len(n.pages) == cap(n.pages) { + n.pages = append(n.pages, new(nodePage)) + } else { + i := len(n.pages) + n.pages = n.pages[:i+1] + if n.pages[i] == nil { + n.pages[i] = new(nodePage) + } } - n.page++ - n.pos = 0 + n.index = 0 } - ret = &n.pages[n.page][n.pos] - *ret = nodeImpl{} - n.pos++ - return + ret := &n.pages[len(n.pages)-1][n.index] + n.index++ + return ret +} + +func (n *nodePool) reset() { + for _, ns := range n.pages { + pages := ns[:] + for i := range pages { + pages[i] = nodeImpl{} + } + } + n.pages = n.pages[:0] + n.index = nodePageSize } // AllocateNOP implements asm.AssemblerBase. @@ -297,7 +314,6 @@ func (a *AssemblerImpl) Reset() { pool := a.pool pool.Reset() *a = AssemblerImpl{ - buf: a.buf, nodePool: a.nodePool, pool: pool, readInstructionAddressNodes: a.readInstructionAddressNodes[:0], @@ -307,8 +323,7 @@ func (a *AssemblerImpl) Reset() { JumpTableEntries: a.JumpTableEntries[:0], }, } - a.nodePool.pos, a.nodePool.page = 0, 0 - a.buf.Reset() + a.nodePool.reset() } // newNode creates a new Node and appends it into the linked list. @@ -341,37 +356,37 @@ func (a *AssemblerImpl) addNode(node *nodeImpl) { } // encodeNode encodes the given node into writer. -func (a *AssemblerImpl) encodeNode(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeNode(buf asm.Buffer, n *nodeImpl) (err error) { switch n.types { case operandTypesNoneToNone: - err = a.encodeNoneToNone(n) + err = a.encodeNoneToNone(buf, n) case operandTypesNoneToRegister: - err = a.encodeNoneToRegister(n) + err = a.encodeNoneToRegister(buf, n) case operandTypesNoneToMemory: - err = a.encodeNoneToMemory(n) + err = a.encodeNoneToMemory(buf, n) case operandTypesNoneToBranch: // Branching operand can be encoded as relative jumps. - err = a.encodeRelativeJump(n) + err = a.encodeRelativeJump(buf, n) case operandTypesRegisterToNone: - err = a.encodeRegisterToNone(n) + err = a.encodeRegisterToNone(buf, n) case operandTypesRegisterToRegister: - err = a.encodeRegisterToRegister(n) + err = a.encodeRegisterToRegister(buf, n) case operandTypesRegisterToMemory: - err = a.encodeRegisterToMemory(n) + err = a.encodeRegisterToMemory(buf, n) case operandTypesRegisterToConst: - err = a.encodeRegisterToConst(n) + err = a.encodeRegisterToConst(buf, n) case operandTypesMemoryToRegister: - err = a.encodeMemoryToRegister(n) + err = a.encodeMemoryToRegister(buf, n) case operandTypesMemoryToConst: - err = a.encodeMemoryToConst(n) + err = a.encodeMemoryToConst(buf, n) case operandTypesConstToRegister: - err = a.encodeConstToRegister(n) + err = a.encodeConstToRegister(buf, n) case operandTypesConstToMemory: - err = a.encodeConstToMemory(n) + err = a.encodeConstToMemory(buf, n) case operandTypesStaticConstToRegister: - err = a.encodeStaticConstToRegister(n) + err = a.encodeStaticConstToRegister(buf, n) case operandTypesRegisterToStaticConst: - err = a.encodeRegisterToStaticConst(n) + err = a.encodeRegisterToStaticConst(buf, n) default: err = fmt.Errorf("encoder undefined for [%s] operand type", n.types) } @@ -382,15 +397,15 @@ func (a *AssemblerImpl) encodeNode(n *nodeImpl) (err error) { } // Assemble implements asm.AssemblerBase -func (a *AssemblerImpl) Assemble() ([]byte, error) { +func (a *AssemblerImpl) Assemble(buf asm.Buffer) error { a.initializeNodesForEncoding() // Continue encoding until we are not forced to re-assemble which happens when // a short relative jump ends up the offset larger than 8-bit length. for { - err := a.encode() + err := a.encode(buf) if err != nil { - return nil, err + return err } if !a.forceReAssemble { @@ -398,16 +413,16 @@ func (a *AssemblerImpl) Assemble() ([]byte, error) { } else { // We reset the length of buffer but don't delete the underlying slice since // the binary size will roughly the same after reassemble. - a.buf.Reset() + buf.Reset() // Reset the re-assemble flag in order to avoid the infinite loop! a.forceReAssemble = false } } - code := a.buf.Bytes() + code := buf.Bytes() for _, n := range a.readInstructionAddressNodes { if err := a.finalizeReadInstructionAddressNode(code, n); err != nil { - return nil, err + return err } } @@ -422,10 +437,7 @@ func (a *AssemblerImpl) Assemble() ([]byte, error) { binary.LittleEndian.PutUint32(code[displacementOffsetInInstruction:], uint32(int32(displacement))) } - if err := a.FinalizeJumpTableEntry(code); err != nil { - return nil, err - } - return code, nil + return a.FinalizeJumpTableEntry(code) } // initializeNodesForEncoding initializes nodeImpl.flag and determine all the jumps @@ -469,31 +481,46 @@ func (a *AssemblerImpl) initializeNodesForEncoding() { } } -func (a *AssemblerImpl) encode() (err error) { +func (a *AssemblerImpl) encode(buf asm.Buffer) error { for n := a.root; n != nil; n = n.next { // If an instruction needs NOP padding, we do so before encoding it. + // + // This is necessary to avoid Intel's jump erratum; see in Section 2.1 + // in for when we have to pad NOP: // https://www.intel.com/content/dam/support/us/en/documents/processors/mitigations-jump-conditional-code-erratum.pdf - if err = a.maybeNOPPadding(n); err != nil { - return + // + // This logic used to be implemented in a function called maybeNOPPadding, + // but the complexity of the logic made it impossible for the compiler to + // inline. Since this function is on a hot code path, we inlined the + // initial checks to skip the function call when instructions do not need + // NOP padding. + switch info := nopPaddingInfo[n.instruction]; { + case info.jmp: + if err := a.encodeJmpNOPPadding(buf, n); err != nil { + return err + } + case info.onNextJmp: + if err := a.encodeOnNextJmpNOPPAdding(buf, n); err != nil { + return err + } } // After the padding, we can finalize the offset of this instruction in the binary. - n.offsetInBinary = uint64(a.buf.Len()) + n.offsetInBinary = uint64(buf.Len()) - if err = a.encodeNode(n); err != nil { - return + if err := a.encodeNode(buf, n); err != nil { + return err } if n.forwardJumpOrigins != nil { - if err = a.resolveForwardRelativeJumps(n); err != nil { - err = fmt.Errorf("invalid relative forward jumps: %w", err) - break + if err := a.resolveForwardRelativeJumps(buf, n); err != nil { + return fmt.Errorf("invalid relative forward jumps: %w", err) } } - a.maybeFlushConstants(n.next == nil) + a.maybeFlushConstants(buf, n.next == nil) } - return + return nil } var nopPaddingInfo = [instructionEnd]struct { @@ -529,55 +556,52 @@ var nopPaddingInfo = [instructionEnd]struct { DECQ: {onNextJmp: true}, } -// maybeNOPPadding maybe appends NOP instructions before the node `n`. -// This is necessary to avoid Intel's jump erratum: -// https://www.intel.com/content/dam/support/us/en/documents/processors/mitigations-jump-conditional-code-erratum.pdf -func (a *AssemblerImpl) maybeNOPPadding(n *nodeImpl) (err error) { - var instructionLen int32 - // See in Section 2.1 in for when we have to pad NOP. - // https://www.intel.com/content/dam/support/us/en/documents/processors/mitigations-jump-conditional-code-erratum.pdf - if info := nopPaddingInfo[n.instruction]; info.jmp { - // In order to know the instruction length before writing into the binary, - // we try encoding it. - prevLen := a.buf.Len() - - // Assign the temporary offset which may or may not be correct depending on the padding decision. - n.offsetInBinary = uint64(prevLen) - - // Encode the node and get the instruction length. - if err = a.encodeNode(n); err != nil { - return - } - instructionLen = int32(a.buf.Len() - prevLen) +func (a *AssemblerImpl) encodeJmpNOPPadding(buf asm.Buffer, n *nodeImpl) error { + // In order to know the instruction length before writing into the binary, + // we try encoding it. + prevLen := buf.Len() - // Revert the written bytes. - a.buf.Truncate(prevLen) - } else if info.onNextJmp { - instructionLen, err = a.fusedInstructionLength(n) - if err != nil { - return err - } - } else { - return + // Assign the temporary offset which may or may not be correct depending on the padding decision. + n.offsetInBinary = uint64(prevLen) + + // Encode the node and get the instruction length. + if err := a.encodeNode(buf, n); err != nil { + return err } + instructionLen := int32(buf.Len() - prevLen) + // Revert the written bytes. + buf.Truncate(prevLen) + return a.encodeNOPPadding(buf, instructionLen) +} + +func (a *AssemblerImpl) encodeOnNextJmpNOPPAdding(buf asm.Buffer, n *nodeImpl) error { + instructionLen, err := a.fusedInstructionLength(buf, n) + if err != nil { + return err + } + return a.encodeNOPPadding(buf, instructionLen) +} + +// encodeNOPPadding maybe appends NOP instructions before the node `n`. +// This is necessary to avoid Intel's jump erratum: +// https://www.intel.com/content/dam/support/us/en/documents/processors/mitigations-jump-conditional-code-erratum.pdf +func (a *AssemblerImpl) encodeNOPPadding(buf asm.Buffer, instructionLen int32) error { const boundaryInBytes int32 = 32 const mask = boundaryInBytes - 1 - var padNum int - currentPos := int32(a.buf.Len()) + currentPos := int32(buf.Len()) if used := currentPos & mask; used+instructionLen >= boundaryInBytes { padNum = int(boundaryInBytes - used) } - - a.padNOP(padNum) - return + a.padNOP(buf, padNum) + return nil } // fusedInstructionLength returns the length of "macro fused instruction" if the // instruction sequence starting from `n` can be fused by processor. Otherwise, // returns zero. -func (a *AssemblerImpl) fusedInstructionLength(n *nodeImpl) (ret int32, err error) { +func (a *AssemblerImpl) fusedInstructionLength(buf asm.Buffer, n *nodeImpl) (ret int32, err error) { // Find the next non-NOP instruction. next := n.next for ; next != nil && next.instruction == NOP; next = next.next { @@ -625,20 +649,20 @@ func (a *AssemblerImpl) fusedInstructionLength(n *nodeImpl) (ret int32, err erro // Now the instruction is ensured to be fused by the processor. // In order to know the fused instruction length before writing into the binary, // we try encoding it. - savedLen := uint64(a.buf.Len()) + savedLen := uint64(buf.Len()) // Encode the nodes into the buffer. - if err = a.encodeNode(n); err != nil { + if err = a.encodeNode(buf, n); err != nil { return } - if err = a.encodeNode(next); err != nil { + if err = a.encodeNode(buf, next); err != nil { return } - ret = int32(uint64(a.buf.Len()) - savedLen) + ret = int32(uint64(buf.Len()) - savedLen) // Revert the written bytes. - a.buf.Truncate(int(savedLen)) + buf.Truncate(int(savedLen)) return } @@ -658,13 +682,13 @@ var nopOpcodes = [][11]byte{ {0x66, 0x66, 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, } -func (a *AssemblerImpl) padNOP(num int) { +func (a *AssemblerImpl) padNOP(buf asm.Buffer, num int) { for num > 0 { singleNopNum := num if singleNopNum > len(nopOpcodes) { singleNopNum = len(nopOpcodes) } - a.buf.Write(nopOpcodes[singleNopNum-1][:singleNopNum]) + buf.AppendBytes(nopOpcodes[singleNopNum-1][:singleNopNum]) num -= singleNopNum } } @@ -898,37 +922,55 @@ func errorEncodingUnsupported(n *nodeImpl) error { return fmt.Errorf("%s is unsupported for %s type", InstructionName(n.instruction), n.types) } -func (a *AssemblerImpl) encodeNoneToNone(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeNoneToNone(buf asm.Buffer, n *nodeImpl) (err error) { + // Throughout the encoding methods, we use this pair of base offset and + // code buffer to write instructions. + // + // The code buffer is allocated at the end of the current buffer to a size + // large enough to hold all the bytes that may be written by the method. + // + // We use Go's append builtin to write to the buffer because it allows the + // compiler to generate much better code than if we made calls to write + // methods to mutate an encapsulated byte slice. + // + // At the end of the method, we truncate the buffer size back to the base + // plus the length of the code buffer so the end of the buffer points right + // after the last byte that was written. + base := buf.Len() + code := buf.Append(4)[:0] + switch n.instruction { case CDQ: // https://www.felixcloutier.com/x86/cwd:cdq:cqo - err = a.buf.WriteByte(0x99) + code = append(code, 0x99) case CQO: // https://www.felixcloutier.com/x86/cwd:cdq:cqo - _, err = a.buf.Write([]byte{rexPrefixW, 0x99}) + code = append(code, rexPrefixW, 0x99) case NOP: // Simply optimize out the NOP instructions. case RET: // https://www.felixcloutier.com/x86/ret - err = a.buf.WriteByte(0xc3) + code = append(code, 0xc3) case UD2: // https://mudongliang.github.io/x86/html/file_module_x86_id_318.html - _, err = a.buf.Write([]byte{0x0f, 0x0b}) + code = append(code, 0x0f, 0x0b) case REPMOVSQ: - _, err = a.buf.Write([]byte{0xf3, rexPrefixW, 0xa5}) + code = append(code, 0xf3, rexPrefixW, 0xa5) case REPSTOSQ: - _, err = a.buf.Write([]byte{0xf3, rexPrefixW, 0xab}) + code = append(code, 0xf3, rexPrefixW, 0xab) case STD: - _, err = a.buf.Write([]byte{0xfd}) + code = append(code, 0xfd) case CLD: - _, err = a.buf.Write([]byte{0xfc}) + code = append(code, 0xfc) default: err = errorEncodingUnsupported(n) } + + buf.Truncate(base + len(code)) return } -func (a *AssemblerImpl) encodeNoneToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeNoneToRegister(buf asm.Buffer, n *nodeImpl) (err error) { regBits, prefix := register3bits(n.dstReg, registerSpecifierPositionModRMFieldRM) // https://wiki.osdev.org/X86-64_Instruction_Encoding#ModR.2FM @@ -954,69 +996,72 @@ func (a *AssemblerImpl) encodeNoneToRegister(n *nodeImpl) (err error) { } } + base := buf.Len() + code := buf.Append(4)[:0] + if prefix != rexPrefixNone { // https://wiki.osdev.org/X86-64_Instruction_Encoding#Encoding - if err = a.buf.WriteByte(prefix); err != nil { - return - } + code = append(code, prefix) } switch n.instruction { case JMP: // https://www.felixcloutier.com/x86/jmp - _, err = a.buf.Write([]byte{0xff, modRM}) + code = append(code, 0xff, modRM) case SETCC: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x93, modRM}) + code = append(code, 0x0f, 0x93, modRM) case SETCS: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x92, modRM}) + code = append(code, 0x0f, 0x92, modRM) case SETEQ: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x94, modRM}) + code = append(code, 0x0f, 0x94, modRM) case SETGE: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x9d, modRM}) + code = append(code, 0x0f, 0x9d, modRM) case SETGT: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x9f, modRM}) + code = append(code, 0x0f, 0x9f, modRM) case SETHI: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x97, modRM}) + code = append(code, 0x0f, 0x97, modRM) case SETLE: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x9e, modRM}) + code = append(code, 0x0f, 0x9e, modRM) case SETLS: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x96, modRM}) + code = append(code, 0x0f, 0x96, modRM) case SETLT: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x9c, modRM}) + code = append(code, 0x0f, 0x9c, modRM) case SETNE: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x95, modRM}) + code = append(code, 0x0f, 0x95, modRM) case SETPC: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x9b, modRM}) + code = append(code, 0x0f, 0x9b, modRM) case SETPS: // https://www.felixcloutier.com/x86/setcc - _, err = a.buf.Write([]byte{0x0f, 0x9a, modRM}) + code = append(code, 0x0f, 0x9a, modRM) case NEGQ: // https://www.felixcloutier.com/x86/neg - _, err = a.buf.Write([]byte{0xf7, modRM}) + code = append(code, 0xf7, modRM) case INCQ: // https://www.felixcloutier.com/x86/inc - _, err = a.buf.Write([]byte{0xff, modRM}) + code = append(code, 0xff, modRM) case DECQ: // https://www.felixcloutier.com/x86/dec - _, err = a.buf.Write([]byte{0xff, modRM}) + code = append(code, 0xff, modRM) default: err = errorEncodingUnsupported(n) } + + buf.Truncate(base + len(code)) return } -func (a *AssemblerImpl) encodeNoneToMemory(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeNoneToMemory(buf asm.Buffer, n *nodeImpl) (err error) { rexPrefix, modRM, sbi, sbiExist, displacementWidth, err := n.getMemoryLocation(true) if err != nil { return err @@ -1041,19 +1086,24 @@ func (a *AssemblerImpl) encodeNoneToMemory(n *nodeImpl) (err error) { return errorEncodingUnsupported(n) } + base := buf.Len() + code := buf.Append(12)[:0] + if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write([]byte{opcode, modRM}) + code = append(code, opcode, modRM) if sbiExist { - a.buf.WriteByte(sbi) + code = append(code, sbi) } if displacementWidth != 0 { - a.writeConst(n.dstConst, displacementWidth) + code = appendConst(code, n.dstConst, displacementWidth) } + + buf.Truncate(base + len(code)) return } @@ -1087,7 +1137,7 @@ var relativeJumpOpcodes = [...]relativeJumpOpcode{ JMP: {short: []byte{0xeb}, long: []byte{0xe9}}, } -func (a *AssemblerImpl) resolveForwardRelativeJumps(target *nodeImpl) (err error) { +func (a *AssemblerImpl) resolveForwardRelativeJumps(buf asm.Buffer, target *nodeImpl) (err error) { offsetInBinary := int64(target.OffsetInBinary()) origin := target.forwardJumpOrigins for ; origin != nil; origin = origin.forwardJumpOrigins { @@ -1107,19 +1157,19 @@ func (a *AssemblerImpl) resolveForwardRelativeJumps(target *nodeImpl) (err error // will always enter the "long jump offset encoding" block below origin.flag ^= nodeFlagShortForwardJump } else { - a.buf.Bytes()[origin.OffsetInBinary()+uint64(instructionLen)-1] = byte(offset) + buf.Bytes()[origin.OffsetInBinary()+uint64(instructionLen)-1] = byte(offset) } } else { // long jump offset encoding. if offset > math.MaxInt32 { return fmt.Errorf("too large jump offset %d for encoding %s", offset, InstructionName(origin.instruction)) } - binary.LittleEndian.PutUint32(a.buf.Bytes()[origin.OffsetInBinary()+uint64(instructionLen)-4:], uint32(offset)) + binary.LittleEndian.PutUint32(buf.Bytes()[origin.OffsetInBinary()+uint64(instructionLen)-4:], uint32(offset)) } } return nil } -func (a *AssemblerImpl) encodeRelativeJump(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRelativeJump(buf asm.Buffer, n *nodeImpl) (err error) { if n.jumpTarget == nil { err = fmt.Errorf("jump target must not be nil for relative %s", InstructionName(n.instruction)) return @@ -1144,17 +1194,22 @@ func (a *AssemblerImpl) encodeRelativeJump(n *nodeImpl) (err error) { return fmt.Errorf("too large jump offset %d for encoding %s", offsetOfEIP, InstructionName(n.instruction)) } + base := buf.Len() + code := buf.Append(6)[:0] + if isShortJump { - a.buf.Write(op.short) - a.writeConst(offsetOfEIP, 8) + code = append(code, op.short...) + code = append(code, byte(offsetOfEIP)) } else { - a.buf.Write(op.long) - a.writeConst(offsetOfEIP, 32) + code = append(code, op.long...) + code = appendUint32(code, uint32(offsetOfEIP)) } + + buf.Truncate(base + len(code)) return } -func (a *AssemblerImpl) encodeRegisterToNone(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRegisterToNone(buf asm.Buffer, n *nodeImpl) (err error) { regBits, prefix := register3bits(n.srcReg, registerSpecifierPositionModRMFieldRM) // https://wiki.osdev.org/X86-64_Instruction_Encoding#ModR.2FM @@ -1194,11 +1249,16 @@ func (a *AssemblerImpl) encodeRegisterToNone(n *nodeImpl) (err error) { err = errorEncodingUnsupported(n) } + base := buf.Len() + code := buf.Append(3)[:0] + if prefix != rexPrefixNone { - a.buf.WriteByte(prefix) + code = append(code, prefix) } - a.buf.Write([]byte{opcode, modRM}) + code = append(code, opcode, modRM) + + buf.Truncate(base + len(code)) return } @@ -1602,9 +1662,11 @@ var registerToRegisterShiftOpcode = [instructionEnd]*struct { SHRQ: {opcode: []byte{0xd3}, modRMExtension: 0b00_101_000, rPrefix: rexPrefixW}, } -func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRegisterToRegister(buf asm.Buffer, n *nodeImpl) (err error) { // Alias for readability inst := n.instruction + base := buf.Len() + code := buf.Append(8)[:0] switch inst { case MOVL, MOVQ: @@ -1639,16 +1701,15 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { if inst == MOVQ && !f2f { rexPrefix |= rexPrefixW } - if mandatoryPrefix != 0 { - a.buf.WriteByte(mandatoryPrefix) + code = append(code, mandatoryPrefix) } - if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write(opcode) - a.buf.WriteByte(modRM) + code = append(code, opcode...) + code = append(code, modRM) + buf.Truncate(base + len(code)) return nil } @@ -1666,39 +1727,40 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { } if op.mandatoryPrefix != 0 { - a.buf.WriteByte(op.mandatoryPrefix) + code = append(code, op.mandatoryPrefix) } if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write(op.opcode) - - a.buf.WriteByte(modRM) + code = append(code, op.opcode...) + code = append(code, modRM) if op.needArg { - a.writeConst(int64(n.arg), 8) + code = append(code, n.arg) } - return nil } else if op := registerToRegisterShiftOpcode[inst]; op != nil { reg3bits, rexPrefix := register3bits(n.dstReg, registerSpecifierPositionModRMFieldRM) rexPrefix |= op.rPrefix if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } // https://wiki.osdev.org/X86-64_Instruction_Encoding#ModR.2FM modRM := 0b11_000_000 | (op.modRMExtension) | reg3bits - a.buf.Write(op.opcode) - a.buf.WriteByte(modRM) - return nil + code = append(code, op.opcode...) + code = append(code, modRM) + } else { + return errorEncodingUnsupported(n) } - return errorEncodingUnsupported(n) + + buf.Truncate(base + len(code)) + return nil } -func (a *AssemblerImpl) encodeRegisterToMemory(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRegisterToMemory(buf asm.Buffer, n *nodeImpl) (err error) { rexPrefix, modRM, sbi, sbiExist, displacementWidth, err := n.getMemoryLocation(true) if err != nil { return err @@ -1837,57 +1899,64 @@ func (a *AssemblerImpl) encodeRegisterToMemory(n *nodeImpl) (err error) { } } + base := buf.Len() + code := buf.Append(16)[:0] + if mandatoryPrefix != 0 { // https://wiki.osdev.org/X86-64_Instruction_Encoding#Mandatory_prefix - a.buf.WriteByte(mandatoryPrefix) + code = append(code, mandatoryPrefix) } if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write(opcode) - - a.buf.WriteByte(modRM) + code = append(code, opcode...) + code = append(code, modRM) if sbiExist { - a.buf.WriteByte(sbi) + code = append(code, sbi) } if displacementWidth != 0 { - a.writeConst(n.dstConst, displacementWidth) + code = appendConst(code, n.dstConst, displacementWidth) } if needArg { - a.writeConst(int64(n.arg), 8) + code = append(code, n.arg) } + + buf.Truncate(base + len(code)) return } -func (a *AssemblerImpl) encodeRegisterToConst(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRegisterToConst(buf asm.Buffer, n *nodeImpl) (err error) { regBits, prefix := register3bits(n.srcReg, registerSpecifierPositionModRMFieldRM) + base := buf.Len() + code := buf.Append(10)[:0] + switch n.instruction { case CMPL, CMPQ: if n.instruction == CMPQ { prefix |= rexPrefixW } if prefix != rexPrefixNone { - a.buf.WriteByte(prefix) + code = append(code, prefix) } is8bitConst := fitInSigned8bit(n.dstConst) // https://www.felixcloutier.com/x86/cmp if n.srcReg == RegAX && !is8bitConst { - a.buf.Write([]byte{0x3d}) + code = append(code, 0x3d) } else { // https://wiki.osdev.org/X86-64_Instruction_Encoding#ModR.2FM modRM := 0b11_000_000 | // Specifying that opeand is register. 0b00_111_000 | // CMP with immediate needs "/7" extension. regBits if is8bitConst { - a.buf.Write([]byte{0x83, modRM}) + code = append(code, 0x83, modRM) } else { - a.buf.Write([]byte{0x81, modRM}) + code = append(code, 0x81, modRM) } } default: @@ -1895,10 +1964,12 @@ func (a *AssemblerImpl) encodeRegisterToConst(n *nodeImpl) (err error) { } if fitInSigned8bit(n.dstConst) { - a.writeConst(n.dstConst, 8) + code = append(code, byte(n.dstConst)) } else { - a.writeConst(n.dstConst, 32) + code = appendUint32(code, uint32(n.dstConst)) } + + buf.Truncate(base + len(code)) return } @@ -1925,7 +1996,7 @@ func (a *AssemblerImpl) finalizeReadInstructionAddressNode(code []byte, n *nodeI return nil } -func (a *AssemblerImpl) encodeReadInstructionAddress(n *nodeImpl) error { +func (a *AssemblerImpl) encodeReadInstructionAddress(buf asm.Buffer, n *nodeImpl) error { dstReg3Bits, rexPrefix := register3bits(n.dstReg, registerSpecifierPositionModRMFieldReg) a.readInstructionAddressNodes = append(a.readInstructionAddressNodes, n) @@ -1938,14 +2009,17 @@ func (a *AssemblerImpl) encodeReadInstructionAddress(n *nodeImpl) error { modRM := 0b00_000_101 | // Indicate "LEAQ [RIP + 32bit displacement], dstReg" encoding. (dstReg3Bits << 3) // Place the dstReg on ModRM:reg. - a.buf.Write([]byte{rexPrefix, opcode, modRM}) - a.writeConst(int64(0), 32) // Preserve + code := buf.Append(7) + code[0] = rexPrefix + code[1] = opcode + code[2] = modRM + binary.LittleEndian.PutUint32(code[3:], 0) // Preserve return nil } -func (a *AssemblerImpl) encodeMemoryToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeMemoryToRegister(buf asm.Buffer, n *nodeImpl) (err error) { if n.instruction == LEAQ && n.readInstructionAddressBeforeTargetInstruction != NONE { - return a.encodeReadInstructionAddress(n) + return a.encodeReadInstructionAddress(buf, n) } rexPrefix, modRM, sbi, sbiExist, displacementWidth, err := n.getMemoryLocation(false) @@ -1960,6 +2034,7 @@ func (a *AssemblerImpl) encodeMemoryToRegister(n *nodeImpl) (err error) { var mandatoryPrefix byte var opcode []byte var needArg bool + switch n.instruction { case ADDL: // https://www.felixcloutier.com/x86/add @@ -2100,34 +2175,38 @@ func (a *AssemblerImpl) encodeMemoryToRegister(n *nodeImpl) (err error) { return errorEncodingUnsupported(n) } + base := buf.Len() + code := buf.Append(16)[:0] + if mandatoryPrefix != 0 { // https://wiki.osdev.org/X86-64_Instruction_Encoding#Mandatory_prefix - a.buf.WriteByte(mandatoryPrefix) + code = append(code, mandatoryPrefix) } if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write(opcode) - - a.buf.WriteByte(modRM) + code = append(code, opcode...) + code = append(code, modRM) if sbiExist { - a.buf.WriteByte(sbi) + code = append(code, sbi) } if displacementWidth != 0 { - a.writeConst(n.srcConst, displacementWidth) + code = appendConst(code, n.srcConst, displacementWidth) } if needArg { - a.writeConst(int64(n.arg), 8) + code = append(code, n.arg) } + + buf.Truncate(base + len(code)) return } -func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeConstToRegister(buf asm.Buffer, n *nodeImpl) (err error) { regBits, rexPrefix := register3bits(n.dstReg, registerSpecifierPositionModRMFieldRM) isFloatReg := isVectorRegister(n.dstReg) @@ -2153,84 +2232,87 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { return fmt.Errorf("constant must fit in signed 8-bit integer for %s, but got %d", InstructionName(n.instruction), n.srcConst) } + base := buf.Len() + code := buf.Append(32)[:0] + isSigned8bitConst := fitInSigned8bit(n.srcConst) switch inst := n.instruction; inst { case ADDQ: // https://www.felixcloutier.com/x86/add rexPrefix |= rexPrefixW if n.dstReg == RegAX && !isSigned8bitConst { - a.buf.Write([]byte{rexPrefix, 0x05}) + code = append(code, rexPrefix, 0x05) } else { modRM := 0b11_000_000 | // Specifying that opeand is register. regBits if isSigned8bitConst { - a.buf.Write([]byte{rexPrefix, 0x83, modRM}) + code = append(code, rexPrefix, 0x83, modRM) } else { - a.buf.Write([]byte{rexPrefix, 0x81, modRM}) + code = append(code, rexPrefix, 0x81, modRM) } } if isSigned8bitConst { - a.writeConst(n.srcConst, 8) + code = append(code, byte(n.srcConst)) } else { - a.writeConst(n.srcConst, 32) + code = appendUint32(code, uint32(n.srcConst)) } case ANDQ: // https://www.felixcloutier.com/x86/and rexPrefix |= rexPrefixW if n.dstReg == RegAX && !isSigned8bitConst { - a.buf.Write([]byte{rexPrefix, 0x25}) + code = append(code, rexPrefix, 0x25) } else { modRM := 0b11_000_000 | // Specifying that opeand is register. 0b00_100_000 | // AND with immediate needs "/4" extension. regBits if isSigned8bitConst { - a.buf.Write([]byte{rexPrefix, 0x83, modRM}) + code = append(code, rexPrefix, 0x83, modRM) } else { - a.buf.Write([]byte{rexPrefix, 0x81, modRM}) + code = append(code, rexPrefix, 0x81, modRM) } } if fitInSigned8bit(n.srcConst) { - a.writeConst(n.srcConst, 8) + code = append(code, byte(n.srcConst)) } else { - a.writeConst(n.srcConst, 32) + code = appendUint32(code, uint32(n.srcConst)) } case TESTQ: // https://www.felixcloutier.com/x86/test rexPrefix |= rexPrefixW if n.dstReg == RegAX && !isSigned8bitConst { - a.buf.Write([]byte{rexPrefix, 0xa9}) + code = append(code, rexPrefix, 0xa9) } else { modRM := 0b11_000_000 | // Specifying that operand is register regBits - a.buf.Write([]byte{rexPrefix, 0xf7, modRM}) + code = append(code, rexPrefix, 0xf7, modRM) } - a.writeConst(n.srcConst, 32) + code = appendUint32(code, uint32(n.srcConst)) case MOVL: // https://www.felixcloutier.com/x86/mov if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write([]byte{0xb8 | regBits}) - a.writeConst(n.srcConst, 32) + code = append(code, 0xb8|regBits) + code = appendUint32(code, uint32(n.srcConst)) case MOVQ: // https://www.felixcloutier.com/x86/mov if fitIn32bit(n.srcConst) { if n.srcConst > math.MaxInt32 { if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write([]byte{0xb8 | regBits}) + code = append(code, 0xb8|regBits) } else { rexPrefix |= rexPrefixW modRM := 0b11_000_000 | // Specifying that opeand is register. regBits - a.buf.Write([]byte{rexPrefix, 0xc7, modRM}) + code = append(code, rexPrefix, 0xc7, modRM) } - a.writeConst(n.srcConst, 32) + code = appendUint32(code, uint32(n.srcConst)) } else { rexPrefix |= rexPrefixW - a.buf.Write([]byte{rexPrefix, 0xb8 | regBits}) - a.writeConst(n.srcConst, 64) + code = append(code, rexPrefix, 0xb8|regBits) + code = appendUint64(code, uint64(n.srcConst)) } case SHLQ: // https://www.felixcloutier.com/x86/sal:sar:shl:shr @@ -2239,10 +2321,9 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { 0b00_100_000 | // SHL with immediate needs "/4" extension. regBits if n.srcConst == 1 { - a.buf.Write([]byte{rexPrefix, 0xd1, modRM}) + code = append(code, rexPrefix, 0xd1, modRM) } else { - a.buf.Write([]byte{rexPrefix, 0xc1, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, rexPrefix, 0xc1, modRM, byte(n.srcConst)) } case SHRQ: // https://www.felixcloutier.com/x86/sal:sar:shl:shr @@ -2251,10 +2332,9 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { 0b00_101_000 | // SHR with immediate needs "/5" extension. regBits if n.srcConst == 1 { - a.buf.Write([]byte{rexPrefix, 0xd1, modRM}) + code = append(code, rexPrefix, 0xd1, modRM) } else { - a.buf.Write([]byte{rexPrefix, 0xc1, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, rexPrefix, 0xc1, modRM, byte(n.srcConst)) } case PSLLD: // https://www.felixcloutier.com/x86/psllw:pslld:psllq @@ -2262,11 +2342,9 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { 0b00_110_000 | // PSLL with immediate needs "/6" extension. regBits if rexPrefix != rexPrefixNone { - a.buf.Write([]byte{0x66, rexPrefix, 0x0f, 0x72, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x66, rexPrefix, 0x0f, 0x72, modRM, byte(n.srcConst)) } else { - a.buf.Write([]byte{0x66, 0x0f, 0x72, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x66, 0x0f, 0x72, modRM, byte(n.srcConst)) } case PSLLQ: // https://www.felixcloutier.com/x86/psllw:pslld:psllq @@ -2274,11 +2352,9 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { 0b00_110_000 | // PSLL with immediate needs "/6" extension. regBits if rexPrefix != rexPrefixNone { - a.buf.Write([]byte{0x66, rexPrefix, 0x0f, 0x73, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x66, rexPrefix, 0x0f, 0x73, modRM, byte(n.srcConst)) } else { - a.buf.Write([]byte{0x66, 0x0f, 0x73, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x66, 0x0f, 0x73, modRM, byte(n.srcConst)) } case PSRLD: // https://www.felixcloutier.com/x86/psrlw:psrld:psrlq @@ -2287,11 +2363,9 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { 0b00_010_000 | // PSRL with immediate needs "/2" extension. regBits if rexPrefix != rexPrefixNone { - a.buf.Write([]byte{0x66, rexPrefix, 0x0f, 0x72, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x66, rexPrefix, 0x0f, 0x72, modRM, byte(n.srcConst)) } else { - a.buf.Write([]byte{0x66, 0x0f, 0x72, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x66, 0x0f, 0x72, modRM, byte(n.srcConst)) } case PSRLQ: // https://www.felixcloutier.com/x86/psrlw:psrld:psrlq @@ -2299,20 +2373,18 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { 0b00_010_000 | // PSRL with immediate needs "/2" extension. regBits if rexPrefix != rexPrefixNone { - a.buf.Write([]byte{0x66, rexPrefix, 0x0f, 0x73, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x66, rexPrefix, 0x0f, 0x73, modRM, byte(n.srcConst)) } else { - a.buf.Write([]byte{0x66, 0x0f, 0x73, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x66, 0x0f, 0x73, modRM, byte(n.srcConst)) } case PSRAW, PSRAD: // https://www.felixcloutier.com/x86/psraw:psrad:psraq modRM := 0b11_000_000 | // Specifying that operand is register. 0b00_100_000 | // PSRAW with immediate needs "/4" extension. regBits - a.buf.WriteByte(0x66) + code = append(code, 0x66) if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } var op byte @@ -2322,62 +2394,61 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { op = 0x71 } - a.buf.Write([]byte{0x0f, op, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x0f, op, modRM, byte(n.srcConst)) case PSRLW: // https://www.felixcloutier.com/x86/psrlw:psrld:psrlq modRM := 0b11_000_000 | // Specifying that operand is register. 0b00_010_000 | // PSRLW with immediate needs "/2" extension. regBits - a.buf.WriteByte(0x66) + code = append(code, 0x66) if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write([]byte{0x0f, 0x71, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x0f, 0x71, modRM, byte(n.srcConst)) case PSLLW: // https://www.felixcloutier.com/x86/psllw:pslld:psllq modRM := 0b11_000_000 | // Specifying that operand is register. 0b00_110_000 | // PSLLW with immediate needs "/6" extension. regBits - a.buf.WriteByte(0x66) + code = append(code, 0x66) if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write([]byte{0x0f, 0x71, modRM}) - a.writeConst(n.srcConst, 8) + code = append(code, 0x0f, 0x71, modRM, byte(n.srcConst)) case XORL, XORQ: // https://www.felixcloutier.com/x86/xor if inst == XORQ { rexPrefix |= rexPrefixW } if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } if n.dstReg == RegAX && !isSigned8bitConst { - a.buf.Write([]byte{0x35}) + code = append(code, 0x35) } else { modRM := 0b11_000_000 | // Specifying that opeand is register. 0b00_110_000 | // XOR with immediate needs "/6" extension. regBits if isSigned8bitConst { - a.buf.Write([]byte{0x83, modRM}) + code = append(code, 0x83, modRM) } else { - a.buf.Write([]byte{0x81, modRM}) + code = append(code, 0x81, modRM) } } if fitInSigned8bit(n.srcConst) { - a.writeConst(n.srcConst, 8) + code = append(code, byte(n.srcConst)) } else { - a.writeConst(n.srcConst, 32) + code = appendUint32(code, uint32(n.srcConst)) } default: err = errorEncodingUnsupported(n) } + + buf.Truncate(base + len(code)) return } -func (a *AssemblerImpl) encodeMemoryToConst(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeMemoryToConst(buf asm.Buffer, n *nodeImpl) (err error) { if !fitIn32bit(n.dstConst) { return fmt.Errorf("too large target const %d for %s", n.dstConst, InstructionName(n.instruction)) } @@ -2406,25 +2477,29 @@ func (a *AssemblerImpl) encodeMemoryToConst(n *nodeImpl) (err error) { return errorEncodingUnsupported(n) } + base := buf.Len() + code := buf.Append(20)[:0] + if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write([]byte{opcode, modRM}) + code = append(code, opcode, modRM) if sbiExist { - a.buf.WriteByte(sbi) + code = append(code, sbi) } if displacementWidth != 0 { - a.writeConst(n.srcConst, displacementWidth) + code = appendConst(code, n.srcConst, displacementWidth) } - a.writeConst(c, constWidth) + code = appendConst(code, c, constWidth) + buf.Truncate(base + len(code)) return } -func (a *AssemblerImpl) encodeConstToMemory(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeConstToMemory(buf asm.Buffer, n *nodeImpl) (err error) { rexPrefix, modRM, sbi, sbiExist, displacementWidth, err := n.getMemoryLocation(true) if err != nil { return err @@ -2456,44 +2531,49 @@ func (a *AssemblerImpl) encodeConstToMemory(n *nodeImpl) (err error) { return errorEncodingUnsupported(n) } + base := buf.Len() + code := buf.Append(20)[:0] + if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) + code = append(code, rexPrefix) } - a.buf.Write([]byte{opcode, modRM}) + code = append(code, opcode, modRM) if sbiExist { - a.buf.WriteByte(sbi) + code = append(code, sbi) } if displacementWidth != 0 { - a.writeConst(n.dstConst, displacementWidth) + code = appendConst(code, n.dstConst, displacementWidth) } - a.writeConst(c, constWidth) + code = appendConst(code, c, constWidth) + + buf.Truncate(base + len(code)) return } -func (a *AssemblerImpl) writeConst(v int64, length byte) { +func appendUint32(code []byte, v uint32) []byte { + b := [4]byte{} + binary.LittleEndian.PutUint32(b[:], uint32(v)) + return append(code, b[:]...) +} + +func appendUint64(code []byte, v uint64) []byte { + b := [8]byte{} + binary.LittleEndian.PutUint64(b[:], uint64(v)) + return append(code, b[:]...) +} + +func appendConst(code []byte, v int64, length byte) []byte { switch length { case 8: - a.buf.WriteByte(byte(int8(v))) + return append(code, byte(v)) case 32: - a.buf.WriteByte(byte(v)) - a.buf.WriteByte(byte(v >> 8)) - a.buf.WriteByte(byte(v >> 16)) - a.buf.WriteByte(byte(v >> 24)) - case 64: - a.buf.WriteByte(byte(v)) - a.buf.WriteByte(byte(v >> 8)) - a.buf.WriteByte(byte(v >> 16)) - a.buf.WriteByte(byte(v >> 24)) - a.buf.WriteByte(byte(v >> 32)) - a.buf.WriteByte(byte(v >> 40)) - a.buf.WriteByte(byte(v >> 48)) - a.buf.WriteByte(byte(v >> 56)) + return appendUint32(code, uint32(v)) default: - panic("BUG: length must be one of 8, 32 or 64") + return appendUint64(code, uint64(v)) } } diff --git a/vendor/github.com/tetratelabs/wazero/internal/asm/amd64/impl_staticconst.go b/vendor/github.com/tetratelabs/wazero/internal/asm/amd64/impl_staticconst.go index a7bb897ce..17a7f228c 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/asm/amd64/impl_staticconst.go +++ b/vendor/github.com/tetratelabs/wazero/internal/asm/amd64/impl_staticconst.go @@ -12,7 +12,7 @@ import ( // limit plus max(length(c) for c in the pool) so we must ensure that limit is less than 2^31. const defaultMaxDisplacementForConstantPool = 1 << 30 -func (a *AssemblerImpl) maybeFlushConstants(isEndOfFunction bool) { +func (a *AssemblerImpl) maybeFlushConstants(buf asm.Buffer, isEndOfFunction bool) { if a.pool.Empty() { return } @@ -21,7 +21,8 @@ func (a *AssemblerImpl) maybeFlushConstants(isEndOfFunction bool) { // If the distance between (the first use in binary) and (end of constant pool) can be larger // than MaxDisplacementForConstantPool, we have to emit the constant pool now, otherwise // a const might be unreachable by a literal move whose maximum offset is +- 2^31. - ((a.pool.PoolSizeInBytes+a.buf.Len())-int(a.pool.FirstUseOffsetInBinary)) >= a.MaxDisplacementForConstantPool { + ((a.pool.PoolSizeInBytes+buf.Len())-int(a.pool.FirstUseOffsetInBinary)) >= a.MaxDisplacementForConstantPool { + if !isEndOfFunction { // Adds the jump instruction to skip the constants if this is not the end of function. // @@ -29,25 +30,25 @@ func (a *AssemblerImpl) maybeFlushConstants(isEndOfFunction bool) { // small enough to fit all consts after the end of function. if a.pool.PoolSizeInBytes >= math.MaxInt8-2 { // long (near-relative) jump: https://www.felixcloutier.com/x86/jmp - a.buf.WriteByte(0xe9) - a.writeConst(int64(a.pool.PoolSizeInBytes), 32) + buf.AppendByte(0xe9) + buf.AppendUint32(uint32(a.pool.PoolSizeInBytes)) } else { // short jump: https://www.felixcloutier.com/x86/jmp - a.buf.WriteByte(0xeb) - a.writeConst(int64(a.pool.PoolSizeInBytes), 8) + buf.AppendByte(0xeb) + buf.AppendByte(byte(a.pool.PoolSizeInBytes)) } } for _, c := range a.pool.Consts { - c.SetOffsetInBinary(uint64(a.buf.Len())) - a.buf.Write(c.Raw) + c.SetOffsetInBinary(uint64(buf.Len())) + buf.AppendBytes(c.Raw) } a.pool.Reset() } } -func (a *AssemblerImpl) encodeRegisterToStaticConst(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRegisterToStaticConst(buf asm.Buffer, n *nodeImpl) (err error) { var opc []byte var rex byte switch n.instruction { @@ -58,7 +59,7 @@ func (a *AssemblerImpl) encodeRegisterToStaticConst(n *nodeImpl) (err error) { default: return errorEncodingUnsupported(n) } - return a.encodeStaticConstImpl(n, opc, rex, 0) + return a.encodeStaticConstImpl(buf, n, opc, rex, 0) } var staticConstToRegisterOpcodes = [...]struct { @@ -91,7 +92,7 @@ var staticConstToRegisterOpcodes = [...]struct { ADDQ: {opcode: []byte{0x03}, rex: rexPrefixW}, } -func (a *AssemblerImpl) encodeStaticConstToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeStaticConstToRegister(buf asm.Buffer, n *nodeImpl) (err error) { var opc []byte var rex, mandatoryPrefix byte info := staticConstToRegisterOpcodes[n.instruction] @@ -105,13 +106,13 @@ func (a *AssemblerImpl) encodeStaticConstToRegister(n *nodeImpl) (err error) { default: opc, rex, mandatoryPrefix = info.opcode, info.rex, info.mandatoryPrefix } - return a.encodeStaticConstImpl(n, opc, rex, mandatoryPrefix) + return a.encodeStaticConstImpl(buf, n, opc, rex, mandatoryPrefix) } // encodeStaticConstImpl encodes an instruction where mod:r/m points to the memory location of the static constant n.staticConst, // and the other operand is the register given at n.srcReg or n.dstReg. -func (a *AssemblerImpl) encodeStaticConstImpl(n *nodeImpl, opcode []byte, rex rexPrefix, mandatoryPrefix byte) (err error) { - a.pool.AddConst(n.staticConst, uint64(a.buf.Len())) +func (a *AssemblerImpl) encodeStaticConstImpl(buf asm.Buffer, n *nodeImpl, opcode []byte, rex rexPrefix, mandatoryPrefix byte) error { + a.pool.AddConst(n.staticConst, uint64(buf.Len())) var reg asm.Register if n.dstReg != asm.NilRegister { @@ -123,37 +124,34 @@ func (a *AssemblerImpl) encodeStaticConstImpl(n *nodeImpl, opcode []byte, rex re reg3Bits, rexPrefix := register3bits(reg, registerSpecifierPositionModRMFieldReg) rexPrefix |= rex - var instLen int + base := buf.Len() + code := buf.Append(len(opcode) + 7)[:0] + if mandatoryPrefix != 0 { - a.buf.WriteByte(mandatoryPrefix) - instLen++ + code = append(code, mandatoryPrefix) } if rexPrefix != rexPrefixNone { - a.buf.WriteByte(rexPrefix) - instLen++ + code = append(code, rexPrefix) } - a.buf.Write(opcode) - instLen += len(opcode) + code = append(code, opcode...) // https://wiki.osdev.org/X86-64_Instruction_Encoding#32.2F64-bit_addressing modRM := 0b00_000_101 | // Indicate "[RIP + 32bit displacement]" encoding. (reg3Bits << 3) // Place the reg on ModRM:reg. - a.buf.WriteByte(modRM) - instLen++ + code = append(code, modRM) // Preserve 4 bytes for displacement which will be filled after we finalize the location. - for i := 0; i < 4; i++ { - a.buf.WriteByte(0) - } - instLen += 4 + code = append(code, 0, 0, 0, 0) if !n.staticConstReferrersAdded { - a.staticConstReferrers = append(a.staticConstReferrers, staticConstReferrer{n: n, instLen: instLen}) + a.staticConstReferrers = append(a.staticConstReferrers, staticConstReferrer{n: n, instLen: len(code)}) n.staticConstReferrersAdded = true } - return + + buf.Truncate(base + len(code)) + return nil } // CompileStaticConstToRegister implements Assembler.CompileStaticConstToRegister. diff --git a/vendor/github.com/tetratelabs/wazero/internal/asm/arm64/consts.go b/vendor/github.com/tetratelabs/wazero/internal/asm/arm64/consts.go index 9df4d5f6a..47ed3cc2d 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/asm/arm64/consts.go +++ b/vendor/github.com/tetratelabs/wazero/internal/asm/arm64/consts.go @@ -506,6 +506,8 @@ const ( BCONDNE // BCONDVS is the B.cond instruction with CondVS. BCONDVS + // BCONDVC is the B.cond instruction with CondVC. + BCONDVC // CLZ is the CLZ instruction. https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/CLZ CLZ @@ -1073,6 +1075,8 @@ func InstructionName(i asm.Instruction) string { return "BCONDNE" case BCONDVS: return "BCONDVS" + case BCONDVC: + return "BCONDVC" case CLZ: return "CLZ" case CLZW: diff --git a/vendor/github.com/tetratelabs/wazero/internal/asm/arm64/impl.go b/vendor/github.com/tetratelabs/wazero/internal/asm/arm64/impl.go index b271dc00e..00bc0d995 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/asm/arm64/impl.go +++ b/vendor/github.com/tetratelabs/wazero/internal/asm/arm64/impl.go @@ -1,7 +1,6 @@ package arm64 import ( - "bytes" "encoding/binary" "errors" "fmt" @@ -10,27 +9,25 @@ import ( ) type nodeImpl struct { - instruction asm.Instruction - - offsetInBinaryField asm.NodeOffsetInBinary // Field suffix to dodge conflict with OffsetInBinary - // jumpTarget holds the target node in the linked for the jump-kind instruction. jumpTarget *nodeImpl // next holds the next node from this node in the assembled linked list. - next *nodeImpl + next *nodeImpl + staticConst *asm.StaticConst + instruction asm.Instruction types operandTypes srcReg, srcReg2, dstReg, dstReg2 asm.Register srcConst, dstConst asm.ConstantValue - vectorArrangement VectorArrangement - srcVectorIndex, dstVectorIndex VectorIndex + offsetInBinary asm.NodeOffsetInBinary // readInstructionAddressBeforeTargetInstruction holds the instruction right before the target of // read instruction address instruction. See asm.assemblerBase.CompileReadInstructionAddress. readInstructionAddressBeforeTargetInstruction asm.Instruction - staticConst *asm.StaticConst + vectorArrangement VectorArrangement + srcVectorIndex, dstVectorIndex VectorIndex } // AssignJumpTarget implements the same method as documented on asm.Node. @@ -50,7 +47,7 @@ func (n *nodeImpl) AssignSourceConstant(value asm.ConstantValue) { // OffsetInBinary implements the same method as documented on asm.Node. func (n *nodeImpl) OffsetInBinary() asm.NodeOffsetInBinary { - return n.offsetInBinaryField + return n.offsetInBinary } // String implements fmt.Stringer. @@ -201,51 +198,67 @@ const ( // AssemblerImpl implements Assembler. type AssemblerImpl struct { - nodePool *nodePool + root *nodeImpl + current *nodeImpl asm.BaseAssemblerImpl - root, current *nodeImpl - buf *bytes.Buffer - temporaryRegister asm.Register - nodeCount int - pool asm.StaticConstPool + relativeJumpNodes []*nodeImpl + adrInstructionNodes []*nodeImpl + nodePool nodePool + pool asm.StaticConstPool + nodeCount int + // MaxDisplacementForConstantPool is fixed to defaultMaxDisplacementForConstPool // but have it as a field here for testability. - MaxDisplacementForConstantPool int - relativeJumpNodes, adrInstructionNodes []*nodeImpl + MaxDisplacementForConstantPool int + + temporaryRegister asm.Register } -const nodePoolPageSize = 1000 +const nodePageSize = 128 + +type nodePage = [nodePageSize]nodeImpl // nodePool is the central allocation pool for nodeImpl used by a single AssemblerImpl. // This reduces the allocations over compilation by reusing AssemblerImpl. type nodePool struct { - pages [][nodePoolPageSize]nodeImpl - // page is the index on pages to allocate node on. - page, - // pos is the index on pages[.page] where the next allocation target exists. - pos int + pages []*nodePage + index int } // allocNode allocates a new nodeImpl for use from the pool. // This expands the pool if there is no space left for it. -func (n *nodePool) allocNode() (ret *nodeImpl) { - if n.pos == nodePoolPageSize { - if len(n.pages)-1 == n.page { - n.pages = append(n.pages, [nodePoolPageSize]nodeImpl{}) +func (n *nodePool) allocNode() *nodeImpl { + if n.index == nodePageSize { + if len(n.pages) == cap(n.pages) { + n.pages = append(n.pages, new(nodePage)) + } else { + i := len(n.pages) + n.pages = n.pages[:i+1] + if n.pages[i] == nil { + n.pages[i] = new(nodePage) + } } - n.page++ - n.pos = 0 + n.index = 0 } - ret = &n.pages[n.page][n.pos] - *ret = nodeImpl{} - n.pos++ - return + ret := &n.pages[len(n.pages)-1][n.index] + n.index++ + return ret +} + +func (n *nodePool) reset() { + for _, ns := range n.pages { + pages := ns[:] + for i := range pages { + pages[i] = nodeImpl{} + } + } + n.pages = n.pages[:0] + n.index = nodePageSize } func NewAssembler(temporaryRegister asm.Register) *AssemblerImpl { return &AssemblerImpl{ - nodePool: &nodePool{pages: [][nodePoolPageSize]nodeImpl{{}}}, - buf: bytes.NewBuffer(nil), + nodePool: nodePool{index: nodePageSize}, temporaryRegister: temporaryRegister, pool: asm.NewStaticConstPool(), MaxDisplacementForConstantPool: defaultMaxDisplacementForConstPool, @@ -267,12 +280,12 @@ func (a *AssemblerImpl) Add(n asm.Node) { // Reset implements asm.AssemblerBase. func (a *AssemblerImpl) Reset() { - buf, np, tmp := a.buf, a.nodePool, a.temporaryRegister pool := a.pool pool.Reset() *a = AssemblerImpl{ - buf: buf, nodePool: np, pool: pool, - temporaryRegister: tmp, + nodePool: a.nodePool, + pool: pool, + temporaryRegister: a.temporaryRegister, adrInstructionNodes: a.adrInstructionNodes[:0], relativeJumpNodes: a.relativeJumpNodes[:0], BaseAssemblerImpl: asm.BaseAssemblerImpl{ @@ -280,8 +293,7 @@ func (a *AssemblerImpl) Reset() { JumpTableEntries: a.JumpTableEntries[:0], }, } - a.nodePool.pos, a.nodePool.page = 0, 0 - a.buf.Reset() + a.nodePool.reset() } // newNode creates a new Node and appends it into the linked list. @@ -316,44 +328,44 @@ func (a *AssemblerImpl) addNode(node *nodeImpl) { } // Assemble implements asm.AssemblerBase -func (a *AssemblerImpl) Assemble() ([]byte, error) { +func (a *AssemblerImpl) Assemble(buf asm.Buffer) error { // arm64 has 32-bit fixed length instructions, // but note that some nodes are encoded as multiple instructions, // so the resulting binary might not be the size of count*8. - a.buf.Grow(a.nodeCount * 8) + buf.Grow(a.nodeCount * 8) for n := a.root; n != nil; n = n.next { - n.offsetInBinaryField = uint64(a.buf.Len()) - if err := a.encodeNode(n); err != nil { - return nil, err + n.offsetInBinary = uint64(buf.Len()) + if err := a.encodeNode(buf, n); err != nil { + return err } - a.maybeFlushConstPool(n.next == nil) + a.maybeFlushConstPool(buf, n.next == nil) } - code := a.buf.Bytes() + code := buf.Bytes() if err := a.FinalizeJumpTableEntry(code); err != nil { - return nil, err + return err } for _, rel := range a.relativeJumpNodes { if err := a.relativeBranchFinalize(code, rel); err != nil { - return nil, err + return err } } for _, adr := range a.adrInstructionNodes { if err := a.finalizeADRInstructionNode(code, adr); err != nil { - return nil, err + return err } } - return code, nil + return nil } const defaultMaxDisplacementForConstPool = (1 << 20) - 1 - 4 // -4 for unconditional branch to skip the constants. // maybeFlushConstPool flushes the constant pool if endOfBinary or a boundary condition was met. -func (a *AssemblerImpl) maybeFlushConstPool(endOfBinary bool) { +func (a *AssemblerImpl) maybeFlushConstPool(buf asm.Buffer, endOfBinary bool) { if a.pool.Empty() { return } @@ -364,7 +376,7 @@ func (a *AssemblerImpl) maybeFlushConstPool(endOfBinary bool) { // Also, if the offset between the first usage of the constant pool and // the first constant would exceed 2^20 -1(= 2MiB-1), which is the maximum offset // for LDR(literal)/ADR instruction, flush all the constants in the pool. - (a.buf.Len()+a.pool.PoolSizeInBytes-int(a.pool.FirstUseOffsetInBinary)) >= a.MaxDisplacementForConstantPool { + (buf.Len()+a.pool.PoolSizeInBytes-int(a.pool.FirstUseOffsetInBinary)) >= a.MaxDisplacementForConstantPool { // Before emitting consts, we have to add br instruction to skip the const pool. // https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/internal/obj/arm64/asm7.go#L1123-L1129 @@ -378,22 +390,22 @@ func (a *AssemblerImpl) maybeFlushConstPool(endOfBinary bool) { skipOffset = 0 } - a.buf.Write([]byte{ + buf.Append4Bytes( byte(skipOffset), - byte(skipOffset >> 8), - byte(skipOffset >> 16), + byte(skipOffset>>8), + byte(skipOffset>>16), 0x14, - }) + ) // Then adding the consts into the binary. for _, c := range a.pool.Consts { - c.SetOffsetInBinary(uint64(a.buf.Len())) - a.buf.Write(c.Raw) + c.SetOffsetInBinary(uint64(buf.Len())) + buf.AppendBytes(c.Raw) } // arm64 instructions are 4-byte (32-bit) aligned, so we must pad the zero consts here. - if pad := a.buf.Len() % 4; pad != 0 { - a.buf.Write(make([]byte, 4-pad)) + if pad := buf.Len() % 4; pad != 0 { + buf.AppendBytes(make([]byte, 4-pad)) } // After the flush, reset the constant pool. @@ -402,46 +414,46 @@ func (a *AssemblerImpl) maybeFlushConstPool(endOfBinary bool) { } // encodeNode encodes the given node into writer. -func (a *AssemblerImpl) encodeNode(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeNode(buf asm.Buffer, n *nodeImpl) (err error) { switch n.types { case operandTypesNoneToNone: - err = a.encodeNoneToNone(n) + err = a.encodeNoneToNone(buf, n) case operandTypesNoneToRegister: - err = a.encodeJumpToRegister(n) + err = a.encodeJumpToRegister(buf, n) case operandTypesNoneToBranch: - err = a.encodeRelativeBranch(n) + err = a.encodeRelativeBranch(buf, n) case operandTypesRegisterToRegister: - err = a.encodeRegisterToRegister(n) + err = a.encodeRegisterToRegister(buf, n) case operandTypesLeftShiftedRegisterToRegister: - err = a.encodeLeftShiftedRegisterToRegister(n) + err = a.encodeLeftShiftedRegisterToRegister(buf, n) case operandTypesTwoRegistersToRegister: - err = a.encodeTwoRegistersToRegister(n) + err = a.encodeTwoRegistersToRegister(buf, n) case operandTypesThreeRegistersToRegister: - err = a.encodeThreeRegistersToRegister(n) + err = a.encodeThreeRegistersToRegister(buf, n) case operandTypesTwoRegistersToNone: - err = a.encodeTwoRegistersToNone(n) + err = a.encodeTwoRegistersToNone(buf, n) case operandTypesRegisterAndConstToNone: - err = a.encodeRegisterAndConstToNone(n) + err = a.encodeRegisterAndConstToNone(buf, n) case operandTypesRegisterToMemory: - err = a.encodeRegisterToMemory(n) + err = a.encodeRegisterToMemory(buf, n) case operandTypesMemoryToRegister: - err = a.encodeMemoryToRegister(n) + err = a.encodeMemoryToRegister(buf, n) case operandTypesRegisterAndConstToRegister, operandTypesConstToRegister: - err = a.encodeConstToRegister(n) + err = a.encodeConstToRegister(buf, n) case operandTypesRegisterToVectorRegister: - err = a.encodeRegisterToVectorRegister(n) + err = a.encodeRegisterToVectorRegister(buf, n) case operandTypesVectorRegisterToRegister: - err = a.encodeVectorRegisterToRegister(n) + err = a.encodeVectorRegisterToRegister(buf, n) case operandTypesMemoryToVectorRegister: - err = a.encodeMemoryToVectorRegister(n) + err = a.encodeMemoryToVectorRegister(buf, n) case operandTypesVectorRegisterToMemory: - err = a.encodeVectorRegisterToMemory(n) + err = a.encodeVectorRegisterToMemory(buf, n) case operandTypesVectorRegisterToVectorRegister: - err = a.encodeVectorRegisterToVectorRegister(n) + err = a.encodeVectorRegisterToVectorRegister(buf, n) case operandTypesStaticConstToVectorRegister: - err = a.encodeStaticConstToVectorRegister(n) + err = a.encodeStaticConstToVectorRegister(buf, n) case operandTypesTwoVectorRegistersToVectorRegister: - err = a.encodeTwoVectorRegistersToVectorRegister(n) + err = a.encodeTwoVectorRegistersToVectorRegister(buf, n) default: err = fmt.Errorf("encoder undefined for [%s] operand type", n.types) } @@ -748,18 +760,19 @@ func errorEncodingUnsupported(n *nodeImpl) error { return fmt.Errorf("%s is unsupported for %s type", InstructionName(n.instruction), n.types) } -func (a *AssemblerImpl) encodeNoneToNone(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeNoneToNone(buf asm.Buffer, n *nodeImpl) error { switch n.instruction { case UDF: - a.buf.Write([]byte{0, 0, 0, 0}) + buf.Append4Bytes(0, 0, 0, 0) + return nil case NOP: + return nil default: - err = errorEncodingUnsupported(n) + return errorEncodingUnsupported(n) } - return } -func (a *AssemblerImpl) encodeJumpToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeJumpToRegister(buf asm.Buffer, n *nodeImpl) error { // "Unconditional branch (register)" in https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Branches--Exception-Generating-and-System-instructions var opc byte switch n.instruction { @@ -776,13 +789,13 @@ func (a *AssemblerImpl) encodeJumpToRegister(n *nodeImpl) (err error) { return fmt.Errorf("invalid destination register: %w", err) } - a.buf.Write([]byte{ - 0x00 | (regBits << 5), - 0x00 | (regBits >> 3), - 0b000_11111 | (opc << 5), - 0b1101011_0 | (opc >> 3), - }) - return + buf.Append4Bytes( + 0x00|(regBits<<5), + 0x00|(regBits>>3), + 0b000_11111|(opc<<5), + 0b1101011_0|(opc>>3), + ) + return err } func (a *AssemblerImpl) relativeBranchFinalize(code []byte, n *nodeImpl) error { @@ -819,6 +832,8 @@ func (a *AssemblerImpl) relativeBranchFinalize(code []byte, n *nodeImpl) error { condBits = 0b0001 case BCONDVS: condBits = 0b0110 + case BCONDVC: + condBits = 0b0111 } branchInstOffset := int64(n.OffsetInBinary()) @@ -857,9 +872,9 @@ func (a *AssemblerImpl) relativeBranchFinalize(code []byte, n *nodeImpl) error { return nil } -func (a *AssemblerImpl) encodeRelativeBranch(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRelativeBranch(buf asm.Buffer, n *nodeImpl) error { switch n.instruction { - case B, BCONDEQ, BCONDGE, BCONDGT, BCONDHI, BCONDHS, BCONDLE, BCONDLO, BCONDLS, BCONDLT, BCONDMI, BCONDNE, BCONDVS, BCONDPL: + case B, BCONDEQ, BCONDGE, BCONDGT, BCONDHI, BCONDHS, BCONDLE, BCONDLO, BCONDLS, BCONDLT, BCONDMI, BCONDNE, BCONDVS, BCONDVC, BCONDPL: default: return errorEncodingUnsupported(n) } @@ -869,9 +884,9 @@ func (a *AssemblerImpl) encodeRelativeBranch(n *nodeImpl) (err error) { } // At this point, we don't yet know that target's branch, so emit the placeholder (4 bytes). - a.buf.Write([]byte{0, 0, 0, 0}) + buf.Append4Bytes(0, 0, 0, 0) a.relativeJumpNodes = append(a.relativeJumpNodes, n) - return + return nil } func checkRegisterToRegisterType(src, dst asm.Register, requireSrcInt, requireDstInt bool) (err error) { @@ -888,7 +903,7 @@ func checkRegisterToRegisterType(src, dst asm.Register, requireSrcInt, requireDs return } -func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRegisterToRegister(buf asm.Buffer, n *nodeImpl) (err error) { switch inst := n.instruction; inst { case ADD, ADDW, SUB: if err = checkRegisterToRegisterType(n.srcReg, n.dstReg, true, true); err != nil { @@ -906,12 +921,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { } srcRegBits, dstRegBits := registerBits(n.srcReg), registerBits(n.dstReg) - a.buf.Write([]byte{ - (dstRegBits << 5) | dstRegBits, - dstRegBits >> 3, + buf.Append4Bytes( + (dstRegBits<<5)|dstRegBits, + dstRegBits>>3, srcRegBits, - (sfops << 5) | 0b01011, - }) + (sfops<<5)|0b01011, + ) case CLZ, CLZW, RBIT, RBITW: if err = checkRegisterToRegisterType(n.srcReg, n.dstReg, true, true); err != nil { return @@ -937,12 +952,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { } srcRegBits, dstRegBits := registerBits(n.srcReg), registerBits(n.dstReg) - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - opcode<<2 | (srcRegBits >> 3), + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + opcode<<2|(srcRegBits>>3), 0b110_00000, - (sf << 7) | 0b0_1011010, - }) + (sf<<7)|0b0_1011010, + ) case CSET: if !isConditionalRegister(n.srcReg) { return fmt.Errorf("CSET requires conditional register but got %s", RegisterName(n.srcReg)) @@ -994,12 +1009,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { } // https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/CSET--Conditional-Set--an-alias-of-CSINC-?lang=en - a.buf.Write([]byte{ - 0b111_00000 | dstRegBits, - (conditionalBits << 4) | 0b0000_0111, + buf.Append4Bytes( + 0b111_00000|dstRegBits, + (conditionalBits<<4)|0b0000_0111, 0b100_11111, 0b10011010, - }) + ) case FABSD, FABSS, FNEGD, FNEGS, FSQRTD, FSQRTS, FCVTSD, FCVTDS, FRINTMD, FRINTMS, FRINTND, FRINTNS, FRINTPD, FRINTPS, FRINTZD, FRINTZS: @@ -1045,12 +1060,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { case FRINTZS: opcode, tp = 0b001011, 0b00 } - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - (opcode << 7) | 0b0_10000_00 | (srcRegBits >> 3), - tp<<6 | 0b00_1_00000 | opcode>>1, + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + (opcode<<7)|0b0_10000_00|(srcRegBits>>3), + tp<<6|0b00_1_00000|opcode>>1, 0b0_00_11110, - }) + ) case FADDD, FADDS, FDIVS, FDIVD, FMAXD, FMAXS, FMIND, FMINS, FMULS, FMULD: if err = checkRegisterToRegisterType(n.srcReg, n.dstReg, false, false); err != nil { @@ -1085,12 +1100,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { opcode, tp = 0b0000, 0b01 } - a.buf.Write([]byte{ - (dstRegBits << 5) | dstRegBits, - opcode<<4 | 0b0000_10_00 | (dstRegBits >> 3), - tp<<6 | 0b00_1_00000 | srcRegBits, + buf.Append4Bytes( + (dstRegBits<<5)|dstRegBits, + opcode<<4|0b0000_10_00|(dstRegBits>>3), + tp<<6|0b00_1_00000|srcRegBits, 0b0001_1110, - }) + ) case FCVTZSD, FCVTZSDW, FCVTZSS, FCVTZSSW, FCVTZUD, FCVTZUDW, FCVTZUS, FCVTZUSW: if err = checkRegisterToRegisterType(n.srcReg, n.dstReg, false, true); err != nil { @@ -1121,12 +1136,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { sf, tp, opcode = 0b0, 0b00, 0b001 } - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - 0 | (srcRegBits >> 3), - tp<<6 | 0b00_1_11_000 | opcode, - sf<<7 | 0b0_0_0_11110, - }) + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + 0|(srcRegBits>>3), + tp<<6|0b00_1_11_000|opcode, + sf<<7|0b0_0_0_11110, + ) case FMOVD, FMOVS: isSrcInt, isDstInt := isIntRegister(n.srcReg), isIntRegister(n.dstReg) @@ -1141,34 +1156,34 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { if inst == FMOVD { tp = 0b01 } - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - 0b0_10000_00 | (srcRegBits >> 3), - tp<<6 | 0b00_1_00000, + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + 0b0_10000_00|(srcRegBits>>3), + tp<<6|0b00_1_00000, 0b000_11110, - }) + ) } else if isSrcInt && !isDstInt { // Int to float. var tp, sf byte if inst == FMOVD { tp, sf = 0b01, 0b1 } - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - srcRegBits >> 3, - tp<<6 | 0b00_1_00_111, - sf<<7 | 0b0_00_11110, - }) + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + srcRegBits>>3, + tp<<6|0b00_1_00_111, + sf<<7|0b0_00_11110, + ) } else { // Float to int. var tp, sf byte if inst == FMOVD { tp, sf = 0b01, 0b1 } - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - srcRegBits >> 3, - tp<<6 | 0b00_1_00_110, - sf<<7 | 0b0_00_11110, - }) + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + srcRegBits>>3, + tp<<6|0b00_1_00_110, + sf<<7|0b0_00_11110, + ) } case MOVD, MOVW: @@ -1180,12 +1195,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { if n.srcReg == RegSP || n.dstReg == RegSP { // Moving between stack pointers. // https://developer.arm.com/documentation/ddi0602/2021-12/Base-Instructions/MOV--to-from-SP---Move-between-register-and-stack-pointer--an-alias-of-ADD--immediate-- - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - srcRegBits >> 3, + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + srcRegBits>>3, 0x0, 0b1001_0001, - }) + ) return } @@ -1193,12 +1208,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { // If this is 64-bit mov from zero register, then we encode this as MOVK. // See "Move wide (immediate)" in // https://developer.arm.com/documentation/ddi0602/2021-06/Index-by-Encoding/Data-Processing----Immediate - a.buf.Write([]byte{ + buf.Append4Bytes( dstRegBits, 0x0, 0b1000_0000, 0b1_10_10010, - }) + ) } else { // MOV can be encoded as ORR (shifted register): "ORR Wd, WZR, Wm". // https://developer.arm.com/documentation/100069/0609/A64-General-Instructions/MOV--register- @@ -1206,12 +1221,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { if inst == MOVD { sf = 0b1 } - a.buf.Write([]byte{ - (zeroRegisterBits << 5) | dstRegBits, - zeroRegisterBits >> 3, - 0b000_00000 | srcRegBits, - sf<<7 | 0b0_01_01010, - }) + buf.Append4Bytes( + (zeroRegisterBits<<5)|dstRegBits, + zeroRegisterBits>>3, + 0b000_00000|srcRegBits, + sf<<7|0b0_01_01010, + ) } case MRS: @@ -1222,12 +1237,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { // For how to specify FPSR register, see "Accessing FPSR" in: // https://developer.arm.com/documentation/ddi0595/2021-12/AArch64-Registers/FPSR--Floating-point-Status-Register?lang=en dstRegBits := registerBits(n.dstReg) - a.buf.Write([]byte{ - 0b001<<5 | dstRegBits, - 0b0100<<4 | 0b0100, - 0b0011_0000 | 0b11<<3 | 0b011, + buf.Append4Bytes( + 0b001<<5|dstRegBits, + 0b0100<<4|0b0100, + 0b0011_0000|0b11<<3|0b011, 0b1101_0101, - }) + ) case MSR: if n.dstReg != RegFPSR { @@ -1237,12 +1252,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { // For how to specify FPSR register, see "Accessing FPSR" in: // https://developer.arm.com/documentation/ddi0595/2021-12/AArch64-Registers/FPSR--Floating-point-Status-Register?lang=en srcRegBits := registerBits(n.srcReg) - a.buf.Write([]byte{ - 0b001<<5 | srcRegBits, - 0b0100<<4 | 0b0100, - 0b0001_0000 | 0b11<<3 | 0b011, + buf.Append4Bytes( + 0b001<<5|srcRegBits, + 0b0100<<4|0b0100, + 0b0001_0000|0b11<<3|0b011, 0b1101_0101, - }) + ) case MUL, MULW: // Multiplications are encoded as MADD (zero register, src, dst), dst = zero + (src * dst) = src * dst. @@ -1259,12 +1274,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { srcRegBits, dstRegBits := registerBits(n.srcReg), registerBits(n.dstReg) - a.buf.Write([]byte{ - dstRegBits<<5 | dstRegBits, - zeroRegisterBits<<2 | dstRegBits>>3, + buf.Append4Bytes( + dstRegBits<<5|dstRegBits, + zeroRegisterBits<<2|dstRegBits>>3, srcRegBits, - sf<<7 | 0b11011, - }) + sf<<7|0b11011, + ) case NEG, NEGW: srcRegBits, dstRegBits := registerBits(n.srcReg), registerBits(n.dstReg) @@ -1280,12 +1295,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { sf = 0b1 } - a.buf.Write([]byte{ - (zeroRegisterBits << 5) | dstRegBits, - zeroRegisterBits >> 3, + buf.Append4Bytes( + (zeroRegisterBits<<5)|dstRegBits, + zeroRegisterBits>>3, srcRegBits, - sf<<7 | 0b0_10_00000 | 0b0_00_01011, - }) + sf<<7|0b0_10_00000|0b0_00_01011, + ) case SDIV, SDIVW, UDIV, UDIVW: srcRegBits, dstRegBits := registerBits(n.srcReg), registerBits(n.dstReg) @@ -1308,12 +1323,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { sf, opcode = 0b0, 0b000010 } - a.buf.Write([]byte{ - (dstRegBits << 5) | dstRegBits, - opcode<<2 | (dstRegBits >> 3), - 0b110_00000 | srcRegBits, - sf<<7 | 0b0_00_11010, - }) + buf.Append4Bytes( + (dstRegBits<<5)|dstRegBits, + opcode<<2|(dstRegBits>>3), + 0b110_00000|srcRegBits, + sf<<7|0b0_00_11010, + ) case SCVTFD, SCVTFWD, SCVTFS, SCVTFWS, UCVTFD, UCVTFS, UCVTFWD, UCVTFWS: srcRegBits, dstRegBits := registerBits(n.srcReg), registerBits(n.dstReg) @@ -1344,12 +1359,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { sf, tp, opcode = 0b0, 0b00, 0b011 } - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - srcRegBits >> 3, - tp<<6 | 0b00_1_00_000 | opcode, - sf<<7 | 0b0_0_0_11110, - }) + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + srcRegBits>>3, + tp<<6|0b00_1_00_000|opcode, + sf<<7|0b0_0_0_11110, + ) case SXTB, SXTBW, SXTH, SXTHW, SXTW: if err = checkRegisterToRegisterType(n.srcReg, n.dstReg, true, true); err != nil { @@ -1363,12 +1378,12 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { if inst == MOVD { sf = 0b1 } - a.buf.Write([]byte{ - (zeroRegisterBits << 5) | dstRegBits, - zeroRegisterBits >> 3, - 0b000_00000 | srcRegBits, - sf<<7 | 0b0_01_01010, - }) + buf.Append4Bytes( + (zeroRegisterBits<<5)|dstRegBits, + zeroRegisterBits>>3, + 0b000_00000|srcRegBits, + sf<<7|0b0_01_01010, + ) return } @@ -1393,19 +1408,19 @@ func (a *AssemblerImpl) encodeRegisterToRegister(n *nodeImpl) (err error) { n, sf, imms = 0b1, 0b1, 0x1f } - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - imms<<2 | (srcRegBits >> 3), - n << 6, - sf<<7 | opc<<5 | 0b10011, - }) + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + imms<<2|(srcRegBits>>3), + n<<6, + sf<<7|opc<<5|0b10011, + ) default: return errorEncodingUnsupported(n) } return } -func (a *AssemblerImpl) encodeLeftShiftedRegisterToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeLeftShiftedRegisterToRegister(buf asm.Buffer, n *nodeImpl) error { baseRegBits, err := intRegisterBits(n.srcReg) if err != nil { return err @@ -1427,19 +1442,19 @@ func (a *AssemblerImpl) encodeLeftShiftedRegisterToRegister(n *nodeImpl) (err er return fmt.Errorf("shift amount must fit in unsigned 6-bit integer (0-64) but got %d", n.srcConst) } shiftByte := byte(n.srcConst) - a.buf.Write([]byte{ - (baseRegBits << 5) | dstRegBits, - (shiftByte << 2) | (baseRegBits >> 3), - (logicalLeftShiftBits << 6) | shiftTargetRegBits, + buf.Append4Bytes( + (baseRegBits<<5)|dstRegBits, + (shiftByte<<2)|(baseRegBits>>3), + (logicalLeftShiftBits<<6)|shiftTargetRegBits, 0b1000_1011, - }) + ) + return err default: return errorEncodingUnsupported(n) } - return } -func (a *AssemblerImpl) encodeTwoRegistersToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeTwoRegistersToRegister(buf asm.Buffer, n *nodeImpl) (err error) { switch inst := n.instruction; inst { case AND, ANDW, ORR, ORRW, EOR, EORW: // See "Logical (shifted register)" in @@ -1460,12 +1475,12 @@ func (a *AssemblerImpl) encodeTwoRegistersToRegister(n *nodeImpl) (err error) { case EORW: sf, opc = 0b0, 0b10 } - a.buf.Write([]byte{ - (srcReg2Bits << 5) | dstRegBits, - srcReg2Bits >> 3, + buf.Append4Bytes( + (srcReg2Bits<<5)|dstRegBits, + srcReg2Bits>>3, srcRegBits, - sf<<7 | opc<<5 | 0b01010, - }) + sf<<7|opc<<5|0b01010, + ) case ASR, ASRW, LSL, LSLW, LSR, LSRW, ROR, RORW: // See "Data-processing (2 source)" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Register?lang=en @@ -1490,12 +1505,12 @@ func (a *AssemblerImpl) encodeTwoRegistersToRegister(n *nodeImpl) (err error) { case RORW: sf, opcode = 0b0, 0b001011 } - a.buf.Write([]byte{ - (srcReg2Bits << 5) | dstRegBits, - opcode<<2 | (srcReg2Bits >> 3), - 0b110_00000 | srcRegBits, - sf<<7 | 0b0_00_11010, - }) + buf.Append4Bytes( + (srcReg2Bits<<5)|dstRegBits, + opcode<<2|(srcReg2Bits>>3), + 0b110_00000|srcRegBits, + sf<<7|0b0_00_11010, + ) case SDIV, SDIVW, UDIV, UDIVW: srcRegBits, srcReg2Bits, dstRegBits := registerBits(n.srcReg), registerBits(n.srcReg2), registerBits(n.dstReg) @@ -1513,12 +1528,12 @@ func (a *AssemblerImpl) encodeTwoRegistersToRegister(n *nodeImpl) (err error) { sf, opcode = 0b0, 0b000010 } - a.buf.Write([]byte{ - (srcReg2Bits << 5) | dstRegBits, - opcode<<2 | (srcReg2Bits >> 3), - 0b110_00000 | srcRegBits, - sf<<7 | 0b0_00_11010, - }) + buf.Append4Bytes( + (srcReg2Bits<<5)|dstRegBits, + opcode<<2|(srcReg2Bits>>3), + 0b110_00000|srcRegBits, + sf<<7|0b0_00_11010, + ) case SUB, SUBW: srcRegBits, srcReg2Bits, dstRegBits := registerBits(n.srcReg), registerBits(n.srcReg2), registerBits(n.dstReg) @@ -1529,12 +1544,12 @@ func (a *AssemblerImpl) encodeTwoRegistersToRegister(n *nodeImpl) (err error) { sf = 0b1 } - a.buf.Write([]byte{ - (srcReg2Bits << 5) | dstRegBits, - srcReg2Bits >> 3, + buf.Append4Bytes( + (srcReg2Bits<<5)|dstRegBits, + srcReg2Bits>>3, srcRegBits, - sf<<7 | 0b0_10_01011, - }) + sf<<7|0b0_10_01011, + ) case FSUBD, FSUBS: srcRegBits, srcReg2Bits, dstRegBits := registerBits(n.srcReg), registerBits(n.srcReg2), registerBits(n.dstReg) @@ -1544,19 +1559,19 @@ func (a *AssemblerImpl) encodeTwoRegistersToRegister(n *nodeImpl) (err error) { if inst == FSUBD { tp = 0b01 } - a.buf.Write([]byte{ - (srcReg2Bits << 5) | dstRegBits, - 0b0011_10_00 | (srcReg2Bits >> 3), - tp<<6 | 0b00_1_00000 | srcRegBits, + buf.Append4Bytes( + (srcReg2Bits<<5)|dstRegBits, + 0b0011_10_00|(srcReg2Bits>>3), + tp<<6|0b00_1_00000|srcRegBits, 0b0_00_11110, - }) + ) default: return errorEncodingUnsupported(n) } return } -func (a *AssemblerImpl) encodeThreeRegistersToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeThreeRegistersToRegister(buf asm.Buffer, n *nodeImpl) error { switch n.instruction { case MSUB, MSUBW: // Dst = Src2 - (Src1 * Src3) @@ -1584,19 +1599,19 @@ func (a *AssemblerImpl) encodeThreeRegistersToRegister(n *nodeImpl) (err error) sf = 0b1 } - a.buf.Write([]byte{ - (src3RegBits << 5) | dstRegBits, - 0b1_0000000 | (src2RegBits << 2) | (src3RegBits >> 3), + buf.Append4Bytes( + (src3RegBits<<5)|dstRegBits, + 0b1_0000000|(src2RegBits<<2)|(src3RegBits>>3), src1RegBits, - sf<<7 | 0b00_11011, - }) + sf<<7|0b00_11011, + ) + return nil default: return errorEncodingUnsupported(n) } - return } -func (a *AssemblerImpl) encodeTwoRegistersToNone(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeTwoRegistersToNone(buf asm.Buffer, n *nodeImpl) error { switch n.instruction { case CMPW, CMP: // Compare on two registers is an alias for "SUBS (src1, src2) ZERO" @@ -1618,12 +1633,13 @@ func (a *AssemblerImpl) encodeTwoRegistersToNone(n *nodeImpl) (err error) { op = 0b011 } - a.buf.Write([]byte{ - (src2RegBits << 5) | zeroRegisterBits, - src2RegBits >> 3, + buf.Append4Bytes( + (src2RegBits<<5)|zeroRegisterBits, + src2RegBits>>3, src1RegBits, - 0b01011 | (op << 5), - }) + 0b01011|(op<<5), + ) + return nil case FCMPS, FCMPD: // "Floating-point compare" section in: // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en @@ -1640,19 +1656,19 @@ func (a *AssemblerImpl) encodeTwoRegistersToNone(n *nodeImpl) (err error) { if n.instruction == FCMPD { ftype = 0b01 } - a.buf.Write([]byte{ - src2RegBits << 5, - 0b001000_00 | (src2RegBits >> 3), - ftype<<6 | 0b1_00000 | src1RegBits, + buf.Append4Bytes( + src2RegBits<<5, + 0b001000_00|(src2RegBits>>3), + ftype<<6|0b1_00000|src1RegBits, 0b000_11110, - }) + ) + return nil default: return errorEncodingUnsupported(n) } - return } -func (a *AssemblerImpl) encodeRegisterAndConstToNone(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRegisterAndConstToNone(buf asm.Buffer, n *nodeImpl) error { if n.instruction != CMP { return errorEncodingUnsupported(n) } @@ -1669,13 +1685,13 @@ func (a *AssemblerImpl) encodeRegisterAndConstToNone(n *nodeImpl) (err error) { return err } - a.buf.Write([]byte{ - (srcRegBits << 5) | zeroRegisterBits, - (byte(n.srcConst) << 2) | (srcRegBits >> 3), - byte(n.srcConst >> 6), + buf.Append4Bytes( + (srcRegBits<<5)|zeroRegisterBits, + (byte(n.srcConst)<<2)|(srcRegBits>>3), + byte(n.srcConst>>6), 0b111_10001, - }) - return + ) + return nil } func fitInSigned9Bits(v int64) bool { @@ -1683,38 +1699,40 @@ func fitInSigned9Bits(v int64) bool { } func (a *AssemblerImpl) encodeLoadOrStoreWithRegisterOffset( - baseRegBits, offsetRegBits, targetRegBits byte, opcode, size, v byte, + buf asm.Buffer, baseRegBits, offsetRegBits, targetRegBits byte, opcode, size, v byte, ) { // See "Load/store register (register offset)". // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Loads-and-Stores?lang=en#ldst_regoff - a.buf.Write([]byte{ - (baseRegBits << 5) | targetRegBits, - 0b011_010_00 | (baseRegBits >> 3), - opcode<<6 | 0b00_1_00000 | offsetRegBits, - size<<6 | v<<2 | 0b00_111_0_00, - }) + buf.Append4Bytes( + (baseRegBits<<5)|targetRegBits, + 0b011_010_00|(baseRegBits>>3), + opcode<<6|0b00_1_00000|offsetRegBits, + size<<6|v<<2|0b00_111_0_00, + ) } // validateMemoryOffset validates the memory offset if the given offset can be encoded in the assembler. // In theory, offset can be any, but for simplicity of our homemade assembler, we limit the offset range // that can be encoded enough for supporting compiler. -func validateMemoryOffset(offset int64) (err error) { +func validateMemoryOffset(offset int64) error { if offset > 255 && offset%4 != 0 { // This is because we only have large offsets for load/store with Wasm value stack or reading type IDs, and its offset // is always multiplied by 4 or 8 (== the size of uint32 or uint64 == the type of wasm.FunctionTypeID or value stack in Go) - err = fmt.Errorf("large memory offset (>255) must be a multiple of 4 but got %d", offset) + return fmt.Errorf("large memory offset (>255) must be a multiple of 4 but got %d", offset) } else if offset < -256 { // 9-bit signed integer's minimum = 2^8. - err = fmt.Errorf("negative memory offset must be larget than or equal -256 but got %d", offset) + return fmt.Errorf("negative memory offset must be larget than or equal -256 but got %d", offset) } else if offset > 1<<31-1 { return fmt.Errorf("large memory offset must be less than %d but got %d", 1<<31-1, offset) + } else { + return nil } - return } // encodeLoadOrStoreWithConstOffset encodes load/store instructions with the constant offset. // // Note: Encoding strategy intentionally matches the Go assembler: https://go.dev/doc/asm func (a *AssemblerImpl) encodeLoadOrStoreWithConstOffset( + buf asm.Buffer, baseRegBits, targetRegBits byte, offset int64, opcode, size, v byte, @@ -1729,12 +1747,12 @@ func (a *AssemblerImpl) encodeLoadOrStoreWithConstOffset( // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Loads-and-Stores?lang=en#ldapstl_unscaled if offset < 0 || offset%datasize != 0 { // This case is encoded as one "unscaled signed store". - a.buf.Write([]byte{ - (baseRegBits << 5) | targetRegBits, - byte(offset<<4) | (baseRegBits >> 3), - opcode<<6 | (0b00_00_11111 & byte(offset>>4)), - size<<6 | v<<2 | 0b00_1_11_0_00, - }) + buf.Append4Bytes( + (baseRegBits<<5)|targetRegBits, + byte(offset<<4)|(baseRegBits>>3), + opcode<<6|(0b00_00_11111&byte(offset>>4)), + size<<6|v<<2|0b00_1_11_0_00, + ) return } } @@ -1744,12 +1762,12 @@ func (a *AssemblerImpl) encodeLoadOrStoreWithConstOffset( if offset%datasize == 0 && offset < (1<<12)<> 3), - opcode<<6 | 0b00_111111&byte(m>>6), - size<<6 | v<<2 | 0b00_1_11_0_01, - }) + buf.Append4Bytes( + (baseRegBits<<5)|targetRegBits, + (byte(m<<2))|(baseRegBits>>3), + opcode<<6|0b00_111111&byte(m>>6), + size<<6|v<<2|0b00_1_11_0_01, + ) return } @@ -1762,7 +1780,7 @@ func (a *AssemblerImpl) encodeLoadOrStoreWithConstOffset( // the const is not used but it is added into the const pool. c := asm.NewStaticConst(make([]byte, 4)) binary.LittleEndian.PutUint32(c.Raw, uint32(offset)) - a.pool.AddConst(c, uint64(a.buf.Len())) + a.pool.AddConst(c, uint64(buf.Len())) // https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/internal/obj/arm64/asm7.go#L3529-L3532 // If the offset is within 24-bits, we can load it with two ADD instructions. @@ -1773,34 +1791,34 @@ func (a *AssemblerImpl) encodeLoadOrStoreWithConstOffset( hi >>= 12 // https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/internal/obj/arm64/asm7.go#L3534-L3535 - a.buf.Write([]byte{ - (baseRegBits << 5) | tmpRegBits, - (byte(hi) << 2) | (baseRegBits >> 3), - 0b01<<6 /* shift by 12 */ | byte(hi>>6), - sfops<<5 | 0b10001, - }) - - a.buf.Write([]byte{ - (tmpRegBits << 5) | targetRegBits, - (byte(m << 2)) | (tmpRegBits >> 3), - opcode<<6 | 0b00_111111&byte(m>>6), - size<<6 | v<<2 | 0b00_1_11_0_01, - }) + buf.Append4Bytes( + (baseRegBits<<5)|tmpRegBits, + (byte(hi)<<2)|(baseRegBits>>3), + 0b01<<6 /* shift by 12 */ |byte(hi>>6), + sfops<<5|0b10001, + ) + + buf.Append4Bytes( + (tmpRegBits<<5)|targetRegBits, + (byte(m<<2))|(tmpRegBits>>3), + opcode<<6|0b00_111111&byte(m>>6), + size<<6|v<<2|0b00_1_11_0_01, + ) } else { // This case we load the const via ldr(literal) into tem register, // and the target const is placed after this instruction below. - loadLiteralOffsetInBinary := uint64(a.buf.Len()) + loadLiteralOffsetInBinary := uint64(buf.Len()) // First we emit the ldr(literal) with offset zero as we don't yet know the const's placement in the binary. // https://developer.arm.com/documentation/ddi0596/2020-12/Base-Instructions/LDR--literal---Load-Register--literal-- - a.buf.Write([]byte{tmpRegBits, 0x0, 0x0, 0b00_011_0_00}) + buf.Append4Bytes(tmpRegBits, 0x0, 0x0, 0b00_011_0_00) // Set the callback for the constant, and we set properly the offset in the callback. c.AddOffsetFinalizedCallback(func(offsetOfConst uint64) { // ldr(literal) encodes offset divided by 4. offset := (int(offsetOfConst) - int(loadLiteralOffsetInBinary)) / 4 - bin := a.buf.Bytes() + bin := buf.Bytes() bin[loadLiteralOffsetInBinary] |= byte(offset << 5) bin[loadLiteralOffsetInBinary+1] |= byte(offset >> 3) bin[loadLiteralOffsetInBinary+2] |= byte(offset >> 11) @@ -1808,17 +1826,17 @@ func (a *AssemblerImpl) encodeLoadOrStoreWithConstOffset( // Then, load the constant with the register offset. // https://developer.arm.com/documentation/ddi0596/2020-12/Base-Instructions/LDR--register---Load-Register--register-- - a.buf.Write([]byte{ - (baseRegBits << 5) | targetRegBits, - 0b011_010_00 | (baseRegBits >> 3), - opcode<<6 | 0b00_1_00000 | tmpRegBits, - size<<6 | v<<2 | 0b00_111_0_00, - }) + buf.Append4Bytes( + (baseRegBits<<5)|targetRegBits, + 0b011_010_00|(baseRegBits>>3), + opcode<<6|0b00_1_00000|tmpRegBits, + size<<6|v<<2|0b00_111_0_00, + ) } return } -func (a *AssemblerImpl) encodeRegisterToMemory(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRegisterToMemory(buf asm.Buffer, n *nodeImpl) (err error) { // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Loads-and-Stores?lang=en#ldst_regoff var ( size, v byte @@ -1863,31 +1881,31 @@ func (a *AssemblerImpl) encodeRegisterToMemory(n *nodeImpl) (err error) { if err != nil { return err } - a.encodeLoadOrStoreWithRegisterOffset(baseRegBits, offsetRegBits, srcRegBits, opcode, size, v) + a.encodeLoadOrStoreWithRegisterOffset(buf, baseRegBits, offsetRegBits, srcRegBits, opcode, size, v) } else { - err = a.encodeLoadOrStoreWithConstOffset(baseRegBits, srcRegBits, n.dstConst, opcode, size, v, datasize, datasizeLog2) + err = a.encodeLoadOrStoreWithConstOffset(buf, baseRegBits, srcRegBits, n.dstConst, opcode, size, v, datasize, datasizeLog2) } return } -func (a *AssemblerImpl) encodeADR(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeADR(buf asm.Buffer, n *nodeImpl) (err error) { dstRegBits, err := intRegisterBits(n.dstReg) if err != nil { return err } - adrInstructionOffsetInBinary := uint64(a.buf.Len()) + adrInstructionOffsetInBinary := uint64(buf.Len()) // At this point, we don't yet know the target offset to read from, // so we emit the ADR instruction with 0 offset, and replace later in the callback. // https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/ADR--Form-PC-relative-address-?lang=en - a.buf.Write([]byte{dstRegBits, 0x0, 0x0, 0b10000}) + buf.Append4Bytes(dstRegBits, 0x0, 0x0, 0b10000) // This case, the ADR's target offset is for the staticConst's initial address. if sc := n.staticConst; sc != nil { a.pool.AddConst(sc, adrInstructionOffsetInBinary) sc.AddOffsetFinalizedCallback(func(offsetOfConst uint64) { - adrInstructionBytes := a.buf.Bytes()[adrInstructionOffsetInBinary : adrInstructionOffsetInBinary+4] + adrInstructionBytes := buf.Bytes()[adrInstructionOffsetInBinary : adrInstructionOffsetInBinary+4] offset := int(offsetOfConst) - int(adrInstructionOffsetInBinary) // See https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/ADR--Form-PC-relative-address-?lang=en @@ -1941,7 +1959,7 @@ func (a *AssemblerImpl) finalizeADRInstructionNode(code []byte, n *nodeImpl) (er return nil } -func (a *AssemblerImpl) encodeMemoryToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeMemoryToRegister(buf asm.Buffer, n *nodeImpl) (err error) { // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Loads-and-Stores?lang=en#ldst_regoff var ( size, v, opcode byte @@ -1950,7 +1968,7 @@ func (a *AssemblerImpl) encodeMemoryToRegister(n *nodeImpl) (err error) { ) switch n.instruction { case ADR: - return a.encodeADR(n) + return a.encodeADR(buf, n) case FLDRD: size, v, datasize, datasizeLog2, opcode, isTargetFloat = 0b11, 0x1, 8, 3, 0b01, true case FLDRS: @@ -1996,10 +2014,10 @@ func (a *AssemblerImpl) encodeMemoryToRegister(n *nodeImpl) (err error) { if err != nil { return err } - a.encodeLoadOrStoreWithRegisterOffset(baseRegBits, offsetRegBits, dstRegBits, opcode, + a.encodeLoadOrStoreWithRegisterOffset(buf, baseRegBits, offsetRegBits, dstRegBits, opcode, size, v) } else { - err = a.encodeLoadOrStoreWithConstOffset(baseRegBits, dstRegBits, n.srcConst, opcode, + err = a.encodeLoadOrStoreWithConstOffset(buf, baseRegBits, dstRegBits, n.srcConst, opcode, size, v, datasize, datasizeLog2) } return @@ -2067,24 +2085,23 @@ func getLowestBit(x uint64) uint64 { return x & (^x + 1) } -func (a *AssemblerImpl) addOrSub64BitRegisters(sfops byte, sp bool, dstRegBits, src1RegBits, src2RegBits byte) { +func (a *AssemblerImpl) addOrSub64BitRegisters(buf asm.Buffer, sfops byte, sp bool, dstRegBits, src1RegBits, src2RegBits byte) { // src1Reg = src1Reg +/- src2Reg - if sp { // https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/ADD--extended-register---Add--extended-register--?lang=en - a.buf.Write([]byte{ - (src1RegBits << 5) | dstRegBits, - 0b011<<5 | src1RegBits>>3, - 1<<5 | src2RegBits, - sfops<<5 | 0b01011, - }) + buf.Append4Bytes( + (src1RegBits<<5)|dstRegBits, + 0b011<<5|src1RegBits>>3, + 1<<5|src2RegBits, + sfops<<5|0b01011, + ) } else { - a.buf.Write([]byte{ - (src1RegBits << 5) | dstRegBits, - src1RegBits >> 3, + buf.Append4Bytes( + (src1RegBits<<5)|dstRegBits, + src1RegBits>>3, src2RegBits, - sfops<<5 | 0b01011, - }) + sfops<<5|0b01011, + ) } } @@ -2132,7 +2149,7 @@ func bitmaskImmediate(c uint64, is64bit bool) (immr, imms, N byte) { return } -func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeConstToRegister(buf asm.Buffer, n *nodeImpl) (err error) { // Alias for readability. c := n.srcConst @@ -2151,12 +2168,12 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { return } immr, imms, N := bitmaskImmediate(uint64(c), false) - a.buf.Write([]byte{ - (dstRegBits << 5) | dstRegBits, - imms<<2 | dstRegBits>>3, - N<<6 | immr, - sf<<7 | opc<<5 | 0b10010, - }) + buf.Append4Bytes( + (dstRegBits<<5)|dstRegBits, + imms<<2|dstRegBits>>3, + N<<6|immr, + sf<<7|opc<<5|0b10010, + ) return case ANDIMM64: var sf, opc byte = 0b1, 0b00 @@ -2165,12 +2182,12 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { return } immr, imms, N := bitmaskImmediate(uint64(c), true) - a.buf.Write([]byte{ - (dstRegBits << 5) | dstRegBits, - imms<<2 | dstRegBits>>3, - N<<6 | immr, - sf<<7 | opc<<5 | 0b10010, - }) + buf.Append4Bytes( + (dstRegBits<<5)|dstRegBits, + imms<<2|dstRegBits>>3, + N<<6|immr, + sf<<7|opc<<5|0b10010, + ) return } @@ -2198,7 +2215,7 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { isSP := n.srcReg == RegSP || n.dstReg == RegSP if c == 0 { // If the constant equals zero, we encode it as ADD (register) with zero register. - a.addOrSub64BitRegisters(sfops, isSP, dstRegBits, srcRegBits, zeroRegisterBits) + a.addOrSub64BitRegisters(buf, sfops, isSP, dstRegBits, srcRegBits, zeroRegisterBits) return } @@ -2207,20 +2224,20 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { // https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/internal/obj/arm64/asm7.go#L2992 if c <= 0xfff { - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - (byte(c) << 2) | (srcRegBits >> 3), - byte(c >> 6), - sfops<<5 | 0b10001, - }) + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + (byte(c)<<2)|(srcRegBits>>3), + byte(c>>6), + sfops<<5|0b10001, + ) } else { c >>= 12 - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - (byte(c) << 2) | (srcRegBits >> 3), - 0b01<<6 /* shift by 12 */ | byte(c>>6), - sfops<<5 | 0b10001, - }) + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + (byte(c)<<2)|(srcRegBits>>3), + 0b01<<6 /* shift by 12 */ |byte(c>>6), + sfops<<5|0b10001, + ) } return } @@ -2232,10 +2249,10 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { tmpRegBits := registerBits(a.temporaryRegister) // MOVZ $c, tmpReg with shifting. - a.load16bitAlignedConst(c>>(16*t), byte(t), tmpRegBits, false, true) + a.load16bitAlignedConst(buf, c>>(16*t), byte(t), tmpRegBits, false, true) // ADD/SUB tmpReg, dstReg - a.addOrSub64BitRegisters(sfops, isSP, dstRegBits, srcRegBits, tmpRegBits) + a.addOrSub64BitRegisters(buf, sfops, isSP, dstRegBits, srcRegBits, tmpRegBits) return } else if t := const16bitAligned(^c); t >= 0 { // Also if the reverse of the const can fit within 16-bit range, do the same ^^. @@ -2243,10 +2260,10 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { tmpRegBits := registerBits(a.temporaryRegister) // MOVN $c, tmpReg with shifting. - a.load16bitAlignedConst(^c>>(16*t), byte(t), tmpRegBits, true, true) + a.load16bitAlignedConst(buf, ^c>>(16*t), byte(t), tmpRegBits, true, true) // ADD/SUB tmpReg, dstReg - a.addOrSub64BitRegisters(sfops, isSP, dstRegBits, srcRegBits, tmpRegBits) + a.addOrSub64BitRegisters(buf, sfops, isSP, dstRegBits, srcRegBits, tmpRegBits) return } @@ -2255,45 +2272,45 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { // https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/internal/obj/arm64/asm7.go#L6570-L6583 tmpRegBits := registerBits(a.temporaryRegister) // OOR $c, tmpReg - a.loadConstViaBitMaskImmediate(uc, tmpRegBits, true) + a.loadConstViaBitMaskImmediate(buf, uc, tmpRegBits, true) // ADD/SUB tmpReg, dstReg - a.addOrSub64BitRegisters(sfops, isSP, dstRegBits, srcRegBits, tmpRegBits) + a.addOrSub64BitRegisters(buf, sfops, isSP, dstRegBits, srcRegBits, tmpRegBits) return } // If the value fits within 24-bit, then we emit two add instructions if 0 <= c && c <= 0xffffff && inst != SUBS && inst != ADDS { // https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/internal/obj/arm64/asm7.go#L3849-L3862 - a.buf.Write([]byte{ - (dstRegBits << 5) | dstRegBits, - (byte(c) << 2) | (dstRegBits >> 3), - byte(c & 0xfff >> 6), - sfops<<5 | 0b10001, - }) + buf.Append4Bytes( + (dstRegBits<<5)|dstRegBits, + (byte(c)<<2)|(dstRegBits>>3), + byte(c&0xfff>>6), + sfops<<5|0b10001, + ) c = c >> 12 - a.buf.Write([]byte{ - (dstRegBits << 5) | dstRegBits, - (byte(c) << 2) | (dstRegBits >> 3), - 0b01_000000 /* shift by 12 */ | byte(c>>6), - sfops<<5 | 0b10001, - }) + buf.Append4Bytes( + (dstRegBits<<5)|dstRegBits, + (byte(c)<<2)|(dstRegBits>>3), + 0b01_000000 /* shift by 12 */ |byte(c>>6), + sfops<<5|0b10001, + ) return } // https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/internal/obj/arm64/asm7.go#L3163-L3203 // Otherwise we use MOVZ and MOVNs for loading const into tmpRegister. tmpRegBits := registerBits(a.temporaryRegister) - a.load64bitConst(c, tmpRegBits) - a.addOrSub64BitRegisters(sfops, isSP, dstRegBits, srcRegBits, tmpRegBits) + a.load64bitConst(buf, c, tmpRegBits) + a.addOrSub64BitRegisters(buf, sfops, isSP, dstRegBits, srcRegBits, tmpRegBits) case MOVW: if c == 0 { - a.buf.Write([]byte{ - (zeroRegisterBits << 5) | dstRegBits, - zeroRegisterBits >> 3, - 0b000_00000 | zeroRegisterBits, + buf.Append4Bytes( + (zeroRegisterBits<<5)|dstRegBits, + zeroRegisterBits>>3, + 0b000_00000|zeroRegisterBits, 0b0_01_01010, - }) + ) return } @@ -2303,7 +2320,7 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { ic := int64(c32) if ic >= 0 && (ic <= 0xfff || (ic&0xfff) == 0 && (uint64(ic>>12) <= 0xfff)) { if isBitMaskImmediate(uint64(c)) { - a.loadConstViaBitMaskImmediate(uint64(c), dstRegBits, false) + a.loadConstViaBitMaskImmediate(buf, uint64(c), dstRegBits, false) return } } @@ -2311,32 +2328,32 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { if t := const16bitAligned(int64(c32)); t >= 0 { // If the const can fit within 16-bit alignment, for example, 0xffff, 0xffff_0000 or 0xffff_0000_0000_0000 // We could load it into temporary with movk. - a.load16bitAlignedConst(int64(c32)>>(16*t), byte(t), dstRegBits, false, false) + a.load16bitAlignedConst(buf, int64(c32)>>(16*t), byte(t), dstRegBits, false, false) } else if t := const16bitAligned(int64(^c32)); t >= 0 { // Also, if the reverse of the const can fit within 16-bit range, do the same ^^. - a.load16bitAlignedConst(int64(^c32)>>(16*t), byte(t), dstRegBits, true, false) + a.load16bitAlignedConst(buf, int64(^c32)>>(16*t), byte(t), dstRegBits, true, false) } else if isBitMaskImmediate(uint64(c)) { - a.loadConstViaBitMaskImmediate(uint64(c), dstRegBits, false) + a.loadConstViaBitMaskImmediate(buf, uint64(c), dstRegBits, false) } else { // Otherwise, we use MOVZ and MOVK to load it. // https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/internal/obj/arm64/asm7.go#L6623-L6630 c16 := uint16(c32) // MOVZ: https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVZ - a.buf.Write([]byte{ - (byte(c16) << 5) | dstRegBits, - byte(c16 >> 3), - 1<<7 | byte(c16>>11), + buf.Append4Bytes( + (byte(c16)<<5)|dstRegBits, + byte(c16>>3), + 1<<7|byte(c16>>11), 0b0_10_10010, - }) + ) // MOVK: https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVK c16 = uint16(c32 >> 16) if c16 != 0 { - a.buf.Write([]byte{ - (byte(c16) << 5) | dstRegBits, - byte(c16 >> 3), - 1<<7 | 0b0_01_00000 /* shift by 16 */ | byte(c16>>11), + buf.Append4Bytes( + (byte(c16)<<5)|dstRegBits, + byte(c16>>3), + 1<<7|0b0_01_00000 /* shift by 16 */ |byte(c16>>11), 0b0_11_10010, - }) + ) } } case MOVD: @@ -2344,7 +2361,7 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { // https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/internal/obj/arm64/asm7.go#L1798-L1852 if c >= 0 && (c <= 0xfff || (c&0xfff) == 0 && (uint64(c>>12) <= 0xfff)) { if isBitMaskImmediate(uint64(c)) { - a.loadConstViaBitMaskImmediate(uint64(c), dstRegBits, true) + a.loadConstViaBitMaskImmediate(buf, uint64(c), dstRegBits, true) return } } @@ -2352,14 +2369,14 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { if t := const16bitAligned(c); t >= 0 { // If the const can fit within 16-bit alignment, for example, 0xffff, 0xffff_0000 or 0xffff_0000_0000_0000 // We could load it into temporary with movk. - a.load16bitAlignedConst(c>>(16*t), byte(t), dstRegBits, false, true) + a.load16bitAlignedConst(buf, c>>(16*t), byte(t), dstRegBits, false, true) } else if t := const16bitAligned(^c); t >= 0 { // Also, if the reverse of the const can fit within 16-bit range, do the same ^^. - a.load16bitAlignedConst((^c)>>(16*t), byte(t), dstRegBits, true, true) + a.load16bitAlignedConst(buf, (^c)>>(16*t), byte(t), dstRegBits, true, true) } else if isBitMaskImmediate(uint64(c)) { - a.loadConstViaBitMaskImmediate(uint64(c), dstRegBits, true) + a.loadConstViaBitMaskImmediate(buf, uint64(c), dstRegBits, true) } else { - a.load64bitConst(c, dstRegBits) + a.load64bitConst(buf, c, dstRegBits) } case LSR: if c == 0 { @@ -2372,12 +2389,12 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { // LSR(immediate) is an alias of UBFM // https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/LSR--immediate---Logical-Shift-Right--immediate---an-alias-of-UBFM-?lang=en - a.buf.Write([]byte{ - (dstRegBits << 5) | dstRegBits, - 0b111111_00 | dstRegBits>>3, - 0b01_000000 | byte(c), + buf.Append4Bytes( + (dstRegBits<<5)|dstRegBits, + 0b111111_00|dstRegBits>>3, + 0b01_000000|byte(c), 0b110_10011, - }) + ) case LSL: if c == 0 { err = errors.New("LSL with zero constant should be optimized out") @@ -2390,12 +2407,12 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { // LSL(immediate) is an alias of UBFM // https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/LSL--immediate---Logical-Shift-Left--immediate---an-alias-of-UBFM- cb := byte(c) - a.buf.Write([]byte{ - (dstRegBits << 5) | dstRegBits, - (0b111111-cb)<<2 | dstRegBits>>3, - 0b01_000000 | (64 - cb), + buf.Append4Bytes( + (dstRegBits<<5)|dstRegBits, + (0b111111-cb)<<2|dstRegBits>>3, + 0b01_000000|(64-cb), 0b110_10011, - }) + ) default: return errorEncodingUnsupported(n) @@ -2403,41 +2420,41 @@ func (a *AssemblerImpl) encodeConstToRegister(n *nodeImpl) (err error) { return } -func (a *AssemblerImpl) movk(v uint64, shfitNum int, dstRegBits byte) { +func (a *AssemblerImpl) movk(buf asm.Buffer, v uint64, shfitNum int, dstRegBits byte) { // https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVK - a.buf.Write([]byte{ - (byte(v) << 5) | dstRegBits, - byte(v >> 3), - 1<<7 | byte(shfitNum)<<5 | (0b000_11111 & byte(v>>11)), + buf.Append4Bytes( + (byte(v)<<5)|dstRegBits, + byte(v>>3), + 1<<7|byte(shfitNum)<<5|(0b000_11111&byte(v>>11)), 0b1_11_10010, - }) + ) } -func (a *AssemblerImpl) movz(v uint64, shfitNum int, dstRegBits byte) { +func (a *AssemblerImpl) movz(buf asm.Buffer, v uint64, shfitNum int, dstRegBits byte) { // https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVZ - a.buf.Write([]byte{ - (byte(v) << 5) | dstRegBits, - byte(v >> 3), - 1<<7 | byte(shfitNum)<<5 | (0b000_11111 & byte(v>>11)), + buf.Append4Bytes( + (byte(v)<<5)|dstRegBits, + byte(v>>3), + 1<<7|byte(shfitNum)<<5|(0b000_11111&byte(v>>11)), 0b1_10_10010, - }) + ) } -func (a *AssemblerImpl) movn(v uint64, shfitNum int, dstRegBits byte) { +func (a *AssemblerImpl) movn(buf asm.Buffer, v uint64, shfitNum int, dstRegBits byte) { // https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVZ - a.buf.Write([]byte{ - (byte(v) << 5) | dstRegBits, - byte(v >> 3), - 1<<7 | byte(shfitNum)<<5 | (0b000_11111 & byte(v>>11)), + buf.Append4Bytes( + (byte(v)<<5)|dstRegBits, + byte(v>>3), + 1<<7|byte(shfitNum)<<5|(0b000_11111&byte(v>>11)), 0b1_00_10010, - }) + ) } // load64bitConst loads a 64-bit constant into the register, following the same logic to decide how to load large 64-bit // consts as in the Go assembler. // // See https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/internal/obj/arm64/asm7.go#L6632-L6759 -func (a *AssemblerImpl) load64bitConst(c int64, dstRegBits byte) { +func (a *AssemblerImpl) load64bitConst(buf asm.Buffer, c int64, dstRegBits byte) { var bits [4]uint64 var zeros, negs int for i := 0; i < 4; i++ { @@ -2453,7 +2470,7 @@ func (a *AssemblerImpl) load64bitConst(c int64, dstRegBits byte) { // one MOVZ instruction. for i, v := range bits { if v != 0 { - a.movz(v, i, dstRegBits) + a.movz(buf, v, i, dstRegBits) } } } else if negs == 3 { @@ -2461,7 +2478,7 @@ func (a *AssemblerImpl) load64bitConst(c int64, dstRegBits byte) { for i, v := range bits { if v != 0xffff { v = ^v - a.movn(v, i, dstRegBits) + a.movn(buf, v, i, dstRegBits) } } } else if zeros == 2 { @@ -2470,10 +2487,10 @@ func (a *AssemblerImpl) load64bitConst(c int64, dstRegBits byte) { for i, v := range bits { if !movz && v != 0 { // MOVZ. // https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVZ - a.movz(v, i, dstRegBits) + a.movz(buf, v, i, dstRegBits) movz = true } else if v != 0 { - a.movk(v, i, dstRegBits) + a.movk(buf, v, i, dstRegBits) } } @@ -2484,10 +2501,10 @@ func (a *AssemblerImpl) load64bitConst(c int64, dstRegBits byte) { if !movn && v != 0xffff { v = ^v // https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVN - a.movn(v, i, dstRegBits) + a.movn(buf, v, i, dstRegBits) movn = true } else if v != 0xffff { - a.movk(v, i, dstRegBits) + a.movk(buf, v, i, dstRegBits) } } @@ -2497,10 +2514,10 @@ func (a *AssemblerImpl) load64bitConst(c int64, dstRegBits byte) { for i, v := range bits { if !movz && v != 0 { // MOVZ. // https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVZ - a.movz(v, i, dstRegBits) + a.movz(buf, v, i, dstRegBits) movz = true } else if v != 0 { - a.movk(v, i, dstRegBits) + a.movk(buf, v, i, dstRegBits) } } @@ -2511,10 +2528,10 @@ func (a *AssemblerImpl) load64bitConst(c int64, dstRegBits byte) { if !movn && v != 0xffff { v = ^v // https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVN - a.movn(v, i, dstRegBits) + a.movn(buf, v, i, dstRegBits) movn = true } else if v != 0xffff { - a.movk(v, i, dstRegBits) + a.movk(buf, v, i, dstRegBits) } } @@ -2524,17 +2541,17 @@ func (a *AssemblerImpl) load64bitConst(c int64, dstRegBits byte) { for i, v := range bits { if !movz && v != 0 { // MOVZ. // https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVZ - a.movz(v, i, dstRegBits) + a.movz(buf, v, i, dstRegBits) movz = true } else if v != 0 { - a.movk(v, i, dstRegBits) + a.movk(buf, v, i, dstRegBits) } } } } -func (a *AssemblerImpl) load16bitAlignedConst(c int64, shiftNum byte, regBits byte, reverse bool, dst64bit bool) { +func (a *AssemblerImpl) load16bitAlignedConst(buf asm.Buffer, c int64, shiftNum byte, regBits byte, reverse bool, dst64bit bool) { var lastByte byte if reverse { // MOVN: https://developer.arm.com/documentation/dui0802/a/A64-General-Instructions/MOVZ @@ -2546,17 +2563,17 @@ func (a *AssemblerImpl) load16bitAlignedConst(c int64, shiftNum byte, regBits by if dst64bit { lastByte |= 0b1 << 7 } - a.buf.Write([]byte{ - (byte(c) << 5) | regBits, - byte(c >> 3), - 1<<7 | (shiftNum << 5) | byte(c>>11), + buf.Append4Bytes( + (byte(c)<<5)|regBits, + byte(c>>3), + 1<<7|(shiftNum<<5)|byte(c>>11), lastByte, - }) + ) } // loadConstViaBitMaskImmediate loads the constant with ORR (bitmask immediate). // https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/ORR--immediate---Bitwise-OR--immediate--?lang=en -func (a *AssemblerImpl) loadConstViaBitMaskImmediate(c uint64, regBits byte, dst64bit bool) { +func (a *AssemblerImpl) loadConstViaBitMaskImmediate(buf asm.Buffer, c uint64, regBits byte, dst64bit bool) { var size uint32 switch { case c != c>>32|c<<32: @@ -2606,12 +2623,12 @@ func (a *AssemblerImpl) loadConstViaBitMaskImmediate(c uint64, regBits byte, dst if dst64bit { sf = 0b1 } - a.buf.Write([]byte{ - (zeroRegisterBits << 5) | regBits, - s<<2 | (zeroRegisterBits >> 3), - n<<6 | r, - sf<<7 | 0b0_01_10010, - }) + buf.Append4Bytes( + (zeroRegisterBits<<5)|regBits, + s<<2|(zeroRegisterBits>>3), + n<<6|r, + sf<<7|0b0_01_10010, + ) } func getOnesSequenceSize(x uint64) (size, nonZeroPos uint32) { @@ -2669,7 +2686,7 @@ func checkArrangementIndexPair(arr VectorArrangement, index VectorIndex) (err er return } -func (a *AssemblerImpl) encodeMemoryToVectorRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeMemoryToVectorRegister(buf asm.Buffer, n *nodeImpl) (err error) { srcBaseRegBits, err := intRegisterBits(n.srcReg) if err != nil { return err @@ -2703,9 +2720,9 @@ func (a *AssemblerImpl) encodeMemoryToVectorRegister(n *nodeImpl) (err error) { if err != nil { return err } - a.encodeLoadOrStoreWithRegisterOffset(srcBaseRegBits, offsetRegBits, dstVectorRegBits, opcode, size, v) + a.encodeLoadOrStoreWithRegisterOffset(buf, srcBaseRegBits, offsetRegBits, dstVectorRegBits, opcode, size, v) } else { - err = a.encodeLoadOrStoreWithConstOffset(srcBaseRegBits, dstVectorRegBits, + err = a.encodeLoadOrStoreWithConstOffset(buf, srcBaseRegBits, dstVectorRegBits, n.srcConst, opcode, size, v, dataSize, dataSizeLog2) } case LD1R: @@ -2735,12 +2752,12 @@ func (a *AssemblerImpl) encodeMemoryToVectorRegister(n *nodeImpl) (err error) { // No offset encoding. // https://developer.arm.com/documentation/ddi0596/2021-12/SIMD-FP-Instructions/LD1R--Load-one-single-element-structure-and-Replicate-to-all-lanes--of-one-register--?lang=en#iclass_as_post_index - a.buf.Write([]byte{ - (srcBaseRegBits << 5) | dstVectorRegBits, - 0b11_000000 | size<<2 | srcBaseRegBits>>3, + buf.Append4Bytes( + (srcBaseRegBits<<5)|dstVectorRegBits, + 0b11_000000|size<<2|srcBaseRegBits>>3, 0b01_000000, - q<<6 | 0b1101, - }) + q<<6|0b1101, + ) default: return errorEncodingUnsupported(n) } @@ -2769,7 +2786,7 @@ func arrangementSizeQ(arr VectorArrangement) (size, q byte) { return } -func (a *AssemblerImpl) encodeVectorRegisterToMemory(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeVectorRegisterToMemory(buf asm.Buffer, n *nodeImpl) (err error) { srcVectorRegBits, err := vectorRegisterBits(n.srcReg) if err != nil { return err @@ -2804,9 +2821,9 @@ func (a *AssemblerImpl) encodeVectorRegisterToMemory(n *nodeImpl) (err error) { if err != nil { return err } - a.encodeLoadOrStoreWithRegisterOffset(dstBaseRegBits, offsetRegBits, srcVectorRegBits, opcode, size, v) + a.encodeLoadOrStoreWithRegisterOffset(buf, dstBaseRegBits, offsetRegBits, srcVectorRegBits, opcode, size, v) } else { - err = a.encodeLoadOrStoreWithConstOffset(dstBaseRegBits, srcVectorRegBits, + err = a.encodeLoadOrStoreWithConstOffset(buf, dstBaseRegBits, srcVectorRegBits, n.dstConst, opcode, size, v, dataSize, dataSizeLog2) } default: @@ -2815,7 +2832,7 @@ func (a *AssemblerImpl) encodeVectorRegisterToMemory(n *nodeImpl) (err error) { return } -func (a *AssemblerImpl) encodeStaticConstToVectorRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeStaticConstToVectorRegister(buf asm.Buffer, n *nodeImpl) (err error) { if n.instruction != VMOV { return errorEncodingUnsupported(n) } @@ -2838,7 +2855,7 @@ func (a *AssemblerImpl) encodeStaticConstToVectorRegister(n *nodeImpl) (err erro opc, constLength = 0b10, 16 } - loadLiteralOffsetInBinary := uint64(a.buf.Len()) + loadLiteralOffsetInBinary := uint64(buf.Len()) a.pool.AddConst(n.staticConst, loadLiteralOffsetInBinary) if len(n.staticConst.Raw) != constLength { @@ -2846,11 +2863,11 @@ func (a *AssemblerImpl) encodeStaticConstToVectorRegister(n *nodeImpl) (err erro n.vectorArrangement, constLength, len(n.staticConst.Raw)) } - a.buf.Write([]byte{dstRegBits, 0x0, 0x0, opc<<6 | 0b11100}) + buf.Append4Bytes(dstRegBits, 0x0, 0x0, opc<<6|0b11100) n.staticConst.AddOffsetFinalizedCallback(func(offsetOfConst uint64) { // LDR (literal, SIMD&FP) encodes offset divided by 4. offset := (int(offsetOfConst) - int(loadLiteralOffsetInBinary)) / 4 - bin := a.buf.Bytes() + bin := buf.Bytes() bin[loadLiteralOffsetInBinary] |= byte(offset << 5) bin[loadLiteralOffsetInBinary+1] |= byte(offset >> 3) bin[loadLiteralOffsetInBinary+2] |= byte(offset >> 11) @@ -2861,8 +2878,8 @@ func (a *AssemblerImpl) encodeStaticConstToVectorRegister(n *nodeImpl) (err erro // advancedSIMDTwoRegisterMisc holds information to encode instructions as "Advanced SIMD two-register miscellaneous" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en var advancedSIMDTwoRegisterMisc = map[asm.Instruction]struct { - u, opcode byte qAndSize map[VectorArrangement]qAndSize + u, opcode byte }{ // https://developer.arm.com/documentation/ddi0596/2021-12/SIMD-FP-Instructions/NOT--Bitwise-NOT--vector--?lang=en NOT: { @@ -3011,8 +3028,8 @@ var advancedSIMDTwoRegisterMisc = map[asm.Instruction]struct { // advancedSIMDThreeDifferent holds information to encode instructions as "Advanced SIMD three different" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en var advancedSIMDThreeDifferent = map[asm.Instruction]struct { - u, opcode byte qAndSize map[VectorArrangement]qAndSize + u, opcode byte }{ // https://developer.arm.com/documentation/ddi0596/2021-12/SIMD-FP-Instructions/UMLAL--UMLAL2--vector---Unsigned-Multiply-Add-Long--vector--?lang=en VUMLAL: {u: 0b1, opcode: 0b1000, qAndSize: map[VectorArrangement]qAndSize{ @@ -3049,8 +3066,8 @@ var advancedSIMDThreeDifferent = map[asm.Instruction]struct { // advancedSIMDThreeSame holds information to encode instructions as "Advanced SIMD three same" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en var advancedSIMDThreeSame = map[asm.Instruction]struct { - u, opcode byte qAndSize map[VectorArrangement]qAndSize + u, opcode byte }{ // https://developer.arm.com/documentation/ddi0596/2021-12/SIMD-FP-Instructions/AND--vector---Bitwise-AND--vector--?lang=en VAND: { @@ -3258,8 +3275,8 @@ var defaultQAndSize = map[VectorArrangement]qAndSize{ // advancedSIMDAcrossLanes holds information to encode instructions as "Advanced SIMD across lanes" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en var advancedSIMDAcrossLanes = map[asm.Instruction]struct { - u, opcode byte qAndSize map[VectorArrangement]qAndSize + u, opcode byte }{ // https://developer.arm.com/documentation/ddi0596/2021-12/SIMD-FP-Instructions/ADDV--Add-across-Vector-?lang=en ADDV: { @@ -3295,8 +3312,8 @@ var advancedSIMDAcrossLanes = map[asm.Instruction]struct { // advancedSIMDScalarPairwise holds information to encode instructions as "Advanced SIMD scalar pairwise" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en var advancedSIMDScalarPairwise = map[asm.Instruction]struct { - u, opcode byte size map[VectorArrangement]byte + u, opcode byte }{ // https://developer.arm.com/documentation/ddi0596/2021-12/SIMD-FP-Instructions/ADDP--scalar---Add-Pair-of-elements--scalar--?lang=en ADDP: {u: 0b0, opcode: 0b11011, size: map[VectorArrangement]byte{VectorArrangement2D: 0b11}}, @@ -3305,9 +3322,9 @@ var advancedSIMDScalarPairwise = map[asm.Instruction]struct { // advancedSIMDCopy holds information to encode instructions as "Advanced SIMD copy" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en var advancedSIMDCopy = map[asm.Instruction]struct { - op byte // TODO: extract common implementation of resolver. resolver func(srcIndex, dstIndex VectorIndex, arr VectorArrangement) (imm5, imm4, q byte, err error) + op byte }{ // https://developer.arm.com/documentation/ddi0596/2021-12/SIMD-FP-Instructions/DUP--element---Duplicate-vector-element-to-vector-or-scalar-?lang=en DUPELEM: {op: 0, resolver: func(srcIndex, dstIndex VectorIndex, arr VectorArrangement) (imm5, imm4, q byte, err error) { @@ -3448,8 +3465,8 @@ var advancedSIMDCopy = map[asm.Instruction]struct { // advancedSIMDTableLookup holds information to encode instructions as "Advanced SIMD table lookup" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en var advancedSIMDTableLookup = map[asm.Instruction]struct { - op, op2, Len byte q map[VectorArrangement]byte + op, op2, Len byte }{ TBL1: {op: 0, op2: 0, Len: 0b00, q: map[VectorArrangement]byte{VectorArrangement16B: 0b1, VectorArrangement8B: 0b0}}, TBL2: {op: 0, op2: 0, Len: 0b01, q: map[VectorArrangement]byte{VectorArrangement16B: 0b1, VectorArrangement8B: 0b0}}, @@ -3458,9 +3475,9 @@ var advancedSIMDTableLookup = map[asm.Instruction]struct { // advancedSIMDShiftByImmediate holds information to encode instructions as "Advanced SIMD shift by immediate" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en var advancedSIMDShiftByImmediate = map[asm.Instruction]struct { - U, opcode byte q map[VectorArrangement]byte immResolver func(shiftAmount int64, arr VectorArrangement) (immh, immb byte, err error) + U, opcode byte }{ // https://developer.arm.com/documentation/ddi0596/2020-12/SIMD-FP-Instructions/SSHLL--SSHLL2--Signed-Shift-Left-Long--immediate-- SSHLL: { @@ -3545,49 +3562,49 @@ func immResolverForSIMDSiftLeftByImmediate(shiftAmount int64, arr VectorArrangem // encodeAdvancedSIMDCopy encodes instruction as "Advanced SIMD copy" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en -func (a *AssemblerImpl) encodeAdvancedSIMDCopy(srcRegBits, dstRegBits, op, imm5, imm4, q byte) { - a.buf.Write([]byte{ - (srcRegBits << 5) | dstRegBits, - imm4<<3 | 0b1<<2 | srcRegBits>>3, +func (a *AssemblerImpl) encodeAdvancedSIMDCopy(buf asm.Buffer, srcRegBits, dstRegBits, op, imm5, imm4, q byte) { + buf.Append4Bytes( + (srcRegBits<<5)|dstRegBits, + imm4<<3|0b1<<2|srcRegBits>>3, imm5, - q<<6 | op<<5 | 0b1110, - }) + q<<6|op<<5|0b1110, + ) } // encodeAdvancedSIMDThreeSame encodes instruction as "Advanced SIMD three same" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en -func (a *AssemblerImpl) encodeAdvancedSIMDThreeSame(src1, src2, dst, opcode, size, q, u byte) { - a.buf.Write([]byte{ - (src2 << 5) | dst, - opcode<<3 | 1<<2 | src2>>3, - size<<6 | 0b1<<5 | src1, - q<<6 | u<<5 | 0b1110, - }) +func (a *AssemblerImpl) encodeAdvancedSIMDThreeSame(buf asm.Buffer, src1, src2, dst, opcode, size, q, u byte) { + buf.Append4Bytes( + (src2<<5)|dst, + opcode<<3|1<<2|src2>>3, + size<<6|0b1<<5|src1, + q<<6|u<<5|0b1110, + ) } // encodeAdvancedSIMDThreeDifferent encodes instruction as "Advanced SIMD three different" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en -func (a *AssemblerImpl) encodeAdvancedSIMDThreeDifferent(src1, src2, dst, opcode, size, q, u byte) { - a.buf.Write([]byte{ - (src2 << 5) | dst, - opcode<<4 | src2>>3, - size<<6 | 0b1<<5 | src1, - q<<6 | u<<5 | 0b1110, - }) +func (a *AssemblerImpl) encodeAdvancedSIMDThreeDifferent(buf asm.Buffer, src1, src2, dst, opcode, size, q, u byte) { + buf.Append4Bytes( + (src2<<5)|dst, + opcode<<4|src2>>3, + size<<6|0b1<<5|src1, + q<<6|u<<5|0b1110, + ) } // encodeAdvancedSIMDPermute encodes instruction as "Advanced SIMD permute" in // https://developer.arm.com/documentation/ddi0596/2021-12/Index-by-Encoding/Data-Processing----Scalar-Floating-Point-and-Advanced-SIMD?lang=en -func (a *AssemblerImpl) encodeAdvancedSIMDPermute(src1, src2, dst, opcode, size, q byte) { - a.buf.Write([]byte{ - (src2 << 5) | dst, - opcode<<4 | 0b1<<3 | src2>>3, - size<<6 | src1, - q<<6 | 0b1110, - }) +func (a *AssemblerImpl) encodeAdvancedSIMDPermute(buf asm.Buffer, src1, src2, dst, opcode, size, q byte) { + buf.Append4Bytes( + (src2<<5)|dst, + opcode<<4|0b1<<3|src2>>3, + size<<6|src1, + q<<6|0b1110, + ) } -func (a *AssemblerImpl) encodeVectorRegisterToVectorRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeVectorRegisterToVectorRegister(buf asm.Buffer, n *nodeImpl) (err error) { var srcVectorRegBits byte if n.srcReg != RegRZR { srcVectorRegBits, err = vectorRegisterBits(n.srcReg) @@ -3610,7 +3627,7 @@ func (a *AssemblerImpl) encodeVectorRegisterToVectorRegister(n *nodeImpl) (err e if err != nil { return err } - a.encodeAdvancedSIMDCopy(srcVectorRegBits, dstVectorRegBits, simdCopy.op, imm5, imm4, q) + a.encodeAdvancedSIMDCopy(buf, srcVectorRegBits, dstVectorRegBits, simdCopy.op, imm5, imm4, q) return nil } @@ -3621,12 +3638,12 @@ func (a *AssemblerImpl) encodeVectorRegisterToVectorRegister(n *nodeImpl) (err e if !ok { return fmt.Errorf("unsupported vector arrangement %s for %s", n.vectorArrangement, InstructionName(n.instruction)) } - a.buf.Write([]byte{ - (srcVectorRegBits << 5) | dstVectorRegBits, - scalarPairwise.opcode<<4 | 1<<3 | srcVectorRegBits>>3, - size<<6 | 0b11<<4 | scalarPairwise.opcode>>4, - 0b1<<6 | scalarPairwise.u<<5 | 0b11110, - }) + buf.Append4Bytes( + (srcVectorRegBits<<5)|dstVectorRegBits, + scalarPairwise.opcode<<4|1<<3|srcVectorRegBits>>3, + size<<6|0b11<<4|scalarPairwise.opcode>>4, + 0b1<<6|scalarPairwise.u<<5|0b11110, + ) return } @@ -3637,12 +3654,12 @@ func (a *AssemblerImpl) encodeVectorRegisterToVectorRegister(n *nodeImpl) (err e if !ok { return fmt.Errorf("unsupported vector arrangement %s for %s", n.vectorArrangement, InstructionName(n.instruction)) } - a.buf.Write([]byte{ - (srcVectorRegBits << 5) | dstVectorRegBits, - twoRegMisc.opcode<<4 | 0b1<<3 | srcVectorRegBits>>3, - qs.size<<6 | 0b1<<5 | twoRegMisc.opcode>>4, - qs.q<<6 | twoRegMisc.u<<5 | 0b01110, - }) + buf.Append4Bytes( + (srcVectorRegBits<<5)|dstVectorRegBits, + twoRegMisc.opcode<<4|0b1<<3|srcVectorRegBits>>3, + qs.size<<6|0b1<<5|twoRegMisc.opcode>>4, + qs.q<<6|twoRegMisc.u<<5|0b01110, + ) return nil } @@ -3651,7 +3668,7 @@ func (a *AssemblerImpl) encodeVectorRegisterToVectorRegister(n *nodeImpl) (err e if !ok { return fmt.Errorf("unsupported vector arrangement %s for %s", n.vectorArrangement, InstructionName(n.instruction)) } - a.encodeAdvancedSIMDThreeSame(srcVectorRegBits, dstVectorRegBits, dstVectorRegBits, threeSame.opcode, qs.size, qs.q, threeSame.u) + a.encodeAdvancedSIMDThreeSame(buf, srcVectorRegBits, dstVectorRegBits, dstVectorRegBits, threeSame.opcode, qs.size, qs.q, threeSame.u) return nil } @@ -3660,7 +3677,7 @@ func (a *AssemblerImpl) encodeVectorRegisterToVectorRegister(n *nodeImpl) (err e if !ok { return fmt.Errorf("unsupported vector arrangement %s for %s", n.vectorArrangement, InstructionName(n.instruction)) } - a.encodeAdvancedSIMDThreeDifferent(srcVectorRegBits, dstVectorRegBits, dstVectorRegBits, threeDifferent.opcode, qs.size, qs.q, threeDifferent.u) + a.encodeAdvancedSIMDThreeDifferent(buf, srcVectorRegBits, dstVectorRegBits, dstVectorRegBits, threeDifferent.opcode, qs.size, qs.q, threeDifferent.u) return nil } @@ -3671,12 +3688,12 @@ func (a *AssemblerImpl) encodeVectorRegisterToVectorRegister(n *nodeImpl) (err e if !ok { return fmt.Errorf("unsupported vector arrangement %s for %s", n.vectorArrangement, InstructionName(n.instruction)) } - a.buf.Write([]byte{ - (srcVectorRegBits << 5) | dstVectorRegBits, - acrossLanes.opcode<<4 | 0b1<<3 | srcVectorRegBits>>3, - qs.size<<6 | 0b11000<<1 | acrossLanes.opcode>>4, - qs.q<<6 | acrossLanes.u<<5 | 0b01110, - }) + buf.Append4Bytes( + (srcVectorRegBits<<5)|dstVectorRegBits, + acrossLanes.opcode<<4|0b1<<3|srcVectorRegBits>>3, + qs.size<<6|0b11000<<1|acrossLanes.opcode>>4, + qs.q<<6|acrossLanes.u<<5|0b01110, + ) return nil } @@ -3685,12 +3702,12 @@ func (a *AssemblerImpl) encodeVectorRegisterToVectorRegister(n *nodeImpl) (err e if !ok { return fmt.Errorf("unsupported vector arrangement %s for %s", n.vectorArrangement, InstructionName(n.instruction)) } - a.buf.Write([]byte{ - (srcVectorRegBits << 5) | dstVectorRegBits, - lookup.Len<<5 | lookup.op<<4 | srcVectorRegBits>>3, - lookup.op2<<6 | dstVectorRegBits, - q<<6 | 0b1110, - }) + buf.Append4Bytes( + (srcVectorRegBits<<5)|dstVectorRegBits, + lookup.Len<<5|lookup.op<<4|srcVectorRegBits>>3, + lookup.op2<<6|dstVectorRegBits, + q<<6|0b1110, + ) return } @@ -3705,24 +3722,24 @@ func (a *AssemblerImpl) encodeVectorRegisterToVectorRegister(n *nodeImpl) (err e return fmt.Errorf("unsupported vector arrangement %s for %s", n.vectorArrangement, InstructionName(n.instruction)) } - a.buf.Write([]byte{ - (srcVectorRegBits << 5) | dstVectorRegBits, - shiftByImmediate.opcode<<3 | 0b1<<2 | srcVectorRegBits>>3, - immh<<3 | immb, - q<<6 | shiftByImmediate.U<<5 | 0b1111, - }) + buf.Append4Bytes( + (srcVectorRegBits<<5)|dstVectorRegBits, + shiftByImmediate.opcode<<3|0b1<<2|srcVectorRegBits>>3, + immh<<3|immb, + q<<6|shiftByImmediate.U<<5|0b1111, + ) return nil } if permute, ok := advancedSIMDPermute[n.instruction]; ok { size, q := arrangementSizeQ(n.vectorArrangement) - a.encodeAdvancedSIMDPermute(srcVectorRegBits, dstVectorRegBits, dstVectorRegBits, permute.opcode, size, q) + a.encodeAdvancedSIMDPermute(buf, srcVectorRegBits, dstVectorRegBits, dstVectorRegBits, permute.opcode, size, q) return } return errorEncodingUnsupported(n) } -func (a *AssemblerImpl) encodeTwoVectorRegistersToVectorRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeTwoVectorRegistersToVectorRegister(buf asm.Buffer, n *nodeImpl) (err error) { var srcRegBits, srcRegBits2, dstRegBits byte srcRegBits, err = vectorRegisterBits(n.srcReg) if err != nil { @@ -3744,7 +3761,7 @@ func (a *AssemblerImpl) encodeTwoVectorRegistersToVectorRegister(n *nodeImpl) (e if !ok { return fmt.Errorf("unsupported vector arrangement %s for %s", n.vectorArrangement, InstructionName(n.instruction)) } - a.encodeAdvancedSIMDThreeSame(srcRegBits, srcRegBits2, dstRegBits, threeSame.opcode, qs.size, qs.q, threeSame.u) + a.encodeAdvancedSIMDThreeSame(buf, srcRegBits, srcRegBits2, dstRegBits, threeSame.opcode, qs.size, qs.q, threeSame.u) return nil } @@ -3753,13 +3770,13 @@ func (a *AssemblerImpl) encodeTwoVectorRegistersToVectorRegister(n *nodeImpl) (e if !ok { return fmt.Errorf("unsupported vector arrangement %s for %s", n.vectorArrangement, InstructionName(n.instruction)) } - a.encodeAdvancedSIMDThreeDifferent(srcRegBits, srcRegBits2, dstRegBits, threeDifferent.opcode, qs.size, qs.q, threeDifferent.u) + a.encodeAdvancedSIMDThreeDifferent(buf, srcRegBits, srcRegBits2, dstRegBits, threeDifferent.opcode, qs.size, qs.q, threeDifferent.u) return nil } if permute, ok := advancedSIMDPermute[n.instruction]; ok { size, q := arrangementSizeQ(n.vectorArrangement) - a.encodeAdvancedSIMDPermute(srcRegBits, srcRegBits2, dstRegBits, permute.opcode, size, q) + a.encodeAdvancedSIMDPermute(buf, srcRegBits, srcRegBits2, dstRegBits, permute.opcode, size, q) return } @@ -3776,18 +3793,18 @@ func (a *AssemblerImpl) encodeTwoVectorRegistersToVectorRegister(n *nodeImpl) (e default: return fmt.Errorf("invalid arrangement %s for EXT", n.vectorArrangement) } - a.buf.Write([]byte{ - (srcRegBits2 << 5) | dstRegBits, - imm4<<3 | srcRegBits2>>3, + buf.Append4Bytes( + (srcRegBits2<<5)|dstRegBits, + imm4<<3|srcRegBits2>>3, srcRegBits, - q<<6 | 0b101110, - }) + q<<6|0b101110, + ) return } return } -func (a *AssemblerImpl) encodeVectorRegisterToRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeVectorRegisterToRegister(buf asm.Buffer, n *nodeImpl) (err error) { if err = checkArrangementIndexPair(n.vectorArrangement, n.srcVectorIndex); err != nil { return } @@ -3807,13 +3824,13 @@ func (a *AssemblerImpl) encodeVectorRegisterToRegister(n *nodeImpl) (err error) if err != nil { return err } - a.encodeAdvancedSIMDCopy(srcVecRegBits, dstRegBits, simdCopy.op, imm5, imm4, q) + a.encodeAdvancedSIMDCopy(buf, srcVecRegBits, dstRegBits, simdCopy.op, imm5, imm4, q) return nil } return errorEncodingUnsupported(n) } -func (a *AssemblerImpl) encodeRegisterToVectorRegister(n *nodeImpl) (err error) { +func (a *AssemblerImpl) encodeRegisterToVectorRegister(buf asm.Buffer, n *nodeImpl) (err error) { srcRegBits, err := intRegisterBits(n.srcReg) if err != nil { return err @@ -3829,7 +3846,7 @@ func (a *AssemblerImpl) encodeRegisterToVectorRegister(n *nodeImpl) (err error) if err != nil { return err } - a.encodeAdvancedSIMDCopy(srcRegBits, dstVectorRegBits, simdCopy.op, imm5, imm4, q) + a.encodeAdvancedSIMDCopy(buf, srcRegBits, dstVectorRegBits, simdCopy.op, imm5, imm4, q) return nil } return errorEncodingUnsupported(n) diff --git a/vendor/github.com/tetratelabs/wazero/internal/asm/assembler.go b/vendor/github.com/tetratelabs/wazero/internal/asm/assembler.go index 9d2dd79a4..dd34f7863 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/asm/assembler.go +++ b/vendor/github.com/tetratelabs/wazero/internal/asm/assembler.go @@ -52,11 +52,12 @@ type ConstantValue = int64 // StaticConst represents an arbitrary constant bytes which are pooled and emitted by assembler into the binary. // These constants can be referenced by instructions. type StaticConst struct { + // offsetFinalizedCallbacks holds callbacks which are called when .OffsetInBinary is finalized by assembler implementation. + offsetFinalizedCallbacks []func(offsetOfConstInBinary uint64) + Raw []byte // OffsetInBinary is the offset of this static const in the result binary. OffsetInBinary uint64 - // offsetFinalizedCallbacks holds callbacks which are called when .OffsetInBinary is finalized by assembler implementation. - offsetFinalizedCallbacks []func(offsetOfConstInBinary uint64) } // NewStaticConst returns the pointer to the new NewStaticConst for given bytes. @@ -79,13 +80,14 @@ func (s *StaticConst) SetOffsetInBinary(offset uint64) { // StaticConstPool holds a bulk of StaticConst which are yet to be emitted into the binary. type StaticConstPool struct { - // FirstUseOffsetInBinary holds the offset of the first instruction which accesses this const pool . - FirstUseOffsetInBinary NodeOffsetInBinary - Consts []*StaticConst // addedConsts is used to deduplicate the consts to reduce the final size of binary. // Note: we can use map on .consts field and remove this field, // but we have the separate field for deduplication in order to have deterministic assembling behavior. addedConsts map[*StaticConst]struct{} + + Consts []*StaticConst + // FirstUseOffsetInBinary holds the offset of the first instruction which accesses this const pool . + FirstUseOffsetInBinary NodeOffsetInBinary // PoolSizeInBytes is the current size of the pool in bytes. PoolSizeInBytes int } @@ -138,7 +140,7 @@ type AssemblerBase interface { Reset() // Assemble produces the final binary for the assembled operations. - Assemble() ([]byte, error) + Assemble(Buffer) error // SetJumpTargetOnNext instructs the assembler that the next node must be // assigned to the given node's jump destination. diff --git a/vendor/github.com/tetratelabs/wazero/internal/asm/buffer.go b/vendor/github.com/tetratelabs/wazero/internal/asm/buffer.go new file mode 100644 index 000000000..0476c380e --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/asm/buffer.go @@ -0,0 +1,235 @@ +package asm + +import ( + "encoding/binary" + "fmt" + "unsafe" + + "github.com/tetratelabs/wazero/internal/platform" +) + +var zero [16]byte + +// CodeSegment represents a memory mapped segment where native CPU instructions +// are written. +// +// To construct code segments, the program must call Next to obtain a buffer +// view capable of writing data at the end of the segment. Next must be called +// before generating the code of a function because it aligns the next write on +// 16 bytes. +// +// Instances of CodeSegment hold references to memory which is NOT managed by +// the garbage collector and therefore must be released *manually* by calling +// their Unmap method to prevent memory leaks. +// +// The zero value is a valid, empty code segment, equivalent to being +// constructed by calling NewCodeSegment(nil). +type CodeSegment struct { + code []byte + size int +} + +// NewCodeSegment constructs a CodeSegment value from a byte slice. +// +// No validation is made that the byte slice is a memory mapped region which can +// be unmapped on Close. +func NewCodeSegment(code []byte) *CodeSegment { + return &CodeSegment{code: code, size: len(code)} +} + +// Map allocates a memory mapping of the given size to the code segment. +// +// Note that programs only need to use this method to initialize the code +// segment to a specific content (e.g. when loading pre-compiled code from a +// file), otherwise the backing memory mapping is allocated on demand when code +// is written to the code segment via Buffers returned by calls to Next. +// +// The method errors is the segment is already backed by a memory mapping. +func (seg *CodeSegment) Map(size int) error { + if seg.code != nil { + return fmt.Errorf("code segment already initialized to memory mapping of size %d", len(seg.code)) + } + b, err := platform.MmapCodeSegment(size) + if err != nil { + return err + } + seg.code = b + seg.size = size + return nil +} + +// Close unmaps the underlying memory region held by the code segment, clearing +// its state back to an empty code segment. +// +// The value is still usable after unmapping its memory, a new memory area can +// be allocated by calling Map or writing to the segment. +func (seg *CodeSegment) Unmap() error { + if seg.code != nil { + if err := platform.MunmapCodeSegment(seg.code[:cap(seg.code)]); err != nil { + return err + } + seg.code = nil + seg.size = 0 + } + return nil +} + +// Addr returns the address of the beginning of the code segment as a uintptr. +func (seg *CodeSegment) Addr() uintptr { + if len(seg.code) > 0 { + return uintptr(unsafe.Pointer(&seg.code[0])) + } + return 0 +} + +// Size returns the size of code segment, which is less or equal to the length +// of the byte slice returned by Len or Bytes. +func (seg *CodeSegment) Size() uintptr { + return uintptr(seg.size) +} + +// Len returns the length of the byte slice referencing the memory mapping of +// the code segment. +func (seg *CodeSegment) Len() int { + return len(seg.code) +} + +// Bytes returns a byte slice to the memory mapping of the code segment. +// +// The returned slice remains valid until more bytes are written to a buffer +// of the code segment, or Unmap is called. +func (seg *CodeSegment) Bytes() []byte { + return seg.code +} + +// Next returns a buffer pointed at the end of the code segment to support +// writing more code instructions to it. +// +// Buffers are passed by value, but they hold a reference to the code segment +// that they were created from. +func (seg *CodeSegment) NextCodeSection() Buffer { + // Align 16-bytes boundary. + seg.AppendBytes(zero[:seg.size&15]) + return Buffer{CodeSegment: seg, off: seg.size} +} + +// Append appends n bytes to the code segment, returning a slice to the appended +// memory region. +// +// The underlying code segment may be reallocated if it was too short to hold +// n more bytes, which invalidates any addresses previously returned by calls +// to Addr. +func (seg *CodeSegment) Append(n int) []byte { + seg.size += n + if seg.size > len(seg.code) { + seg.growToSize() + } + return seg.code[seg.size-n:] +} + +// AppendByte appends a single byte to the code segment. +// +// The underlying code segment may be reallocated if it was too short to hold +// one more byte, which invalidates any addresses previously returned by calls +// to Addr. +func (seg *CodeSegment) AppendByte(b byte) { + seg.size++ + if seg.size > len(seg.code) { + seg.growToSize() + } + seg.code[seg.size-1] = b +} + +// AppendBytes appends a copy of b to the code segment. +// +// The underlying code segment may be reallocated if it was too short to hold +// len(b) more bytes, which invalidates any addresses previously returned by +// calls to Addr. +func (seg *CodeSegment) AppendBytes(b []byte) { + copy(seg.Append(len(b)), b) +} + +// AppendUint32 appends a 32 bits integer to the code segment. +// +// The underlying code segment may be reallocated if it was too short to hold +// four more bytes, which invalidates any addresses previously returned by calls +// to Addr. +func (seg *CodeSegment) AppendUint32(u uint32) { + seg.size += 4 + if seg.size > len(seg.code) { + seg.growToSize() + } + // This can be replaced by an unsafe operation to assign the uint32, which + // keeps the function cost below the inlining threshold. However, it did not + // show any improvements in arm64 benchmarks so we retained this safer code. + binary.LittleEndian.PutUint32(seg.code[seg.size-4:], u) +} + +// growMode grows the code segment so that another section can be added to it. +// +// The method is marked go:noinline so that it doesn't get inline in Append, +// and AppendByte, which keeps the inlining score of those methods low enough +// that they can be inlined at the call sites. +// +//go:noinline +func (seg *CodeSegment) growToSize() { + seg.Grow(0) +} + +// Grow ensure that the capacity of the code segment is large enough to hold n +// more bytes. +// +// The underlying code segment may be reallocated if it was too short, which +// invalidates any addresses previously returned by calls to Addr. +func (seg *CodeSegment) Grow(n int) { + size := len(seg.code) + want := seg.size + n + if size >= want { + return + } + if size == 0 { + size = 65536 + } + for size < want { + size *= 2 + } + b, err := platform.RemapCodeSegment(seg.code, size) + if err != nil { + // The only reason for growing the buffer to error is if we run + // out of memory, so panic for now as it greatly simplifies error + // handling to assume writing to the buffer would never fail. + panic(err) + } + seg.code = b +} + +// Buffer is a reference type representing a section beginning at the end of a +// code segment where new instructions can be written. +type Buffer struct { + *CodeSegment + off int +} + +func (buf Buffer) Cap() int { + return len(buf.code) - buf.off +} + +func (buf Buffer) Len() int { + return buf.size - buf.off +} + +func (buf Buffer) Bytes() []byte { + return buf.code[buf.off:buf.size:buf.size] +} + +func (buf Buffer) Reset() { + buf.size = buf.off +} + +func (buf Buffer) Truncate(n int) { + buf.size = buf.off + n +} + +func (buf Buffer) Append4Bytes(a, b, c, d byte) { + buf.AppendUint32(uint32(a) | uint32(b)<<8 | uint32(c)<<16 | uint32(d)<<24) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/bitpack/offset_array.go b/vendor/github.com/tetratelabs/wazero/internal/bitpack/offset_array.go new file mode 100644 index 000000000..8cafd1882 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/bitpack/offset_array.go @@ -0,0 +1,224 @@ +package bitpack + +import ( + "math" +) + +// OffsetArray is an interface representing read-only views of arrays of 64 bits +// offsets. +type OffsetArray interface { + // Returns the value at index i. + // + // The method complexity may be anywhere between O(1) and O(N). + Index(i int) uint64 + // Returns the number of offsets in the array. + // + // The method complexity must be O(1). + Len() int +} + +// OffsetArrayLen is a helper function to access the length of an offset array. +// It is similar to calling Len on the array but handles the special case where +// the array is nil, in which case it returns zero. +func OffsetArrayLen(array OffsetArray) int { + if array != nil { + return array.Len() + } + return 0 +} + +// NewOffsetArray constructs a new array of offsets from the slice of values +// passed as argument. The slice is not retained, the returned array always +// holds a copy of the values. +// +// The underlying implementation of the offset array applies a compression +// mechanism derived from Frame-of-Reference and Delta Encoding to minimize +// the memory footprint of the array. This compression model works best when +// the input is made of ordered values, otherwise the deltas between values +// are likely to be too large to benefit from delta encoding. +// +// See https://lemire.me/blog/2012/02/08/effective-compression-using-frame-of-reference-and-delta-coding/ +func NewOffsetArray(values []uint64) OffsetArray { + if len(values) == 0 { + return emptyOffsetArray{} + } + if len(values) <= smallOffsetArrayCapacity { + return newSmallOffsetArray(values) + } + + maxDelta := uint64(0) + lastValue := values[0] + // TODO: the pre-processing we perform here can be optimized using SIMD + // instructions. + for _, value := range values[1:] { + if delta := value - lastValue; delta > maxDelta { + maxDelta = delta + } + lastValue = value + } + + switch { + case maxDelta > math.MaxUint32: + return newOffsetArray(values) + case maxDelta > math.MaxUint16: + return newDeltaArray[uint32](values) + case maxDelta > math.MaxUint8: + return newDeltaArray[uint16](values) + case maxDelta > 15: + return newDeltaArray[uint8](values) + default: + return newDeltaArrayUint4(values) + } +} + +type offsetArray struct { + values []uint64 +} + +func newOffsetArray(values []uint64) *offsetArray { + a := &offsetArray{ + values: make([]uint64, len(values)), + } + copy(a.values, values) + return a +} + +func (a *offsetArray) Index(i int) uint64 { + return a.values[i] +} + +func (a *offsetArray) Len() int { + return len(a.values) +} + +type emptyOffsetArray struct{} + +func (emptyOffsetArray) Index(int) uint64 { + panic("index out of bounds") +} + +func (emptyOffsetArray) Len() int { + return 0 +} + +const smallOffsetArrayCapacity = 7 + +type smallOffsetArray struct { + length int + values [smallOffsetArrayCapacity]uint64 +} + +func newSmallOffsetArray(values []uint64) *smallOffsetArray { + a := &smallOffsetArray{length: len(values)} + copy(a.values[:], values) + return a +} + +func (a *smallOffsetArray) Index(i int) uint64 { + if i < 0 || i >= a.length { + panic("index out of bounds") + } + return a.values[i] +} + +func (a *smallOffsetArray) Len() int { + return a.length +} + +type uintType interface { + uint8 | uint16 | uint32 | uint64 +} + +type deltaArray[T uintType] struct { + deltas []T + firstValue uint64 +} + +func newDeltaArray[T uintType](values []uint64) *deltaArray[T] { + a := &deltaArray[T]{ + deltas: make([]T, len(values)-1), + firstValue: values[0], + } + lastValue := values[0] + for i, value := range values[1:] { + a.deltas[i] = T(value - lastValue) + lastValue = value + } + return a +} + +func (a *deltaArray[T]) Index(i int) uint64 { + if i < 0 || i >= a.Len() { + panic("index out of bounds") + } + value := a.firstValue + // TODO: computing the prefix sum can be vectorized; + // see https://en.algorithmica.org/hpc/algorithms/prefix/ + for _, delta := range a.deltas[:i] { + value += uint64(delta) + } + return value +} + +func (a *deltaArray[T]) Len() int { + return len(a.deltas) + 1 +} + +// deltaArrayUint4 is a specialization of deltaArray which packs 4 bits integers +// to hold deltas between 0 and 15; based on the analysis of compiling Python, +// it appeared that most source offset deltas were under 16, so using this +// data structure cuts by 50% the memory needed compared to deltaArray[uint8]. +// +// Here is the distribution of source offset deltas for Python 3.13: +// +// - <=15 : 10240 +// - <=255 : 9565 +// - <=65535 : 1163 +// +// Memory profiles showed that using deltaArrayUint4 (compared to deltaArray[T]) +// dropped the memory footprint of source mappings for Python from 6MB to 4.5MB. +type deltaArrayUint4 struct { + deltas []byte + numValues int + firstValue uint64 +} + +func newDeltaArrayUint4(values []uint64) *deltaArrayUint4 { + a := &deltaArrayUint4{ + deltas: make([]byte, len(values)/2+1), + numValues: len(values), + firstValue: values[0], + } + lastValue := values[0] + for i, value := range values[1:] { + a.assign(i, value-lastValue) + lastValue = value + } + return a +} + +func (a *deltaArrayUint4) assign(i int, v uint64) { + index, shift := uint(i)>>1, 4*(uint(i)&1) + a.deltas[index] &= ^(0xF << shift) + a.deltas[index] |= byte(v) << shift +} + +func (a *deltaArrayUint4) index(i int) uint64 { + index, shift := uint(i)>>1, 4*(uint(i)&1) + return uint64((a.deltas[index] >> shift) & 0xF) +} + +func (a *deltaArrayUint4) Index(i int) uint64 { + if i < 0 || i >= a.Len() { + panic("index out of bounds") + } + value := a.firstValue + for j := 0; j < i; j++ { + value += a.index(j) + } + return value +} + +func (a *deltaArrayUint4) Len() int { + return a.numValues +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/RATIONALE.md b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/RATIONALE.md index 0fcea3a79..9cb7513e3 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/RATIONALE.md +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/RATIONALE.md @@ -75,3 +75,38 @@ and as of Go 1.20, these assembler functions are considered as _unsafe_ for asyn From the Go runtime point of view, the execution of runtime-generated machine codes is considered as a part of that trampoline function. Therefore, runtime-generated machine code is also correctly considered unsafe for async preemption. + +## Why context cancellation is handled in Go code rather than native code + +Since [wazero v1.0.0-pre.9](https://github.com/tetratelabs/wazero/releases/tag/v1.0.0-pre.9), the runtime +supports integration with Go contexts to interrupt execution after a timeout, or in response to explicit cancellation. +This support is internally implemented as a special opcode `builtinFunctionCheckExitCode` that triggers the execution of +a Go function (`ModuleInstance.FailIfClosed`) that atomically checks a sentinel value at strategic points in the code +(e.g. [within loops][checkexitcode_loop]). + +[It _is indeed_ possible to check the sentinel value directly, without leaving the native world][native_check], thus sparing some cycles; +however, because native code never preempts (see section above), this may lead to a state where the other goroutines +never get the chance to run, and thus never get the chance to set the sentinel value; effectively preventing +cancellation from taking place. + +[checkexitcode_loop]: https://github.com/tetratelabs/wazero/blob/86444c67a37dbf9e693ae5b365901f64968d9025/internal/wazeroir/compiler.go#L467-L476 +[native_check]: https://github.com/tetratelabs/wazero/issues/1409 + +## Source Offset Mapping + +When translating code from WebAssembly to the wazero IR, and compiling to native +binary, wazero keeps track of two indexes to correlate native program counters +to the original source offset that they were generated from. + +Source offset maps are useful for debugging, but holding indexes in memory for +all instructions can have a significant overhead. To reduce the memory footprint +of the compiled modules, wazero uses data structures inspired by +[frame-of-reference and delta encoding][FOR]. + +Because wazero does not reorder instructions, the source offsets are naturally +sorted during compilation, and the distance between two consecutive offsets is +usually small. Encoding deltas instead of the absolute values allows most of +the indexes to store offsets with an overhead of 8 bits per instruction, instead +of recording 64 bits integers for absolute code positions. + +[FOR]: https://lemire.me/blog/2012/02/08/effective-compression-using-frame-of-reference-and-delta-coding/ diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/arch.go b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/arch.go index 3eb1cd3f0..81b9efc3a 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/arch.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/arch.go @@ -11,10 +11,9 @@ var newArchContext func() archContext // nativecall is used by callEngine.execWasmFunction and the entrypoint to enter the compiled native code. // codeSegment is the pointer to the initial instruction of the compiled native code. -// ce is "*callEngine" as uintptr. // // Note: this is implemented in per-arch Go assembler file. For example, arch_amd64.s implements this for amd64. -func nativecall(codeSegment, ce uintptr, moduleInstanceAddress *wasm.ModuleInstance) +func nativecall(codeSegment uintptr, ce *callEngine, moduleInstanceAddress *wasm.ModuleInstance) // registerNameFn is used for debugging purpose to have register symbols in the string of runtimeValueLocation. var registerNameFn func(register asm.Register) string diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/compiler.go b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/compiler.go index 837a3376f..b2c79becc 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/compiler.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/compiler.go @@ -16,9 +16,9 @@ type compiler interface { // compilePreamble is called before compiling any wazeroir operation. // This is used, for example, to initialize the reserved registers, etc. compilePreamble() error - // compile generates the byte slice of native code. + // compile generates the native code into buf. // stackPointerCeil is the max stack pointer that the target function would reach. - compile() (code []byte, stackPointerCeil uint64, err error) + compile(buf asm.Buffer) (stackPointerCeil uint64, err error) // compileGoHostFunction adds the trampoline code from which native code can jump into the Go-defined host function. // TODO: maybe we wouldn't need to have trampoline for host functions. compileGoDefinedHostFunction() error diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine.go b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine.go index b6f1104a6..d5ec8e27b 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine.go @@ -13,6 +13,7 @@ import ( "github.com/tetratelabs/wazero/api" "github.com/tetratelabs/wazero/experimental" "github.com/tetratelabs/wazero/internal/asm" + "github.com/tetratelabs/wazero/internal/bitpack" "github.com/tetratelabs/wazero/internal/filecache" "github.com/tetratelabs/wazero/internal/internalapi" "github.com/tetratelabs/wazero/internal/platform" @@ -129,14 +130,6 @@ type ( // initialFn is the initial function for this call engine. initialFn *function - // ctx is the context.Context passed to all the host function calls. - // This is modified when there's a function listener call, otherwise it's always the context.Context - // passed to the Call API. - ctx context.Context - // contextStack is a stack of contexts which is pushed and popped by function listeners. - // This is used and modified when there are function listeners. - contextStack *contextStack - // stackIterator provides a way to iterate over the stack for Listeners. // It is setup and valid only during a call to a Listener hook. stackIterator stackIterator @@ -144,14 +137,6 @@ type ( ensureTermination bool } - // contextStack is a stack of context.Context. - contextStack struct { - // See note at top of file before modifying this struct. - - self context.Context - prev *contextStack - } - // moduleContext holds the per-function call specific module information. // This is subject to be manipulated from compiled native code whenever we make function calls. moduleContext struct { @@ -272,18 +257,14 @@ type ( moduleInstance *wasm.ModuleInstance // typeID is the corresponding wasm.FunctionTypeID for funcType. typeID wasm.FunctionTypeID - // index is the function Index in this module. - index wasm.Index // funcType is the function type for this function. Created during compilation. funcType *wasm.FunctionType - // def is the api.Function for this function. Created during compilation. - def api.FunctionDefinition // parent holds code from which this is created. parent *compiledFunction } compiledModule struct { - executable []byte + executable asm.CodeSegment functions []compiledFunction source *wasm.Module ensureTermination bool @@ -293,28 +274,46 @@ type ( // compiled by wazero compiler. compiledFunction struct { // codeSegment is holding the compiled native code as a byte slice. - executableOffset int + executableOffset uintptr // See the doc for codeStaticData type. // stackPointerCeil is the max of the stack pointer this function can reach. Lazily applied via maybeGrowStack. stackPointerCeil uint64 + index wasm.Index goFunc interface{} listener experimental.FunctionListener parent *compiledModule sourceOffsetMap sourceOffsetMap } - // sourceOffsetMap holds the information to retrieve the original offset in the Wasm binary from the - // offset in the native binary. + // sourceOffsetMap holds the information to retrieve the original offset in + // the Wasm binary from the offset in the native binary. + // + // The fields are implemented as bit-packed arrays of 64 bits integers to + // reduce the memory footprint. Indexing into such arrays is not as fast as + // indexing into a simple slice, but the source offset map is intended to be + // used for debugging, lookups into the arrays should not appear on code + // paths that are critical to the application performance. + // + // The bitpack.OffsetArray fields may be nil, use bitpack.OffsetArrayLen to + // determine whether they are empty prior to indexing into the arrays to + // avoid panics caused by accessing nil pointers. sourceOffsetMap struct { // See note at top of file before modifying this struct. // irOperationOffsetsInNativeBinary is index-correlated with irOperationSourceOffsetsInWasmBinary, // and maps each index (corresponding to each IR Operation) to the offset in the compiled native code. - irOperationOffsetsInNativeBinary []uint64 + irOperationOffsetsInNativeBinary bitpack.OffsetArray // irOperationSourceOffsetsInWasmBinary is index-correlated with irOperationOffsetsInNativeBinary. // See wazeroir.CompilationResult irOperationOffsetsInNativeBinary. - irOperationSourceOffsetsInWasmBinary []uint64 + irOperationSourceOffsetsInWasmBinary bitpack.OffsetArray + } + + // functionListenerInvocation captures arguments needed to perform function + // listener invocations when unwinding the call stack. + functionListenerInvocation struct { + experimental.FunctionListener + def api.FunctionDefinition } ) @@ -353,7 +352,7 @@ const ( functionCodeInitialAddressOffset = 0 functionModuleInstanceOffset = 8 functionTypeIDOffset = 16 - functionSize = 56 + functionSize = 40 // Offsets for wasm.ModuleInstance. moduleInstanceGlobalsOffset = 32 @@ -474,16 +473,10 @@ func (s nativeCallStatusCode) String() (ret string) { // releaseCompiledModule is a runtime.SetFinalizer function that munmaps the compiledModule.executable. func releaseCompiledModule(cm *compiledModule) { - e := cm.executable - if e == nil { - return // already released - } - - // Setting this to nil allows tests to know the correct finalizer function was called. - cm.executable = nil - if err := platform.MunmapCodeSegment(e); err != nil { - // munmap failure cannot recover, and happen asynchronously on the finalizer thread. While finalizer - // functions can return errors, they are ignored. + if err := cm.executable.Unmap(); err != nil { + // munmap failure cannot recover, and happen asynchronously on the + // finalizer thread. While finalizer functions can return errors, + // they are ignored. panic(fmt.Errorf("compiler: failed to munmap code segment: %w", err)) } } @@ -532,25 +525,44 @@ func (e *engine) CompileModule(_ context.Context, module *wasm.Module, listeners return e.addCompiledModule(module, cm, withGoFunc) } - bodies := make([][]byte, localFuncs) // As this uses mmap, we need to munmap on the compiled machine code when it's GCed. e.setFinalizer(cm, releaseCompiledModule) ln := len(listeners) cmp := newCompiler() + asmNodes := new(asmNodes) + offsets := new(offsets) + + // The executable code is allocated in memory mappings held by the + // CodeSegment, which gros on demand when it exhausts its capacity. + var executable asm.CodeSegment + defer func() { + // At the end of the function, the executable is set on the compiled + // module and the local variable cleared; until then, the function owns + // the memory mapping and is reponsible for clearing it if it returns + // due to an error. Note that an error at this stage is not recoverable + // so we panic if we fail to unmap the memory segment. + if err := executable.Unmap(); err != nil { + panic(fmt.Errorf("compiler: failed to munmap code segment: %w", err)) + } + }() + for i := range module.CodeSection { typ := &module.TypeSection[module.FunctionSection[i]] - var lsn experimental.FunctionListener - if i < ln { - lsn = listeners[i] - } + buf := executable.NextCodeSection() funcIndex := wasm.Index(i) compiledFn := &cm.functions[i] - var body []byte + compiledFn.executableOffset = executable.Size() + compiledFn.parent = cm + compiledFn.index = importedFuncs + funcIndex + if i < ln { + compiledFn.listener = listeners[i] + } + if codeSeg := &module.CodeSection[i]; codeSeg.GoFunc != nil { - cmp.Init(typ, nil, lsn != nil) + cmp.Init(typ, nil, compiledFn.listener != nil) withGoFunc = true - if body, err = compileGoDefinedHostFunction(cmp); err != nil { - def := module.FunctionDefinitionSection[funcIndex+importedFuncs] + if err = compileGoDefinedHostFunction(buf, cmp); err != nil { + def := module.FunctionDefinition(compiledFn.index) return fmt.Errorf("error compiling host go func[%s]: %w", def.DebugName(), err) } compiledFn.goFunc = codeSeg.GoFunc @@ -559,47 +571,23 @@ func (e *engine) CompileModule(_ context.Context, module *wasm.Module, listeners if err != nil { return fmt.Errorf("failed to lower func[%d]: %v", i, err) } - cmp.Init(typ, ir, lsn != nil) + cmp.Init(typ, ir, compiledFn.listener != nil) - body, compiledFn.stackPointerCeil, compiledFn.sourceOffsetMap, err = compileWasmFunction(cmp, ir) + compiledFn.stackPointerCeil, compiledFn.sourceOffsetMap, err = compileWasmFunction(buf, cmp, ir, asmNodes, offsets) if err != nil { - def := module.FunctionDefinitionSection[funcIndex+importedFuncs] + def := module.FunctionDefinition(compiledFn.index) return fmt.Errorf("error compiling wasm func[%s]: %w", def.DebugName(), err) } } - - // The `body` here is the view owned by assembler and will be overridden by the next iteration, so copy the body here. - bodyCopied := make([]byte, len(body)) - copy(bodyCopied, body) - bodies[i] = bodyCopied - compiledFn.listener = lsn - compiledFn.parent = cm - } - - var executableOffset int - for i, b := range bodies { - cm.functions[i].executableOffset = executableOffset - // Align 16-bytes boundary. - executableOffset = (executableOffset + len(b) + 15) &^ 15 - } - - executable, err := platform.MmapCodeSegment(executableOffset) - if err != nil { - return err - } - - for i, b := range bodies { - offset := cm.functions[i].executableOffset - copy(executable[offset:], b) } if runtime.GOARCH == "arm64" { // On arm64, we cannot give all of rwx at the same time, so we change it to exec. - if err = platform.MprotectRX(executable); err != nil { + if err := platform.MprotectRX(executable.Bytes()); err != nil { return err } } - cm.executable = executable + cm.executable, executable = executable, asm.CodeSegment{} return e.addCompiledModule(module, cm, withGoFunc) } @@ -626,12 +614,10 @@ func (e *engine) NewModuleEngine(module *wasm.Module, instance *wasm.ModuleInsta offset := int(module.ImportFunctionCount) + i typeIndex := module.FunctionSection[i] me.functions[offset] = function{ - codeInitialAddress: uintptr(unsafe.Pointer(&cm.executable[c.executableOffset])), + codeInitialAddress: cm.executable.Addr() + c.executableOffset, moduleInstance: instance, - index: wasm.Index(offset), typeID: instance.TypeIDs[typeIndex], funcType: &module.TypeSection[typeIndex], - def: &module.FunctionDefinitionSection[offset], parent: c, } } @@ -643,8 +629,6 @@ func (e *moduleEngine) ResolveImportedFunction(index, indexInImportedModule wasm imported := importedModuleEngine.(*moduleEngine) // Copies the content from the import target moduleEngine. e.functions[index] = imported.functions[indexInImportedModule] - // Update the .index field to the value in this Module. - e.functions[index].index = index } // FunctionInstanceReference implements the same method as documented on wasm.ModuleEngine. @@ -652,20 +636,21 @@ func (e *moduleEngine) FunctionInstanceReference(funcIndex wasm.Index) wasm.Refe return uintptr(unsafe.Pointer(&e.functions[funcIndex])) } +// NewFunction implements wasm.ModuleEngine. func (e *moduleEngine) NewFunction(index wasm.Index) api.Function { - // Note: The input parameters are pre-validated, so a compiled function is only absent on close. Updates to - // code on close aren't locked, neither is this read. - compiled := &e.functions[index] + return e.newFunction(&e.functions[index]) +} +func (e *moduleEngine) newFunction(f *function) api.Function { initStackSize := initialStackSize - if initialStackSize < compiled.parent.stackPointerCeil { - initStackSize = compiled.parent.stackPointerCeil * 2 + if initialStackSize < f.parent.stackPointerCeil { + initStackSize = f.parent.stackPointerCeil * 2 } - return e.newCallEngine(initStackSize, compiled) + return e.newCallEngine(initStackSize, f) } // LookupFunction implements the same method as documented on wasm.ModuleEngine. -func (e *moduleEngine) LookupFunction(t *wasm.TableInstance, typeId wasm.FunctionTypeID, tableOffset wasm.Index) (idx wasm.Index, err error) { +func (e *moduleEngine) LookupFunction(t *wasm.TableInstance, typeId wasm.FunctionTypeID, tableOffset wasm.Index) (f api.Function, err error) { if tableOffset >= uint32(len(t.References)) || t.Type != wasm.RefTypeFuncref { err = wasmruntime.ErrRuntimeInvalidTableAccess return @@ -681,8 +666,7 @@ func (e *moduleEngine) LookupFunction(t *wasm.TableInstance, typeId wasm.Functio err = wasmruntime.ErrRuntimeIndirectCallTypeMismatch return } - idx = tf.index - + f = e.newFunction(tf) return } @@ -700,7 +684,12 @@ func functionFromUintptr(ptr uintptr) *function { // Definition implements the same method as documented on wasm.ModuleEngine. func (ce *callEngine) Definition() api.FunctionDefinition { - return ce.initialFn.def + return ce.initialFn.definition() +} + +func (f *function) definition() api.FunctionDefinition { + compiled := f.parent + return compiled.parent.source.FunctionDefinition(compiled.index) } // Call implements the same method as documented on wasm.ModuleEngine. @@ -740,7 +729,7 @@ func (ce *callEngine) call(ctx context.Context, params, results []uint64) (_ []u // and we have to make sure that all the runtime errors, including the one happening inside // host functions, will be captured as errors, not panics. defer func() { - err = ce.deferredOnCall(recover()) + err = ce.deferredOnCall(ctx, m, recover()) if err == nil { // If the module closed during the call, and the call didn't err for another reason, set an ExitError. err = m.FailIfClosed() @@ -820,7 +809,7 @@ func callFrameOffset(funcType *wasm.FunctionType) (ret int) { // the state of callEngine so that it can be used for the subsequent calls. // // This is defined for testability. -func (ce *callEngine) deferredOnCall(recovered interface{}) (err error) { +func (ce *callEngine) deferredOnCall(ctx context.Context, m *wasm.ModuleInstance, recovered interface{}) (err error) { if recovered != nil { builder := wasmdebug.NewErrorBuilder() @@ -829,20 +818,29 @@ func (ce *callEngine) deferredOnCall(recovered interface{}) (err error) { fn := ce.fn pc := uint64(ce.returnAddress) stackBasePointer := int(ce.stackBasePointerInBytes >> 3) + functionListeners := make([]functionListenerInvocation, 0, 16) + for { - def := fn.def + def := fn.definition() // sourceInfo holds the source code information corresponding to the frame. // It is not empty only when the DWARF is enabled. var sources []string - if p := fn.parent; p.parent.executable != nil { - if len(fn.parent.sourceOffsetMap.irOperationSourceOffsetsInWasmBinary) != 0 { + if p := fn.parent; p.parent.executable.Bytes() != nil { + if fn.parent.sourceOffsetMap.irOperationSourceOffsetsInWasmBinary != nil { offset := fn.getSourceOffsetInWasmBinary(pc) sources = p.parent.source.DWARFLines.Line(offset) } } builder.AddFrame(def.DebugName(), def.ParamTypes(), def.ResultTypes(), sources) + if fn.parent.listener != nil { + functionListeners = append(functionListeners, functionListenerInvocation{ + FunctionListener: fn.parent.listener, + def: fn.definition(), + }) + } + callFrameOffset := callFrameOffset(fn.funcType) if stackBasePointer != 0 { frame := *(*callFrame)(unsafe.Pointer(&ce.stack[stackBasePointer+callFrameOffset])) @@ -853,7 +851,11 @@ func (ce *callEngine) deferredOnCall(recovered interface{}) (err error) { break } } + err = builder.FromRecovered(recovered) + for i := range functionListeners { + functionListeners[i].Abort(ctx, m, functionListeners[i].def, err) + } } // Allows the reuse of CallEngine. @@ -867,25 +869,41 @@ func (ce *callEngine) deferredOnCall(recovered interface{}) (err error) { // If needPreviousInstr equals true, this returns the previous instruction's offset for the given pc. func (f *function) getSourceOffsetInWasmBinary(pc uint64) uint64 { srcMap := &f.parent.sourceOffsetMap - n := len(srcMap.irOperationOffsetsInNativeBinary) + 1 + n := bitpack.OffsetArrayLen(srcMap.irOperationOffsetsInNativeBinary) + 1 // Calculate the offset in the compiled native binary. pcOffsetInNativeBinary := pc - uint64(f.codeInitialAddress) - // Then, do the binary search on the list of offsets in the native binary for all the IR operations. - // This returns the index of the *next* IR operation of the one corresponding to the origin of this pc. + // Then, do the binary search on the list of offsets in the native binary + // for all the IR operations. This returns the index of the *next* IR + // operation of the one corresponding to the origin of this pc. // See sort.Search. + // + // TODO: the underlying implementation of irOperationOffsetsInNativeBinary + // uses uses delta encoding an calls to the Index method might require a + // O(N) scan of the underlying array, turning binary search into a + // O(N*log(N)) operation. If this code path ends up being a bottleneck, + // we could add a Search method on the bitpack.OffsetArray types to delegate + // the lookup to the underlying data structure, allowing for the selection + // of a more optimized version of the algorithm. If you do so, please add a + // benchmark to verify the impact on compute time. index := sort.Search(n, func(i int) bool { if i == n-1 { return true } - return srcMap.irOperationOffsetsInNativeBinary[i] >= pcOffsetInNativeBinary + return srcMap.irOperationOffsetsInNativeBinary.Index(i) >= pcOffsetInNativeBinary }) + if index == 0 && bitpack.OffsetArrayLen(srcMap.irOperationSourceOffsetsInWasmBinary) > 0 { + // When pc is the beginning of the function, the next IR + // operation (returned by sort.Search) is the first of the + // offset map. + return srcMap.irOperationSourceOffsetsInWasmBinary.Index(0) + } if index == n || index == 0 { // This case, somehow pc is not found in the source offset map. return 0 } else { - return srcMap.irOperationSourceOffsetsInWasmBinary[index-1] + return srcMap.irOperationSourceOffsetsInWasmBinary.Index(index - 1) } } @@ -978,12 +996,11 @@ const ( func (ce *callEngine) execWasmFunction(ctx context.Context, m *wasm.ModuleInstance) { codeAddr := ce.initialFn.codeInitialAddress modAddr := ce.initialFn.moduleInstance - ce.ctx = ctx entry: { // Call into the native code. - nativecall(codeAddr, uintptr(unsafe.Pointer(ce)), modAddr) + nativecall(codeAddr, ce, modAddr) // Check the status code from Compiler code. switch status := ce.exitContext.statusCode; status { @@ -1004,9 +1021,9 @@ entry: fn := calleeHostFunction.parent.goFunc switch fn := fn.(type) { case api.GoModuleFunction: - fn.Call(ce.ctx, ce.callerModuleInstance, stack) + fn.Call(ctx, ce.callerModuleInstance, stack) case api.GoFunction: - fn.Call(ce.ctx, stack) + fn.Call(ctx, stack) } codeAddr, modAddr = ce.returnAddress, ce.moduleInstance @@ -1021,9 +1038,9 @@ entry: case builtinFunctionIndexTableGrow: ce.builtinFunctionTableGrow(caller.moduleInstance.Tables) case builtinFunctionIndexFunctionListenerBefore: - ce.builtinFunctionFunctionListenerBefore(ce.ctx, m, caller) + ce.builtinFunctionFunctionListenerBefore(ctx, m, caller) case builtinFunctionIndexFunctionListenerAfter: - ce.builtinFunctionFunctionListenerAfter(ce.ctx, m, caller) + ce.builtinFunctionFunctionListenerAfter(ctx, m, caller) case builtinFunctionIndexCheckExitCode: // Note: this operation must be done in Go, not native code. The reason is that // native code cannot be preempted and that means it can block forever if there are not @@ -1100,13 +1117,15 @@ type stackIterator struct { stack []uint64 fn *function base int + pc uint64 started bool } -func (si *stackIterator) reset(stack []uint64, fn *function, base int) { +func (si *stackIterator) reset(stack []uint64, fn *function, base int, pc uint64) { si.stack = stack si.fn = fn si.base = base + si.pc = pc si.started = false } @@ -1117,7 +1136,7 @@ func (si *stackIterator) clear() { si.started = false } -// Next implements experimental.StackIterator. +// Next implements the same method as documented on experimental.StackIterator. func (si *stackIterator) Next() bool { if !si.started { si.started = true @@ -1129,6 +1148,7 @@ func (si *stackIterator) Next() bool { } frame := si.base + callFrameOffset(si.fn.funcType) + si.pc = si.stack[frame+0] si.base = int(si.stack[frame+1] >> 3) // *function lives in the third field of callFrame struct. This must be // aligned with the definition of callFrame struct. @@ -1136,46 +1156,71 @@ func (si *stackIterator) Next() bool { return si.fn != nil } -// FunctionDefinition implements experimental.StackIterator. -func (si *stackIterator) FunctionDefinition() api.FunctionDefinition { - return si.fn.def +// ProgramCounter implements the same method as documented on experimental.StackIterator. +func (si *stackIterator) ProgramCounter() experimental.ProgramCounter { + return experimental.ProgramCounter(si.pc) } -// Parameters implements experimental.StackIterator. +// Function implements the same method as documented on experimental.StackIterator. +func (si *stackIterator) Function() experimental.InternalFunction { + return internalFunction{si.fn} +} + +// Parameters implements the same method as documented on experimental.StackIterator. func (si *stackIterator) Parameters() []uint64 { return si.stack[si.base : si.base+si.fn.funcType.ParamNumInUint64] } +// internalFunction implements experimental.InternalFunction. +type internalFunction struct{ *function } + +// Definition implements the same method as documented on experimental.InternalFunction. +func (f internalFunction) Definition() api.FunctionDefinition { + return f.definition() +} + +// SourceOffsetForPC implements the same method as documented on experimental.InternalFunction. +func (f internalFunction) SourceOffsetForPC(pc experimental.ProgramCounter) uint64 { + p := f.parent + if bitpack.OffsetArrayLen(p.sourceOffsetMap.irOperationSourceOffsetsInWasmBinary) == 0 { + return 0 // source not available + } + return f.getSourceOffsetInWasmBinary(uint64(pc)) +} + func (ce *callEngine) builtinFunctionFunctionListenerBefore(ctx context.Context, mod api.Module, fn *function) { base := int(ce.stackBasePointerInBytes >> 3) - ce.stackIterator.reset(ce.stack, fn, base) + pc := uint64(ce.returnAddress) + ce.stackIterator.reset(ce.stack, fn, base, pc) params := ce.stack[base : base+fn.funcType.ParamNumInUint64] - listerCtx := fn.parent.listener.Before(ctx, mod, fn.def, params, &ce.stackIterator) - prevStackTop := ce.contextStack - ce.contextStack = &contextStack{self: ctx, prev: prevStackTop} + fn.parent.listener.Before(ctx, mod, fn.definition(), params, &ce.stackIterator) - ce.ctx = listerCtx ce.stackIterator.clear() } func (ce *callEngine) builtinFunctionFunctionListenerAfter(ctx context.Context, mod api.Module, fn *function) { base := int(ce.stackBasePointerInBytes >> 3) - fn.parent.listener.After(ctx, mod, fn.def, nil, ce.stack[base:base+fn.funcType.ResultNumInUint64]) - ce.ctx = ce.contextStack.self - ce.contextStack = ce.contextStack.prev + fn.parent.listener.After(ctx, mod, fn.definition(), ce.stack[base:base+fn.funcType.ResultNumInUint64]) } -func compileGoDefinedHostFunction(cmp compiler) (body []byte, err error) { - if err = cmp.compileGoDefinedHostFunction(); err != nil { - return +func compileGoDefinedHostFunction(buf asm.Buffer, cmp compiler) error { + if err := cmp.compileGoDefinedHostFunction(); err != nil { + return err } + _, err := cmp.compile(buf) + return err +} - body, _, err = cmp.compile() - return +type asmNodes struct { + nodes []asm.Node +} + +type offsets struct { + values []uint64 } -func compileWasmFunction(cmp compiler, ir *wazeroir.CompilationResult) (body []byte, spCeil uint64, sm sourceOffsetMap, err error) { +func compileWasmFunction(buf asm.Buffer, cmp compiler, ir *wazeroir.CompilationResult, asmNodes *asmNodes, offsets *offsets) (spCeil uint64, sm sourceOffsetMap, err error) { if err = cmp.compilePreamble(); err != nil { err = fmt.Errorf("failed to emit preamble: %w", err) return @@ -1184,7 +1229,8 @@ func compileWasmFunction(cmp compiler, ir *wazeroir.CompilationResult) (body []b needSourceOffsets := len(ir.IROperationSourceOffsetsInWasmBinary) > 0 var irOpBegins []asm.Node if needSourceOffsets { - irOpBegins = make([]asm.Node, len(ir.Operations)) + irOpBegins = append(asmNodes.nodes[:0], make([]asm.Node, len(ir.Operations))...) + defer func() { asmNodes.nodes = irOpBegins }() } var skip bool @@ -1498,20 +1544,20 @@ func compileWasmFunction(cmp compiler, ir *wazeroir.CompilationResult) (body []b } } - body, spCeil, err = cmp.compile() + spCeil, err = cmp.compile(buf) if err != nil { err = fmt.Errorf("failed to compile: %w", err) return } if needSourceOffsets { - offsetInNativeBin := make([]uint64, len(irOpBegins)) + offsetInNativeBin := append(offsets.values[:0], make([]uint64, len(irOpBegins))...) + offsets.values = offsetInNativeBin for i, nop := range irOpBegins { offsetInNativeBin[i] = nop.OffsetInBinary() } - sm.irOperationOffsetsInNativeBinary = offsetInNativeBin - sm.irOperationSourceOffsetsInWasmBinary = make([]uint64, len(ir.IROperationSourceOffsetsInWasmBinary)) - copy(sm.irOperationSourceOffsetsInWasmBinary, ir.IROperationSourceOffsetsInWasmBinary) + sm.irOperationOffsetsInNativeBinary = bitpack.NewOffsetArray(offsetInNativeBin) + sm.irOperationSourceOffsetsInWasmBinary = bitpack.NewOffsetArray(ir.IROperationSourceOffsetsInWasmBinary) } return } diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine_cache.go b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine_cache.go index 70e56dee6..e6b3b0e91 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine_cache.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine_cache.go @@ -86,7 +86,7 @@ func (e *engine) getCompiledModuleFromCache(module *wasm.Module) (cm *compiledMo // We retrieve *code structures from `cached`. var staleCache bool // Note: cached.Close is ensured to be called in deserializeCodes. - cm, staleCache, err = deserializeCompiledModule(e.wazeroVersion, cached) + cm, staleCache, err = deserializeCompiledModule(e.wazeroVersion, cached, module) if err != nil { hit = false return @@ -123,13 +123,13 @@ func serializeCompiledModule(wazeroVersion string, cm *compiledModule) io.Reader buf.Write(u64.LeBytes(uint64(f.executableOffset))) } // The length of code segment (8 bytes). - buf.Write(u64.LeBytes(uint64(len(cm.executable)))) + buf.Write(u64.LeBytes(uint64(cm.executable.Len()))) // Append the native code. - buf.Write(cm.executable) + buf.Write(cm.executable.Bytes()) return bytes.NewReader(buf.Bytes()) } -func deserializeCompiledModule(wazeroVersion string, reader io.ReadCloser) (cm *compiledModule, staleCache bool, err error) { +func deserializeCompiledModule(wazeroVersion string, reader io.ReadCloser, module *wasm.Module) (cm *compiledModule, staleCache bool, err error) { defer reader.Close() cacheHeaderSize := len(wazeroMagic) + 1 /* version size */ + len(wazeroVersion) + 1 /* ensure termination */ + 4 /* number of functions */ @@ -160,6 +160,8 @@ func deserializeCompiledModule(wazeroVersion string, reader io.ReadCloser) (cm * functionsNum := binary.LittleEndian.Uint32(header[len(header)-4:]) cm = &compiledModule{functions: make([]compiledFunction, functionsNum), ensureTermination: ensureTermination} + imported := module.ImportFunctionCount + var eightBytes [8]byte for i := uint32(0); i < functionsNum; i++ { f := &cm.functions[i] @@ -177,7 +179,8 @@ func deserializeCompiledModule(wazeroVersion string, reader io.ReadCloser) (cm * err = fmt.Errorf("compilationcache: error reading func[%d] executable offset: %v", i, err) return } - f.executableOffset = int(offset) + f.executableOffset = uintptr(offset) + f.index = imported + i } executableLen, err := readUint64(reader, &eightBytes) @@ -187,12 +190,12 @@ func deserializeCompiledModule(wazeroVersion string, reader io.ReadCloser) (cm * } if executableLen > 0 { - if cm.executable, err = platform.MmapCodeSegment(int(executableLen)); err != nil { + if err = cm.executable.Map(int(executableLen)); err != nil { err = fmt.Errorf("compilationcache: error mmapping executable (len=%d): %v", executableLen, err) return } - _, err = io.ReadFull(reader, cm.executable) + _, err = io.ReadFull(reader, cm.executable.Bytes()) if err != nil { err = fmt.Errorf("compilationcache: error reading executable (len=%d): %v", executableLen, err) return @@ -200,7 +203,7 @@ func deserializeCompiledModule(wazeroVersion string, reader io.ReadCloser) (cm * if runtime.GOARCH == "arm64" { // On arm64, we cannot give all of rwx at the same time, so we change it to exec. - if err = platform.MprotectRX(cm.executable); err != nil { + if err = platform.MprotectRX(cm.executable.Bytes()); err != nil { return } } diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/impl_amd64.go b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/impl_amd64.go index 4690e87de..79b299ec9 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/impl_amd64.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/impl_amd64.go @@ -93,6 +93,7 @@ type amd64Compiler struct { stackPointerCeil uint64 // assignStackPointerCeilNeeded holds an asm.Node whose AssignDestinationConstant must be called with the determined stack pointer ceiling. assignStackPointerCeilNeeded asm.Node + compiledTrapTargets [nativeCallStatusModuleClosed]asm.Node withListener bool typ *wasm.FunctionType // locationStackForEntrypoint is the initial location stack for all functions. To reuse the allocated stack, @@ -328,7 +329,7 @@ func (c *amd64Compiler) compileGoDefinedHostFunction() error { } // compile implements compiler.compile for the amd64 architecture. -func (c *amd64Compiler) compile() (code []byte, stackPointerCeil uint64, err error) { +func (c *amd64Compiler) compile(buf asm.Buffer) (stackPointerCeil uint64, err error) { // c.stackPointerCeil tracks the stack pointer ceiling (max seen) value across all runtimeValueLocationStack(s) // used for all labels (via setLocationStack), excluding the current one. // Hence, we check here if the final block's max one exceeds the current c.stackPointerCeil. @@ -341,7 +342,7 @@ func (c *amd64Compiler) compile() (code []byte, stackPointerCeil uint64, err err // Note this MUST be called before Assemble() below. c.assignStackPointerCeil(stackPointerCeil) - code, err = c.assembler.Assemble() + err = c.assembler.Assemble(buf) return } @@ -583,7 +584,7 @@ func (c *amd64Compiler) compileBrIf(o *wazeroir.UnionOperation) error { return err } // Check if the value not equals zero. - c.assembler.CompileRegisterToConst(amd64.CMPQ, cond.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, cond.register, cond.register) // Emit jump instruction which jumps when the value does not equals zero. jmpWithCond = c.assembler.CompileJump(amd64.JNE) @@ -869,13 +870,9 @@ func (c *amd64Compiler) compileCallIndirect(o *wazeroir.UnionOperation) error { // tmp = &module.Tables[0] + Index*8 = &module.Tables[0] + sizeOf(*TableInstance)*index = module.Tables[o.TableIndex]. c.assembler.CompileMemoryToRegister(amd64.MOVQ, tmp, int64(tableIndex*8), tmp) - // Then, we need to check if the offset doesn't exceed the length of table. + // Then, we need to trap if the offset exceeds the length of table. c.assembler.CompileMemoryToRegister(amd64.CMPQ, tmp, tableInstanceTableLenOffset, offset.register) - notLengthExceedJump := c.assembler.CompileJump(amd64.JHI) - - // If it exceeds, we return the function with nativeCallStatusCodeInvalidTableAccess. - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - c.assembler.SetJumpTargetOnNext(notLengthExceedJump) + c.compileMaybeExitFromNativeCode(amd64.JHI, nativeCallStatusCodeInvalidTableAccess) // next we check if the target's type matches the operation's one. // In order to get the type instance's address, we have to multiply the offset @@ -893,15 +890,10 @@ func (c *amd64Compiler) compileCallIndirect(o *wazeroir.UnionOperation) error { // At this point offset.register holds the address of *code (as uintptr) at wasm.Table[offset]. // // Check if the value of table[offset] equals zero, meaning that the target is uninitialized. - c.assembler.CompileRegisterToConst(amd64.CMPQ, offset.register, 0) - - // Jump if the target is initialized element. - jumpIfInitialized := c.assembler.CompileJump(amd64.JNE) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, offset.register, offset.register) - // If not initialized, we return the function with nativeCallStatusCodeInvalidTableAccess. - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - - c.assembler.SetJumpTargetOnNext(jumpIfInitialized) + // Skipped if the target is initialized. + c.compileMaybeExitFromNativeCode(amd64.JNE, nativeCallStatusCodeInvalidTableAccess) // Next, we need to check the type matches, i.e. table[offset].source.TypeID == targetFunctionType's typeID. // @@ -911,14 +903,9 @@ func (c *amd64Compiler) compileCallIndirect(o *wazeroir.UnionOperation) error { tmp2) c.assembler.CompileMemoryToRegister(amd64.MOVL, tmp2, int64(typeIndex)*4, tmp2) - // Jump if the type matches. + // Skipped if the type matches. c.assembler.CompileMemoryToRegister(amd64.CMPL, offset.register, functionTypeIDOffset, tmp2) - jumpIfTypeMatch := c.assembler.CompileJump(amd64.JEQ) - - // Otherwise, exit with type mismatch status. - c.compileExitFromNativeCode(nativeCallStatusCodeTypeMismatchOnIndirectCall) - - c.assembler.SetJumpTargetOnNext(jumpIfTypeMatch) + c.compileMaybeExitFromNativeCode(amd64.JEQ, nativeCallStatusCodeTypeMismatchOnIndirectCall) targetFunctionType := &c.ir.Types[typeIndex] if err = c.compileCallFunctionImpl(offset.register, targetFunctionType); err != nil { return nil @@ -947,7 +934,7 @@ func (c *amd64Compiler) compileSelectV128Impl(selectorReg asm.Register) error { } // Compare the conditional value with zero. - c.assembler.CompileRegisterToConst(amd64.CMPQ, selectorReg, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, selectorReg, selectorReg) // Set the jump if the top value is not zero. jmpIfNotZero := c.assembler.CompileJump(amd64.JNE) @@ -988,7 +975,7 @@ func (c *amd64Compiler) compileSelect(o *wazeroir.UnionOperation) error { peekedX1 := c.locationStack.peek() // Compare the conditional value with zero. - c.assembler.CompileRegisterToConst(amd64.CMPQ, cv.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, cv.register, cv.register) // Now we can use c.register as temporary location. // We alias it here for readability. @@ -1288,15 +1275,14 @@ func (c *amd64Compiler) compileClz(o *wazeroir.UnionOperation) error { c.assembler.CompileRegisterToRegister(amd64.LZCNTQ, target.register, target.register) } } else { - // On x86 mac, we cannot use LZCNT as it always results in zero. - // Instead we combine BSR (calculating most significant set bit) - // with XOR. This logic is described in + // On processors that do not support LZCNT, we combine BSR (calculating + // most significant set bit) with XOR. This logic is described in // "Replace Raw Assembly Code with Builtin Intrinsics" section in: // https://developer.apple.com/documentation/apple-silicon/addressing-architectural-differences-in-your-macos-code. // First, we have to check if the target is non-zero as BSR is undefined // on zero. See https://www.felixcloutier.com/x86/bsr. - c.assembler.CompileRegisterToConst(amd64.CMPQ, target.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, target.register, target.register) jmpIfNonZero := c.assembler.CompileJump(amd64.JNE) // If the value is zero, we just push the const value. @@ -1352,12 +1338,14 @@ func (c *amd64Compiler) compileCtz(o *wazeroir.UnionOperation) error { c.assembler.CompileRegisterToRegister(amd64.TZCNTQ, target.register, target.register) } } else { - // Somehow, if the target value is zero, TZCNT always returns zero: this is wrong. - // Meanwhile, we need branches for non-zero and zero cases on macos. - // TODO: find the reference to this behavior and put the link here. + // On processors that do not support TZCNT, the BSF instruction is + // executed instead. The key difference between TZCNT and BSF + // instruction is that if source operand is zero, the content of + // destination operand is undefined. + // https://www.felixcloutier.com/x86/tzcnt.html // First we compare the target with zero. - c.assembler.CompileRegisterToConst(amd64.CMPQ, target.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, target.register, target.register) jmpIfNonZero := c.assembler.CompileJump(amd64.JNE) // If the value is zero, we just push the const value. @@ -1522,18 +1510,13 @@ func (c *amd64Compiler) performDivisionOnInts(isRem, is32Bit, signed bool) error // Check if the x2 equals zero. if is32Bit { - c.assembler.CompileRegisterToConst(amd64.CMPL, x2.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTL, x2.register, x2.register) } else { - c.assembler.CompileRegisterToConst(amd64.CMPQ, x2.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, x2.register, x2.register) } - // Jump if the divisor is not zero. - jmpIfNotZero := c.assembler.CompileJump(amd64.JNE) - - // Otherwise, we return with nativeCallStatusIntegerDivisionByZero status. - c.compileExitFromNativeCode(nativeCallStatusIntegerDivisionByZero) - - c.assembler.SetJumpTargetOnNext(jmpIfNotZero) + // Skipped if the divisor is nonzero. + c.compileMaybeExitFromNativeCode(amd64.JNE, nativeCallStatusIntegerDivisionByZero) // next, we ensure that x1 is placed on AX. x1 := c.locationStack.pop() @@ -1566,29 +1549,17 @@ func (c *amd64Compiler) performDivisionOnInts(isRem, is32Bit, signed bool) error // for divisions on (-2^31) / -1 where we do not need to emit the special branches. // For detail, please refer to https://stackoverflow.com/questions/56303282/why-idiv-with-1-causes-floating-point-exception - // First we compare the division with -1. - if is32Bit { - c.assembler.CompileRegisterToConst(amd64.CMPL, x2.register, -1) - } else { - c.assembler.CompileRegisterToConst(amd64.CMPQ, x2.register, -1) - } - - // If it doesn't equal minus one, we jump to the normal case. - okJmp := c.assembler.CompileJump(amd64.JNE) - - // Otherwise, we store zero into the remainder result register (DX). + // First we store zero into the remainder result register (DX) and compare the divisor with -1. if is32Bit { c.assembler.CompileRegisterToRegister(amd64.XORL, remainderRegister, remainderRegister) + c.assembler.CompileRegisterToConst(amd64.CMPL, x2.register, -1) } else { c.assembler.CompileRegisterToRegister(amd64.XORQ, remainderRegister, remainderRegister) + c.assembler.CompileRegisterToConst(amd64.CMPQ, x2.register, -1) } - // Emit the exit jump instruction for the divisor -1 case so - // we skips the normal case. - signedRemMinusOneDivisorJmp = c.assembler.CompileJump(amd64.JMP) - - // Set the normal case's jump target. - c.assembler.SetJumpTargetOnNext(okJmp) + // If it equals minus one, we skip the normal case. + signedRemMinusOneDivisorJmp = c.assembler.CompileJump(amd64.JEQ) } else if isSignedDiv { // For signed division, we have to have branches for "math.MinInt{32,64} / -1" // case which results in the floating point exception via division error as @@ -1605,7 +1576,7 @@ func (c *amd64Compiler) performDivisionOnInts(isRem, is32Bit, signed bool) error nonMinusOneDivisorJmp := c.assembler.CompileJump(amd64.JNE) // next we check if the quotient is the most negative value for the signed integer. - // That means whether or not we try to do (math.MaxInt32 / -1) or (math.Math.Int64 / -1) respectively. + // That means whether or not we try to do (math.MinInt32 / -1) or (math.MinInt64 / -1) respectively. if is32Bit { if err := c.assembler.CompileRegisterToStaticConst(amd64.CMPL, x1.register, c.minimum32BitSignedInt); err != nil { return err @@ -1616,17 +1587,12 @@ func (c *amd64Compiler) performDivisionOnInts(isRem, is32Bit, signed bool) error } } - // If it doesn't equal, we jump to the normal case. - jmpOK := c.assembler.CompileJump(amd64.JNE) - - // Otherwise, we are trying to do (math.MaxInt32 / -1) or (math.Math.Int64 / -1), - // and that is the overflow in division as the result becomes 2^31 which is larger than + // Trap if we are trying to do (math.MinInt32 / -1) or (math.MinInt64 / -1), + // as that is the overflow in division as the result becomes 2^31 which is larger than // the maximum of signed 32-bit int (2^31-1). - c.compileExitFromNativeCode(nativeCallStatusIntegerOverflow) - + c.compileMaybeExitFromNativeCode(amd64.JNE, nativeCallStatusIntegerOverflow) // Set the normal case's jump target. c.assembler.SetJumpTargetOnNext(nonMinusOneDivisorJmp) - c.assembler.SetJumpTargetOnNext(jmpOK) } // Now ready to emit the div instruction. @@ -2195,20 +2161,18 @@ func (c *amd64Compiler) emitUnsignedI32TruncFromFloat(isFloat32Bit, nonTrapping } // Check the parity flag (set when the value is NaN), and if it is set, we should raise an exception. - jmpIfNotNaN := c.assembler.CompileJump(amd64.JPC) // jump if parity is not set. - var nonTrappingNaNJump asm.Node - if !nonTrapping { - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidFloatToIntConversion) - } else { + if nonTrapping { + jmpIfNotNaN := c.assembler.CompileJump(amd64.JPC) // jump if parity is not set. // In non trapping case, NaN is casted as zero. // Zero out the result register by XOR itsself. c.assembler.CompileRegisterToRegister(amd64.XORL, result, result) nonTrappingNaNJump = c.assembler.CompileJump(amd64.JMP) + c.assembler.SetJumpTargetOnNext(jmpIfNotNaN) + } else { + c.compileMaybeExitFromNativeCode(amd64.JPC, nativeCallStatusCodeInvalidFloatToIntConversion) } - c.assembler.SetJumpTargetOnNext(jmpIfNotNaN) - // Jump if the source float value is above or equal math.MaxInt32+1. jmpAboveOrEqualMaxIn32PlusOne := c.assembler.CompileJump(amd64.JCC) @@ -2221,20 +2185,19 @@ func (c *amd64Compiler) emitUnsignedI32TruncFromFloat(isFloat32Bit, nonTrapping // Then if the result is minus, it is invalid conversion from minus float (incl. -Inf). c.assembler.CompileRegisterToRegister(amd64.TESTL, result, result) - jmpIfNotMinusOrMinusInf := c.assembler.CompileJump(amd64.JPL) var nonTrappingMinusJump asm.Node - if !nonTrapping { - c.compileExitFromNativeCode(nativeCallStatusIntegerOverflow) - } else { + if nonTrapping { + jmpIfNotMinusOrMinusInf := c.assembler.CompileJump(amd64.JPL) // In non trapping case, the minus value is casted as zero. // Zero out the result register by XOR itsself. c.assembler.CompileRegisterToRegister(amd64.XORL, result, result) nonTrappingMinusJump = c.assembler.CompileJump(amd64.JMP) + c.assembler.SetJumpTargetOnNext(jmpIfNotMinusOrMinusInf) + } else { + c.compileMaybeExitFromNativeCode(amd64.JPL, nativeCallStatusIntegerOverflow) } - c.assembler.SetJumpTargetOnNext(jmpIfNotMinusOrMinusInf) - // Otherwise, the values is valid. okJmpForLessThanMaxInt32PlusOne := c.assembler.CompileJump(amd64.JMP) @@ -2264,7 +2227,18 @@ func (c *amd64Compiler) emitUnsignedI32TruncFromFloat(isFloat32Bit, nonTrapping c.assembler.CompileRegisterToRegister(amd64.TESTL, result, result) // If the result is minus, the conversion is invalid (from NaN or +Inf) - jmpIfPlusInf := c.assembler.CompileJump(amd64.JMI) + var nonTrappingAboveOrEqualMaxInt32PlusOne asm.Node + if nonTrapping { + jmpIfNotPlusInf := c.assembler.CompileJump(amd64.JPL) + err = c.assembler.CompileStaticConstToRegister(amd64.MOVL, c.maximum32BitUnsignedInt, result) + if err != nil { + return err + } + nonTrappingAboveOrEqualMaxInt32PlusOne = c.assembler.CompileJump(amd64.JMP) + c.assembler.SetJumpTargetOnNext(jmpIfNotPlusInf) + } else { + c.compileMaybeExitFromNativeCode(amd64.JPL, nativeCallStatusIntegerOverflow) + } // Otherwise, we successfully converted the source float minus (math.MaxInt32+1) to int. // So, we retrieve the original source float value by adding the sign mask. @@ -2272,22 +2246,10 @@ func (c *amd64Compiler) emitUnsignedI32TruncFromFloat(isFloat32Bit, nonTrapping return err } - okJmpForAboveOrEqualMaxInt32PlusOne := c.assembler.CompileJump(amd64.JMP) - - c.assembler.SetJumpTargetOnNext(jmpIfPlusInf) - if !nonTrapping { - c.compileExitFromNativeCode(nativeCallStatusIntegerOverflow) - } else { - err = c.assembler.CompileStaticConstToRegister(amd64.MOVL, c.maximum32BitUnsignedInt, result) - if err != nil { - return err - } - } - // We jump to the next instructions for valid cases. c.assembler.SetJumpTargetOnNext(okJmpForLessThanMaxInt32PlusOne) - c.assembler.SetJumpTargetOnNext(okJmpForAboveOrEqualMaxInt32PlusOne) if nonTrapping { + c.assembler.SetJumpTargetOnNext(nonTrappingAboveOrEqualMaxInt32PlusOne) c.assembler.SetJumpTargetOnNext(nonTrappingMinusJump) c.assembler.SetJumpTargetOnNext(nonTrappingNaNJump) } @@ -2322,20 +2284,18 @@ func (c *amd64Compiler) emitUnsignedI64TruncFromFloat(isFloat32Bit, nonTrapping } // Check the parity flag (set when the value is NaN), and if it is set, we should raise an exception. - jmpIfNotNaN := c.assembler.CompileJump(amd64.JPC) // jump if parity is c.not set. - var nonTrappingNaNJump asm.Node - if !nonTrapping { - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidFloatToIntConversion) - } else { + if nonTrapping { + jmpIfNotNaN := c.assembler.CompileJump(amd64.JPC) // jump if parity is c.not set. // In non trapping case, NaN is casted as zero. // Zero out the result register by XOR itsself. c.assembler.CompileRegisterToRegister(amd64.XORQ, result, result) nonTrappingNaNJump = c.assembler.CompileJump(amd64.JMP) + c.assembler.SetJumpTargetOnNext(jmpIfNotNaN) + } else { + c.compileMaybeExitFromNativeCode(amd64.JPC, nativeCallStatusCodeInvalidFloatToIntConversion) } - c.assembler.SetJumpTargetOnNext(jmpIfNotNaN) - // Jump if the source float values is above or equal math.MaxInt64+1. jmpAboveOrEqualMaxIn32PlusOne := c.assembler.CompileJump(amd64.JCC) @@ -2348,20 +2308,19 @@ func (c *amd64Compiler) emitUnsignedI64TruncFromFloat(isFloat32Bit, nonTrapping // Then if the result is minus, it is invalid conversion from minus float (incl. -Inf). c.assembler.CompileRegisterToRegister(amd64.TESTQ, result, result) - jmpIfNotMinusOrMinusInf := c.assembler.CompileJump(amd64.JPL) var nonTrappingMinusJump asm.Node - if !nonTrapping { - c.compileExitFromNativeCode(nativeCallStatusIntegerOverflow) - } else { + if nonTrapping { + jmpIfNotMinusOrMinusInf := c.assembler.CompileJump(amd64.JPL) // In non trapping case, the minus value is casted as zero. // Zero out the result register by XOR itsself. c.assembler.CompileRegisterToRegister(amd64.XORQ, result, result) nonTrappingMinusJump = c.assembler.CompileJump(amd64.JMP) + c.assembler.SetJumpTargetOnNext(jmpIfNotMinusOrMinusInf) + } else { + c.compileMaybeExitFromNativeCode(amd64.JPL, nativeCallStatusIntegerOverflow) } - c.assembler.SetJumpTargetOnNext(jmpIfNotMinusOrMinusInf) - // Otherwise, the values is valid. okJmpForLessThanMaxInt64PlusOne := c.assembler.CompileJump(amd64.JMP) @@ -2391,7 +2350,18 @@ func (c *amd64Compiler) emitUnsignedI64TruncFromFloat(isFloat32Bit, nonTrapping c.assembler.CompileRegisterToRegister(amd64.TESTQ, result, result) // If the result is minus, the conversion is invalid (from NaN or +Inf) - jmpIfPlusInf := c.assembler.CompileJump(amd64.JMI) + var nonTrappingAboveOrEqualMaxInt64PlusOne asm.Node + if nonTrapping { + jmpIfNotPlusInf := c.assembler.CompileJump(amd64.JPL) + err = c.assembler.CompileStaticConstToRegister(amd64.MOVQ, c.maximum64BitUnsignedInt, result) + if err != nil { + return err + } + nonTrappingAboveOrEqualMaxInt64PlusOne = c.assembler.CompileJump(amd64.JMP) + c.assembler.SetJumpTargetOnNext(jmpIfNotPlusInf) + } else { + c.compileMaybeExitFromNativeCode(amd64.JPL, nativeCallStatusIntegerOverflow) + } // Otherwise, we successfully converted the the source float minus (math.MaxInt64+1) to int. // So, we retrieve the original source float value by adding the sign mask. @@ -2399,22 +2369,10 @@ func (c *amd64Compiler) emitUnsignedI64TruncFromFloat(isFloat32Bit, nonTrapping return err } - okJmpForAboveOrEqualMaxInt64PlusOne := c.assembler.CompileJump(amd64.JMP) - - c.assembler.SetJumpTargetOnNext(jmpIfPlusInf) - if !nonTrapping { - c.compileExitFromNativeCode(nativeCallStatusIntegerOverflow) - } else { - err = c.assembler.CompileStaticConstToRegister(amd64.MOVQ, c.maximum64BitUnsignedInt, result) - if err != nil { - return err - } - } - // We jump to the next instructions for valid cases. c.assembler.SetJumpTargetOnNext(okJmpForLessThanMaxInt64PlusOne) - c.assembler.SetJumpTargetOnNext(okJmpForAboveOrEqualMaxInt64PlusOne) if nonTrapping { + c.assembler.SetJumpTargetOnNext(nonTrappingAboveOrEqualMaxInt64PlusOne) c.assembler.SetJumpTargetOnNext(nonTrappingMinusJump) c.assembler.SetJumpTargetOnNext(nonTrappingNaNJump) } @@ -2466,22 +2424,21 @@ func (c *amd64Compiler) emitSignedI32TruncFromFloat(isFloat32Bit, nonTrapping bo } // Check the parity flag (set when the value is NaN), and if it is set, we should raise an exception. - jmpIfNotNaN := c.assembler.CompileJump(amd64.JPC) // jump if parity is not set. - var nontrappingNanJump asm.Node - if !nonTrapping { - // If the value is NaN, we return the function with nativeCallStatusCodeInvalidFloatToIntConversion. - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidFloatToIntConversion) - } else { + if nonTrapping { + jmpIfNotNaN := c.assembler.CompileJump(amd64.JPC) // jump if parity is not set. // In non trapping case, NaN is casted as zero. // Zero out the result register by XOR itsself. c.assembler.CompileRegisterToRegister(amd64.XORL, result, result) nontrappingNanJump = c.assembler.CompileJump(amd64.JMP) + c.assembler.SetJumpTargetOnNext(jmpIfNotNaN) + } else { + // If the value is NaN, we return the function with nativeCallStatusCodeInvalidFloatToIntConversion. + c.compileMaybeExitFromNativeCode(amd64.JPC, nativeCallStatusCodeInvalidFloatToIntConversion) } // Check if the value is larger than or equal the minimum 32-bit integer value, // meaning that the value exceeds the lower bound of 32-bit signed integer range. - c.assembler.SetJumpTargetOnNext(jmpIfNotNaN) if isFloat32Bit { err = c.assembler.CompileStaticConstToRegister(amd64.UCOMISS, c.float32ForMinimumSigned32bitInteger, source.register) } else { @@ -2492,12 +2449,11 @@ func (c *amd64Compiler) emitSignedI32TruncFromFloat(isFloat32Bit, nonTrapping bo } if !nonTrapping { - // Jump if the value exceeds the lower bound. - var jmpIfExceedsLowerBound asm.Node + // Trap if the value does not exceed the lower bound. if isFloat32Bit { - jmpIfExceedsLowerBound = c.assembler.CompileJump(amd64.JCS) + c.compileMaybeExitFromNativeCode(amd64.JCC, nativeCallStatusIntegerOverflow) } else { - jmpIfExceedsLowerBound = c.assembler.CompileJump(amd64.JLS) + c.compileMaybeExitFromNativeCode(amd64.JHI, nativeCallStatusIntegerOverflow) } // At this point, the value is the minimum signed 32-bit int (=-2147483648.000000) or larger than 32-bit maximum. @@ -2511,14 +2467,11 @@ func (c *amd64Compiler) emitSignedI32TruncFromFloat(isFloat32Bit, nonTrapping bo return err } - jmpIfMinimumSignedInt := c.assembler.CompileJump(amd64.JCS) // jump if the value is minus (= the minimum signed 32-bit int). - - c.assembler.SetJumpTargetOnNext(jmpIfExceedsLowerBound) - c.compileExitFromNativeCode(nativeCallStatusIntegerOverflow) + // Trap if the value is not minus (= the minimum signed 32-bit int). + c.compileMaybeExitFromNativeCode(amd64.JCS, nativeCallStatusIntegerOverflow) // We jump to the next instructions for valid cases. c.assembler.SetJumpTargetOnNext(okJmp) - c.assembler.SetJumpTargetOnNext(jmpIfMinimumSignedInt) } else { // Jump if the value does not exceed the lower bound. var jmpIfNotExceedsLowerBound asm.Node @@ -2604,21 +2557,20 @@ func (c *amd64Compiler) emitSignedI64TruncFromFloat(isFloat32Bit, nonTrapping bo } // Check the parity flag (set when the value is NaN), and if it is set, we should raise an exception. - jmpIfNotNaN := c.assembler.CompileJump(amd64.JPC) // jump if parity is not set. - var nontrappingNanJump asm.Node - if !nonTrapping { - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidFloatToIntConversion) - } else { + if nonTrapping { + jmpIfNotNaN := c.assembler.CompileJump(amd64.JPC) // jump if parity is not set. // In non trapping case, NaN is casted as zero. // Zero out the result register by XOR itsself. c.assembler.CompileRegisterToRegister(amd64.XORQ, result, result) nontrappingNanJump = c.assembler.CompileJump(amd64.JMP) + c.assembler.SetJumpTargetOnNext(jmpIfNotNaN) + } else { + c.compileMaybeExitFromNativeCode(amd64.JPC, nativeCallStatusCodeInvalidFloatToIntConversion) } // Check if the value is larger than or equal the minimum 64-bit integer value, // meaning that the value exceeds the lower bound of 64-bit signed integer range. - c.assembler.SetJumpTargetOnNext(jmpIfNotNaN) if isFloat32Bit { err = c.assembler.CompileStaticConstToRegister(amd64.UCOMISS, c.float32ForMinimumSigned64bitInteger, source.register) } else { @@ -2630,7 +2582,7 @@ func (c *amd64Compiler) emitSignedI64TruncFromFloat(isFloat32Bit, nonTrapping bo if !nonTrapping { // Jump if the value is -Inf. - jmpIfExceedsLowerBound := c.assembler.CompileJump(amd64.JCS) + c.compileMaybeExitFromNativeCode(amd64.JCC, nativeCallStatusIntegerOverflow) // At this point, the value is the minimum signed 64-bit int (=-9223372036854775808.0) or larger than 64-bit maximum. // So, check if the value equals the minimum signed 64-bit int. @@ -2643,14 +2595,11 @@ func (c *amd64Compiler) emitSignedI64TruncFromFloat(isFloat32Bit, nonTrapping bo return err } - jmpIfMinimumSignedInt := c.assembler.CompileJump(amd64.JCS) // jump if the value is minus (= the minimum signed 64-bit int). - - c.assembler.SetJumpTargetOnNext(jmpIfExceedsLowerBound) - c.compileExitFromNativeCode(nativeCallStatusIntegerOverflow) + // Trap if the value is not minus (= the minimum signed 64-bit int). + c.compileMaybeExitFromNativeCode(amd64.JCS, nativeCallStatusIntegerOverflow) // We jump to the next instructions for valid cases. c.assembler.SetJumpTargetOnNext(okJmp) - c.assembler.SetJumpTargetOnNext(jmpIfMinimumSignedInt) } else { // Jump if the value is not -Inf. jmpIfNotExceedsLowerBound := c.assembler.CompileJump(amd64.JCC) @@ -3503,13 +3452,8 @@ func (c *amd64Compiler) compileMemoryAccessCeilSetup(offsetArg uint32, targetSiz c.assembler.CompileMemoryToRegister(amd64.CMPQ, amd64ReservedRegisterForCallEngine, callEngineModuleContextMemorySliceLenOffset, result) - // Jump if the value is within the memory length. - okJmp := c.assembler.CompileJump(amd64.JCC) - - // Otherwise, we exit the function with out-of-bounds status code. - c.compileExitFromNativeCode(nativeCallStatusCodeMemoryOutOfBounds) - - c.assembler.SetJumpTargetOnNext(okJmp) + // Trap if the value is out-of-bounds of memory length. + c.compileMaybeExitFromNativeCode(amd64.JCC, nativeCallStatusCodeMemoryOutOfBounds) c.locationStack.markRegisterUnused(result) return result, nil @@ -3663,9 +3607,7 @@ func (c *amd64Compiler) compileInitImpl(isTable bool, index, tableIndex uint32) c.assembler.CompileMemoryToRegister(amd64.CMPQ, instanceAddr, 8, // DataInstance and Element instance holds the length is stored at offset 8. sourceOffset.register) - sourceBoundOKJump := c.assembler.CompileJump(amd64.JCC) - c.compileExitFromNativeCode(outOfBoundsErrorStatus) - c.assembler.SetJumpTargetOnNext(sourceBoundOKJump) + c.compileMaybeExitFromNativeCode(amd64.JCC, outOfBoundsErrorStatus) // Check destination bounds and if exceeds the length, exit with out of bounds error. if isTable { @@ -3680,14 +3622,12 @@ func (c *amd64Compiler) compileInitImpl(isTable bool, index, tableIndex uint32) destinationOffset.register) } - destinationBoundOKJump := c.assembler.CompileJump(amd64.JCC) - c.compileExitFromNativeCode(outOfBoundsErrorStatus) - c.assembler.SetJumpTargetOnNext(destinationBoundOKJump) + c.compileMaybeExitFromNativeCode(amd64.JCC, outOfBoundsErrorStatus) // Otherwise, ready to copy the value from source to destination. // // If the copy size equal zero, we skip the entire instructions below. - c.assembler.CompileRegisterToConst(amd64.CMPQ, copySize.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, copySize.register, copySize.register) skipJump := c.assembler.CompileJump(amd64.JEQ) var scale int16 @@ -3781,7 +3721,7 @@ func (c *amd64Compiler) compileLoadDataInstanceAddress(dataIndex uint32, dst asm // compileCopyLoopImpl implements a REP MOVSQ memory copy for the given range with support for both directions. func (c *amd64Compiler) compileCopyLoopImpl(destinationOffset, sourceOffset, copySize *runtimeValueLocation, backwards bool, bwOffset uint8) { // skip if nothing to copy - c.assembler.CompileRegisterToConst(amd64.CMPQ, copySize.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, copySize.register, copySize.register) emptyEightGroupsJump := c.assembler.CompileJump(amd64.JEQ) // Prepare registers for swaps. There will never be more than 3 XCHGs in total. @@ -3893,23 +3833,18 @@ func (c *amd64Compiler) compileMemoryCopy() error { c.assembler.CompileRegisterToRegister(amd64.ADDQ, copySize.register, sourceOffset.register) // destinationOffset += size. c.assembler.CompileRegisterToRegister(amd64.ADDQ, copySize.register, destinationOffset.register) + // tmp = max(sourceOffset, destinationOffset). + c.assembler.CompileRegisterToRegister(amd64.CMPQ, sourceOffset.register, destinationOffset.register) + c.assembler.CompileRegisterToRegister(amd64.MOVQ, sourceOffset.register, tmp) + c.assembler.CompileRegisterToRegister(amd64.CMOVQCS, destinationOffset.register, tmp) - // Check source bounds and if exceeds the length, exit with out of bounds error. - c.assembler.CompileMemoryToRegister(amd64.CMPQ, - amd64ReservedRegisterForCallEngine, callEngineModuleContextMemorySliceLenOffset, sourceOffset.register) - sourceBoundOKJump := c.assembler.CompileJump(amd64.JCC) - c.compileExitFromNativeCode(nativeCallStatusCodeMemoryOutOfBounds) - c.assembler.SetJumpTargetOnNext(sourceBoundOKJump) - - // Check destination bounds and if exceeds the length, exit with out of bounds error. + // Check maximum bounds and if exceeds the length, exit with out of bounds error. c.assembler.CompileMemoryToRegister(amd64.CMPQ, - amd64ReservedRegisterForCallEngine, callEngineModuleContextMemorySliceLenOffset, destinationOffset.register) - destinationBoundOKJump := c.assembler.CompileJump(amd64.JCC) - c.compileExitFromNativeCode(nativeCallStatusCodeMemoryOutOfBounds) - c.assembler.SetJumpTargetOnNext(destinationBoundOKJump) + amd64ReservedRegisterForCallEngine, callEngineModuleContextMemorySliceLenOffset, tmp) + c.compileMaybeExitFromNativeCode(amd64.JCC, nativeCallStatusCodeMemoryOutOfBounds) // Skip zero size. - c.assembler.CompileRegisterToConst(amd64.CMPQ, copySize.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, copySize.register, copySize.register) skipJump := c.assembler.CompileJump(amd64.JEQ) // If dest < source, we can copy forwards @@ -3942,7 +3877,7 @@ func (c *amd64Compiler) compileMemoryCopy() error { // compileFillLoopImpl implements a REP STOSQ fill loop. func (c *amd64Compiler) compileFillLoopImpl(destinationOffset, value, fillSize *runtimeValueLocation, tmp asm.Register, replicateByte bool) { // Skip if nothing to fill. - c.assembler.CompileRegisterToConst(amd64.CMPQ, fillSize.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, fillSize.register, fillSize.register) emptyEightGroupsJump := c.assembler.CompileJump(amd64.JEQ) if replicateByte { @@ -4027,18 +3962,16 @@ func (c *amd64Compiler) compileFillImpl(isTable bool, tableIndex uint32) error { amd64ReservedRegisterForCallEngine, callEngineModuleContextMemorySliceLenOffset, destinationOffset.register) } - destinationBoundOKJump := c.assembler.CompileJump(amd64.JCC) if isTable { - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) + c.compileMaybeExitFromNativeCode(amd64.JCC, nativeCallStatusCodeInvalidTableAccess) } else { - c.compileExitFromNativeCode(nativeCallStatusCodeMemoryOutOfBounds) + c.compileMaybeExitFromNativeCode(amd64.JCC, nativeCallStatusCodeMemoryOutOfBounds) } - c.assembler.SetJumpTargetOnNext(destinationBoundOKJump) // Otherwise, ready to copy the value from source to destination. // // If the copy size equal zero, we skip the entire instructions below. - c.assembler.CompileRegisterToConst(amd64.CMPQ, copySize.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, copySize.register, copySize.register) skipJump := c.assembler.CompileJump(amd64.JEQ) // destinationOffset -= size. @@ -4054,7 +3987,7 @@ func (c *amd64Compiler) compileFillImpl(isTable bool, tableIndex uint32) error { // destinationOffset += memory buffer's absolute address. c.assembler.CompileRegisterToRegister(amd64.ADDQ, amd64ReservedRegisterForMemory, destinationOffset.register) - // Copy first %15 bytes with simple MOVB instruction. + // Copy first % 16 bytes with simple MOVB instruction. beginCopyLoop := c.assembler.CompileStandAlone(amd64.NOP) c.assembler.CompileConstToRegister(amd64.TESTQ, 15, copySize.register) breakLoop := c.assembler.CompileJump(amd64.JEQ) @@ -4153,20 +4086,16 @@ func (c *amd64Compiler) compileTableCopy(o *wazeroir.UnionOperation) error { c.assembler.CompileMemoryToRegister(amd64.MOVQ, amd64ReservedRegisterForCallEngine, callEngineModuleContextTablesElement0AddressOffset, tmp) c.assembler.CompileMemoryToRegister(amd64.MOVQ, tmp, int64(srcTableIndex*8), tmp) c.assembler.CompileMemoryToRegister(amd64.CMPQ, tmp, tableInstanceTableLenOffset, sourceOffset.register) - sourceBoundOKJump := c.assembler.CompileJump(amd64.JCC) - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - c.assembler.SetJumpTargetOnNext(sourceBoundOKJump) + c.compileMaybeExitFromNativeCode(amd64.JCC, nativeCallStatusCodeInvalidTableAccess) // Check destination bounds and if exceeds the length, exit with out of bounds error. c.assembler.CompileMemoryToRegister(amd64.MOVQ, amd64ReservedRegisterForCallEngine, callEngineModuleContextTablesElement0AddressOffset, tmp) c.assembler.CompileMemoryToRegister(amd64.MOVQ, tmp, int64(dstTableIndex*8), tmp) c.assembler.CompileMemoryToRegister(amd64.CMPQ, tmp, tableInstanceTableLenOffset, destinationOffset.register) - destinationBoundOKJump := c.assembler.CompileJump(amd64.JCC) - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - c.assembler.SetJumpTargetOnNext(destinationBoundOKJump) + c.compileMaybeExitFromNativeCode(amd64.JCC, nativeCallStatusCodeInvalidTableAccess) // Skip zero size. - c.assembler.CompileRegisterToConst(amd64.CMPQ, copySize.register, 0) + c.assembler.CompileRegisterToRegister(amd64.TESTQ, copySize.register, copySize.register) skipJump := c.assembler.CompileJump(amd64.JEQ) // If dest < source, we can copy forwards. @@ -4256,9 +4185,7 @@ func (c *amd64Compiler) compileTableGet(o *wazeroir.UnionOperation) error { // Out of bounds check. c.assembler.CompileMemoryToRegister(amd64.CMPQ, ref, tableInstanceTableLenOffset, offset.register) - boundOKJmp := c.assembler.CompileJump(amd64.JHI) - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - c.assembler.SetJumpTargetOnNext(boundOKJmp) + c.compileMaybeExitFromNativeCode(amd64.JHI, nativeCallStatusCodeInvalidTableAccess) // ref = [&tables[TableIndex] + tableInstanceTableOffset] = &tables[TableIndex].References[0] c.assembler.CompileMemoryToRegister(amd64.MOVQ, ref, tableInstanceTableOffset, ref) @@ -4306,9 +4233,7 @@ func (c *amd64Compiler) compileTableSet(o *wazeroir.UnionOperation) error { // Out of bounds check. c.assembler.CompileMemoryToRegister(amd64.CMPQ, tmp, tableInstanceTableLenOffset, offset.register) - boundOKJmp := c.assembler.CompileJump(amd64.JHI) - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - c.assembler.SetJumpTargetOnNext(boundOKJmp) + c.compileMaybeExitFromNativeCode(amd64.JHI, nativeCallStatusCodeInvalidTableAccess) // tmp = [&tables[TableIndex] + tableInstanceTableOffset] = &tables[TableIndex].References[0] c.assembler.CompileMemoryToRegister(amd64.MOVQ, tmp, tableInstanceTableOffset, tmp) @@ -4788,11 +4713,7 @@ func (c *amd64Compiler) compileReturnFunction() error { ) c.assembler.CompileRegisterToRegister(amd64.TESTQ, returnAddressRegister, returnAddressRegister) - jmpIfNotReturn := c.assembler.CompileJump(amd64.JNE) - c.compileExitFromNativeCode(nativeCallStatusCodeReturned) - - // Otherwise, we return to the caller. - c.assembler.SetJumpTargetOnNext(jmpIfNotReturn) + c.compileMaybeExitFromNativeCode(amd64.JNE, nativeCallStatusCodeReturned) // Alias for readability. tmpRegister := amd64CallingConventionDestinationFunctionModuleInstanceAddressRegister @@ -4895,16 +4816,52 @@ func (c *amd64Compiler) compileReleaseRegisterToStack(loc *runtimeValueLocation) } } -func (c *amd64Compiler) compileExitFromNativeCode(status nativeCallStatusCode) { - c.assembler.CompileConstToMemory(amd64.MOVB, int64(status), - amd64ReservedRegisterForCallEngine, callEngineExitContextNativeCallStatusCodeOffset) +func (c *amd64Compiler) compileMaybeExitFromNativeCode(skipCondition asm.Instruction, status nativeCallStatusCode) { + if target := c.compiledTrapTargets[status]; target != nil { + // We've already compiled this. + // Invert the return condition to jump into the appropriate target. + var returnCondition asm.Instruction + switch skipCondition { + case amd64.JHI: + returnCondition = amd64.JLS + case amd64.JLS: + returnCondition = amd64.JHI + case amd64.JNE: + returnCondition = amd64.JEQ + case amd64.JEQ: + returnCondition = amd64.JNE + case amd64.JCC: + returnCondition = amd64.JCS + case amd64.JCS: + returnCondition = amd64.JCC + case amd64.JPC: + returnCondition = amd64.JPS + case amd64.JPS: + returnCondition = amd64.JPC + case amd64.JPL: + returnCondition = amd64.JMI + case amd64.JMI: + returnCondition = amd64.JPL + default: + panic("BUG: couldn't invert condition") + } + c.assembler.CompileJump(returnCondition).AssignJumpTarget(target) + } else { + skip := c.assembler.CompileJump(skipCondition) + c.compileExitFromNativeCode(status) + c.assembler.SetJumpTargetOnNext(skip) + } +} - // Write back the cached SP to the actual eng.stackPointer. - c.assembler.CompileConstToMemory(amd64.MOVQ, int64(c.locationStack.sp), - amd64ReservedRegisterForCallEngine, callEngineStackContextStackPointerOffset) +func (c *amd64Compiler) compileExitFromNativeCode(status nativeCallStatusCode) { + if target := c.compiledTrapTargets[status]; target != nil { + c.assembler.CompileJump(amd64.JMP).AssignJumpTarget(target) + } switch status { case nativeCallStatusCodeReturned: + // Save the target for reuse. + c.compiledTrapTargets[status] = c.compileNOP() case nativeCallStatusCodeCallGoHostFunction, nativeCallStatusCodeCallBuiltInFunction: // Read the return address, and write it to callEngine.exitContext.returnAddress. returnAddressReg, ok := c.locationStack.takeFreeRegister(registerTypeGeneralPurpose) @@ -4915,14 +4872,27 @@ func (c *amd64Compiler) compileExitFromNativeCode(status nativeCallStatusCode) { c.assembler.CompileRegisterToMemory(amd64.MOVQ, returnAddressReg, amd64ReservedRegisterForCallEngine, callEngineExitContextReturnAddressOffset) default: - // This case, the execution traps, so take tmpReg and store the instruction address onto callEngine.returnAddress - // so that the stack trace can contain the top frame's source position. - tmpReg := amd64.RegR15 - c.assembler.CompileReadInstructionAddress(tmpReg, amd64.MOVQ) - c.assembler.CompileRegisterToMemory(amd64.MOVQ, - tmpReg, amd64ReservedRegisterForCallEngine, callEngineExitContextReturnAddressOffset) + if c.ir.IROperationSourceOffsetsInWasmBinary != nil { + // This case, the execution traps and we want the top frame's source position in the stack trace. + // Take RegR15 and store the instruction address onto callEngine.returnAddress. + returnAddressReg := amd64.RegR15 + c.assembler.CompileReadInstructionAddress(returnAddressReg, amd64.MOVQ) + c.assembler.CompileRegisterToMemory(amd64.MOVQ, + returnAddressReg, amd64ReservedRegisterForCallEngine, callEngineExitContextReturnAddressOffset) + } else { + // We won't use the source position, so just save the target for reuse. + c.compiledTrapTargets[status] = c.compileNOP() + } } + // Write the status to callEngine.exitContext.statusCode. + c.assembler.CompileConstToMemory(amd64.MOVB, int64(status), + amd64ReservedRegisterForCallEngine, callEngineExitContextNativeCallStatusCodeOffset) + + // Write back the cached SP to the actual eng.stackPointer. + c.assembler.CompileConstToMemory(amd64.MOVQ, int64(c.locationStack.sp), + amd64ReservedRegisterForCallEngine, callEngineStackContextStackPointerOffset) + c.assembler.CompileStandAlone(amd64.RET) } diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/impl_arm64.go b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/impl_arm64.go index 5bb305637..af0248188 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/impl_arm64.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/impl_arm64.go @@ -27,6 +27,7 @@ type arm64Compiler struct { stackPointerCeil uint64 // assignStackPointerCeilNeeded holds an asm.Node whose AssignDestinationConstant must be called with the determined stack pointer ceiling. assignStackPointerCeilNeeded asm.Node + compiledTrapTargets [nativeCallStatusModuleClosed]asm.Node withListener bool typ *wasm.FunctionType br *bytes.Reader @@ -140,7 +141,7 @@ func (c *arm64Compiler) compileNOP() asm.Node { } // compile implements compiler.compile for the arm64 architecture. -func (c *arm64Compiler) compile() (code []byte, stackPointerCeil uint64, err error) { +func (c *arm64Compiler) compile(buf asm.Buffer) (stackPointerCeil uint64, err error) { // c.stackPointerCeil tracks the stack pointer ceiling (max seen) value across all runtimeValueLocationStack(s) // used for all labels (via setLocationStack), excluding the current one. // Hence, we check here if the final block's max one exceeds the current c.stackPointerCeil. @@ -153,7 +154,7 @@ func (c *arm64Compiler) compile() (code []byte, stackPointerCeil uint64, err err // Note: this must be called before Assemble() below. c.assignStackPointerCeil(stackPointerCeil) - code, err = c.assembler.Assemble() + err = c.assembler.Assemble(buf) return } @@ -350,13 +351,9 @@ func (c *arm64Compiler) compileReturnFunction() error { c.compileLoadValueOnStackToRegister(returnAddress) c.assembler.CompileTwoRegistersToNone(arm64.CMP, arm64ReservedRegisterForTemporary, arm64.RegRZR) - // Br if the address does not equal zero. - brIfNotEqual := c.assembler.CompileJump(arm64.BCONDNE) - // Otherwise, exit. - c.compileExitFromNativeCode(nativeCallStatusCodeReturned) - + // Br if the address does not equal zero, otherwise, exit. // If the address doesn't equal zero, return br into returnAddressRegister (caller's return address). - c.assembler.SetJumpTargetOnNext(brIfNotEqual) + c.compileMaybeExitFromNativeCode(arm64.BCONDNE, nativeCallStatusCodeReturned) // Alias for readability. tmp := arm64CallingConventionModuleInstanceAddressRegister @@ -382,13 +379,77 @@ func (c *arm64Compiler) compileReturnFunction() error { return nil } +func (c *arm64Compiler) compileMaybeExitFromNativeCode(skipCondition asm.Instruction, status nativeCallStatusCode) { + if target := c.compiledTrapTargets[status]; target != nil { + // We've already compiled this. + // Invert the condition to jump into the appropriate target. + var trapCondition asm.Instruction + switch skipCondition { + case arm64.BCONDEQ: + trapCondition = arm64.BCONDNE + case arm64.BCONDNE: + trapCondition = arm64.BCONDEQ + case arm64.BCONDLO: + trapCondition = arm64.BCONDHS + case arm64.BCONDHS: + trapCondition = arm64.BCONDLO + case arm64.BCONDLS: + trapCondition = arm64.BCONDHI + case arm64.BCONDHI: + trapCondition = arm64.BCONDLS + case arm64.BCONDVS: + trapCondition = arm64.BCONDVC + case arm64.BCONDVC: + trapCondition = arm64.BCONDVS + default: + panic("BUG: couldn't invert condition") + } + c.assembler.CompileJump(trapCondition).AssignJumpTarget(target) + } else { + skip := c.assembler.CompileJump(skipCondition) + c.compileExitFromNativeCode(status) + c.assembler.SetJumpTargetOnNext(skip) + } +} + // compileExitFromNativeCode adds instructions to give the control back to ce.exec with the given status code. func (c *arm64Compiler) compileExitFromNativeCode(status nativeCallStatusCode) { + if target := c.compiledTrapTargets[status]; target != nil { + c.assembler.CompileJump(arm64.B).AssignJumpTarget(target) + } + + switch status { + case nativeCallStatusCodeReturned: + // Save the target for reuse. + c.compiledTrapTargets[status] = c.compileNOP() + case nativeCallStatusCodeCallGoHostFunction, nativeCallStatusCodeCallBuiltInFunction: + // Read the return address, and write it to callEngine.exitContext.returnAddress. + c.assembler.CompileReadInstructionAddress(arm64ReservedRegisterForTemporary, arm64.RET) + c.assembler.CompileRegisterToMemory( + arm64.STRD, arm64ReservedRegisterForTemporary, + arm64ReservedRegisterForCallEngine, callEngineExitContextReturnAddressOffset, + ) + default: + if c.ir.IROperationSourceOffsetsInWasmBinary != nil { + // This case, the execution traps, and we want the top frame's source position in the stack trace. + // We store the instruction address onto callEngine.returnAddress. + c.assembler.CompileReadInstructionAddress(arm64ReservedRegisterForTemporary, arm64.STRD) + c.assembler.CompileRegisterToMemory( + arm64.STRD, arm64ReservedRegisterForTemporary, + arm64ReservedRegisterForCallEngine, callEngineExitContextReturnAddressOffset, + ) + } else { + // We won't use the source position, so just save the target for reuse. + c.compiledTrapTargets[status] = c.compileNOP() + } + } + // Write the current stack pointer to the ce.stackPointer. c.assembler.CompileConstToRegister(arm64.MOVD, int64(c.locationStack.sp), arm64ReservedRegisterForTemporary) c.assembler.CompileRegisterToMemory(arm64.STRD, arm64ReservedRegisterForTemporary, arm64ReservedRegisterForCallEngine, callEngineStackContextStackPointerOffset) + // Write the status to callEngine.exitContext.statusCode. if status != 0 { c.assembler.CompileConstToRegister(arm64.MOVW, int64(status), arm64ReservedRegisterForTemporary) c.assembler.CompileRegisterToMemory(arm64.STRW, arm64ReservedRegisterForTemporary, @@ -399,25 +460,6 @@ func (c *arm64Compiler) compileExitFromNativeCode(status nativeCallStatusCode) { arm64ReservedRegisterForCallEngine, callEngineExitContextNativeCallStatusCodeOffset) } - switch status { - case nativeCallStatusCodeReturned: - case nativeCallStatusCodeCallGoHostFunction, nativeCallStatusCodeCallBuiltInFunction: - // Read the return address, and write it to callEngine.exitContext.returnAddress. - c.assembler.CompileReadInstructionAddress(arm64ReservedRegisterForTemporary, arm64.RET) - c.assembler.CompileRegisterToMemory( - arm64.STRD, arm64ReservedRegisterForTemporary, - arm64ReservedRegisterForCallEngine, callEngineExitContextReturnAddressOffset, - ) - default: - // This case, the execution traps, store the instruction address onto callEngine.returnAddress - // so that the stack trace can contain the top frame's source position. - c.assembler.CompileReadInstructionAddress(arm64ReservedRegisterForTemporary, arm64.STRD) - c.assembler.CompileRegisterToMemory( - arm64.STRD, arm64ReservedRegisterForTemporary, - arm64ReservedRegisterForCallEngine, callEngineExitContextReturnAddressOffset, - ) - } - // The return address to the Go code is stored in archContext.compilerReturnAddress which // is embedded in ce. We load the value to the tmpRegister, and then // invoke RET with that register. @@ -1163,12 +1205,9 @@ func (c *arm64Compiler) compileCallIndirect(o *wazeroir.UnionOperation) (err err // "cmp tmp2, offset" c.assembler.CompileTwoRegistersToNone(arm64.CMP, tmp2, offsetReg) - // If it exceeds len(table), we exit the execution. - brIfOffsetOK := c.assembler.CompileJump(arm64.BCONDLO) - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - + // If it exceeds len(table), we trap. + c.compileMaybeExitFromNativeCode(arm64.BCONDLO, nativeCallStatusCodeInvalidTableAccess) // Otherwise, we proceed to do function type check. - c.assembler.SetJumpTargetOnNext(brIfOffsetOK) // We need to obtain the absolute address of table element. // "tmp = &Tables[tableIndex].table[0]" @@ -1192,10 +1231,10 @@ func (c *arm64Compiler) compileCallIndirect(o *wazeroir.UnionOperation) (err err // Check if the value of table[offset] equals zero, meaning that the target element is uninitialized. c.assembler.CompileTwoRegistersToNone(arm64.CMP, arm64.RegRZR, offsetReg) - brIfInitialized := c.assembler.CompileJump(arm64.BCONDNE) - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - c.assembler.SetJumpTargetOnNext(brIfInitialized) + // Skipped if the target is initialized. + c.compileMaybeExitFromNativeCode(arm64.BCONDNE, nativeCallStatusCodeInvalidTableAccess) + // next we check the type matches, i.e. table[offset].source.TypeID == targetFunctionType. // "tmp = table[offset].typeID" c.assembler.CompileMemoryToRegister( @@ -1211,10 +1250,8 @@ func (c *arm64Compiler) compileCallIndirect(o *wazeroir.UnionOperation) (err err // Compare these two values, and if they equal, we are ready to make function call. c.assembler.CompileTwoRegistersToNone(arm64.CMPW, tmp, tmp2) - brIfTypeMatched := c.assembler.CompileJump(arm64.BCONDEQ) - c.compileExitFromNativeCode(nativeCallStatusCodeTypeMismatchOnIndirectCall) - - c.assembler.SetJumpTargetOnNext(brIfTypeMatched) + // Skipped if the type matches. + c.compileMaybeExitFromNativeCode(arm64.BCONDEQ, nativeCallStatusCodeTypeMismatchOnIndirectCall) targetFunctionType := &c.ir.Types[typeIndex] if err := c.compileCallImpl(offsetReg, targetFunctionType); err != nil { @@ -1720,11 +1757,8 @@ func (c *arm64Compiler) compileIntegerDivPrecheck(is32Bit, isSigned bool, divide c.assembler.CompileTwoRegistersToNone(cmpInst, arm64.RegRZR, divisor) // If it is zero, we exit with nativeCallStatusIntegerDivisionByZero. - brIfDivisorNonZero := c.assembler.CompileJump(arm64.BCONDNE) - c.compileExitFromNativeCode(nativeCallStatusIntegerDivisionByZero) - + c.compileMaybeExitFromNativeCode(arm64.BCONDNE, nativeCallStatusIntegerDivisionByZero) // Otherwise, we proceed. - c.assembler.SetJumpTargetOnNext(brIfDivisorNonZero) // If the operation is a signed integer div, we have to do an additional check on overflow. if isSigned { @@ -1747,13 +1781,10 @@ func (c *arm64Compiler) compileIntegerDivPrecheck(is32Bit, isSigned bool, divide c.assembler.CompileTwoRegistersToNone(cmpInst, arm64ReservedRegisterForTemporary, dividend) // If they not equal, we are safe to execute the division. - brIfDividendNotMinInt := c.assembler.CompileJump(arm64.BCONDNE) - // Otherwise, we raise overflow error. - c.compileExitFromNativeCode(nativeCallStatusIntegerOverflow) + c.compileMaybeExitFromNativeCode(arm64.BCONDNE, nativeCallStatusIntegerOverflow) c.assembler.SetJumpTargetOnNext(brIfDivisorNonMinusOne) - c.assembler.SetJumpTargetOnNext(brIfDividendNotMinInt) } return nil } @@ -1802,11 +1833,8 @@ func (c *arm64Compiler) compileRem(o *wazeroir.UnionOperation) error { c.assembler.CompileTwoRegistersToNone(cmpInst, arm64.RegRZR, divisorReg) // If it is zero, we exit with nativeCallStatusIntegerDivisionByZero. - brIfDivisorNonZero := c.assembler.CompileJump(arm64.BCONDNE) - c.compileExitFromNativeCode(nativeCallStatusIntegerDivisionByZero) - + c.compileMaybeExitFromNativeCode(arm64.BCONDNE, nativeCallStatusIntegerDivisionByZero) // Otherwise, we proceed. - c.assembler.SetJumpTargetOnNext(brIfDivisorNonZero) // Temporarily mark them used to allocate a result register while keeping these values. c.markRegisterUsed(dividend.register, divisor.register) @@ -2256,13 +2284,10 @@ func (c *arm64Compiler) compileITruncFromF(o *wazeroir.UnionOperation) error { c.assembler.CompileTwoRegistersToNone(floatcmp, sourceReg, sourceReg) // VS flag is set if at least one of values for FCMP is NaN. // https://developer.arm.com/documentation/dui0801/g/Condition-Codes/Comparison-of-condition-code-meanings-in-integer-and-floating-point-code - brIfSourceNaN := c.assembler.CompileJump(arm64.BCONDVS) - // If the source value is not NaN, the operation was overflow. - c.compileExitFromNativeCode(nativeCallStatusIntegerOverflow) + c.compileMaybeExitFromNativeCode(arm64.BCONDVS, nativeCallStatusIntegerOverflow) // Otherwise, the operation was invalid as this is trying to convert NaN to integer. - c.assembler.SetJumpTargetOnNext(brIfSourceNaN) c.compileExitFromNativeCode(nativeCallStatusCodeInvalidFloatToIntConversion) // Otherwise, we branch into the next instruction. @@ -2822,7 +2847,7 @@ func (c *arm64Compiler) compileStoreImpl(offsetArg uint32, storeInst asm.Instruc return nil } -// compileMemoryAccessOffsetSetup pops the top value from the stack (called "base"), stores "base + offsetArg + targetSizeInBytes" +// compileMemoryAccessOffsetSetup pops the top value from the stack (called "base"), stores "base + offsetArg" // into a register, and returns the stored register. We call the result "offset" because we access the memory // as memory.Buffer[offset: offset+targetSizeInBytes]. // @@ -2859,14 +2884,12 @@ func (c *arm64Compiler) compileMemoryAccessOffsetSetup(offsetArg uint32, targetS // Check if offsetRegister(= base+offsetArg+targetSizeInBytes) > len(memory.Buffer). c.assembler.CompileTwoRegistersToNone(arm64.CMP, arm64ReservedRegisterForTemporary, offsetRegister) - boundsOK := c.assembler.CompileJump(arm64.BCONDLS) // If offsetRegister(= base+offsetArg+targetSizeInBytes) exceeds the memory length, // we exit the function with nativeCallStatusCodeMemoryOutOfBounds. - c.compileExitFromNativeCode(nativeCallStatusCodeMemoryOutOfBounds) + c.compileMaybeExitFromNativeCode(arm64.BCONDLS, nativeCallStatusCodeMemoryOutOfBounds) // Otherwise, we subtract targetSizeInBytes from offsetRegister. - c.assembler.SetJumpTargetOnNext(boundsOK) c.assembler.CompileConstToRegister(arm64.SUB, targetSizeInBytes, offsetRegister) return offsetRegister, nil } @@ -3124,13 +3147,10 @@ func (c *arm64Compiler) compileInitImpl(isTable bool, index, tableIndex uint32) arm64ReservedRegisterForTemporary) c.assembler.CompileTwoRegistersToNone(arm64.CMP, arm64ReservedRegisterForTemporary, sourceOffset.register) - sourceBoundsOK := c.assembler.CompileJump(arm64.BCONDLS) - // If not, raise out of bounds memory access error. - c.compileExitFromNativeCode(outOfBoundsErrorStatus) - - c.assembler.SetJumpTargetOnNext(sourceBoundsOK) + c.compileMaybeExitFromNativeCode(arm64.BCONDLS, outOfBoundsErrorStatus) + // Otherwise, ready to copy the value from destination to source. // Check destination bounds. if isTable { // arm64ReservedRegisterForTemporary = &tables[0] @@ -3154,14 +3174,10 @@ func (c *arm64Compiler) compileInitImpl(isTable bool, index, tableIndex uint32) } c.assembler.CompileTwoRegistersToNone(arm64.CMP, arm64ReservedRegisterForTemporary, destinationOffset.register) - destinationBoundsOK := c.assembler.CompileJump(arm64.BCONDLS) - // If not, raise out of bounds memory access error. - c.compileExitFromNativeCode(outOfBoundsErrorStatus) + c.compileMaybeExitFromNativeCode(arm64.BCONDLS, outOfBoundsErrorStatus) // Otherwise, ready to copy the value from source to destination. - c.assembler.SetJumpTargetOnNext(destinationBoundsOK) - if !isZeroRegister(copySize.register) { // If the size equals zero, we can skip the entire instructions beflow. c.assembler.CompileTwoRegistersToNone(arm64.CMP, arm64.RegRZR, copySize.register) @@ -3345,12 +3361,8 @@ func (c *arm64Compiler) compileCopyImpl(isTable bool, srcTableIndex, dstTableInd // Check memory len >= sourceOffset. c.assembler.CompileTwoRegistersToNone(arm64.CMP, arm64ReservedRegisterForTemporary, sourceOffset.register) - sourceBoundsOK := c.assembler.CompileJump(arm64.BCONDLS) - // If not, raise out of bounds memory access error. - c.compileExitFromNativeCode(outOfBoundsErrorStatus) - - c.assembler.SetJumpTargetOnNext(sourceBoundsOK) + c.compileMaybeExitFromNativeCode(arm64.BCONDLS, outOfBoundsErrorStatus) // Otherwise, check memory len >= destinationOffset. if isTable { @@ -3371,14 +3383,10 @@ func (c *arm64Compiler) compileCopyImpl(isTable bool, srcTableIndex, dstTableInd } c.assembler.CompileTwoRegistersToNone(arm64.CMP, arm64ReservedRegisterForTemporary, destinationOffset.register) - destinationBoundsOK := c.assembler.CompileJump(arm64.BCONDLS) - // If not, raise out of bounds memory access error. - c.compileExitFromNativeCode(outOfBoundsErrorStatus) + c.compileMaybeExitFromNativeCode(arm64.BCONDLS, outOfBoundsErrorStatus) // Otherwise, ready to copy the value from source to destination. - c.assembler.SetJumpTargetOnNext(destinationBoundsOK) - var ldr, str asm.Instruction var movSize int64 if isTable { @@ -3545,6 +3553,11 @@ func (c *arm64Compiler) compileMemoryFill() error { // TODO: the compiled code in this function should be reused and compile at once as // the code is independent of any module. func (c *arm64Compiler) compileFillImpl(isTable bool, tableIndex uint32) error { + outOfBoundsErrorStatus := nativeCallStatusCodeMemoryOutOfBounds + if isTable { + outOfBoundsErrorStatus = nativeCallStatusCodeInvalidTableAccess + } + fillSize, err := c.popValueOnRegister() if err != nil { return err @@ -3597,19 +3610,12 @@ func (c *arm64Compiler) compileFillImpl(isTable bool, tableIndex uint32) error { // Check len >= destinationOffset. c.assembler.CompileTwoRegistersToNone(arm64.CMP, arm64ReservedRegisterForTemporary, destinationOffset.register) - destinationBoundsOK := c.assembler.CompileJump(arm64.BCONDLS) // If not, raise the runtime error. - if isTable { - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - } else { - c.compileExitFromNativeCode(nativeCallStatusCodeMemoryOutOfBounds) - } + c.compileMaybeExitFromNativeCode(arm64.BCONDLS, outOfBoundsErrorStatus) // Otherwise, ready to copy the value from destination to source. - c.assembler.SetJumpTargetOnNext(destinationBoundsOK) - - // If the size equals zero, we can skip the entire instructions beflow. + // If the size equals zero, we can skip the entire instructions below. c.assembler.CompileTwoRegistersToNone(arm64.CMP, arm64.RegRZR, fillSize.register) skipCopyJump := c.assembler.CompileJump(arm64.BCONDEQ) @@ -3781,9 +3787,7 @@ func (c *arm64Compiler) compileTableGet(o *wazeroir.UnionOperation) error { c.assembler.CompileTwoRegistersToNone(arm64.CMP, ref, offset.register) // If it exceeds len(table), we exit the execution. - brIfBoundsOK := c.assembler.CompileJump(arm64.BCONDLO) - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - c.assembler.SetJumpTargetOnNext(brIfBoundsOK) + c.compileMaybeExitFromNativeCode(arm64.BCONDLO, nativeCallStatusCodeInvalidTableAccess) // ref = [&tables[TableIndex] + tableInstanceTableOffset] = &tables[TableIndex].References[0] c.assembler.CompileMemoryToRegister(arm64.LDRD, @@ -3843,9 +3847,7 @@ func (c *arm64Compiler) compileTableSet(o *wazeroir.UnionOperation) error { c.assembler.CompileTwoRegistersToNone(arm64.CMP, tmp, offset.register) // If it exceeds len(table), we exit the execution. - brIfBoundsOK := c.assembler.CompileJump(arm64.BCONDLO) - c.compileExitFromNativeCode(nativeCallStatusCodeInvalidTableAccess) - c.assembler.SetJumpTargetOnNext(brIfBoundsOK) + c.compileMaybeExitFromNativeCode(arm64.BCONDLO, nativeCallStatusCodeInvalidTableAccess) // tmp = [&tables[TableIndex] + tableInstanceTableOffset] = &tables[TableIndex].References[0] c.assembler.CompileMemoryToRegister(arm64.LDRD, diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/interpreter/interpreter.go b/vendor/github.com/tetratelabs/wazero/internal/engine/interpreter/interpreter.go index d10f25715..ad3e7f760 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/interpreter/interpreter.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/interpreter/interpreter.go @@ -29,17 +29,17 @@ var callStackCeiling = 2000 // engine is an interpreter implementation of wasm.Engine type engine struct { - enabledFeatures api.CoreFeatures - codes map[wasm.ModuleID][]code // guarded by mutex. - mux sync.RWMutex + enabledFeatures api.CoreFeatures + compiledFunctions map[wasm.ModuleID][]compiledFunction // guarded by mutex. + mux sync.RWMutex // labelAddressResolutionCache is the temporary cache used to map LabelKind -> FrameID -> the index to the body. labelAddressResolutionCache [wazeroir.LabelKindNum][]uint64 } func NewEngine(_ context.Context, enabledFeatures api.CoreFeatures, _ filecache.Cache) wasm.Engine { return &engine{ - enabledFeatures: enabledFeatures, - codes: map[wasm.ModuleID][]code{}, + enabledFeatures: enabledFeatures, + compiledFunctions: map[wasm.ModuleID][]compiledFunction{}, } } @@ -50,30 +50,30 @@ func (e *engine) Close() (err error) { // CompiledModuleCount implements the same method as documented on wasm.Engine. func (e *engine) CompiledModuleCount() uint32 { - return uint32(len(e.codes)) + return uint32(len(e.compiledFunctions)) } // DeleteCompiledModule implements the same method as documented on wasm.Engine. func (e *engine) DeleteCompiledModule(m *wasm.Module) { - e.deleteCodes(m) + e.deleteCompiledFunctions(m) } -func (e *engine) deleteCodes(module *wasm.Module) { +func (e *engine) deleteCompiledFunctions(module *wasm.Module) { e.mux.Lock() defer e.mux.Unlock() - delete(e.codes, module.ID) + delete(e.compiledFunctions, module.ID) } -func (e *engine) addCodes(module *wasm.Module, fs []code) { +func (e *engine) addCompiledFunctions(module *wasm.Module, fs []compiledFunction) { e.mux.Lock() defer e.mux.Unlock() - e.codes[module.ID] = fs + e.compiledFunctions[module.ID] = fs } -func (e *engine) getCodes(module *wasm.Module) (fs []code, ok bool) { +func (e *engine) getCompiledFunctions(module *wasm.Module) (fs []compiledFunction, ok bool) { e.mux.RLock() defer e.mux.RUnlock() - fs, ok = e.codes[module.ID] + fs, ok = e.compiledFunctions[module.ID] return } @@ -101,15 +101,15 @@ type callEngine struct { // frames are the function call stack. frames []*callFrame - // compiled is the initial function for this call engine. - compiled *function + // f is the initial function for this call engine. + f *function // stackiterator for Listeners to walk frames and stack. stackIterator stackIterator } func (e *moduleEngine) newCallEngine(compiled *function) *callEngine { - return &callEngine{compiled: compiled} + return &callEngine{f: compiled} } func (ce *callEngine) pushValue(v uint64) { @@ -187,22 +187,21 @@ type callFrame struct { base int } -type code struct { +type compiledFunction struct { source *wasm.Module body []wazeroir.UnionOperation listener experimental.FunctionListener offsetsInWasmBinary []uint64 hostFn interface{} ensureTermination bool + index wasm.Index } type function struct { - index wasm.Index funcType *wasm.FunctionType - def api.FunctionDefinition moduleInstance *wasm.ModuleInstance typeID wasm.FunctionTypeID - parent *code + parent *compiledFunction } // functionFromUintptr resurrects the original *function from the given uintptr @@ -223,10 +222,12 @@ type stackIterator struct { frames []*callFrame started bool fn *function + pc uint64 } func (si *stackIterator) reset(stack []uint64, frames []*callFrame, f *function) { si.fn = f + si.pc = 0 si.stack = stack si.frames = frames si.started = false @@ -239,7 +240,7 @@ func (si *stackIterator) clear() { si.fn = nil } -// Next implements experimental.StackIterator. +// Next implements the same method as documented on experimental.StackIterator. func (si *stackIterator) Next() bool { if !si.started { si.started = true @@ -253,36 +254,65 @@ func (si *stackIterator) Next() bool { frame := si.frames[len(si.frames)-1] si.stack = si.stack[:frame.base] si.fn = frame.f + si.pc = frame.pc si.frames = si.frames[:len(si.frames)-1] return true } -// FunctionDefinition implements experimental.StackIterator. -func (si *stackIterator) FunctionDefinition() api.FunctionDefinition { - return si.fn.def +// Function implements the same method as documented on +// experimental.StackIterator. +func (si *stackIterator) Function() experimental.InternalFunction { + return internalFunction{si.fn} +} + +// ProgramCounter implements the same method as documented on +// experimental.StackIterator. +func (si *stackIterator) ProgramCounter() experimental.ProgramCounter { + return experimental.ProgramCounter(si.pc) } -// Args implements experimental.StackIterator. +// Parameters implements the same method as documented on +// experimental.StackIterator. func (si *stackIterator) Parameters() []uint64 { paramsCount := si.fn.funcType.ParamNumInUint64 top := len(si.stack) return si.stack[top-paramsCount:] } +// internalFunction implements experimental.InternalFunction. +type internalFunction struct{ *function } + +// Definition implements the same method as documented on +// experimental.InternalFunction. +func (f internalFunction) Definition() api.FunctionDefinition { + return f.definition() +} + +// SourceOffsetForPC implements the same method as documented on +// experimental.InternalFunction. +func (f internalFunction) SourceOffsetForPC(pc experimental.ProgramCounter) uint64 { + offsetsMap := f.parent.offsetsInWasmBinary + if uint64(pc) < uint64(len(offsetsMap)) { + return offsetsMap[pc] + } + return 0 +} + // interpreter mode doesn't maintain call frames in the stack, so pass the zero size to the IR. const callFrameStackSize = 0 // CompileModule implements the same method as documented on wasm.Engine. func (e *engine) CompileModule(_ context.Context, module *wasm.Module, listeners []experimental.FunctionListener, ensureTermination bool) error { - if _, ok := e.getCodes(module); ok { // cache hit! + if _, ok := e.getCompiledFunctions(module); ok { // cache hit! return nil } - funcs := make([]code, len(module.FunctionSection)) + funcs := make([]compiledFunction, len(module.FunctionSection)) irCompiler, err := wazeroir.NewCompiler(e.enabledFeatures, callFrameStackSize, module, ensureTermination) if err != nil { return err } + imported := module.ImportFunctionCount for i := range module.CodeSection { var lsn experimental.FunctionListener if i < len(listeners) { @@ -302,15 +332,16 @@ func (e *engine) CompileModule(_ context.Context, module *wasm.Module, listeners } err = e.lowerIR(ir, compiled) if err != nil { - def := module.FunctionDefinitionSection[uint32(i)+module.ImportFunctionCount] + def := module.FunctionDefinition(uint32(i) + module.ImportFunctionCount) return fmt.Errorf("failed to lower func[%s] to wazeroir: %w", def.DebugName(), err) } } compiled.source = module compiled.ensureTermination = ensureTermination compiled.listener = lsn + compiled.index = imported + uint32(i) } - e.addCodes(module, funcs) + e.addCompiledFunctions(module, funcs) return nil } @@ -321,7 +352,7 @@ func (e *engine) NewModuleEngine(module *wasm.Module, instance *wasm.ModuleInsta functions: make([]function, len(module.FunctionSection)+int(module.ImportFunctionCount)), } - codes, ok := e.getCodes(module) + codes, ok := e.getCompiledFunctions(module) if !ok { return nil, errors.New("source module must be compiled before instantiation") } @@ -331,11 +362,9 @@ func (e *engine) NewModuleEngine(module *wasm.Module, instance *wasm.ModuleInsta offset := i + int(module.ImportFunctionCount) typeIndex := module.FunctionSection[i] me.functions[offset] = function{ - index: wasm.Index(offset), moduleInstance: instance, typeID: instance.TypeIDs[typeIndex], funcType: &module.TypeSection[typeIndex], - def: &module.FunctionDefinitionSection[offset], parent: c, } } @@ -343,7 +372,7 @@ func (e *engine) NewModuleEngine(module *wasm.Module, instance *wasm.ModuleInsta } // lowerIR lowers the wazeroir operations to engine friendly struct. -func (e *engine) lowerIR(ir *wazeroir.CompilationResult, ret *code) error { +func (e *engine) lowerIR(ir *wazeroir.CompilationResult, ret *compiledFunction) error { // Copy the body from the result. ret.body = make([]wazeroir.UnionOperation, len(ir.Operations)) copy(ret.body, ir.Operations) @@ -411,7 +440,6 @@ func (e *engine) setLabelAddress(op *uint64, label wazeroir.Label) { func (e *moduleEngine) ResolveImportedFunction(index, indexInImportedModule wasm.Index, importedModuleEngine wasm.ModuleEngine) { imported := importedModuleEngine.(*moduleEngine) e.functions[index] = imported.functions[indexInImportedModule] - e.functions[index].index = index } // FunctionInstanceReference implements the same method as documented on wasm.ModuleEngine. @@ -428,7 +456,7 @@ func (e *moduleEngine) NewFunction(index wasm.Index) (ce api.Function) { } // LookupFunction implements the same method as documented on wasm.ModuleEngine. -func (e *moduleEngine) LookupFunction(t *wasm.TableInstance, typeId wasm.FunctionTypeID, tableOffset wasm.Index) (idx wasm.Index, err error) { +func (e *moduleEngine) LookupFunction(t *wasm.TableInstance, typeId wasm.FunctionTypeID, tableOffset wasm.Index) (f api.Function, err error) { if tableOffset >= uint32(len(t.References)) { err = wasmruntime.ErrRuntimeInvalidTableAccess return @@ -444,18 +472,24 @@ func (e *moduleEngine) LookupFunction(t *wasm.TableInstance, typeId wasm.Functio err = wasmruntime.ErrRuntimeIndirectCallTypeMismatch return } - idx = tf.index + + f = e.newCallEngine(tf) return } // Definition implements the same method as documented on api.Function. func (ce *callEngine) Definition() api.FunctionDefinition { - return ce.compiled.def + return ce.f.definition() +} + +func (f *function) definition() api.FunctionDefinition { + compiled := f.parent + return compiled.source.FunctionDefinition(compiled.index) } // Call implements the same method as documented on api.Function. func (ce *callEngine) Call(ctx context.Context, params ...uint64) (results []uint64, err error) { - ft := ce.compiled.funcType + ft := ce.f.funcType if n := ft.ParamNumInUint64; n != len(params) { return nil, fmt.Errorf("expected %d params, but passed %d", n, len(params)) } @@ -464,7 +498,7 @@ func (ce *callEngine) Call(ctx context.Context, params ...uint64) (results []uin // CallWithStack implements the same method as documented on api.Function. func (ce *callEngine) CallWithStack(ctx context.Context, stack []uint64) error { - params, results, err := wasm.SplitCallStack(ce.compiled.funcType, stack) + params, results, err := wasm.SplitCallStack(ce.f.funcType, stack) if err != nil { return err } @@ -473,8 +507,8 @@ func (ce *callEngine) CallWithStack(ctx context.Context, stack []uint64) error { } func (ce *callEngine) call(ctx context.Context, params, results []uint64) (_ []uint64, err error) { - m := ce.compiled.moduleInstance - if ce.compiled.parent.ensureTermination { + m := ce.f.moduleInstance + if ce.f.parent.ensureTermination { select { case <-ctx.Done(): // If the provided context is already done, close the call context @@ -493,23 +527,23 @@ func (ce *callEngine) call(ctx context.Context, params, results []uint64) (_ []u // TODO: ^^ Will not fail if the function was imported from a closed module. if v := recover(); v != nil { - err = ce.recoverOnCall(v) + err = ce.recoverOnCall(ctx, m, v) } }() ce.pushValues(params) - if ce.compiled.parent.ensureTermination { + if ce.f.parent.ensureTermination { done := m.CloseModuleOnCanceledOrTimeout(ctx) defer done() } - ce.callFunction(ctx, m, ce.compiled) + ce.callFunction(ctx, m, ce.f) // This returns a safe copy of the results, instead of a slice view. If we // returned a re-slice, the caller could accidentally or purposefully // corrupt the stack of subsequent calls. - ft := ce.compiled.funcType + ft := ce.f.funcType if results == nil && ft.ResultNumInUint64 > 0 { results = make([]uint64, ft.ResultNumInUint64) } @@ -517,23 +551,42 @@ func (ce *callEngine) call(ctx context.Context, params, results []uint64) (_ []u return results, nil } +// functionListenerInvocation captures arguments needed to perform function +// listener invocations when unwinding the call stack. +type functionListenerInvocation struct { + experimental.FunctionListener + def api.FunctionDefinition +} + // recoverOnCall takes the recovered value `recoverOnCall`, and wraps it // with the call frame stack traces. Also, reset the state of callEngine // so that it can be used for the subsequent calls. -func (ce *callEngine) recoverOnCall(v interface{}) (err error) { +func (ce *callEngine) recoverOnCall(ctx context.Context, m *wasm.ModuleInstance, v interface{}) (err error) { builder := wasmdebug.NewErrorBuilder() frameCount := len(ce.frames) + functionListeners := make([]functionListenerInvocation, 0, 16) + for i := 0; i < frameCount; i++ { frame := ce.popFrame() f := frame.f - def := f.def + def := f.definition() var sources []string if parent := frame.f.parent; parent.body != nil && len(parent.offsetsInWasmBinary) > 0 { sources = parent.source.DWARFLines.Line(parent.offsetsInWasmBinary[frame.pc]) } builder.AddFrame(def.DebugName(), def.ParamTypes(), def.ResultTypes(), sources) + if f.parent.listener != nil { + functionListeners = append(functionListeners, functionListenerInvocation{ + FunctionListener: f.parent.listener, + def: f.definition(), + }) + } } + err = builder.FromRecovered(v) + for i := range functionListeners { + functionListeners[i].Abort(ctx, m, functionListeners[i].def, err) + } // Allows the reuse of CallEngine. ce.stack, ce.frames = ce.stack[:0], ce.frames[:0] @@ -551,12 +604,12 @@ func (ce *callEngine) callFunction(ctx context.Context, m *wasm.ModuleInstance, } func (ce *callEngine) callGoFunc(ctx context.Context, m *wasm.ModuleInstance, f *function, stack []uint64) { - def, typ := f.def, f.funcType + typ := f.funcType lsn := f.parent.listener if lsn != nil { params := stack[:typ.ParamNumInUint64] ce.stackIterator.reset(ce.stack, ce.frames, f) - ctx = lsn.Before(ctx, m, def, params, &ce.stackIterator) + lsn.Before(ctx, m, f.definition(), params, &ce.stackIterator) ce.stackIterator.clear() } frame := &callFrame{f: f, base: len(ce.stack)} @@ -574,7 +627,7 @@ func (ce *callEngine) callGoFunc(ctx context.Context, m *wasm.ModuleInstance, f if lsn != nil { // TODO: This doesn't get the error due to use of panic to propagate them. results := stack[:typ.ResultNumInUint64] - lsn.After(ctx, m, def, nil, results) + lsn.After(ctx, m, f.definition(), results) } } @@ -4047,13 +4100,13 @@ func i32Abs(v uint32) uint32 { } func (ce *callEngine) callNativeFuncWithListener(ctx context.Context, m *wasm.ModuleInstance, f *function, fnl experimental.FunctionListener) context.Context { - def, typ := &f.moduleInstance.Definitions[f.index], f.funcType + def, typ := f.definition(), f.funcType ce.stackIterator.reset(ce.stack, ce.frames, f) - ctx = fnl.Before(ctx, m, def, ce.peekValues(len(typ.Params)), &ce.stackIterator) + fnl.Before(ctx, m, def, ce.peekValues(len(typ.Params)), &ce.stackIterator) ce.stackIterator.clear() ce.callNativeFunc(ctx, m, f) - fnl.After(ctx, m, def, nil, ce.peekValues(len(typ.Results))) + fnl.After(ctx, m, def, ce.peekValues(len(typ.Results))) return ctx } diff --git a/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants.go b/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants.go new file mode 100644 index 000000000..868b9c16a --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants.go @@ -0,0 +1,13 @@ +//go:build !windows && !js && !illumos && !solaris + +package fsapi + +import "syscall" + +// Simple aliases to constants in the syscall package for portability with +// platforms which do not have them (e.g. windows) +const ( + O_DIRECTORY = syscall.O_DIRECTORY + O_NOFOLLOW = syscall.O_NOFOLLOW + O_NONBLOCK = syscall.O_NONBLOCK +) diff --git a/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_js.go b/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_js.go new file mode 100644 index 000000000..af73ddb66 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_js.go @@ -0,0 +1,8 @@ +package fsapi + +// See the comments on the same constants in constants_windows.go +const ( + O_DIRECTORY = 1 << 29 + O_NOFOLLOW = 1 << 30 + O_NONBLOCK = 1 << 31 +) diff --git a/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_sun.go b/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_sun.go new file mode 100644 index 000000000..a0de49b73 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_sun.go @@ -0,0 +1,12 @@ +//go:build illumos || solaris + +package fsapi + +import "syscall" + +// See https://github.com/illumos/illumos-gate/blob/edd580643f2cf1434e252cd7779e83182ea84945/usr/src/uts/common/sys/fcntl.h#L90 +const ( + O_DIRECTORY = 0x1000000 + O_NOFOLLOW = syscall.O_NOFOLLOW + O_NONBLOCK = syscall.O_NONBLOCK +) diff --git a/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_windows.go b/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_windows.go new file mode 100644 index 000000000..33aed8705 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/fsapi/constants_windows.go @@ -0,0 +1,24 @@ +package fsapi + +import "syscall" + +// Windows does not have these constants, we declare placeholders which should +// not conflict with other open flags. These placeholders are not declared as +// value zero so code written in a way which expects them to be bit flags still +// works as expected. +// +// Since those placeholder are not interpreted by the open function, the unix +// features they represent are also not implemented on windows: +// +// - O_DIRECTORY allows programs to ensure that the opened file is a directory. +// This could be emulated by doing a stat call on the file after opening it +// to verify that it is in fact a directory, then closing it and returning an +// error if it is not. +// +// - O_NOFOLLOW allows programs to ensure that if the opened file is a symbolic +// link, the link itself is opened instead of its target. +const ( + O_DIRECTORY = 1 << 29 + O_NOFOLLOW = 1 << 30 + O_NONBLOCK = syscall.O_NONBLOCK +) diff --git a/vendor/github.com/tetratelabs/wazero/internal/fsapi/dir.go b/vendor/github.com/tetratelabs/wazero/internal/fsapi/dir.go new file mode 100644 index 000000000..c28783b46 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/fsapi/dir.go @@ -0,0 +1,99 @@ +package fsapi + +import ( + "fmt" + "io/fs" + "syscall" + "time" +) + +// Dirent is an entry read from a directory. +// +// This is a portable variant of syscall.Dirent containing fields needed for +// WebAssembly ABI including WASI snapshot-01 and wasi-filesystem. Unlike +// fs.DirEntry, this may include the Ino. +type Dirent struct { + // ^^ Dirent name matches syscall.Dirent + + // Name is the base name of the directory entry. + Name string + + // Ino is the file serial number, or zero if not available. + Ino uint64 + + // Type is fs.FileMode masked on fs.ModeType. For example, zero is a + // regular file, fs.ModeDir is a directory and fs.ModeIrregular is unknown. + Type fs.FileMode +} + +func (d *Dirent) String() string { + return fmt.Sprintf("name=%s, type=%v, ino=%d", d.Name, d.Type, d.Ino) +} + +// IsDir returns true if the Type is fs.ModeDir. +func (d *Dirent) IsDir() bool { + return d.Type == fs.ModeDir +} + +// DirFile is embeddable to reduce the amount of functions to implement a file. +type DirFile struct{} + +// IsAppend implements File.IsAppend +func (DirFile) IsAppend() bool { + return false +} + +// SetAppend implements File.SetAppend +func (DirFile) SetAppend(bool) syscall.Errno { + return syscall.EISDIR +} + +// IsNonblock implements File.IsNonblock +func (DirFile) IsNonblock() bool { + return false +} + +// SetNonblock implements File.SetNonblock +func (DirFile) SetNonblock(bool) syscall.Errno { + return syscall.EISDIR +} + +// IsDir implements File.IsDir +func (DirFile) IsDir() (bool, syscall.Errno) { + return true, 0 +} + +// Read implements File.Read +func (DirFile) Read([]byte) (int, syscall.Errno) { + return 0, syscall.EISDIR +} + +// Pread implements File.Pread +func (DirFile) Pread([]byte, int64) (int, syscall.Errno) { + return 0, syscall.EISDIR +} + +// Seek implements File.Seek +func (DirFile) Seek(int64, int) (int64, syscall.Errno) { + return 0, syscall.EISDIR +} + +// PollRead implements File.PollRead +func (DirFile) PollRead(*time.Duration) (ready bool, errno syscall.Errno) { + return false, syscall.ENOSYS +} + +// Write implements File.Write +func (DirFile) Write([]byte) (int, syscall.Errno) { + return 0, syscall.EISDIR +} + +// Pwrite implements File.Pwrite +func (DirFile) Pwrite([]byte, int64) (int, syscall.Errno) { + return 0, syscall.EISDIR +} + +// Truncate implements File.Truncate +func (DirFile) Truncate(int64) syscall.Errno { + return syscall.EISDIR +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/fsapi/file.go b/vendor/github.com/tetratelabs/wazero/internal/fsapi/file.go new file mode 100644 index 000000000..2d6ad0372 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/fsapi/file.go @@ -0,0 +1,382 @@ +package fsapi + +import ( + "io/fs" + "syscall" + "time" +) + +// File is a writeable fs.File bridge backed by syscall functions needed for ABI +// including WASI and runtime.GOOS=js. +// +// Implementations should embed UnimplementedFile for forward compatability. Any +// unsupported method or parameter should return syscall.ENOSYS. +// +// # Errors +// +// All methods that can return an error return a syscall.Errno, which is zero +// on success. +// +// Restricting to syscall.Errno matches current WebAssembly host functions, +// which are constrained to well-known error codes. For example, `GOOS=js` maps +// hard coded values and panics otherwise. More commonly, WASI maps syscall +// errors to u32 numeric values. +// +// # Notes +// +// A writable filesystem abstraction is not yet implemented as of Go 1.20. See +// https://github.com/golang/go/issues/45757 +type File interface { + // Ino returns the inode (Stat_t.Ino) of this file, zero if unknown or an + // error there was an error retrieving it. + // + // # Errors + // + // Possible errors are those from Stat, except syscall.ENOSYS should not + // be returned. Zero should be returned if there is no implementation. + // + // # Notes + // + // - Some implementations implement this with a cached call to Stat. + Ino() (uint64, syscall.Errno) + + // IsNonblock returns true if the file was opened with O_NONBLOCK, or + // SetNonblock was successfully enabled on this file. + // + // # Notes + // + // - This might not match the underlying state of the file descriptor if + // the file was not opened via OpenFile. + IsNonblock() bool + + // SetNonblock toggles the non-blocking mode (O_NONBLOCK) of this file. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed. + // + // # Notes + // + // - This is like syscall.SetNonblock and `fcntl` with O_NONBLOCK in + // POSIX. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html + SetNonblock(enable bool) syscall.Errno + + // IsAppend returns true if the file was opened with syscall.O_APPEND, or + // SetAppend was successfully enabled on this file. + // + // # Notes + // + // - This might not match the underlying state of the file descriptor if + // the file was not opened via OpenFile. + IsAppend() bool + + // SetAppend toggles the append mode (syscall.O_APPEND) of this file. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed. + // + // # Notes + // + // - There is no `O_APPEND` for `fcntl` in POSIX, so implementations may + // have to re-open the underlying file to apply this. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html + SetAppend(enable bool) syscall.Errno + + // Stat is similar to syscall.Fstat. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed. + // + // # Notes + // + // - This is like syscall.Fstat and `fstatat` with `AT_FDCWD` in POSIX. + // See https://pubs.opengroup.org/onlinepubs/9699919799/functions/stat.html + // - A fs.FileInfo backed implementation sets atim, mtim and ctim to the + // same value. + // - Windows allows you to stat a closed directory. + Stat() (Stat_t, syscall.Errno) + + // IsDir returns true if this file is a directory or an error there was an + // error retrieving this information. + // + // # Errors + // + // Possible errors are those from Stat. + // + // # Notes + // + // - Some implementations implement this with a cached call to Stat. + IsDir() (bool, syscall.Errno) + + // Read attempts to read all bytes in the file into `buf`, and returns the + // count read even on error. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed or not readable. + // - syscall.EISDIR: the file was a directory. + // + // # Notes + // + // - This is like io.Reader and `read` in POSIX, preferring semantics of + // io.Reader. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html + // - Unlike io.Reader, there is no io.EOF returned on end-of-file. To + // read the file completely, the caller must repeat until `n` is zero. + Read(buf []byte) (n int, errno syscall.Errno) + + // Pread attempts to read all bytes in the file into `p`, starting at the + // offset `off`, and returns the count read even on error. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed or not readable. + // - syscall.EINVAL: the offset was negative. + // - syscall.EISDIR: the file was a directory. + // + // # Notes + // + // - This is like io.ReaderAt and `pread` in POSIX, preferring semantics + // of io.ReaderAt. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html + // - Unlike io.ReaderAt, there is no io.EOF returned on end-of-file. To + // read the file completely, the caller must repeat until `n` is zero. + Pread(buf []byte, off int64) (n int, errno syscall.Errno) + + // Seek attempts to set the next offset for Read or Write and returns the + // resulting absolute offset or an error. + // + // # Parameters + // + // The `offset` parameters is interpreted in terms of `whence`: + // - io.SeekStart: relative to the start of the file, e.g. offset=0 sets + // the next Read or Write to the beginning of the file. + // - io.SeekCurrent: relative to the current offset, e.g. offset=16 sets + // the next Read or Write 16 bytes past the prior. + // - io.SeekEnd: relative to the end of the file, e.g. offset=-1 sets the + // next Read or Write to the last byte in the file. + // + // # Behavior when a directory + // + // The only supported use case for a directory is seeking to `offset` zero + // (`whence` = io.SeekStart). This should have the same behavior as + // os.File, which resets any internal state used by Readdir. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed or not readable. + // - syscall.EINVAL: the offset was negative. + // + // # Notes + // + // - This is like io.Seeker and `fseek` in POSIX, preferring semantics + // of io.Seeker. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/fseek.html + Seek(offset int64, whence int) (newOffset int64, errno syscall.Errno) + + // PollRead returns if the file has data ready to be read or an error. + // + // # Parameters + // + // The `timeout` parameter when nil blocks up to forever. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // + // # Notes + // + // - This is like `poll` in POSIX, for a single file. + // See https://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html + // - No-op files, such as those which read from /dev/null, should return + // immediately true to avoid hangs (because data will never become + // available). + PollRead(timeout *time.Duration) (ready bool, errno syscall.Errno) + + // Readdir reads the contents of the directory associated with file and + // returns a slice of up to n Dirent values in an arbitrary order. This is + // a stateful function, so subsequent calls return any next values. + // + // If n > 0, Readdir returns at most n entries or an error. + // If n <= 0, Readdir returns all remaining entries or an error. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.ENOTDIR: the file was not a directory + // + // # Notes + // + // - This is like `Readdir` on os.File, but unlike `readdir` in POSIX. + // See https://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html + // - For portability reasons, no error is returned at the end of the + // directory, when the file is closed or removed while open. + // See https://github.com/ziglang/zig/blob/0.10.1/lib/std/fs.zig#L635-L637 + Readdir(n int) (dirents []Dirent, errno syscall.Errno) + // ^-- TODO: consider being more like POSIX, for example, returning a + // closeable Dirent object that can iterate on demand. This would + // centralize sizing logic needed by wasi, particularly extra dirents + // stored in the sys.FileEntry type. It could possibly reduce the need to + // reopen the whole file. + + // Write attempts to write all bytes in `p` to the file, and returns the + // count written even on error. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file was closed, not writeable, or a directory. + // + // # Notes + // + // - This is like io.Writer and `write` in POSIX, preferring semantics of + // io.Writer. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html + Write(buf []byte) (n int, errno syscall.Errno) + + // Pwrite attempts to write all bytes in `p` to the file at the given + // offset `off`, and returns the count written even on error. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed or not writeable. + // - syscall.EINVAL: the offset was negative. + // - syscall.EISDIR: the file was a directory. + // + // # Notes + // + // - This is like io.WriterAt and `pwrite` in POSIX, preferring semantics + // of io.WriterAt. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html + Pwrite(buf []byte, off int64) (n int, errno syscall.Errno) + + // Truncate truncates a file to a specified length. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed. + // - syscall.EINVAL: the `size` is negative. + // - syscall.EISDIR: the file was a directory. + // + // # Notes + // + // - This is like syscall.Ftruncate and `ftruncate` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html + // - Windows does not error when calling Truncate on a closed file. + Truncate(size int64) syscall.Errno + + // Sync synchronizes changes to the file. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.EBADF: the file or directory was closed. + // + // # Notes + // + // - This is like syscall.Fsync and `fsync` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html + // - This returns with no error instead of syscall.ENOSYS when + // unimplemented. This prevents fake filesystems from erring. + // - Windows does not error when calling Sync on a closed file. + Sync() syscall.Errno + + // Datasync synchronizes the data of a file. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.EBADF: the file or directory was closed. + // + // # Notes + // + // - This is like syscall.Fdatasync and `fdatasync` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html + // - This returns with no error instead of syscall.ENOSYS when + // unimplemented. This prevents fake filesystems from erring. + // - As this is commonly missing, some implementations dispatch to Sync. + Datasync() syscall.Errno + + // Chmod changes the mode of the file. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed. + // + // # Notes + // + // - This is like syscall.Fchmod and `fchmod` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchmod.html + // - Windows ignores the execute bit, and any permissions come back as + // group and world. For example, chmod of 0400 reads back as 0444, and + // 0700 0666. Also, permissions on directories aren't supported at all. + Chmod(fs.FileMode) syscall.Errno + + // Chown changes the owner and group of a file. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed. + // + // # Notes + // + // - This is like syscall.Fchown and `fchown` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchown.html + // - This always returns syscall.ENOSYS on windows. + Chown(uid, gid int) syscall.Errno + + // Utimens set file access and modification times of this file, at + // nanosecond precision. + // + // # Parameters + // + // The `times` parameter includes the access and modification timestamps to + // assign. Special syscall.Timespec NSec values UTIME_NOW and UTIME_OMIT may be + // specified instead of real timestamps. A nil `times` parameter behaves the + // same as if both were set to UTIME_NOW. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EBADF: the file or directory was closed. + // + // # Notes + // + // - This is like syscall.UtimesNano and `futimens` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html + // - Windows requires files to be open with syscall.O_RDWR, which means you + // cannot use this to update timestamps on a directory (syscall.EPERM). + Utimens(times *[2]syscall.Timespec) syscall.Errno + + // Close closes the underlying file. + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // + // # Notes + // + // - This is like syscall.Close and `close` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html + Close() syscall.Errno +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/fsapi/fs.go b/vendor/github.com/tetratelabs/wazero/internal/fsapi/fs.go new file mode 100644 index 000000000..9a46bfe6c --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/fsapi/fs.go @@ -0,0 +1,365 @@ +package fsapi + +import ( + "io/fs" + "syscall" +) + +// FS is a writeable fs.FS bridge backed by syscall functions needed for ABI +// including WASI and runtime.GOOS=js. +// +// Implementations should embed UnimplementedFS for forward compatability. Any +// unsupported method or parameter should return syscall.ENO +// +// # Errors +// +// All methods that can return an error return a syscall.Errno, which is zero +// on success. +// +// Restricting to syscall.Errno matches current WebAssembly host functions, +// which are constrained to well-known error codes. For example, `GOOS=js` maps +// hard coded values and panics otherwise. More commonly, WASI maps syscall +// errors to u32 numeric values. +// +// # Notes +// +// A writable filesystem abstraction is not yet implemented as of Go 1.20. See +// https://github.com/golang/go/issues/45757 +type FS interface { + // String should return a human-readable format of the filesystem + // + // For example, if this filesystem is backed by the real directory + // "/tmp/wasm", the expected value is "/tmp/wasm". + // + // When the host filesystem isn't a real filesystem, substitute a symbolic, + // human-readable name. e.g. "virtual" + String() string + + // OpenFile opens a file. It should be closed via Close on File. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `path` or `flag` is invalid. + // - syscall.EISDIR: the path was a directory, but flag included + // syscall.O_RDWR or syscall.O_WRONLY + // - syscall.ENOENT: `path` doesn't exist and `flag` doesn't contain + // os.O_CREATE. + // + // # Constraints on the returned file + // + // Implementations that can read flags should enforce them regardless of + // the type returned. For example, while os.File implements io.Writer, + // attempts to write to a directory or a file opened with os.O_RDONLY fail + // with a syscall.EBADF. + // + // Some implementations choose whether to enforce read-only opens, namely + // fs.FS. While fs.FS is supported (Adapt), wazero cannot runtime enforce + // open flags. Instead, we encourage good behavior and test our built-in + // implementations. + // + // # Notes + // + // - This is like os.OpenFile, except the path is relative to this file + // system, and syscall.Errno is returned instead of os.PathError. + // - flag are the same as os.OpenFile, for example, os.O_CREATE. + // - Implications of permissions when os.O_CREATE are described in Chmod + // notes. + // - This is like `open` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html + OpenFile(path string, flag int, perm fs.FileMode) (File, syscall.Errno) + // ^^ TODO: Consider syscall.Open, though this implies defining and + // coercing flags and perms similar to what is done in os.OpenFile. + + // Lstat gets file status without following symbolic links. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.ENOENT: `path` doesn't exist. + // + // # Notes + // + // - This is like syscall.Lstat, except the `path` is relative to this + // file system. + // - This is like `lstat` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/lstat.html + // - An fs.FileInfo backed implementation sets atim, mtim and ctim to the + // same value. + // - When the path is a symbolic link, the stat returned is for the link, + // not the file it refers to. + Lstat(path string) (Stat_t, syscall.Errno) + + // Stat gets file status. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.ENOENT: `path` doesn't exist. + // + // # Notes + // + // - This is like syscall.Stat, except the `path` is relative to this + // file system. + // - This is like `stat` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/stat.html + // - An fs.FileInfo backed implementation sets atim, mtim and ctim to the + // same value. + // - When the path is a symbolic link, the stat returned is for the file + // it refers to. + Stat(path string) (Stat_t, syscall.Errno) + + // Mkdir makes a directory. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `path` is invalid. + // - syscall.EEXIST: `path` exists and is a directory. + // - syscall.ENOTDIR: `path` exists and is a file. + // + // # Notes + // + // - This is like syscall.Mkdir, except the `path` is relative to this + // file system. + // - This is like `mkdir` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html + // - Implications of permissions are described in Chmod notes. + Mkdir(path string, perm fs.FileMode) syscall.Errno + // ^^ TODO: Consider syscall.Mkdir, though this implies defining and + // coercing flags and perms similar to what is done in os.Mkdir. + + // Chmod changes the mode of the file. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `path` is invalid. + // - syscall.ENOENT: `path` does not exist. + // + // # Notes + // + // - This is like syscall.Chmod, except the `path` is relative to this + // file system. + // - This is like `chmod` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/chmod.html + // - Windows ignores the execute bit, and any permissions come back as + // group and world. For example, chmod of 0400 reads back as 0444, and + // 0700 0666. Also, permissions on directories aren't supported at all. + Chmod(path string, perm fs.FileMode) syscall.Errno + + // Chown changes the owner and group of a file. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `path` is invalid. + // - syscall.ENOENT: `path` does not exist. + // + // # Notes + // + // - This is like syscall.Chown, except the `path` is relative to this + // file system. + // - This is like `chown` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html + // - This always returns syscall.ENOSYS on windows. + Chown(path string, uid, gid int) syscall.Errno + + // Lchown changes the owner and group of a symbolic link. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `path` is invalid. + // - syscall.ENOENT: `path` does not exist. + // + // # Notes + // + // - This is like syscall.Lchown, except the `path` is relative to this + // file system. + // - This is like `lchown` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html + // - Windows will always return syscall.ENOSYS + Lchown(path string, uid, gid int) syscall.Errno + + // Rename renames file or directory. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `from` or `to` is invalid. + // - syscall.ENOENT: `from` or `to` don't exist. + // - syscall.ENOTDIR: `from` is a directory and `to` exists as a file. + // - syscall.EISDIR: `from` is a file and `to` exists as a directory. + // - syscall.ENOTEMPTY: `both from` and `to` are existing directory, but + // `to` is not empty. + // + // # Notes + // + // - This is like syscall.Rename, except the paths are relative to this + // file system. + // - This is like `rename` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html + // - Windows doesn't let you overwrite an existing directory. + Rename(from, to string) syscall.Errno + + // Rmdir removes a directory. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `path` is invalid. + // - syscall.ENOENT: `path` doesn't exist. + // - syscall.ENOTDIR: `path` exists, but isn't a directory. + // - syscall.ENOTEMPTY: `path` exists, but isn't empty. + // + // # Notes + // + // - This is like syscall.Rmdir, except the `path` is relative to this + // file system. + // - This is like `rmdir` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/rmdir.html + // - As of Go 1.19, Windows maps syscall.ENOTDIR to syscall.ENOENT. + Rmdir(path string) syscall.Errno + + // Unlink removes a directory entry. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `path` is invalid. + // - syscall.ENOENT: `path` doesn't exist. + // - syscall.EISDIR: `path` exists, but is a directory. + // + // # Notes + // + // - This is like syscall.Unlink, except the `path` is relative to this + // file system. + // - This is like `unlink` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html + // - On Windows, syscall.Unlink doesn't delete symlink to directory unlike other platforms. Implementations might + // want to combine syscall.RemoveDirectory with syscall.Unlink in order to delete such links on Windows. + // See https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-removedirectorya + Unlink(path string) syscall.Errno + + // Link creates a "hard" link from oldPath to newPath, in contrast to a + // soft link (via Symlink). + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EPERM: `oldPath` is invalid. + // - syscall.ENOENT: `oldPath` doesn't exist. + // - syscall.EISDIR: `newPath` exists, but is a directory. + // + // # Notes + // + // - This is like syscall.Link, except the `oldPath` is relative to this + // file system. + // - This is like `link` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html + Link(oldPath, newPath string) syscall.Errno + + // Symlink creates a "soft" link from oldPath to newPath, in contrast to a + // hard link (via Link). + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EPERM: `oldPath` or `newPath` is invalid. + // - syscall.EEXIST: `newPath` exists. + // + // # Notes + // + // - This is like syscall.Symlink, except the `oldPath` is relative to + // this file system. + // - This is like `symlink` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/symlink.html + // - Only `newPath` is relative to this file system and `oldPath` is kept + // as-is. That is because the link is only resolved relative to the + // directory when dereferencing it (e.g. ReadLink). + // See https://github.com/bytecodealliance/cap-std/blob/v1.0.4/cap-std/src/fs/dir.rs#L404-L409 + // for how others implement this. + // - Symlinks in Windows requires `SeCreateSymbolicLinkPrivilege`. + // Otherwise, syscall.EPERM results. + // See https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links + Symlink(oldPath, linkName string) syscall.Errno + + // Readlink reads the contents of a symbolic link. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `path` is invalid. + // + // # Notes + // + // - This is like syscall.Readlink, except the path is relative to this + // filesystem. + // - This is like `readlink` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html + // - On Windows, the path separator is different from other platforms, + // but to provide consistent results to Wasm, this normalizes to a "/" + // separator. + Readlink(path string) (string, syscall.Errno) + + // Truncate truncates a file to a specified length. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `path` is invalid or size is negative. + // - syscall.ENOENT: `path` doesn't exist. + // - syscall.EISDIR: `path` is a directory. + // - syscall.EACCES: `path` doesn't have write access. + // + // # Notes + // + // - This is like syscall.Truncate, except the path is relative to this + // filesystem. + // - This is like `truncate` in POSIX. See + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html + Truncate(path string, size int64) syscall.Errno + + // Utimens set file access and modification times on a path relative to + // this file system, at nanosecond precision. + // + // # Parameters + // + // The `times` parameter includes the access and modification timestamps to + // assign. Special syscall.Timespec NSec values platform.UTIME_NOW and + // platform.UTIME_OMIT may be specified instead of real timestamps. A nil + // `times` parameter behaves the same as if both were set to + // platform.UTIME_NOW. + // + // When the `symlinkFollow` parameter is true and the path is a symbolic link, + // the target of expanding that link is updated. + // + // # Errors + // + // A zero syscall.Errno is success. The below are expected otherwise: + // - syscall.ENOSYS: the implementation does not support this function. + // - syscall.EINVAL: `path` is invalid. + // - syscall.EEXIST: `path` exists and is a directory. + // - syscall.ENOTDIR: `path` exists and is a file. + // + // # Notes + // + // - This is like syscall.UtimesNano and `utimensat` with `AT_FDCWD` in + // POSIX. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html + Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.Errno +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/stat.go b/vendor/github.com/tetratelabs/wazero/internal/fsapi/stat.go similarity index 50% rename from vendor/github.com/tetratelabs/wazero/internal/platform/stat.go rename to vendor/github.com/tetratelabs/wazero/internal/fsapi/stat.go index b6858a24b..3901a6aff 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/stat.go +++ b/vendor/github.com/tetratelabs/wazero/internal/fsapi/stat.go @@ -1,9 +1,6 @@ -package platform +package fsapi -import ( - "io/fs" - "syscall" -) +import "io/fs" // Stat_t is similar to syscall.Stat_t, and fields frequently used by // WebAssembly ABI including WASI snapshot-01, GOOS=js and wasi-filesystem. @@ -49,54 +46,3 @@ type Stat_t struct { // Ctim is the last file status change timestamp in epoch nanoseconds. Ctim int64 } - -// Lstat is like syscall.Lstat. This returns syscall.ENOENT if the path doesn't -// exist. -// -// # Notes -// -// The primary difference between this and Stat is, when the path is a -// symbolic link, the stat is about the link, not its target, such as directory -// listings. -func Lstat(path string) (Stat_t, syscall.Errno) { - return lstat(path) // extracted to override more expensively in windows -} - -// Stat is like syscall.Stat. This returns syscall.ENOENT if the path doesn't -// exist. -func Stat(path string) (Stat_t, syscall.Errno) { - return stat(path) // extracted to override more expensively in windows -} - -// StatFile is like syscall.Fstat, but for fs.File instead of a file -// descriptor. This returns syscall.EBADF if the file or directory was closed. -// Note: windows allows you to stat a closed directory. -func StatFile(f fs.File) (Stat_t, syscall.Errno) { - st, errno := statFile(f) - if errno == syscall.EIO { - errno = syscall.EBADF - } - return st, errno -} - -func defaultStatFile(f fs.File) (Stat_t, syscall.Errno) { - if t, err := f.Stat(); err != nil { - return Stat_t{}, UnwrapOSError(err) - } else { - return statFromFileInfo(t), 0 - } -} - -func statFromDefaultFileInfo(t fs.FileInfo) Stat_t { - st := Stat_t{} - st.Ino = 0 - st.Dev = 0 - st.Mode = t.Mode() - st.Nlink = 1 - st.Size = t.Size() - mtim := t.ModTime().UnixNano() // Set all times to the mod time - st.Atim = mtim - st.Mtim = mtim - st.Ctim = mtim - return st -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/fsapi/unimplemented.go b/vendor/github.com/tetratelabs/wazero/internal/fsapi/unimplemented.go new file mode 100644 index 000000000..7a57468ba --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/fsapi/unimplemented.go @@ -0,0 +1,205 @@ +package fsapi + +import ( + "io/fs" + "syscall" + "time" +) + +// UnimplementedFS is an FS that returns syscall.ENOSYS for all functions, +// This should be embedded to have forward compatible implementations. +type UnimplementedFS struct{} + +// String implements fmt.Stringer +func (UnimplementedFS) String() string { + return "Unimplemented:/" +} + +// Open implements the same method as documented on fs.FS +func (UnimplementedFS) Open(name string) (fs.File, error) { + return nil, &fs.PathError{Op: "open", Path: name, Err: syscall.ENOSYS} +} + +// OpenFile implements FS.OpenFile +func (UnimplementedFS) OpenFile(path string, flag int, perm fs.FileMode) (File, syscall.Errno) { + return nil, syscall.ENOSYS +} + +// Lstat implements FS.Lstat +func (UnimplementedFS) Lstat(path string) (Stat_t, syscall.Errno) { + return Stat_t{}, syscall.ENOSYS +} + +// Stat implements FS.Stat +func (UnimplementedFS) Stat(path string) (Stat_t, syscall.Errno) { + return Stat_t{}, syscall.ENOSYS +} + +// Readlink implements FS.Readlink +func (UnimplementedFS) Readlink(path string) (string, syscall.Errno) { + return "", syscall.ENOSYS +} + +// Mkdir implements FS.Mkdir +func (UnimplementedFS) Mkdir(path string, perm fs.FileMode) syscall.Errno { + return syscall.ENOSYS +} + +// Chmod implements FS.Chmod +func (UnimplementedFS) Chmod(path string, perm fs.FileMode) syscall.Errno { + return syscall.ENOSYS +} + +// Chown implements FS.Chown +func (UnimplementedFS) Chown(path string, uid, gid int) syscall.Errno { + return syscall.ENOSYS +} + +// Lchown implements FS.Lchown +func (UnimplementedFS) Lchown(path string, uid, gid int) syscall.Errno { + return syscall.ENOSYS +} + +// Rename implements FS.Rename +func (UnimplementedFS) Rename(from, to string) syscall.Errno { + return syscall.ENOSYS +} + +// Rmdir implements FS.Rmdir +func (UnimplementedFS) Rmdir(path string) syscall.Errno { + return syscall.ENOSYS +} + +// Link implements FS.Link +func (UnimplementedFS) Link(_, _ string) syscall.Errno { + return syscall.ENOSYS +} + +// Symlink implements FS.Symlink +func (UnimplementedFS) Symlink(_, _ string) syscall.Errno { + return syscall.ENOSYS +} + +// Unlink implements FS.Unlink +func (UnimplementedFS) Unlink(path string) syscall.Errno { + return syscall.ENOSYS +} + +// Utimens implements FS.Utimens +func (UnimplementedFS) Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.Errno { + return syscall.ENOSYS +} + +// Truncate implements FS.Truncate +func (UnimplementedFS) Truncate(string, int64) syscall.Errno { + return syscall.ENOSYS +} + +// UnimplementedFile is a File that returns syscall.ENOSYS for all functions, +// except where no-op are otherwise documented. +// +// This should be embedded to have forward compatible implementations. +type UnimplementedFile struct{} + +// Ino implements File.Ino +func (UnimplementedFile) Ino() (uint64, syscall.Errno) { + return 0, 0 +} + +// IsAppend implements File.IsAppend +func (UnimplementedFile) IsAppend() bool { + return false +} + +// SetAppend implements File.SetAppend +func (UnimplementedFile) SetAppend(bool) syscall.Errno { + return syscall.ENOSYS +} + +// IsNonblock implements File.IsNonblock +func (UnimplementedFile) IsNonblock() bool { + return false +} + +// SetNonblock implements File.SetNonblock +func (UnimplementedFile) SetNonblock(bool) syscall.Errno { + return syscall.ENOSYS +} + +// Stat implements File.Stat +func (UnimplementedFile) Stat() (Stat_t, syscall.Errno) { + return Stat_t{}, syscall.ENOSYS +} + +// IsDir implements File.IsDir +func (UnimplementedFile) IsDir() (bool, syscall.Errno) { + return false, syscall.ENOSYS +} + +// Read implements File.Read +func (UnimplementedFile) Read([]byte) (int, syscall.Errno) { + return 0, syscall.ENOSYS +} + +// Pread implements File.Pread +func (UnimplementedFile) Pread([]byte, int64) (int, syscall.Errno) { + return 0, syscall.ENOSYS +} + +// Seek implements File.Seek +func (UnimplementedFile) Seek(int64, int) (int64, syscall.Errno) { + return 0, syscall.ENOSYS +} + +// Readdir implements File.Readdir +func (UnimplementedFile) Readdir(int) (dirents []Dirent, errno syscall.Errno) { + return nil, syscall.ENOSYS +} + +// PollRead implements File.PollRead +func (UnimplementedFile) PollRead(*time.Duration) (ready bool, errno syscall.Errno) { + return false, syscall.ENOSYS +} + +// Write implements File.Write +func (UnimplementedFile) Write([]byte) (int, syscall.Errno) { + return 0, syscall.ENOSYS +} + +// Pwrite implements File.Pwrite +func (UnimplementedFile) Pwrite([]byte, int64) (int, syscall.Errno) { + return 0, syscall.ENOSYS +} + +// Truncate implements File.Truncate +func (UnimplementedFile) Truncate(int64) syscall.Errno { + return syscall.ENOSYS +} + +// Sync implements File.Sync +func (UnimplementedFile) Sync() syscall.Errno { + return 0 // not syscall.ENOSYS +} + +// Datasync implements File.Datasync +func (UnimplementedFile) Datasync() syscall.Errno { + return 0 // not syscall.ENOSYS +} + +// Chmod implements File.Chmod +func (UnimplementedFile) Chmod(fs.FileMode) syscall.Errno { + return syscall.ENOSYS +} + +// Chown implements File.Chown +func (UnimplementedFile) Chown(int, int) syscall.Errno { + return syscall.ENOSYS +} + +// Utimens implements File.Utimens +func (UnimplementedFile) Utimens(*[2]syscall.Timespec) syscall.Errno { + return syscall.ENOSYS +} + +// Close implements File.Close +func (UnimplementedFile) Close() (errno syscall.Errno) { return } diff --git a/vendor/github.com/tetratelabs/wazero/internal/gojs/fs.go b/vendor/github.com/tetratelabs/wazero/internal/gojs/fs.go index 1fe298a45..3ecd5d0cc 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/gojs/fs.go +++ b/vendor/github.com/tetratelabs/wazero/internal/gojs/fs.go @@ -3,18 +3,15 @@ package gojs import ( "context" "fmt" - "io" - "io/fs" "os" "syscall" "github.com/tetratelabs/wazero/api" + "github.com/tetratelabs/wazero/internal/fsapi" "github.com/tetratelabs/wazero/internal/gojs/custom" "github.com/tetratelabs/wazero/internal/gojs/goos" "github.com/tetratelabs/wazero/internal/gojs/util" - "github.com/tetratelabs/wazero/internal/platform" internalsys "github.com/tetratelabs/wazero/internal/sys" - "github.com/tetratelabs/wazero/internal/sysfs" "github.com/tetratelabs/wazero/internal/wasm" ) @@ -49,16 +46,6 @@ var ( oEXCL = float64(os.O_EXCL) ) -// The following interfaces are used until we finalize our own FD-scoped file. -type ( - // chmodFile is implemented by os.File in file_posix.go - chmodFile interface{ Chmod(fs.FileMode) error } - // syncFile is implemented by os.File in file_posix.go - syncFile interface{ Sync() error } - // truncateFile is implemented by os.File in file_posix.go - truncateFile interface{ Truncate(size int64) error } -) - // jsfs = js.Global().Get("fs") // fs_js.go init // // js.fsCall conventions: @@ -190,14 +177,14 @@ func syscallFstat(fsc *internalsys.FSContext, fd int32) (*jsSt, error) { return nil, syscall.EBADF } - if st, err := f.Stat(); err != nil { - return nil, platform.UnwrapOSError(err) + if st, errno := f.File.Stat(); errno != 0 { + return nil, errno } else { return newJsSt(st), nil } } -func newJsSt(st platform.Stat_t) *jsSt { +func newJsSt(st fsapi.Stat_t) *jsSt { ret := &jsSt{} ret.isDir = st.Mode.IsDir() ret.dev = st.Dev @@ -244,33 +231,26 @@ func (jsfsRead) invoke(ctx context.Context, mod api.Module, args ...interface{}) fOffset := args[4] // nil unless Pread callback := args[5].(funcWrapper) - n, err := syscallRead(mod, fd, fOffset, buf.Unwrap()[offset:offset+byteCount]) - return callback.invoke(ctx, mod, goos.RefJsfs, err, n) // note: error first + var err error + n, errno := syscallRead(mod, fd, fOffset, buf.Unwrap()[offset:offset+byteCount]) + if errno != 0 { + err = errno + } + // It is safe to cast to uint32 because n <= uint32(byteCount). + return callback.invoke(ctx, mod, goos.RefJsfs, err, uint32(n)) // note: error first } // syscallRead is like syscall.Read -func syscallRead(mod api.Module, fd int32, offset interface{}, p []byte) (n uint32, err error) { +func syscallRead(mod api.Module, fd int32, offset interface{}, buf []byte) (n int, errno syscall.Errno) { fsc := mod.(*wasm.ModuleInstance).Sys.FS() - f, ok := fsc.LookupFile(fd) - if !ok { - err = syscall.EBADF - } - - var reader io.Reader = f.File - - if offset != nil { - reader = sysfs.ReaderAtOffset(f.File, toInt64(offset)) - } - - if nRead, e := reader.Read(p); e == nil || e == io.EOF { - // fs_js.go cannot parse io.EOF so coerce it to nil. - // See https://github.com/golang/go/issues/43913 - n = uint32(nRead) + if f, ok := fsc.LookupFile(fd); !ok { + return 0, syscall.EBADF + } else if offset != nil { + return f.File.Pread(buf, toInt64(offset)) } else { - err = e + return f.File.Read(buf) } - return } // jsfsWrite implements jsFn for syscall.Write and syscall.Pwrite. @@ -292,35 +272,29 @@ func (jsfsWrite) invoke(ctx context.Context, mod api.Module, args ...interface{} callback := args[5].(funcWrapper) if byteCount > 0 { // empty is possible on EOF - n, err := syscallWrite(mod, fd, fOffset, buf.Unwrap()[offset:offset+byteCount]) - return callback.invoke(ctx, mod, goos.RefJsfs, err, n) // note: error first + n, errno := syscallWrite(mod, fd, fOffset, buf.Unwrap()[offset:offset+byteCount]) + var err error + if errno != 0 { + err = errno + } + // It is safe to cast to uint32 because n <= uint32(byteCount). + return callback.invoke(ctx, mod, goos.RefJsfs, err, uint32(n)) // note: error first } return callback.invoke(ctx, mod, goos.RefJsfs, nil, goos.RefValueZero) } // syscallWrite is like syscall.Write -func syscallWrite(mod api.Module, fd int32, offset interface{}, p []byte) (n uint32, err error) { +func syscallWrite(mod api.Module, fd int32, offset interface{}, buf []byte) (n int, errno syscall.Errno) { fsc := mod.(*wasm.ModuleInstance).Sys.FS() - - var writer io.Writer if f, ok := fsc.LookupFile(fd); !ok { - err = syscall.EBADF + errno = syscall.EBADF } else if offset != nil { - writer = sysfs.WriterAtOffset(f.File, toInt64(offset)) - } else if writer, ok = f.File.(io.Writer); !ok { - err = syscall.EBADF - } - - if err != nil { - return - } - - if nWritten, e := writer.Write(p); e == nil || e == io.EOF { - // fs_js.go cannot parse io.EOF so coerce it to nil. - // See https://github.com/golang/go/issues/43913 - n = uint32(nWritten) + n, errno = f.File.Pwrite(buf, toInt64(offset)) } else { - err = e + n, errno = f.File.Write(buf) + } + if errno == syscall.ENOSYS { + errno = syscall.EBADF // e.g. unimplemented for write } return } @@ -351,12 +325,12 @@ func syscallReaddir(_ context.Context, mod api.Module, name string) (*objectArra } defer f.Close() //nolint - if names, errno := platform.Readdirnames(f, -1); errno != 0 { + if dirents, errno := f.Readdir(-1); errno != 0 { return nil, errno } else { - entries := make([]interface{}, 0, len(names)) - for _, e := range names { - entries = append(entries, e) + entries := make([]interface{}, 0, len(dirents)) + for _, e := range dirents { + entries = append(entries, e.Name) } return &objectArray{entries}, nil } @@ -498,10 +472,8 @@ func (jsfsFchmod) invoke(ctx context.Context, mod api.Module, args ...interface{ var errno syscall.Errno if f, ok := fsc.LookupFile(fd); !ok { errno = syscall.EBADF - } else if chmodFile, ok := f.File.(chmodFile); !ok { - errno = syscall.EBADF // possibly a fake file } else { - errno = platform.UnwrapOSError(chmodFile.Chmod(mode)) + errno = f.File.Chmod(mode) } return jsfsInvoke(ctx, mod, callback, errno) @@ -543,7 +515,7 @@ func (jsfsFchown) invoke(ctx context.Context, mod api.Module, args ...interface{ if f, ok := fsc.LookupFile(fd); !ok { errno = syscall.EBADF } else { - errno = platform.ChownFile(f.File, int(uid), int(gid)) + errno = f.File.Chown(int(uid), int(gid)) } return jsfsInvoke(ctx, mod, callback, errno) @@ -601,10 +573,8 @@ func (jsfsFtruncate) invoke(ctx context.Context, mod api.Module, args ...interfa var errno syscall.Errno if f, ok := fsc.LookupFile(fd); !ok { errno = syscall.EBADF - } else if truncateFile, ok := f.File.(truncateFile); !ok { - errno = syscall.EBADF // possibly a fake file } else { - errno = platform.UnwrapOSError(truncateFile.Truncate(length)) + errno = f.File.Truncate(length) } return jsfsInvoke(ctx, mod, callback, errno) @@ -678,10 +648,8 @@ func (jsfsFsync) invoke(ctx context.Context, mod api.Module, args ...interface{} var errno syscall.Errno if f, ok := fsc.LookupFile(fd); !ok { errno = syscall.EBADF - } else if syncFile, ok := f.File.(syncFile); !ok { - errno = syscall.EBADF // possibly a fake file } else { - errno = platform.UnwrapOSError(syncFile.Sync()) + errno = f.File.Sync() } return jsfsInvoke(ctx, mod, callback, errno) diff --git a/vendor/github.com/tetratelabs/wazero/internal/gojs/runtime.go b/vendor/github.com/tetratelabs/wazero/internal/gojs/runtime.go index ad9ecf6dc..dc6c3a0b6 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/gojs/runtime.go +++ b/vendor/github.com/tetratelabs/wazero/internal/gojs/runtime.go @@ -3,12 +3,12 @@ package gojs import ( "context" "fmt" + "syscall" "time" "github.com/tetratelabs/wazero/api" "github.com/tetratelabs/wazero/internal/gojs/custom" "github.com/tetratelabs/wazero/internal/gojs/goarch" - internalsys "github.com/tetratelabs/wazero/internal/sys" "github.com/tetratelabs/wazero/internal/wasm" ) @@ -42,10 +42,20 @@ func wasmWrite(_ context.Context, mod api.Module, stack goarch.Stack) { p := stack.ParamBytes(mod.Memory(), 1 /*, 2 */) fsc := mod.(*wasm.ModuleInstance).Sys.FS() - if writer := internalsys.WriterForFile(fsc, fd); writer == nil { + if f, ok := fsc.LookupFile(fd); ok { + _, errno := f.File.Write(p) + switch errno { + case 0: + return // success + case syscall.ENOSYS: + return // e.g. unimplemented for write + case syscall.EBADF: + return // e.g. not opened for write + default: + panic(fmt.Errorf("error writing p: %w", errno)) + } + } else { panic(fmt.Errorf("fd %d invalid", fd)) - } else if _, err := writer.Write(p); err != nil { - panic(fmt.Errorf("error writing p: %w", err)) } } diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/chown_unix.go b/vendor/github.com/tetratelabs/wazero/internal/platform/chown_unix.go deleted file mode 100644 index 5e0753da2..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/chown_unix.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build !windows - -package platform - -import "syscall" - -func fchown(fd uintptr, uid, gid int) syscall.Errno { - return UnwrapOSError(syscall.Fchown(int(fd), uid, gid)) -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/dir.go b/vendor/github.com/tetratelabs/wazero/internal/platform/dir.go deleted file mode 100644 index b58386dfa..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/dir.go +++ /dev/null @@ -1,138 +0,0 @@ -package platform - -import ( - "fmt" - "io" - "io/fs" - "syscall" -) - -// Readdirnames reads the names of the directory associated with file and -// returns a slice of up to n strings in an arbitrary order. This is a stateful -// function, so subsequent calls return any next values. -// -// If n > 0, Readdirnames returns at most n entries or an error. -// If n <= 0, Readdirnames returns all remaining entries or an error. -// -// # Errors -// -// A zero syscall.Errno is success. -// -// For portability reasons, no error is returned on io.EOF, when the file is -// closed or removed while open. -// See https://github.com/ziglang/zig/blob/0.10.1/lib/std/fs.zig#L635-L637 -func Readdirnames(f fs.File, n int) (names []string, errno syscall.Errno) { - switch f := f.(type) { - case readdirnamesFile: - var err error - names, err = f.Readdirnames(n) - if errno = adjustReaddirErr(err); errno != 0 { - return - } - case fs.ReadDirFile: - entries, err := f.ReadDir(n) - if errno = adjustReaddirErr(err); errno != 0 { - return - } - names = make([]string, 0, len(entries)) - for _, e := range entries { - names = append(names, e.Name()) - } - default: - errno = syscall.ENOTDIR - } - return -} - -// Dirent is an entry read from a directory. -// -// This is a portable variant of syscall.Dirent containing fields needed for -// WebAssembly ABI including WASI snapshot-01 and wasi-filesystem. Unlike -// fs.DirEntry, this may include the Ino. -type Dirent struct { - // ^^ Dirent name matches syscall.Dirent - - // Name is the base name of the directory entry. - Name string - - // Ino is the file serial number, or zero if not available. - Ino uint64 - - // Type is fs.FileMode masked on fs.ModeType. For example, zero is a - // regular file, fs.ModeDir is a directory and fs.ModeIrregular is unknown. - Type fs.FileMode -} - -func (d *Dirent) String() string { - return fmt.Sprintf("name=%s, type=%v, ino=%d", d.Name, d.Type, d.Ino) -} - -// IsDir returns true if the Type is fs.ModeDir. -func (d *Dirent) IsDir() bool { - return d.Type == fs.ModeDir -} - -// Readdir reads the contents of the directory associated with file and returns -// a slice of up to n Dirent values in an arbitrary order. This is a stateful -// function, so subsequent calls return any next values. -// -// If n > 0, Readdir returns at most n entries or an error. -// If n <= 0, Readdir returns all remaining entries or an error. -// -// # Errors -// -// A zero syscall.Errno is success. -// -// For portability reasons, no error is returned on io.EOF, when the file is -// closed or removed while open. -// See https://github.com/ziglang/zig/blob/0.10.1/lib/std/fs.zig#L635-L637 -func Readdir(f fs.File, n int) (dirents []*Dirent, errno syscall.Errno) { - // ^^ case format is to match POSIX and similar to os.File.Readdir - - switch f := f.(type) { - case readdirFile: - fis, e := f.Readdir(n) - if errno = adjustReaddirErr(e); errno != 0 { - return - } - dirents = make([]*Dirent, 0, len(fis)) - - // linux/darwin won't have to fan out to lstat, but windows will. - var ino uint64 - for _, t := range fis { - if ino, errno = inoFromFileInfo(f, t); errno != 0 { - return - } - dirents = append(dirents, &Dirent{Name: t.Name(), Ino: ino, Type: t.Mode().Type()}) - } - case fs.ReadDirFile: - entries, e := f.ReadDir(n) - if errno = adjustReaddirErr(e); errno != 0 { - return - } - dirents = make([]*Dirent, 0, len(entries)) - for _, e := range entries { - // By default, we don't attempt to read inode data - dirents = append(dirents, &Dirent{Name: e.Name(), Type: e.Type()}) - } - default: - errno = syscall.ENOTDIR - } - return -} - -func adjustReaddirErr(err error) syscall.Errno { - if err == io.EOF { - return 0 // e.g. Readdir on darwin returns io.EOF, but linux doesn't. - } else if errno := UnwrapOSError(err); errno != 0 { - // Ignore errors when the file was closed or removed. - switch errno { - case syscall.EIO, syscall.EBADF: // closed while open - return 0 - case syscall.ENOENT: // Linux error when removed while open - return 0 - } - return errno - } - return 0 -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/errno_windows.go b/vendor/github.com/tetratelabs/wazero/internal/platform/errno_windows.go index e89b763ee..d07e10cb3 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/errno_windows.go +++ b/vendor/github.com/tetratelabs/wazero/internal/platform/errno_windows.go @@ -5,7 +5,7 @@ import "syscall" // See https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- const ( // ERROR_ACCESS_DENIED is a Windows error returned by syscall.Unlink - // instead of syscall.EPERM + // instead of syscall.EACCES ERROR_ACCESS_DENIED = syscall.Errno(5) // ERROR_INVALID_HANDLE is a Windows error returned by syscall.Write @@ -59,7 +59,11 @@ func adjustErrno(err syscall.Errno) syscall.Errno { return syscall.EEXIST case ERROR_INVALID_HANDLE: return syscall.EBADF - case ERROR_ACCESS_DENIED, ERROR_PRIVILEGE_NOT_HELD: + case ERROR_ACCESS_DENIED: + // POSIX read and write functions expect EBADF, not EACCES when not + // open for reading or writing. + return syscall.EBADF + case ERROR_PRIVILEGE_NOT_HELD: return syscall.EPERM case ERROR_NEGATIVE_SEEK, ERROR_INVALID_NAME: return syscall.EINVAL diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/error.go b/vendor/github.com/tetratelabs/wazero/internal/platform/error.go index 82ed9b6cb..3219e5265 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/error.go +++ b/vendor/github.com/tetratelabs/wazero/internal/platform/error.go @@ -21,7 +21,7 @@ func UnwrapOSError(err error) syscall.Errno { // Note: Once we have our own file type, we should never see these. switch err { case nil, io.EOF: - return 0 + return 0 // EOF is not a syscall.Errno case fs.ErrInvalid: return syscall.EINVAL case fs.ErrPermission: diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/file.go b/vendor/github.com/tetratelabs/wazero/internal/platform/file.go deleted file mode 100644 index c247854c5..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/file.go +++ /dev/null @@ -1,50 +0,0 @@ -package platform - -import ( - "io" - "io/fs" -) - -// ReadFile declares all read interfaces defined on os.File used by wazero. -type ReadFile interface { - fdFile // for the number of links. - readdirnamesFile - readdirFile - fs.ReadDirFile - io.ReaderAt // for pread - io.Seeker // fallback for ReaderAt for embed:fs -} - -// File declares all interfaces defined on os.File used by wazero. -type File interface { - ReadFile - io.Writer - io.WriterAt // for pwrite - chmodFile - syncFile - truncateFile -} - -// The following interfaces are used until we finalize our own FD-scoped file. -type ( - // PathFile is implemented on files that retain the path to their pre-open. - PathFile interface { - Path() string - } - // fdFile is implemented by os.File in file_unix.go and file_windows.go - fdFile interface{ Fd() (fd uintptr) } - // readdirnamesFile is implemented by os.File in dir.go - readdirnamesFile interface { - Readdirnames(n int) (names []string, err error) - } - // readdirFile is implemented by os.File in dir.go - readdirFile interface { - Readdir(n int) ([]fs.FileInfo, error) - } - // chmodFile is implemented by os.File in file_posix.go - chmodFile interface{ Chmod(fs.FileMode) error } - // syncFile is implemented by os.File in file_posix.go - syncFile interface{ Sync() error } - // truncateFile is implemented by os.File in file_posix.go - truncateFile interface{ Truncate(size int64) error } -) diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_linux.go b/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_linux.go new file mode 100644 index 000000000..55906e827 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_linux.go @@ -0,0 +1,76 @@ +package platform + +import ( + "math/bits" + "os" + "sort" + "strconv" + "strings" + "syscall" +) + +const ( + // https://man7.org/linux/man-pages/man2/mmap.2.html + __MAP_HUGE_SHIFT = 26 + __MAP_HUGETLB = 0x40000 +) + +var hugePagesConfigs []hugePagesConfig + +type hugePagesConfig struct { + size int + flag int +} + +func (hpc *hugePagesConfig) match(size int) bool { + return (size & (hpc.size - 1)) == 0 +} + +func init() { + dirents, err := os.ReadDir("/sys/kernel/mm/hugepages/") + if err != nil { + return + } + + for _, dirent := range dirents { + name := dirent.Name() + if !strings.HasPrefix(name, "hugepages-") { + continue + } + if !strings.HasSuffix(name, "kB") { + continue + } + n, err := strconv.ParseUint(name[10:len(name)-2], 10, 64) + if err != nil { + continue + } + if bits.OnesCount64(n) != 1 { + continue + } + n *= 1024 + hugePagesConfigs = append(hugePagesConfigs, hugePagesConfig{ + size: int(n), + flag: int(bits.TrailingZeros64(n)<<__MAP_HUGE_SHIFT) | __MAP_HUGETLB, + }) + } + + sort.Slice(hugePagesConfigs, func(i, j int) bool { + return hugePagesConfigs[i].size > hugePagesConfigs[j].size + }) +} + +func mmapCodeSegment(size, prot int) ([]byte, error) { + flags := syscall.MAP_ANON | syscall.MAP_PRIVATE + + for _, hugePagesConfig := range hugePagesConfigs { + if hugePagesConfig.match(size) { + b, err := syscall.Mmap(-1, 0, size, prot, flags|hugePagesConfig.flag) + if err != nil { + continue + } + return b, nil + } + } + + return syscall.Mmap(-1, 0, size, prot, flags) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_other.go b/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_other.go new file mode 100644 index 000000000..620cdd3c6 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_other.go @@ -0,0 +1,18 @@ +// This uses syscall.Mprotect. Go's SDK only supports this on darwin and linux. +//go:build darwin || freebsd + +package platform + +import "syscall" + +func mmapCodeSegment(size, prot int) ([]byte, error) { + return syscall.Mmap( + -1, + 0, + size, + prot, + // Anonymous as this is not an actual file, but a memory, + // Private as this is in-process memory region. + syscall.MAP_ANON|syscall.MAP_PRIVATE, + ) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/mmap.go b/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_unix.go similarity index 52% rename from vendor/github.com/tetratelabs/wazero/internal/platform/mmap.go rename to vendor/github.com/tetratelabs/wazero/internal/platform/mmap_unix.go index 870528dbd..03b6cc601 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/mmap.go +++ b/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_unix.go @@ -1,4 +1,3 @@ -// This uses syscall.Mprotect. Go's SDK only supports this on darwin and linux. //go:build darwin || linux || freebsd package platform @@ -8,6 +7,11 @@ import ( "unsafe" ) +const ( + mmapProtAMD64 = syscall.PROT_READ | syscall.PROT_WRITE | syscall.PROT_EXEC + mmapProtARM64 = syscall.PROT_READ | syscall.PROT_WRITE +) + func munmapCodeSegment(code []byte) error { return syscall.Munmap(code) } @@ -15,20 +19,8 @@ func munmapCodeSegment(code []byte) error { // mmapCodeSegmentAMD64 gives all read-write-exec permission to the mmap region // to enter the function. Otherwise, segmentation fault exception is raised. func mmapCodeSegmentAMD64(size int) ([]byte, error) { - buf, err := syscall.Mmap( - -1, - 0, - size, - // The region must be RWX: RW for writing native codes, X for executing the region. - syscall.PROT_READ|syscall.PROT_WRITE|syscall.PROT_EXEC, - // Anonymous as this is not an actual file, but a memory, - // Private as this is in-process memory region. - syscall.MAP_ANON|syscall.MAP_PRIVATE, - ) - if err != nil { - return nil, err - } - return buf, err + // The region must be RWX: RW for writing native codes, X for executing the region. + return mmapCodeSegment(size, mmapProtAMD64) } // mmapCodeSegmentARM64 cannot give all read-write-exec permission to the mmap region. @@ -36,29 +28,15 @@ func mmapCodeSegmentAMD64(size int) ([]byte, error) { // to the region so that we can write contents at call-sites. Callers are responsible to // execute MprotectRX on the returned buffer. func mmapCodeSegmentARM64(size int) ([]byte, error) { - buf, err := syscall.Mmap( - -1, - 0, - size, - // The region must be RW: RW for writing native codes. - syscall.PROT_READ|syscall.PROT_WRITE, - // Anonymous as this is not an actual file, but a memory, - // Private as this is in-process memory region. - syscall.MAP_ANON|syscall.MAP_PRIVATE, - ) - if err != nil { - return nil, err - } - return buf, err + // The region must be RW: RW for writing native codes. + return mmapCodeSegment(size, mmapProtARM64) } -// MprotectRX is like syscall.Mprotect, defined locally so that freebsd compiles. +// MprotectRX is like syscall.Mprotect with RX permission, defined locally so that freebsd compiles. func MprotectRX(b []byte) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) - } else { - _p0 = unsafe.Pointer(&_zero) } const prot = syscall.PROT_READ | syscall.PROT_EXEC _, _, e1 := syscall.Syscall(syscall.SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_windows.go b/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_windows.go index efa98a85b..fb8944b42 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_windows.go +++ b/vendor/github.com/tetratelabs/wazero/internal/platform/mmap_windows.go @@ -29,7 +29,7 @@ func munmapCodeSegment(code []byte) error { // allocateMemory commits the memory region via the "VirtualAlloc" function. // See https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc func allocateMemory(size uintptr, protect uintptr) (uintptr, error) { - address := uintptr(0) // TODO: document why zero + address := uintptr(0) // system determines where to allocate the region. alloctype := windows_MEM_COMMIT if r, _, err := procVirtualAlloc.Call(address, size, alloctype, protect); r == 0 { return 0, fmt.Errorf("compiler: VirtualAlloc error: %w", ensureErr(err)) @@ -41,10 +41,10 @@ func allocateMemory(size uintptr, protect uintptr) (uintptr, error) { // freeMemory releases the memory region via the "VirtualFree" function. // See https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualfree func freeMemory(code []byte) error { - address := uintptr(unsafe.Pointer(&code[0])) + address := unsafe.Pointer(&code[0]) size := uintptr(0) // size must be 0 because we're using MEM_RELEASE. freetype := windows_MEM_RELEASE - if r, _, err := procVirtualFree.Call(address, size, freetype); r == 0 { + if r, _, err := procVirtualFree.Call(uintptr(address), size, freetype); r == 0 { return fmt.Errorf("compiler: VirtualFree error: %w", ensureErr(err)) } return nil diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/mremap_other.go b/vendor/github.com/tetratelabs/wazero/internal/platform/mremap_other.go new file mode 100644 index 000000000..5be501c19 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/platform/mremap_other.go @@ -0,0 +1,23 @@ +//go:build !(darwin || linux || freebsd) + +package platform + +func remapCodeSegmentAMD64(code []byte, size int) ([]byte, error) { + b, err := mmapCodeSegmentAMD64(size) + if err != nil { + return nil, err + } + copy(b, code) + mustMunmapCodeSegment(code) + return b, nil +} + +func remapCodeSegmentARM64(code []byte, size int) ([]byte, error) { + b, err := mmapCodeSegmentARM64(size) + if err != nil { + return nil, err + } + copy(b, code) + mustMunmapCodeSegment(code) + return b, nil +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/mremap_unix.go b/vendor/github.com/tetratelabs/wazero/internal/platform/mremap_unix.go new file mode 100644 index 000000000..5017aaf7a --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/platform/mremap_unix.go @@ -0,0 +1,21 @@ +//go:build darwin || linux || freebsd + +package platform + +func remapCodeSegmentAMD64(code []byte, size int) ([]byte, error) { + return remapCodeSegment(code, size, mmapProtAMD64) +} + +func remapCodeSegmentARM64(code []byte, size int) ([]byte, error) { + return remapCodeSegment(code, size, mmapProtARM64) +} + +func remapCodeSegment(code []byte, size, prot int) ([]byte, error) { + b, err := mmapCodeSegment(size, prot) + if err != nil { + return nil, err + } + copy(b, code) + mustMunmapCodeSegment(code) + return b, nil +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/open_file.go b/vendor/github.com/tetratelabs/wazero/internal/platform/open_file.go deleted file mode 100644 index a047e2eee..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/open_file.go +++ /dev/null @@ -1,23 +0,0 @@ -//go:build !windows && !js && !illumos && !solaris - -package platform - -import ( - "io/fs" - "os" - "syscall" -) - -// Simple aliases to constants in the syscall package for portability with -// platforms which do not have them (e.g. windows) -const ( - O_DIRECTORY = syscall.O_DIRECTORY - O_NOFOLLOW = syscall.O_NOFOLLOW -) - -// OpenFile is like os.OpenFile except it returns syscall.Errno. A zero -// syscall.Errno is success. -func OpenFile(path string, flag int, perm fs.FileMode) (File, syscall.Errno) { - f, err := os.OpenFile(path, flag, perm) - return f, UnwrapOSError(err) -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/open_file_js.go b/vendor/github.com/tetratelabs/wazero/internal/platform/open_file_js.go deleted file mode 100644 index 182cb481d..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/open_file_js.go +++ /dev/null @@ -1,19 +0,0 @@ -package platform - -import ( - "io/fs" - "os" - "syscall" -) - -// See the comments on the same constants in open_file_windows.go -const ( - O_DIRECTORY = 1 << 29 - O_NOFOLLOW = 1 << 30 -) - -func OpenFile(path string, flag int, perm fs.FileMode) (File, syscall.Errno) { - flag &= ^(O_DIRECTORY | O_NOFOLLOW) // erase placeholders - f, err := os.OpenFile(path, flag, perm) - return f, UnwrapOSError(err) -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/open_file_sun.go b/vendor/github.com/tetratelabs/wazero/internal/platform/open_file_sun.go deleted file mode 100644 index 941293ce0..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/open_file_sun.go +++ /dev/null @@ -1,20 +0,0 @@ -//go:build illumos || solaris - -package platform - -import ( - "io/fs" - "os" - "syscall" -) - -const ( - // See https://github.com/illumos/illumos-gate/blob/edd580643f2cf1434e252cd7779e83182ea84945/usr/src/uts/common/sys/fcntl.h#L90 - O_DIRECTORY = 0x1000000 - O_NOFOLLOW = syscall.O_NOFOLLOW -) - -func OpenFile(path string, flag int, perm fs.FileMode) (File, syscall.Errno) { - f, err := os.OpenFile(path, flag, perm) - return f, UnwrapOSError(err) -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/platform.go b/vendor/github.com/tetratelabs/wazero/internal/platform/platform.go index 518e11e41..267db8809 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/platform.go +++ b/vendor/github.com/tetratelabs/wazero/internal/platform/platform.go @@ -5,7 +5,6 @@ package platform import ( - "errors" "runtime" "strings" ) @@ -16,8 +15,6 @@ var IsGo120 = strings.Contains(runtime.Version(), "go1.20") // archRequirementsVerified is set by platform-specific init to true if the platform is supported var archRequirementsVerified bool -var _zero uintptr - // CompilerSupported is exported for tests and includes constraints here and also the assembler. func CompilerSupported() bool { switch runtime.GOOS { @@ -34,7 +31,7 @@ func CompilerSupported() bool { // See https://man7.org/linux/man-pages/man2/mmap.2.html for mmap API and flags. func MmapCodeSegment(size int) ([]byte, error) { if size == 0 { - panic(errors.New("BUG: MmapCodeSegment with zero length")) + panic("BUG: MmapCodeSegment with zero length") } if runtime.GOARCH == "amd64" { return mmapCodeSegmentAMD64(size) @@ -43,10 +40,46 @@ func MmapCodeSegment(size int) ([]byte, error) { } } +// RemapCodeSegment reallocates the memory mapping of an existing code segment +// to increase its size. The previous code mapping is unmapped and must not be +// reused after the function returns. +// +// This is similar to mremap(2) on linux, and emulated on platforms which do not +// have this syscall. +// +// See https://man7.org/linux/man-pages/man2/mremap.2.html +func RemapCodeSegment(code []byte, size int) ([]byte, error) { + if size < len(code) { + panic("BUG: RemapCodeSegment with size less than code") + } + if code == nil { + return MmapCodeSegment(size) + } + if runtime.GOARCH == "amd64" { + return remapCodeSegmentAMD64(code, size) + } else { + return remapCodeSegmentARM64(code, size) + } +} + // MunmapCodeSegment unmaps the given memory region. func MunmapCodeSegment(code []byte) error { if len(code) == 0 { - panic(errors.New("BUG: MunmapCodeSegment with zero length")) + panic("BUG: MunmapCodeSegment with zero length") } return munmapCodeSegment(code) } + +// mustMunmapCodeSegment panics instead of returning an error to the +// application. +// +// # Why panic? +// +// It is less disruptive to the application to leak the previous block if it +// could be unmapped than to leak the new block and return an error. +// Realistically, either scenarios are pretty hard to debug, so we panic. +func mustMunmapCodeSegment(code []byte) { + if err := munmapCodeSegment(code); err != nil { + panic(err) + } +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/rename.go b/vendor/github.com/tetratelabs/wazero/internal/platform/rename.go deleted file mode 100644 index 2b537fae2..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/rename.go +++ /dev/null @@ -1,12 +0,0 @@ -//go:build !windows - -package platform - -import "syscall" - -func Rename(from, to string) syscall.Errno { - if from == to { - return 0 - } - return UnwrapOSError(syscall.Rename(from, to)) -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/select_unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/platform/select_unsupported.go deleted file mode 100644 index 672ca400e..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/select_unsupported.go +++ /dev/null @@ -1,12 +0,0 @@ -//go:build !darwin && !linux && !windows - -package platform - -import ( - "syscall" - "time" -) - -func syscall_select(n int, r, w, e *FdSet, timeout *time.Duration) (int, error) { - return -1, syscall.ENOSYS -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/stat_unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/platform/stat_unsupported.go deleted file mode 100644 index 32e944383..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/stat_unsupported.go +++ /dev/null @@ -1,39 +0,0 @@ -//go:build (!((amd64 || arm64 || riscv64) && linux) && !((amd64 || arm64) && (darwin || freebsd)) && !((amd64 || arm64) && windows)) || js - -package platform - -import ( - "io/fs" - "os" - "syscall" -) - -func lstat(path string) (Stat_t, syscall.Errno) { - t, err := os.Lstat(path) - if errno := UnwrapOSError(err); errno == 0 { - return statFromFileInfo(t), 0 - } else { - return Stat_t{}, errno - } -} - -func stat(path string) (Stat_t, syscall.Errno) { - t, err := os.Stat(path) - if errno := UnwrapOSError(err); errno == 0 { - return statFromFileInfo(t), 0 - } else { - return Stat_t{}, errno - } -} - -func statFile(f fs.File) (Stat_t, syscall.Errno) { - return defaultStatFile(f) -} - -func inoFromFileInfo(_ readdirFile, t fs.FileInfo) (ino uint64, err syscall.Errno) { - return -} - -func statFromFileInfo(t fs.FileInfo) Stat_t { - return statFromDefaultFileInfo(t) -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/sync.go b/vendor/github.com/tetratelabs/wazero/internal/platform/sync.go deleted file mode 100644 index a93e24bad..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/sync.go +++ /dev/null @@ -1,14 +0,0 @@ -package platform - -import ( - "io/fs" - "syscall" -) - -// Fdatasync is like syscall.Fdatasync except that's only defined in linux. -// -// Note: This returns with no error instead of syscall.ENOSYS when -// unimplemented. This prevents fake filesystems from erring. -func Fdatasync(f fs.File) syscall.Errno { - return fdatasync(f) -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/sync_linux.go b/vendor/github.com/tetratelabs/wazero/internal/platform/sync_linux.go deleted file mode 100644 index 41ae44c8a..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/sync_linux.go +++ /dev/null @@ -1,20 +0,0 @@ -//go:build linux - -package platform - -import ( - "io/fs" - "syscall" -) - -func fdatasync(f fs.File) syscall.Errno { - if fd, ok := f.(fdFile); ok { - return UnwrapOSError(syscall.Fdatasync(int(fd.Fd()))) - } - - // Attempt to sync everything, even if we only need to sync the data. - if s, ok := f.(syncFile); ok { - return UnwrapOSError(s.Sync()) - } - return 0 -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/sync_unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/platform/sync_unsupported.go deleted file mode 100644 index 38284aa5a..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/sync_unsupported.go +++ /dev/null @@ -1,16 +0,0 @@ -//go:build !linux - -package platform - -import ( - "io/fs" - "syscall" -) - -func fdatasync(f fs.File) syscall.Errno { - // Attempt to sync everything, even if we only need to sync the data. - if s, ok := f.(syncFile); ok { - return UnwrapOSError(s.Sync()) - } - return 0 -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/time_cgo.go b/vendor/github.com/tetratelabs/wazero/internal/platform/time_cgo.go index 2f6a28999..ff01d90ce 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/time_cgo.go +++ b/vendor/github.com/tetratelabs/wazero/internal/platform/time_cgo.go @@ -7,6 +7,5 @@ import _ "unsafe" // for go:linkname // nanotime uses runtime.nanotime as it is available on all platforms and // benchmarks faster than using time.Since. // -//go:noescape //go:linkname nanotime runtime.nanotime func nanotime() int64 diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/unlink.go b/vendor/github.com/tetratelabs/wazero/internal/platform/unlink.go deleted file mode 100644 index 9555da515..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/unlink.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build !windows - -package platform - -import "syscall" - -func Unlink(name string) (errno syscall.Errno) { - err := syscall.Unlink(name) - if errno = UnwrapOSError(err); errno == syscall.EPERM { - errno = syscall.EISDIR - } - return errno -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/wrap_windows.go b/vendor/github.com/tetratelabs/wazero/internal/platform/wrap_windows.go deleted file mode 100644 index 59cfce3bb..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/wrap_windows.go +++ /dev/null @@ -1,132 +0,0 @@ -package platform - -import ( - "io/fs" - "syscall" -) - -// windowsWrappedFile deals with errno portability issues in Windows. This code -// is likely to change as we complete WASI and GOOS=js. -// -// If we don't map to syscall.Errno, wasm will crash in odd way attempting the -// same. This approach is an alternative to making our own fs.File public type. -// We aren't doing that yet, as mapping problems are generally contained to -// Windows. Hence, file is intentionally not exported. -// -// Note: Don't test for this type as it is wrapped when using sysfs.NewReadFS. -type windowsWrappedFile struct { - File - path string - flag int - perm fs.FileMode - dirInitialized bool - - fileType *fs.FileMode - - // closed is true when closed was called. This ensures proper syscall.EBADF - // TODO: extract a base wrapper type to cover all cases. - closed bool -} - -// Path implements PathFile -func (w *windowsWrappedFile) Path() string { - return w.path -} - -// Readdir implements readdirFile. -func (w *windowsWrappedFile) Readdir(n int) (fis []fs.FileInfo, err error) { - if err = w.requireFile("Readdir", false, true); err != nil { - return - } else if err = w.maybeInitDir(); err != nil { - return - } - - return w.File.Readdir(n) -} - -// ReadDir implements fs.ReadDirFile. -func (w *windowsWrappedFile) ReadDir(n int) (dirents []fs.DirEntry, err error) { - if err = w.requireFile("ReadDir", false, true); err != nil { - return - } else if err = w.maybeInitDir(); err != nil { - return - } - - return w.File.ReadDir(n) -} - -// Write implements io.Writer -func (w *windowsWrappedFile) Write(p []byte) (n int, err error) { - if err = w.requireFile("Write", false, false); err != nil { - return - } - - return w.File.Write(p) -} - -// Close implements io.Closer -func (w *windowsWrappedFile) Close() (err error) { - if w.closed { - return - } - - if err = w.File.Close(); err != nil { - w.closed = true - } - return -} - -func (w *windowsWrappedFile) maybeInitDir() error { - if w.dirInitialized { - return nil - } - - // On Windows, once the directory is opened, changes to the directory are - // not visible on ReadDir on that already-opened file handle. - // - // To provide consistent behavior with other platforms, we re-open it. - if err := w.File.Close(); err != nil { - return err - } - newW, errno := openFile(w.path, w.flag, w.perm) - if errno != 0 { - return &fs.PathError{Op: "OpenFile", Path: w.path, Err: errno} - } - w.File = newW - w.dirInitialized = true - return nil -} - -// requireFile is used to making syscalls which will fail. -func (w *windowsWrappedFile) requireFile(op string, readOnly, isDir bool) error { - var ft fs.FileMode - var err error - if w.closed { - err = syscall.EBADF - } else if readOnly && w.flag&syscall.O_RDONLY == 0 { - err = syscall.EBADF - } else if ft, err = w.getFileType(); err == nil && isDir != ft.IsDir() { - if isDir { - err = syscall.ENOTDIR - } else { - err = syscall.EBADF - } - } else if err == nil { - return nil - } - return &fs.PathError{Op: op, Path: w.path, Err: err} -} - -// getFileType caches the file type as this cannot change on an open file. -func (w *windowsWrappedFile) getFileType() (fs.FileMode, error) { - if w.fileType == nil { - st, errno := StatFile(w.File) - if errno != 0 { - return 0, nil - } - ft := st.Mode & fs.ModeType - w.fileType = &ft - return ft, nil - } - return *w.fileType, nil -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sock/sock.go b/vendor/github.com/tetratelabs/wazero/internal/sock/sock.go new file mode 100644 index 000000000..6c0be1516 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sock/sock.go @@ -0,0 +1,88 @@ +package sock + +import ( + "fmt" + "net" + "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" +) + +// TCPSock is a pseudo-file representing a TCP socket. +type TCPSock interface { + fsapi.File + + Accept() (TCPConn, syscall.Errno) +} + +// TCPConn is a pseudo-file representing a TCP connection. +type TCPConn interface { + fsapi.File + + // Recvfrom only supports the flag sysfs.MSG_PEEK + Recvfrom(p []byte, flags int) (n int, errno syscall.Errno) + + Shutdown(how int) syscall.Errno +} + +// ConfigKey is a context.Context Value key. Its associated value should be a Config. +type ConfigKey struct{} + +// Config is an internal struct meant to implement +// the interface in experimental/sock/Config. +type Config struct { + // TCPAddresses is a slice of the configured host:port pairs. + TCPAddresses []TCPAddress +} + +// TCPAddress is a host:port pair to pre-open. +type TCPAddress struct { + // Host is the host name for this listener. + Host string + // Port is the port number for this listener. + Port int +} + +// WithTCPListener implements the method of the same name in experimental/sock/Config. +// +// However, to avoid cyclic dependencies, this is returning the *Config in this scope. +// The interface is implemented in experimental/sock/Config via delegation. +func (c *Config) WithTCPListener(host string, port int) *Config { + ret := c.clone() + ret.TCPAddresses = append(ret.TCPAddresses, TCPAddress{host, port}) + return &ret +} + +// Makes a deep copy of this sockConfig. +func (c *Config) clone() Config { + ret := *c + ret.TCPAddresses = make([]TCPAddress, 0, len(c.TCPAddresses)) + ret.TCPAddresses = append(ret.TCPAddresses, c.TCPAddresses...) + return ret +} + +// BuildTCPListeners build listeners from the current configuration. +func (c *Config) BuildTCPListeners() (tcpListeners []*net.TCPListener, err error) { + for _, tcpAddr := range c.TCPAddresses { + var ln net.Listener + ln, err = net.Listen("tcp", tcpAddr.String()) + if err != nil { + break + } + if tcpln, ok := ln.(*net.TCPListener); ok { + tcpListeners = append(tcpListeners, tcpln) + } + } + if err != nil { + // An error occurred, cleanup. + for _, l := range tcpListeners { + _ = l.Close() // Ignore errors, we are already cleaning. + } + tcpListeners = nil + } + return +} + +func (t TCPAddress) String() string { + return fmt.Sprintf("%s:%d", t.Host, t.Port) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sys/fs.go b/vendor/github.com/tetratelabs/wazero/internal/sys/fs.go index 7436e2d84..3f1eb6e54 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/sys/fs.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sys/fs.go @@ -1,15 +1,16 @@ package sys import ( - "fmt" "io" "io/fs" - "os" + "net" + "path" "syscall" - "time" "github.com/tetratelabs/wazero/internal/descriptor" + "github.com/tetratelabs/wazero/internal/fsapi" "github.com/tetratelabs/wazero/internal/platform" + socketapi "github.com/tetratelabs/wazero/internal/sock" "github.com/tetratelabs/wazero/internal/sysfs" ) @@ -31,245 +32,51 @@ const ( FdPreopen ) -const modeDevice = uint32(fs.ModeDevice | 0o640) - -type stdioFileWriter struct { - w io.Writer - s fs.FileInfo -} - -// Stat implements fs.File -func (w *stdioFileWriter) Stat() (fs.FileInfo, error) { return w.s, nil } - -// Read implements fs.File -func (w *stdioFileWriter) Read([]byte) (n int, err error) { - return // emulate os.Stdout which returns zero -} - -// Write implements io.Writer -func (w *stdioFileWriter) Write(p []byte) (n int, err error) { - return w.w.Write(p) -} - -// Close implements fs.File -func (w *stdioFileWriter) Close() error { - // Don't actually close the underlying file, as we didn't open it! - return nil -} - -// StdioFilePoller is a strategy for polling a StdioFileReader for a given duration. -// It returns true if the reader has data ready to be read, false and/or an error otherwise. -type StdioFilePoller interface { - Poll(duration time.Duration) (bool, error) -} - -// PollerDefaultStdin is a poller that checks standard input. -var PollerDefaultStdin = &pollerDefaultStdin{} - -type pollerDefaultStdin struct{} - -// Poll implements StdioFilePoller for pollerDefaultStdin. -func (*pollerDefaultStdin) Poll(duration time.Duration) (bool, error) { - fdSet := platform.FdSet{} - fdSet.Set(int(FdStdin)) - count, err := platform.Select(int(FdStdin+1), &fdSet, nil, nil, &duration) - return count > 0, err -} - -// PollerAlwaysReady is a poller that ignores the given timeout, and it returns true and no error. -var PollerAlwaysReady = &pollerAlwaysReady{} - -type pollerAlwaysReady struct{} - -// Poll implements StdioFilePoller for pollerAlwaysReady. -func (*pollerAlwaysReady) Poll(time.Duration) (bool, error) { return true, nil } - -// PollerNeverReady is a poller that waits for the given duration, and it always returns false and no error. -var PollerNeverReady = &pollerNeverReady{} - -type pollerNeverReady struct{} - -// Poll implements StdioFilePoller for pollerNeverReady. -func (*pollerNeverReady) Poll(d time.Duration) (bool, error) { time.Sleep(d); return false, nil } - -// StdioFileReader implements io.Reader for stdio files. -type StdioFileReader struct { - r io.Reader - s fs.FileInfo - poll StdioFilePoller -} - -// NewStdioFileReader is a constructor for StdioFileReader. -func NewStdioFileReader(reader io.Reader, fileInfo fs.FileInfo, poll StdioFilePoller) *StdioFileReader { - return &StdioFileReader{ - r: reader, - s: fileInfo, - poll: poll, - } -} - -// Poll invokes the StdioFilePoller that was given at the NewStdioFileReader constructor. -func (r *StdioFileReader) Poll(duration time.Duration) (bool, error) { - return r.poll.Poll(duration) -} - -// Stat implements fs.File -func (r *StdioFileReader) Stat() (fs.FileInfo, error) { return r.s, nil } - -// Read implements fs.File -func (r *StdioFileReader) Read(p []byte) (n int, err error) { - return r.r.Read(p) -} - -// Close implements fs.File -func (r *StdioFileReader) Close() error { - // Don't actually close the underlying file, as we didn't open it! - return nil -} - -var ( - noopStdinStat = stdioFileInfo{0, modeDevice} - noopStdoutStat = stdioFileInfo{1, modeDevice} - noopStderrStat = stdioFileInfo{2, modeDevice} -) - -// stdioFileInfo implements fs.FileInfo where index zero is the FD and one is the mode. -type stdioFileInfo [2]uint32 - -func (s stdioFileInfo) Name() string { - switch s[0] { - case 0: - return "stdin" - case 1: - return "stdout" - case 2: - return "stderr" - default: - panic(fmt.Errorf("BUG: incorrect FD %d", s[0])) - } -} - -func (stdioFileInfo) Size() int64 { return 0 } -func (s stdioFileInfo) Mode() fs.FileMode { return fs.FileMode(s[1]) } -func (stdioFileInfo) ModTime() time.Time { return time.Unix(0, 0) } -func (stdioFileInfo) IsDir() bool { return false } -func (stdioFileInfo) Sys() interface{} { return nil } - -type lazyDir struct { - fs sysfs.FS - f fs.File -} - -// Stat implements fs.File -func (r *lazyDir) Stat() (fs.FileInfo, error) { - if f, err := r.file(); err != 0 { - return nil, err - } else { - return f.Stat() - } -} - -func (r *lazyDir) file() (f fs.File, errno syscall.Errno) { - if f = r.f; r.f != nil { - return - } - r.f, errno = r.fs.OpenFile(".", os.O_RDONLY, 0) - f = r.f - return -} - -// Read implements fs.File -func (r *lazyDir) Read(p []byte) (n int, err error) { - if f, errno := r.file(); errno != 0 { - return 0, errno - } else { - return f.Read(p) - } -} - -// Close implements fs.File -func (r *lazyDir) Close() error { - f := r.f - if f == nil { - return nil // never opened - } - return f.Close() -} +const modeDevice = fs.ModeDevice | 0o640 // FileEntry maps a path to an open file in a file system. type FileEntry struct { // Name is the name of the directory up to its pre-open, or the pre-open // name itself when IsPreopen. // - // Note: This can drift on rename. + // # Notes + // + // - This can drift on rename. + // - This relates to the guest path, which is not the real file path + // except if the entire host filesystem was made available. Name string // IsPreopen is a directory that is lazily opened. IsPreopen bool // FS is the filesystem associated with the pre-open. - FS sysfs.FS - - // cachedStat includes fields that won't change while a file is open. - cachedStat *cachedStat + FS fsapi.FS // File is always non-nil. - File fs.File - - // ReadDir is present when this File is a fs.ReadDirFile and `ReadDir` - // was called. - ReadDir *ReadDir - - openPath string - openFlag int - openPerm fs.FileMode + File fsapi.File } -type cachedStat struct { - // Ino is the file serial number, or zero if not available. - Ino uint64 - - // Type is the same as what's documented on platform.Dirent. - Type fs.FileMode -} - -// CachedStat returns the cacheable parts of platform.Stat_t or an error if -// they couldn't be retrieved. -func (f *FileEntry) CachedStat() (ino uint64, fileType fs.FileMode, err error) { - if f.cachedStat == nil { - if _, err = f.Stat(); err != nil { - return - } - } - return f.cachedStat.Ino, f.cachedStat.Type, nil -} - -// Stat returns the underlying stat of this file. -func (f *FileEntry) Stat() (st platform.Stat_t, err error) { - var errno syscall.Errno - if ld, ok := f.File.(*lazyDir); ok { - var sf fs.File - if sf, errno = ld.file(); errno == 0 { - st, errno = platform.StatFile(sf) - } - } else { - st, errno = platform.StatFile(f.File) - } +const direntBufSize = 16 - if errno != 0 { - err = errno - } else { - f.cachedStat = &cachedStat{Ino: st.Ino, Type: st.Mode & fs.ModeType} - } - return -} +// Readdir is the status of a prior fs.ReadDirFile call. +type Readdir struct { + // cursor is the current position in the buffer. + cursor uint64 -// ReadDir is the status of a prior fs.ReadDirFile call. -type ReadDir struct { - // CountRead is the total count of files read including Dirents. - CountRead uint64 + // countRead is the total count of files read including Dirents. + // + // Notes: + // + // * countRead is the index of the next file in the list. This is + // also the value that Cookie returns, so it should always be + // higher or equal than the cookie given in Rewind. + // + // * this can overflow to negative, which means our implementation + // doesn't support writing greater than max int64 entries. + // countRead uint64 + countRead uint64 - // Dirents is the contents of the last platform.Readdir call. Notably, + // dirents is a fixed buffer of size direntBufSize. Notably, // directory listing are not rewindable, so we keep entries around in case // the caller mis-estimated their buffer and needs a few still cached. // @@ -277,125 +84,217 @@ type ReadDir struct { // In wasi preview1, dot and dot-dot entries are required to exist, but the // reverse is true for preview2. More importantly, preview2 holds separate // stateful dir-entry-streams per file. - Dirents []*platform.Dirent -} + dirents []fsapi.Dirent -type FSContext struct { - // rootFS is the root ("/") mount. - rootFS sysfs.FS + // dirInit seeks and reset the provider for dirents to the beginning + // and returns an initial batch (e.g. dot directories). + dirInit func() ([]fsapi.Dirent, syscall.Errno) - // openedFiles is a map of file descriptor numbers (>=FdPreopen) to open files - // (or directories) and defaults to empty. - // TODO: This is unguarded, so not goroutine-safe! - openedFiles FileTable + // dirReader fetches a new batch of direntBufSize elements. + dirReader func(n uint64) ([]fsapi.Dirent, syscall.Errno) } -// FileTable is a specialization of the descriptor.Table type used to map file -// descriptors to file entries. -type FileTable = descriptor.Table[int32, *FileEntry] +// NewReaddir is a constructor for Readdir. It takes a dirInit +func NewReaddir( + dirInit func() ([]fsapi.Dirent, syscall.Errno), + dirReader func(n uint64) ([]fsapi.Dirent, syscall.Errno), +) (*Readdir, syscall.Errno) { + d := &Readdir{dirReader: dirReader, dirInit: dirInit} + return d, d.init() +} -// NewFSContext creates a FSContext with stdio streams and an optional -// pre-opened filesystem. +// init resets the cursor and invokes the dirInit, dirReader +// methods to reset the internal state of the Readdir struct. // -// If `preopened` is not sysfs.UnimplementedFS, it is inserted into -// the file descriptor table as FdPreopen. -func (c *Context) NewFSContext(stdin io.Reader, stdout, stderr io.Writer, rootFS sysfs.FS) (err error) { - c.fsc.rootFS = rootFS - inReader, err := stdinReader(stdin) - if err != nil { - return err +// Note: this is different from Reset, because it will not short-circuit +// when cursor is already 0, but it will force an unconditional reload. +func (d *Readdir) init() syscall.Errno { + d.cursor = 0 + d.countRead = 0 + // Reset the buffer to the initial state. + initialDirents, errno := d.dirInit() + if errno != 0 { + return errno } - c.fsc.openedFiles.Insert(inReader) - outWriter, err := stdioWriter(stdout, noopStdoutStat) - if err != nil { - return err + if len(initialDirents) > direntBufSize { + return syscall.EINVAL } - c.fsc.openedFiles.Insert(outWriter) - errWriter, err := stdioWriter(stderr, noopStderrStat) - if err != nil { - return err + d.dirents = initialDirents + // Fill the buffer with more data. + count := direntBufSize - len(initialDirents) + if count == 0 { + // No need to fill up the buffer further. + return 0 } - c.fsc.openedFiles.Insert(errWriter) - - if _, ok := rootFS.(sysfs.UnimplementedFS); ok { - return nil + dirents, errno := d.dirReader(uint64(count)) + if errno != 0 { + return errno } + d.dirents = append(d.dirents, dirents...) + return 0 +} - if comp, ok := rootFS.(*sysfs.CompositeFS); ok { - preopens := comp.FS() - for i, p := range comp.GuestPaths() { - c.fsc.openedFiles.Insert(&FileEntry{ - FS: preopens[i], - Name: p, - IsPreopen: true, - File: &lazyDir{fs: rootFS}, - }) +// newReaddirFromFileEntry is a constructor for Readdir that takes a FileEntry to initialize. +func newReaddirFromFileEntry(f *FileEntry) (*Readdir, syscall.Errno) { + // Generate the dotEntries only once and return it many times in the dirInit closure. + dotEntries, errno := synthesizeDotEntries(f) + if errno != 0 { + return nil, errno + } + dirInit := func() ([]fsapi.Dirent, syscall.Errno) { + // Ensure we always rewind to the beginning when we re-init. + if _, errno := f.File.Seek(0, io.SeekStart); errno != 0 { + return nil, errno } - } else { - c.fsc.openedFiles.Insert(&FileEntry{ - FS: rootFS, - Name: "/", - IsPreopen: true, - File: &lazyDir{fs: rootFS}, - }) + // Return the dotEntries that we have already generated outside the closure. + return dotEntries, 0 } - - return nil + dirReader := func(n uint64) ([]fsapi.Dirent, syscall.Errno) { return f.File.Readdir(int(n)) } + return NewReaddir(dirInit, dirReader) } -func stdinReader(r io.Reader) (*FileEntry, error) { - if r == nil { - r = eofReader{} +// synthesizeDotEntries generates a slice of the two elements "." and "..". +func synthesizeDotEntries(f *FileEntry) (result []fsapi.Dirent, errno syscall.Errno) { + dotIno, errno := f.File.Ino() + if errno != 0 { + return nil, errno } - var freader *StdioFileReader - if stdioFileReader, ok := r.(*StdioFileReader); ok { - freader = stdioFileReader - } else { - s, err := stdioStat(r, noopStdinStat) - if err != nil { - return nil, err + result = append(result, fsapi.Dirent{Name: ".", Ino: dotIno, Type: fs.ModeDir}) + dotDotIno := uint64(0) + if !f.IsPreopen && f.Name != "." { + if st, errno := f.FS.Stat(path.Dir(f.Name)); errno != 0 { + return nil, errno + } else { + dotDotIno = st.Ino } - freader = NewStdioFileReader(r, s, PollerDefaultStdin) } - return &FileEntry{Name: noopStdinStat.Name(), File: freader}, nil + result = append(result, fsapi.Dirent{Name: "..", Ino: dotDotIno, Type: fs.ModeDir}) + return result, 0 } -func stdioWriter(w io.Writer, defaultStat stdioFileInfo) (*FileEntry, error) { - if w == nil { - w = io.Discard +// Reset seeks the internal cursor to 0 and refills the buffer. +func (d *Readdir) Reset() syscall.Errno { + if d.countRead == 0 { + return 0 } - s, err := stdioStat(w, defaultStat) - if err != nil { - return nil, err + return d.init() +} + +// Skip is equivalent to calling n times Advance. +func (d *Readdir) Skip(n uint64) { + end := d.countRead + n + var err syscall.Errno = 0 + for d.countRead < end && err == 0 { + err = d.Advance() } - return &FileEntry{Name: s.Name(), File: &stdioFileWriter{w: w, s: s}}, nil } -func stdioStat(f interface{}, defaultStat stdioFileInfo) (fs.FileInfo, error) { - if f, ok := f.(*os.File); ok { - if st, err := f.Stat(); err == nil { - mode := uint32(st.Mode() & fs.ModeType) - return stdioFileInfo{defaultStat[0], mode}, nil - } else { - return nil, err +// Cookie returns a cookie representing the current state of the ReadDir struct. +// +// Note: this returns the countRead field, but it is an implementation detail. +func (d *Readdir) Cookie() uint64 { + return d.countRead +} + +// Rewind seeks the internal cursor to the state represented by the cookie. +// It returns a syscall.Errno if the cursor was reset and an I/O error occurred while trying to re-init. +func (d *Readdir) Rewind(cookie int64) syscall.Errno { + unsignedCookie := uint64(cookie) + switch { + case cookie < 0 || unsignedCookie > d.countRead: + // the cookie can neither be negative nor can it be larger than countRead. + return syscall.EINVAL + case cookie == 0 && d.countRead == 0: + return 0 + case cookie == 0 && d.countRead != 0: + // This means that there was a previous call to the dir, but cookie is reset. + // This happens when the program calls rewinddir, for example: + // https://github.com/WebAssembly/wasi-libc/blob/659ff414560721b1660a19685110e484a081c3d4/libc-bottom-half/cloudlibc/src/libc/dirent/rewinddir.c#L10-L12 + return d.Reset() + case unsignedCookie < d.countRead: + if cookie/direntBufSize != int64(d.countRead)/direntBufSize { + // The cookie is not 0, but it points into a window before the current one. + return syscall.ENOSYS + } + // We are allowed to rewind back to a previous offset within the current window. + d.countRead = unsignedCookie + d.cursor = d.countRead % direntBufSize + return 0 + default: + // The cookie is valid. + return 0 + } +} + +// Peek emits the current value. +// It returns syscall.ENOENT when there are no entries left in the directory. +func (d *Readdir) Peek() (*fsapi.Dirent, syscall.Errno) { + switch { + case d.cursor == uint64(len(d.dirents)): + // We're past the buf size, fill it up again. + dirents, errno := d.dirReader(direntBufSize) + if errno != 0 { + return nil, errno + } + d.dirents = append(d.dirents, dirents...) + fallthrough + default: // d.cursor < direntBufSize FIXME + if d.cursor == uint64(len(d.dirents)) { + return nil, syscall.ENOENT } + dirent := &d.dirents[d.cursor] + return dirent, 0 } - return defaultStat, nil } +// Advance advances the internal counters and indices to the next value. +// It also empties and refill the buffer with the next set of values when the internal cursor +// reaches the end of it. +func (d *Readdir) Advance() syscall.Errno { + if d.cursor == uint64(len(d.dirents)) { + return syscall.ENOENT + } + d.cursor++ + d.countRead++ + return 0 +} + +type FSContext struct { + // rootFS is the root ("/") mount. + rootFS fsapi.FS + + // openedFiles is a map of file descriptor numbers (>=FdPreopen) to open files + // (or directories) and defaults to empty. + // TODO: This is unguarded, so not goroutine-safe! + openedFiles FileTable + + // readdirs is a map of numeric identifiers to Readdir structs + // and defaults to empty. + // TODO: This is unguarded, so not goroutine-safe! + readdirs ReaddirTable +} + +// FileTable is a specialization of the descriptor.Table type used to map file +// descriptors to file entries. +type FileTable = descriptor.Table[int32, *FileEntry] + +// ReaddirTable is a specialization of the descriptor.Table type used to map file +// descriptors to Readdir structs. +type ReaddirTable = descriptor.Table[int32, *Readdir] + // RootFS returns the underlying filesystem. Any files that should be added to // the table should be inserted via InsertFile. -func (c *FSContext) RootFS() sysfs.FS { +func (c *FSContext) RootFS() fsapi.FS { return c.rootFS } // OpenFile opens the file into the table and returns its file descriptor. // The result must be closed by CloseFile or Close. -func (c *FSContext) OpenFile(fs sysfs.FS, path string, flag int, perm fs.FileMode) (int32, syscall.Errno) { +func (c *FSContext) OpenFile(fs fsapi.FS, path string, flag int, perm fs.FileMode) (int32, syscall.Errno) { if f, errno := fs.OpenFile(path, flag, perm); errno != 0 { return 0, errno } else { - fe := &FileEntry{openPath: path, FS: fs, File: f, openFlag: flag, openPerm: perm} + fe := &FileEntry{FS: fs, File: f} if path == "/" || path == "." { fe.Name = "" } else { @@ -409,76 +308,67 @@ func (c *FSContext) OpenFile(fs sysfs.FS, path string, flag int, perm fs.FileMod } } -// ReOpenDir re-opens the directory while keeping the same file descriptor. -// TODO: this might not be necessary once we have our own File type. -func (c *FSContext) ReOpenDir(fd int32) (*FileEntry, syscall.Errno) { - f, ok := c.openedFiles.Lookup(fd) - if !ok { - return nil, syscall.EBADF - } else if _, ft, err := f.CachedStat(); err != nil { - return nil, platform.UnwrapOSError(err) - } else if ft.Type() != fs.ModeDir { - return nil, syscall.EISDIR +// SockAccept accepts a socketapi.TCPConn into the file table and returns +// its file descriptor. +func (c *FSContext) SockAccept(sockFD int32, nonblock bool) (int32, syscall.Errno) { + var sock socketapi.TCPSock + if e, ok := c.LookupFile(sockFD); !ok || !e.IsPreopen { + return 0, syscall.EBADF // Not a preopen + } else if sock, ok = e.File.(socketapi.TCPSock); !ok { + return 0, syscall.EBADF // Not a sock } - if errno := c.reopen(f); errno != 0 { - return nil, errno - } - - f.ReadDir.CountRead, f.ReadDir.Dirents = 0, nil - return f, 0 -} - -func (c *FSContext) reopen(f *FileEntry) syscall.Errno { - if err := f.File.Close(); err != nil { - return platform.UnwrapOSError(err) + var conn socketapi.TCPConn + var errno syscall.Errno + if conn, errno = sock.Accept(); errno != 0 { + return 0, errno + } else if nonblock { + if errno = conn.SetNonblock(true); errno != 0 { + _ = conn.Close() + return 0, errno + } } - // Re-opens with the same parameters as before. - opened, errno := f.FS.OpenFile(f.openPath, f.openFlag, f.openPerm) - if errno != 0 { - return errno + fe := &FileEntry{File: conn} + if newFD, ok := c.openedFiles.Insert(fe); !ok { + return 0, syscall.EBADF + } else { + return newFD, 0 } - - // Reset the state. - f.File = opened - return 0 } -// ChangeOpenFlag changes the open flag of the given opened file pointed by `fd`. -// Currently, this only supports the change of syscall.O_APPEND flag. -func (c *FSContext) ChangeOpenFlag(fd int32, flag int) syscall.Errno { - f, ok := c.LookupFile(fd) - if !ok { - return syscall.EBADF - } else if _, ft, err := f.CachedStat(); err != nil { - return platform.UnwrapOSError(err) - } else if ft.Type() == fs.ModeDir { - return syscall.EISDIR - } +// LookupFile returns a file if it is in the table. +func (c *FSContext) LookupFile(fd int32) (*FileEntry, bool) { + return c.openedFiles.Lookup(fd) +} - if flag&syscall.O_APPEND != 0 { - f.openFlag |= syscall.O_APPEND +// LookupReaddir returns a Readdir struct or creates an empty one if it was not present. +// +// Note: this currently assumes that idx == fd, where fd is the file descriptor of the directory. +// CloseFile will delete this idx from the internal store. In the future, idx may be independent +// of a file fd, and the idx may have to be disposed with an explicit CloseReaddir. +func (c *FSContext) LookupReaddir(idx int32, f *FileEntry) (*Readdir, syscall.Errno) { + if item, _ := c.readdirs.Lookup(idx); item != nil { + return item, 0 } else { - f.openFlag &= ^syscall.O_APPEND + item, err := newReaddirFromFileEntry(f) + if err != 0 { + return nil, err + } + ok := c.readdirs.InsertAt(item, idx) + if !ok { + return nil, syscall.EINVAL + } + return item, 0 } - - // Changing the flag while opening is not really supported well in Go. Even when using - // syscall package, the feasibility of doing so really depends on the platform. For examples: - // - // * This appendMode (bool) cannot be changed later. - // https://github.com/golang/go/blob/go1.20/src/os/file_unix.go#L60 - // * On Windows, re-opening it is the only way to emulate the behavior. - // https://github.com/bytecodealliance/system-interface/blob/62b97f9776b86235f318c3a6e308395a1187439b/src/fs/fd_flags.rs#L196 - // - // Therefore, here we re-open the file while keeping the file descriptor. - // TODO: this might be improved once we have our own File type. - return c.reopen(f) } -// LookupFile returns a file if it is in the table. -func (c *FSContext) LookupFile(fd int32) (*FileEntry, bool) { - return c.openedFiles.Lookup(fd) +// CloseReaddir delete the Readdir struct at the given index +// +// Note: Currently only necessary in tests. In the future, the idx will have to be disposed explicitly, +// unless we maintain a map fd -> []idx, and we let CloseFile close all the idx in []idx. +func (c *FSContext) CloseReaddir(idx int32) { + c.readdirs.Delete(idx) } // Renumber assigns the file pointed by the descriptor `from` to `to`. @@ -516,6 +406,7 @@ func (c *FSContext) CloseFile(fd int32) syscall.Errno { return syscall.EBADF } c.openedFiles.Delete(fd) + c.readdirs.Delete(fd) return platform.UnwrapOSError(f.File.Close()) } @@ -523,24 +414,69 @@ func (c *FSContext) CloseFile(fd int32) syscall.Errno { func (c *FSContext) Close() (err error) { // Close any files opened in this context c.openedFiles.Range(func(fd int32, entry *FileEntry) bool { - if e := entry.File.Close(); e != nil { - err = e // This means err returned == the last non-nil error. + if errno := entry.File.Close(); errno != 0 { + err = errno // This means err returned == the last non-nil error. } return true }) // A closed FSContext cannot be reused so clear the state instead of // using Reset. c.openedFiles = FileTable{} + c.readdirs = ReaddirTable{} return } -// WriterForFile returns a writer for the given file descriptor or nil if not -// opened or not writeable (e.g. a directory or a file not opened for writes). -func WriterForFile(fsc *FSContext, fd int32) (writer io.Writer) { - if f, ok := fsc.LookupFile(fd); !ok { - return - } else if w, ok := f.File.(io.Writer); ok { - writer = w +// NewFSContext creates a FSContext with stdio streams and an optional +// pre-opened filesystem. +// +// If `preopened` is not UnimplementedFS, it is inserted into +// the file descriptor table as FdPreopen. +func (c *Context) NewFSContext( + stdin io.Reader, + stdout, stderr io.Writer, + rootFS fsapi.FS, + tcpListeners []*net.TCPListener, +) (err error) { + c.fsc.rootFS = rootFS + inFile, err := stdinFileEntry(stdin) + if err != nil { + return err + } + c.fsc.openedFiles.Insert(inFile) + outWriter, err := stdioWriterFileEntry("stdout", stdout) + if err != nil { + return err + } + c.fsc.openedFiles.Insert(outWriter) + errWriter, err := stdioWriterFileEntry("stderr", stderr) + if err != nil { + return err + } + c.fsc.openedFiles.Insert(errWriter) + + if _, ok := rootFS.(fsapi.UnimplementedFS); ok { + // don't add to the pre-opens + } else if comp, ok := rootFS.(*sysfs.CompositeFS); ok { + preopens := comp.FS() + for i, p := range comp.GuestPaths() { + c.fsc.openedFiles.Insert(&FileEntry{ + FS: preopens[i], + Name: p, + IsPreopen: true, + File: &lazyDir{fs: rootFS}, + }) + } + } else { + c.fsc.openedFiles.Insert(&FileEntry{ + FS: rootFS, + Name: "/", + IsPreopen: true, + File: &lazyDir{fs: rootFS}, + }) + } + + for _, tl := range tcpListeners { + c.fsc.openedFiles.Insert(&FileEntry{IsPreopen: true, File: sysfs.NewTCPListenerFile(tl)}) } - return + return nil } diff --git a/vendor/github.com/tetratelabs/wazero/internal/sys/lazy.go b/vendor/github.com/tetratelabs/wazero/internal/sys/lazy.go new file mode 100644 index 000000000..df68b51b6 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sys/lazy.go @@ -0,0 +1,136 @@ +package sys + +import ( + "io/fs" + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" +) + +// compile-time check to ensure lazyDir implements internalapi.File. +var _ fsapi.File = (*lazyDir)(nil) + +type lazyDir struct { + fsapi.DirFile + + fs fsapi.FS + f fsapi.File +} + +// Ino implements the same method as documented on internalapi.File +func (r *lazyDir) Ino() (uint64, syscall.Errno) { + if f, ok := r.file(); !ok { + return 0, syscall.EBADF + } else { + return f.Ino() + } +} + +// IsAppend implements the same method as documented on internalapi.File +func (r *lazyDir) IsAppend() bool { + return false +} + +// SetAppend implements the same method as documented on internalapi.File +func (r *lazyDir) SetAppend(bool) syscall.Errno { + return syscall.EISDIR +} + +// Seek implements the same method as documented on internalapi.File +func (r *lazyDir) Seek(offset int64, whence int) (newOffset int64, errno syscall.Errno) { + if f, ok := r.file(); !ok { + return 0, syscall.EBADF + } else { + return f.Seek(offset, whence) + } +} + +// Stat implements the same method as documented on internalapi.File +func (r *lazyDir) Stat() (fsapi.Stat_t, syscall.Errno) { + if f, ok := r.file(); !ok { + return fsapi.Stat_t{}, syscall.EBADF + } else { + return f.Stat() + } +} + +// Readdir implements the same method as documented on internalapi.File +func (r *lazyDir) Readdir(n int) (dirents []fsapi.Dirent, errno syscall.Errno) { + if f, ok := r.file(); !ok { + return nil, syscall.EBADF + } else { + return f.Readdir(n) + } +} + +// Sync implements the same method as documented on internalapi.File +func (r *lazyDir) Sync() syscall.Errno { + if f, ok := r.file(); !ok { + return syscall.EBADF + } else { + return f.Sync() + } +} + +// Datasync implements the same method as documented on internalapi.File +func (r *lazyDir) Datasync() syscall.Errno { + if f, ok := r.file(); !ok { + return syscall.EBADF + } else { + return f.Datasync() + } +} + +// Chmod implements the same method as documented on internalapi.File +func (r *lazyDir) Chmod(mode fs.FileMode) syscall.Errno { + if f, ok := r.file(); !ok { + return syscall.EBADF + } else { + return f.Chmod(mode) + } +} + +// Chown implements the same method as documented on internalapi.File +func (r *lazyDir) Chown(uid, gid int) syscall.Errno { + if f, ok := r.file(); !ok { + return syscall.EBADF + } else { + return f.Chown(uid, gid) + } +} + +// Utimens implements the same method as documented on internalapi.File +func (r *lazyDir) Utimens(times *[2]syscall.Timespec) syscall.Errno { + if f, ok := r.file(); !ok { + return syscall.EBADF + } else { + return f.Utimens(times) + } +} + +// file returns the underlying file or false if it doesn't exist. +func (r *lazyDir) file() (fsapi.File, bool) { + if f := r.f; r.f != nil { + return f, true + } + var errno syscall.Errno + r.f, errno = r.fs.OpenFile(".", os.O_RDONLY, 0) + switch errno { + case 0: + return r.f, true + case syscall.ENOENT: + return nil, false + default: + panic(errno) // unexpected + } +} + +// Close implements fs.File +func (r *lazyDir) Close() syscall.Errno { + f := r.f + if f == nil { + return 0 // never opened + } + return f.Close() +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sys/stdio.go b/vendor/github.com/tetratelabs/wazero/internal/sys/stdio.go new file mode 100644 index 000000000..c9e852c5e --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sys/stdio.go @@ -0,0 +1,121 @@ +package sys + +import ( + "io" + "os" + "syscall" + "time" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" + "github.com/tetratelabs/wazero/internal/sysfs" +) + +// StdinFile is a fs.ModeDevice file for use implementing FdStdin. +// This is safer than reading from os.DevNull as it can never overrun +// operating system file descriptors. +type StdinFile struct { + noopStdinFile + io.Reader +} + +// Read implements the same method as documented on internalapi.File +func (f *StdinFile) Read(buf []byte) (int, syscall.Errno) { + n, err := f.Reader.Read(buf) + return n, platform.UnwrapOSError(err) +} + +type writerFile struct { + noopStdoutFile + + w io.Writer +} + +// Write implements the same method as documented on internalapi.File +func (f *writerFile) Write(buf []byte) (int, syscall.Errno) { + n, err := f.w.Write(buf) + return n, platform.UnwrapOSError(err) +} + +// noopStdinFile is a fs.ModeDevice file for use implementing FdStdin. This is +// safer than reading from os.DevNull as it can never overrun operating system +// file descriptors. +type noopStdinFile struct { + noopStdioFile +} + +// AccessMode implements the same method as documented on internalapi.File +func (noopStdinFile) AccessMode() int { + return syscall.O_RDONLY +} + +// Read implements the same method as documented on internalapi.File +func (noopStdinFile) Read([]byte) (int, syscall.Errno) { + return 0, 0 // Always EOF +} + +// PollRead implements the same method as documented on internalapi.File +func (noopStdinFile) PollRead(*time.Duration) (ready bool, errno syscall.Errno) { + return true, 0 // always ready to read nothing +} + +// noopStdoutFile is a fs.ModeDevice file for use implementing FdStdout and +// FdStderr. +type noopStdoutFile struct { + noopStdioFile +} + +// AccessMode implements the same method as documented on internalapi.File +func (noopStdoutFile) AccessMode() int { + return syscall.O_WRONLY +} + +// Write implements the same method as documented on internalapi.File +func (noopStdoutFile) Write(buf []byte) (int, syscall.Errno) { + return len(buf), 0 // same as io.Discard +} + +type noopStdioFile struct { + fsapi.UnimplementedFile +} + +// Stat implements the same method as documented on internalapi.File +func (noopStdioFile) Stat() (fsapi.Stat_t, syscall.Errno) { + return fsapi.Stat_t{Mode: modeDevice, Nlink: 1}, 0 +} + +// IsDir implements the same method as documented on internalapi.File +func (noopStdioFile) IsDir() (bool, syscall.Errno) { + return false, 0 +} + +// Close implements the same method as documented on internalapi.File +func (noopStdioFile) Close() (errno syscall.Errno) { return } + +func stdinFileEntry(r io.Reader) (*FileEntry, error) { + if r == nil { + return &FileEntry{Name: "stdin", IsPreopen: true, File: &noopStdinFile{}}, nil + } else if f, ok := r.(*os.File); ok { + if f, err := sysfs.NewStdioFile(true, f); err != nil { + return nil, err + } else { + return &FileEntry{Name: "stdin", IsPreopen: true, File: f}, nil + } + } else { + return &FileEntry{Name: "stdin", IsPreopen: true, File: &StdinFile{Reader: r}}, nil + } +} + +func stdioWriterFileEntry(name string, w io.Writer) (*FileEntry, error) { + if w == nil { + return &FileEntry{Name: name, IsPreopen: true, File: &noopStdoutFile{}}, nil + } else if f, ok := w.(*os.File); ok { + if f, err := sysfs.NewStdioFile(false, f); err != nil { + return nil, err + } else { + return &FileEntry{Name: name, IsPreopen: true, File: f}, nil + } + } else { + return &FileEntry{Name: name, IsPreopen: true, File: &writerFile{w: w}}, nil + } +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sys/sys.go b/vendor/github.com/tetratelabs/wazero/internal/sys/sys.go index a0b5dbd5b..f035712ee 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/sys/sys.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sys/sys.go @@ -4,10 +4,11 @@ import ( "errors" "fmt" "io" + "net" "time" + "github.com/tetratelabs/wazero/internal/fsapi" "github.com/tetratelabs/wazero/internal/platform" - "github.com/tetratelabs/wazero/internal/sysfs" "github.com/tetratelabs/wazero/sys" ) @@ -97,7 +98,7 @@ func (c *Context) Osyield() { c.osyield() } -// FS returns the possibly empty (sysfs.UnimplementedFS) file system context. +// FS returns the possibly empty (UnimplementedFS) file system context. func (c *Context) FS() *FSContext { return &c.fsc } @@ -108,20 +109,12 @@ func (c *Context) RandSource() io.Reader { return c.randSource } -// eofReader is safer than reading from os.DevNull as it can never overrun operating system file descriptors. -type eofReader struct{} - -// Read implements io.Reader -// Note: This doesn't use a pointer reference as it has no state and an empty struct doesn't allocate. -func (eofReader) Read([]byte) (int, error) { - return 0, io.EOF -} - -// DefaultContext returns Context with no values set except a possible nil fs.FS +// DefaultContext returns Context with no values set except a possible nil +// fsapi.FS. // -// This is only used for testing. -func DefaultContext(fs sysfs.FS) *Context { - if sysCtx, err := NewContext(0, nil, nil, nil, nil, nil, nil, nil, 0, nil, 0, nil, nil, fs); err != nil { +// Note: This is only used for testing. +func DefaultContext(fs fsapi.FS) *Context { + if sysCtx, err := NewContext(0, nil, nil, nil, nil, nil, nil, nil, 0, nil, 0, nil, nil, fs, nil); err != nil { panic(fmt.Errorf("BUG: DefaultContext should never error: %w", err)) } else { return sysCtx @@ -142,7 +135,8 @@ func NewContext( nanotimeResolution sys.ClockResolution, nanosleep sys.Nanosleep, osyield sys.Osyield, - rootFS sysfs.FS, + rootFS fsapi.FS, + tcpListeners []*net.TCPListener, ) (sysCtx *Context, err error) { sysCtx = &Context{args: args, environ: environ} @@ -195,9 +189,9 @@ func NewContext( } if rootFS != nil { - err = sysCtx.NewFSContext(stdin, stdout, stderr, rootFS) + err = sysCtx.NewFSContext(stdin, stdout, stderr, rootFS, tcpListeners) } else { - err = sysCtx.NewFSContext(stdin, stdout, stderr, sysfs.UnimplementedFS{}) + err = sysCtx.NewFSContext(stdin, stdout, stderr, fsapi.UnimplementedFS{}, tcpListeners) } return diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/adapter.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/adapter.go index 8ccd227ba..022ca6976 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/sysfs/adapter.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/adapter.go @@ -3,34 +3,31 @@ package sysfs import ( "fmt" "io/fs" - "os" "path" - "runtime" - "strings" "syscall" - "github.com/tetratelabs/wazero/internal/platform" + "github.com/tetratelabs/wazero/internal/fsapi" ) -// Adapt adapts the input to FS unless it is already one. Use NewDirFS instead +// Adapt adapts the input to api.FS unless it is already one. Use NewDirFS instead // of os.DirFS as it handles interop issues such as windows support. // -// Note: This performs no flag verification on FS.OpenFile. fs.FS cannot read -// flags as there is no parameter to pass them through with. Moreover, fs.FS +// Note: This performs no flag verification on OpenFile. fsapi.FS cannot read +// flags as there is no parameter to pass them through with. Moreover, fsapi.FS // documentation does not require the file to be present. In summary, we can't // enforce flag behavior. -func Adapt(fs fs.FS) FS { +func Adapt(fs fs.FS) fsapi.FS { if fs == nil { - return UnimplementedFS{} + return fsapi.UnimplementedFS{} } - if sys, ok := fs.(FS); ok { + if sys, ok := fs.(fsapi.FS); ok { return sys } return &adapter{fs: fs} } type adapter struct { - UnimplementedFS + fsapi.UnimplementedFS fs fs.FS } @@ -39,34 +36,26 @@ func (a *adapter) String() string { return fmt.Sprintf("%v", a.fs) } -// Open implements the same method as documented on fs.FS -func (a *adapter) Open(name string) (fs.File, error) { - return a.fs.Open(name) +// OpenFile implements the same method as documented on api.FS +func (a *adapter) OpenFile(path string, flag int, perm fs.FileMode) (fsapi.File, syscall.Errno) { + return OpenFSFile(a.fs, cleanPath(path), flag, perm) } -// OpenFile implements FS.OpenFile -func (a *adapter) OpenFile(path string, flag int, perm fs.FileMode) (fs.File, syscall.Errno) { - path = cleanPath(path) - f, err := a.fs.Open(path) - return f, platform.UnwrapOSError(err) -} - -// Stat implements FS.Stat -func (a *adapter) Stat(path string) (platform.Stat_t, syscall.Errno) { - name := cleanPath(path) - f, err := a.fs.Open(name) - if err != nil { - return platform.Stat_t{}, platform.UnwrapOSError(err) +// Stat implements the same method as documented on api.FS +func (a *adapter) Stat(path string) (fsapi.Stat_t, syscall.Errno) { + f, errno := a.OpenFile(path, syscall.O_RDONLY, 0) + if errno != 0 { + return fsapi.Stat_t{}, errno } defer f.Close() - return platform.StatFile(f) + return f.Stat() } -// Lstat implements FS.Lstat -func (a *adapter) Lstat(path string) (platform.Stat_t, syscall.Errno) { - // At this time, we make the assumption that fs.FS instances do not support +// Lstat implements the same method as documented on api.FS +func (a *adapter) Lstat(path string) (fsapi.Stat_t, syscall.Errno) { + // At this time, we make the assumption that api.FS instances do not support // symbolic links, therefore Lstat is the same as Stat. This is obviously - // not true but until fs.FS has a solid story for how to handle symlinks we + // not true but until api.FS has a solid story for how to handle symlinks we // are better off not making a decision that would be difficult to revert // later on. // @@ -87,26 +76,3 @@ func cleanPath(name string) string { cleaned = path.Clean(cleaned) // e.g. "sub/." -> "sub" return cleaned } - -// fsOpen implements the Open method as documented on fs.FS -func fsOpen(f FS, name string) (fs.File, error) { - if !fs.ValidPath(name) { // FS.OpenFile has fewer constraints than fs.FS - return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrInvalid} - } - - // This isn't a production-grade fs.FS implementation. The only special - // cases we address here are to pass testfs.TestFS. - - if runtime.GOOS == "windows" { - switch { - case strings.Contains(name, "\\"): - return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrInvalid} - } - } - - if f, err := f.OpenFile(name, os.O_RDONLY, 0); err != 0 { - return nil, &fs.PathError{Op: "open", Path: name, Err: err} - } else { - return f, nil - } -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/chown.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/chown.go similarity index 61% rename from vendor/github.com/tetratelabs/wazero/internal/platform/chown.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/chown.go index d8c273d58..93c774c92 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/chown.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/chown.go @@ -1,9 +1,10 @@ -package platform +package sysfs import ( - "io/fs" "os" "syscall" + + "github.com/tetratelabs/wazero/internal/platform" ) // Chown is like os.Chown, except it returns a syscall.Errno, not a @@ -14,7 +15,7 @@ import ( // See https://linux.die.net/man/3/chown func Chown(path string, uid, gid int) syscall.Errno { err := os.Chown(path, uid, gid) - return UnwrapOSError(err) + return platform.UnwrapOSError(err) } // Lchown is like os.Lchown, except it returns a syscall.Errno, not a @@ -25,17 +26,5 @@ func Chown(path string, uid, gid int) syscall.Errno { // See https://linux.die.net/man/3/lchown func Lchown(path string, uid, gid int) syscall.Errno { err := os.Lchown(path, uid, gid) - return UnwrapOSError(err) -} - -// ChownFile is like syscall.Fchown, but for nanosecond precision and -// fs.File instead of a file descriptor. This returns syscall.EBADF if the file -// or directory was closed. See https://linux.die.net/man/3/fchown -// -// Note: This always returns syscall.ENOSYS on windows. -func ChownFile(f fs.File, uid, gid int) syscall.Errno { - if f, ok := f.(fdFile); ok { - return fchown(f.Fd(), uid, gid) - } - return syscall.ENOSYS + return platform.UnwrapOSError(err) } diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/chown_unix.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/chown_unix.go new file mode 100644 index 000000000..5907a9d98 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/chown_unix.go @@ -0,0 +1,13 @@ +//go:build !windows + +package sysfs + +import ( + "syscall" + + "github.com/tetratelabs/wazero/internal/platform" +) + +func fchown(fd uintptr, uid, gid int) syscall.Errno { + return platform.UnwrapOSError(syscall.Fchown(int(fd), uid, gid)) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/chown_unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/chown_unsupported.go similarity index 93% rename from vendor/github.com/tetratelabs/wazero/internal/platform/chown_unsupported.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/chown_unsupported.go index 38b7187d1..5e7fd79be 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/chown_unsupported.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/chown_unsupported.go @@ -1,6 +1,6 @@ //go:build windows -package platform +package sysfs import "syscall" diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_linux.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_linux.go new file mode 100644 index 000000000..715a952df --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_linux.go @@ -0,0 +1,14 @@ +//go:build linux + +package sysfs + +import ( + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/platform" +) + +func datasync(f *os.File) syscall.Errno { + return platform.UnwrapOSError(syscall.Fdatasync(int(f.Fd()))) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_unsupported.go new file mode 100644 index 000000000..4261f5657 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_unsupported.go @@ -0,0 +1,13 @@ +//go:build !linux + +package sysfs + +import ( + "os" + "syscall" +) + +func datasync(f *os.File) syscall.Errno { + // Attempt to sync everything, even if we only need to sync the data. + return fsync(f) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/dir.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/dir.go new file mode 100644 index 000000000..8462e846f --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/dir.go @@ -0,0 +1,26 @@ +package sysfs + +import ( + "io" + "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" +) + +func adjustReaddirErr(f fsapi.File, isClosed bool, err error) syscall.Errno { + if err == io.EOF { + return 0 // e.g. Readdir on darwin returns io.EOF, but linux doesn't. + } else if errno := platform.UnwrapOSError(err); errno != 0 { + errno = dirError(f, isClosed, errno) + // Ignore errors when the file was closed or removed. + switch errno { + case syscall.EIO, syscall.EBADF: // closed while open + return 0 + case syscall.ENOENT: // Linux error when removed while open + return 0 + } + return errno + } + return 0 +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/dirfs.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/dirfs.go index 92c81b52b..5f2645de8 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/sysfs/dirfs.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/dirfs.go @@ -5,10 +5,11 @@ import ( "os" "syscall" + "github.com/tetratelabs/wazero/internal/fsapi" "github.com/tetratelabs/wazero/internal/platform" ) -func NewDirFS(dir string) FS { +func NewDirFS(dir string) fsapi.FS { return &dirFS{ dir: dir, cleanedDir: ensureTrailingPathSeparator(dir), @@ -23,7 +24,7 @@ func ensureTrailingPathSeparator(dir string) string { } type dirFS struct { - UnimplementedFS + fsapi.UnimplementedFS dir string // cleanedDir is for easier OS-specific concatenation, as it always has // a trailing path separator. @@ -35,27 +36,22 @@ func (d *dirFS) String() string { return d.dir } -// Open implements the same method as documented on fs.FS -func (d *dirFS) Open(name string) (fs.File, error) { - return fsOpen(d, name) +// OpenFile implements the same method as documented on api.FS +func (d *dirFS) OpenFile(path string, flag int, perm fs.FileMode) (fsapi.File, syscall.Errno) { + return OpenOSFile(d.join(path), flag, perm) } -// OpenFile implements FS.OpenFile -func (d *dirFS) OpenFile(path string, flag int, perm fs.FileMode) (fs.File, syscall.Errno) { - return platform.OpenFile(d.join(path), flag, perm) +// Lstat implements the same method as documented on api.FS +func (d *dirFS) Lstat(path string) (fsapi.Stat_t, syscall.Errno) { + return lstat(d.join(path)) } -// Lstat implements FS.Lstat -func (d *dirFS) Lstat(path string) (platform.Stat_t, syscall.Errno) { - return platform.Lstat(d.join(path)) +// Stat implements the same method as documented on api.FS +func (d *dirFS) Stat(path string) (fsapi.Stat_t, syscall.Errno) { + return stat(d.join(path)) } -// Stat implements FS.Stat -func (d *dirFS) Stat(path string) (platform.Stat_t, syscall.Errno) { - return platform.Stat(d.join(path)) -} - -// Mkdir implements FS.Mkdir +// Mkdir implements the same method as documented on api.FS func (d *dirFS) Mkdir(path string, perm fs.FileMode) (errno syscall.Errno) { err := os.Mkdir(d.join(path), perm) if errno = platform.UnwrapOSError(err); errno == syscall.ENOTDIR { @@ -64,29 +60,29 @@ func (d *dirFS) Mkdir(path string, perm fs.FileMode) (errno syscall.Errno) { return } -// Chmod implements FS.Chmod +// Chmod implements the same method as documented on api.FS func (d *dirFS) Chmod(path string, perm fs.FileMode) syscall.Errno { err := os.Chmod(d.join(path), perm) return platform.UnwrapOSError(err) } -// Chown implements FS.Chown +// Chown implements the same method as documented on api.FS func (d *dirFS) Chown(path string, uid, gid int) syscall.Errno { - return platform.Chown(d.join(path), uid, gid) + return Chown(d.join(path), uid, gid) } -// Lchown implements FS.Lchown +// Lchown implements the same method as documented on api.FS func (d *dirFS) Lchown(path string, uid, gid int) syscall.Errno { - return platform.Lchown(d.join(path), uid, gid) + return Lchown(d.join(path), uid, gid) } -// Rename implements FS.Rename +// Rename implements the same method as documented on api.FS func (d *dirFS) Rename(from, to string) syscall.Errno { from, to = d.join(from), d.join(to) - return platform.Rename(from, to) + return Rename(from, to) } -// Readlink implements FS.Readlink +// Readlink implements the same method as documented on api.FS func (d *dirFS) Readlink(path string) (string, syscall.Errno) { // Note: do not use syscall.Readlink as that causes race on Windows. // In any case, syscall.Readlink does almost the same logic as os.Readlink. @@ -97,24 +93,24 @@ func (d *dirFS) Readlink(path string) (string, syscall.Errno) { return platform.ToPosixPath(dst), 0 } -// Link implements FS.Link. +// Link implements the same method as documented on api.FS func (d *dirFS) Link(oldName, newName string) syscall.Errno { err := os.Link(d.join(oldName), d.join(newName)) return platform.UnwrapOSError(err) } -// Rmdir implements FS.Rmdir +// Rmdir implements the same method as documented on api.FS func (d *dirFS) Rmdir(path string) syscall.Errno { err := syscall.Rmdir(d.join(path)) return platform.UnwrapOSError(err) } -// Unlink implements FS.Unlink +// Unlink implements the same method as documented on api.FS func (d *dirFS) Unlink(path string) (err syscall.Errno) { - return platform.Unlink(d.join(path)) + return Unlink(d.join(path)) } -// Symlink implements FS.Symlink +// Symlink implements the same method as documented on api.FS func (d *dirFS) Symlink(oldName, link string) syscall.Errno { // Note: do not resolve `oldName` relative to this dirFS. The link result is always resolved // when dereference the `link` on its usage (e.g. readlink, read, etc). @@ -123,12 +119,12 @@ func (d *dirFS) Symlink(oldName, link string) syscall.Errno { return platform.UnwrapOSError(err) } -// Utimens implements FS.Utimens +// Utimens implements the same method as documented on api.FS func (d *dirFS) Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.Errno { - return platform.Utimens(d.join(path), times, symlinkFollow) + return Utimens(d.join(path), times, symlinkFollow) } -// Truncate implements FS.Truncate +// Truncate implements the same method as documented on api.FS func (d *dirFS) Truncate(path string, size int64) syscall.Errno { // Use os.Truncate as syscall.Truncate doesn't exist on Windows. err := os.Truncate(d.join(path), size) diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/file.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/file.go new file mode 100644 index 000000000..f4a7cbf8a --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/file.go @@ -0,0 +1,434 @@ +package sysfs + +import ( + "io" + "io/fs" + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" +) + +func NewStdioFile(stdin bool, f fs.File) (fsapi.File, error) { + // Return constant stat, which has fake times, but keep the underlying + // file mode. Fake times are needed to pass wasi-testsuite. + // https://github.com/WebAssembly/wasi-testsuite/blob/af57727/tests/rust/src/bin/fd_filestat_get.rs#L1-L19 + var mode fs.FileMode + if st, err := f.Stat(); err != nil { + return nil, err + } else { + mode = st.Mode() + } + var flag int + if stdin { + flag = syscall.O_RDONLY + } else { + flag = syscall.O_WRONLY + } + var file fsapi.File + if of, ok := f.(*os.File); ok { + // This is ok because functions that need path aren't used by stdioFile + file = newOsFile("", flag, 0, of) + } else { + file = &fsFile{file: f} + } + return &stdioFile{File: file, st: fsapi.Stat_t{Mode: mode, Nlink: 1}}, nil +} + +func OpenFile(path string, flag int, perm fs.FileMode) (*os.File, syscall.Errno) { + if flag&fsapi.O_DIRECTORY != 0 && flag&(syscall.O_WRONLY|syscall.O_RDWR) != 0 { + return nil, syscall.EISDIR // invalid to open a directory writeable + } + return openFile(path, flag, perm) +} + +func OpenOSFile(path string, flag int, perm fs.FileMode) (fsapi.File, syscall.Errno) { + f, errno := OpenFile(path, flag, perm) + if errno != 0 { + return nil, errno + } + return newOsFile(path, flag, perm, f), 0 +} + +func OpenFSFile(fs fs.FS, path string, flag int, perm fs.FileMode) (fsapi.File, syscall.Errno) { + if flag&fsapi.O_DIRECTORY != 0 && flag&(syscall.O_WRONLY|syscall.O_RDWR) != 0 { + return nil, syscall.EISDIR // invalid to open a directory writeable + } + f, err := fs.Open(path) + if errno := platform.UnwrapOSError(err); errno != 0 { + return nil, errno + } + // Don't return an os.File because the path is not absolute. osFile needs + // the path to be real and certain fs.File impls are subrooted. + return &fsFile{fs: fs, name: path, file: f}, 0 +} + +type stdioFile struct { + fsapi.File + st fsapi.Stat_t +} + +// IsDir implements File.IsDir +func (f *stdioFile) IsDir() (bool, syscall.Errno) { + return false, 0 +} + +// Stat implements File.Stat +func (f *stdioFile) Stat() (fsapi.Stat_t, syscall.Errno) { + return f.st, 0 +} + +// Close implements File.Close +func (f *stdioFile) Close() syscall.Errno { + return 0 +} + +// fsFile is used for wrapped os.File, like os.Stdin or any fs.File +// implementation. Notably, this does not have access to the full file path. +// so certain operations can't be supported, such as inode lookups on Windows. +type fsFile struct { + fsapi.UnimplementedFile + + // fs is the file-system that opened the file, or nil when wrapped for + // pre-opens like stdio. + fs fs.FS + + // name is what was used in fs for Open, so it may not be the actual path. + name string + + // file is always set, possibly an os.File like os.Stdin. + file fs.File + + // closed is true when closed was called. This ensures proper syscall.EBADF + closed bool + + // cachedStat includes fields that won't change while a file is open. + cachedSt *cachedStat +} + +type cachedStat struct { + // fileType is the same as what's documented on Dirent. + fileType fs.FileMode + + // ino is the same as what's documented on Dirent. + ino uint64 +} + +// cachedStat returns the cacheable parts of platform.sys.Stat_t or an error if +// they couldn't be retrieved. +func (f *fsFile) cachedStat() (fileType fs.FileMode, ino uint64, errno syscall.Errno) { + if f.cachedSt == nil { + if _, errno = f.Stat(); errno != 0 { + return + } + } + return f.cachedSt.fileType, f.cachedSt.ino, 0 +} + +// Ino implements File.Ino +func (f *fsFile) Ino() (uint64, syscall.Errno) { + if _, ino, errno := f.cachedStat(); errno != 0 { + return 0, errno + } else { + return ino, 0 + } +} + +// IsAppend implements File.IsAppend +func (f *fsFile) IsAppend() bool { + return false +} + +// SetAppend implements File.SetAppend +func (f *fsFile) SetAppend(bool) (errno syscall.Errno) { + return fileError(f, f.closed, syscall.ENOSYS) +} + +// IsDir implements File.IsDir +func (f *fsFile) IsDir() (bool, syscall.Errno) { + if ft, _, errno := f.cachedStat(); errno != 0 { + return false, errno + } else if ft.Type() == fs.ModeDir { + return true, 0 + } + return false, 0 +} + +// Stat implements File.Stat +func (f *fsFile) Stat() (st fsapi.Stat_t, errno syscall.Errno) { + if f.closed { + errno = syscall.EBADF + return + } + + // While some functions in fsapi.File need the full path, especially in + // Windows, stat does not. Casting here allows os.DirFS to return inode + // information. + if of, ok := f.file.(*os.File); ok { + if st, errno = statFile(of); errno != 0 { + return + } + return f.cacheStat(st) + } else if t, err := f.file.Stat(); err != nil { + errno = platform.UnwrapOSError(err) + return + } else { + st = StatFromDefaultFileInfo(t) + return f.cacheStat(st) + } +} + +func (f *fsFile) cacheStat(st fsapi.Stat_t) (fsapi.Stat_t, syscall.Errno) { + f.cachedSt = &cachedStat{fileType: st.Mode & fs.ModeType, ino: st.Ino} + return st, 0 +} + +// Read implements File.Read +func (f *fsFile) Read(buf []byte) (n int, errno syscall.Errno) { + if n, errno = read(f.file, buf); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + return +} + +// Pread implements File.Pread +func (f *fsFile) Pread(buf []byte, off int64) (n int, errno syscall.Errno) { + if ra, ok := f.file.(io.ReaderAt); ok { + if n, errno = pread(ra, buf, off); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + return + } + + // See /RATIONALE.md "fd_pread: io.Seeker fallback when io.ReaderAt is not supported" + if rs, ok := f.file.(io.ReadSeeker); ok { + // Determine the current position in the file, as we need to revert it. + currentOffset, err := rs.Seek(0, io.SeekCurrent) + if err != nil { + return 0, fileError(f, f.closed, platform.UnwrapOSError(err)) + } + + // Put the read position back when complete. + defer func() { _, _ = rs.Seek(currentOffset, io.SeekStart) }() + + // If the current offset isn't in sync with this reader, move it. + if off != currentOffset { + if _, err = rs.Seek(off, io.SeekStart); err != nil { + return 0, fileError(f, f.closed, platform.UnwrapOSError(err)) + } + } + + n, err = rs.Read(buf) + if errno = platform.UnwrapOSError(err); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + } else { + errno = syscall.ENOSYS // unsupported + } + return +} + +// Seek implements File.Seek. +func (f *fsFile) Seek(offset int64, whence int) (newOffset int64, errno syscall.Errno) { + // If this is a directory, and we're attempting to seek to position zero, + // we have to re-open the file to ensure the directory state is reset. + var isDir bool + if offset == 0 && whence == io.SeekStart { + if isDir, errno = f.IsDir(); errno != 0 { + return + } else if isDir { + return 0, f.reopen() + } + } + + if s, ok := f.file.(io.Seeker); ok { + if newOffset, errno = seek(s, offset, whence); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + } else { + errno = syscall.ENOSYS // unsupported + } + return +} + +func (f *fsFile) reopen() syscall.Errno { + _ = f.close() + var err error + f.file, err = f.fs.Open(f.name) + return platform.UnwrapOSError(err) +} + +// Readdir implements File.Readdir. Notably, this uses fs.ReadDirFile if +// available. +func (f *fsFile) Readdir(n int) (dirents []fsapi.Dirent, errno syscall.Errno) { + if of, ok := f.file.(*os.File); ok { + // We can't use f.name here because it is the path up to the fsapi.FS, + // not necessarily the real path. For this reason, Windows may not be + // able to populate inodes. However, Darwin and Linux will. + if dirents, errno = readdir(of, "", n); errno != 0 { + errno = adjustReaddirErr(f, f.closed, errno) + } + return + } + + // Try with fs.ReadDirFile which is available on api.FS implementations + // like embed:fs. + if rdf, ok := f.file.(fs.ReadDirFile); ok { + entries, e := rdf.ReadDir(n) + if errno = adjustReaddirErr(f, f.closed, e); errno != 0 { + return + } + dirents = make([]fsapi.Dirent, 0, len(entries)) + for _, e := range entries { + // By default, we don't attempt to read inode data + dirents = append(dirents, fsapi.Dirent{Name: e.Name(), Type: e.Type()}) + } + } else { + errno = syscall.ENOTDIR + } + return +} + +// Write implements File.Write +func (f *fsFile) Write(buf []byte) (n int, errno syscall.Errno) { + if w, ok := f.file.(io.Writer); ok { + if n, errno = write(w, buf); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + } else { + errno = syscall.ENOSYS // unsupported + } + return +} + +// Pwrite implements File.Pwrite +func (f *fsFile) Pwrite(buf []byte, off int64) (n int, errno syscall.Errno) { + if wa, ok := f.file.(io.WriterAt); ok { + if n, errno = pwrite(wa, buf, off); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + } else { + errno = syscall.ENOSYS // unsupported + } + return +} + +// Close implements File.Close +func (f *fsFile) Close() syscall.Errno { + if f.closed { + return 0 + } + f.closed = true + return f.close() +} + +func (f *fsFile) close() syscall.Errno { + return platform.UnwrapOSError(f.file.Close()) +} + +// dirError is used for commands that work against a directory, but not a file. +func dirError(f fsapi.File, isClosed bool, errno syscall.Errno) syscall.Errno { + if vErrno := validate(f, isClosed, false, true); vErrno != 0 { + return vErrno + } + return errno +} + +// fileError is used for commands that work against a file, but not a directory. +func fileError(f fsapi.File, isClosed bool, errno syscall.Errno) syscall.Errno { + if vErrno := validate(f, isClosed, true, false); vErrno != 0 { + return vErrno + } + return errno +} + +// validate is used to making syscalls which will fail. +func validate(f fsapi.File, isClosed, wantFile, wantDir bool) syscall.Errno { + if isClosed { + return syscall.EBADF + } + + isDir, errno := f.IsDir() + if errno != 0 { + return errno + } + + if wantFile && isDir { + return syscall.EISDIR + } else if wantDir && !isDir { + return syscall.ENOTDIR + } + return 0 +} + +func read(r io.Reader, buf []byte) (n int, errno syscall.Errno) { + if len(buf) == 0 { + return 0, 0 // less overhead on zero-length reads. + } + + n, err := r.Read(buf) + return n, platform.UnwrapOSError(err) +} + +func pread(ra io.ReaderAt, buf []byte, off int64) (n int, errno syscall.Errno) { + if len(buf) == 0 { + return 0, 0 // less overhead on zero-length reads. + } + + n, err := ra.ReadAt(buf, off) + return n, platform.UnwrapOSError(err) +} + +func seek(s io.Seeker, offset int64, whence int) (int64, syscall.Errno) { + if uint(whence) > io.SeekEnd { + return 0, syscall.EINVAL // negative or exceeds the largest valid whence + } + + newOffset, err := s.Seek(offset, whence) + return newOffset, platform.UnwrapOSError(err) +} + +func readdir(f *os.File, path string, n int) (dirents []fsapi.Dirent, errno syscall.Errno) { + fis, e := f.Readdir(n) + if errno = platform.UnwrapOSError(e); errno != 0 { + return + } + + dirents = make([]fsapi.Dirent, 0, len(fis)) + + // linux/darwin won't have to fan out to lstat, but windows will. + var ino uint64 + for fi := range fis { + t := fis[fi] + if ino, errno = inoFromFileInfo(path, t); errno != 0 { + return + } + dirents = append(dirents, fsapi.Dirent{Name: t.Name(), Ino: ino, Type: t.Mode().Type()}) + } + return +} + +func write(w io.Writer, buf []byte) (n int, errno syscall.Errno) { + if len(buf) == 0 { + return 0, 0 // less overhead on zero-length writes. + } + + n, err := w.Write(buf) + return n, platform.UnwrapOSError(err) +} + +func pwrite(w io.WriterAt, buf []byte, off int64) (n int, errno syscall.Errno) { + if len(buf) == 0 { + return 0, 0 // less overhead on zero-length writes. + } + + n, err := w.WriteAt(buf, off) + return n, platform.UnwrapOSError(err) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/file_test.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/file_test.go new file mode 100644 index 000000000..3f10c6126 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/file_test.go @@ -0,0 +1,1061 @@ +package sysfs + +import ( + "embed" + "io" + "io/fs" + "os" + "path" + "runtime" + "strings" + "syscall" + "testing" + gofstest "testing/fstest" + "time" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" + "github.com/tetratelabs/wazero/internal/testing/require" +) + +//go:embed file_test.go +var embedFS embed.FS + +var ( + //go:embed testdata + testdata embed.FS + wazeroFile = "wazero.txt" + emptyFile = "empty.txt" +) + +func TestStdioFileSetNonblock(t *testing.T) { + // Test using os.Pipe as it is known to support non-blocking reads. + r, w, err := os.Pipe() + require.NoError(t, err) + defer r.Close() + defer w.Close() + + rF, err := NewStdioFile(true, r) + require.NoError(t, err) + + errno := rF.SetNonblock(true) + require.EqualErrno(t, 0, errno) + require.True(t, rF.IsNonblock()) + + errno = rF.SetNonblock(false) + require.EqualErrno(t, 0, errno) + require.False(t, rF.IsNonblock()) +} + +func TestRegularFileSetNonblock(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Nonblock on regular files is not supported on Windows") + } + + // Test using os.Pipe as it is known to support non-blocking reads. + r, w, err := os.Pipe() + require.NoError(t, err) + defer r.Close() + defer w.Close() + + rF := newOsFile("", syscall.O_RDONLY, 0, r) + + errno := rF.SetNonblock(true) + require.EqualErrno(t, 0, errno) + require.True(t, rF.IsNonblock()) + + // Read from the file without ever writing to it should not block. + buf := make([]byte, 8) + _, e := rF.Read(buf) + require.EqualErrno(t, syscall.EAGAIN, e) + + errno = rF.SetNonblock(false) + require.EqualErrno(t, 0, errno) + require.False(t, rF.IsNonblock()) +} + +func TestReadFdNonblock(t *testing.T) { + // Test using os.Pipe as it is known to support non-blocking reads. + r, w, err := os.Pipe() + require.NoError(t, err) + defer r.Close() + defer w.Close() + + fd := r.Fd() + err = setNonblock(fd, true) + require.NoError(t, err) + + // Read from the file without ever writing to it should not block. + buf := make([]byte, 8) + _, e := readFd(fd, buf) + if runtime.GOOS == "windows" { + require.EqualErrno(t, syscall.ENOSYS, e) + } else { + require.EqualErrno(t, syscall.EAGAIN, e) + } +} + +func TestFileSetAppend(t *testing.T) { + tmpDir := t.TempDir() + + fPath := path.Join(tmpDir, "file") + require.NoError(t, os.WriteFile(fPath, []byte("0123456789"), 0o600)) + + // Open without APPEND. + f, errno := OpenOSFile(fPath, os.O_RDWR, 0o600) + require.EqualErrno(t, 0, errno) + require.False(t, f.IsAppend()) + + // Set the APPEND flag. + require.EqualErrno(t, 0, f.SetAppend(true)) + require.True(t, f.IsAppend()) + + requireFileContent := func(exp string) { + buf, err := os.ReadFile(fPath) + require.NoError(t, err) + require.Equal(t, exp, string(buf)) + } + + // with O_APPEND flag, the data is appended to buffer. + _, errno = f.Write([]byte("wazero")) + require.EqualErrno(t, 0, errno) + requireFileContent("0123456789wazero") + + // Remove the APPEND flag. + require.EqualErrno(t, 0, f.SetAppend(false)) + require.False(t, f.IsAppend()) + + // without O_APPEND flag, the data writes at offset zero + _, errno = f.Write([]byte("wazero")) + require.EqualErrno(t, 0, errno) + requireFileContent("wazero6789wazero") +} + +func TestFileIno(t *testing.T) { + tmpDir := t.TempDir() + dirFS, embedFS, mapFS := dirEmbedMapFS(t, tmpDir) + + // get the expected inode + st, errno := stat(tmpDir) + require.EqualErrno(t, 0, errno) + + tests := []struct { + name string + fs fs.FS + expectedIno uint64 + }{ + {name: "os.DirFS", fs: dirFS, expectedIno: st.Ino}, + {name: "embed.api.FS", fs: embedFS}, + {name: "fstest.MapFS", fs: mapFS}, + } + + for _, tc := range tests { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + d, errno := OpenFSFile(tc.fs, ".", syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer d.Close() + + ino, errno := d.Ino() + require.EqualErrno(t, 0, errno) + if !canReadDirInode() { + tc.expectedIno = 0 + } + require.Equal(t, tc.expectedIno, ino) + }) + } + + t.Run("OS", func(t *testing.T) { + d, errno := OpenOSFile(tmpDir, syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer d.Close() + + ino, errno := d.Ino() + require.EqualErrno(t, 0, errno) + if canReadDirInode() { + require.Equal(t, st.Ino, ino) + } else { + require.Zero(t, ino) + } + }) +} + +func canReadDirInode() bool { + if runtime.GOOS != "windows" { + return true + } else { + return strings.HasPrefix(runtime.Version(), "go1.20") + } +} + +func TestFileIsDir(t *testing.T) { + dirFS, embedFS, mapFS := dirEmbedMapFS(t, t.TempDir()) + + tests := []struct { + name string + fs fs.FS + }{ + {name: "os.DirFS", fs: dirFS}, + {name: "embed.api.FS", fs: embedFS}, + {name: "fstest.MapFS", fs: mapFS}, + } + + for _, tc := range tests { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + t.Run("file", func(t *testing.T) { + f, errno := OpenFSFile(tc.fs, wazeroFile, syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer f.Close() + + isDir, errno := f.IsDir() + require.EqualErrno(t, 0, errno) + require.False(t, isDir) + }) + + t.Run("dir", func(t *testing.T) { + d, errno := OpenFSFile(tc.fs, ".", syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer d.Close() + + isDir, errno := d.IsDir() + require.EqualErrno(t, 0, errno) + require.True(t, isDir) + }) + }) + } + + t.Run("OS dir", func(t *testing.T) { + d, errno := OpenOSFile(t.TempDir(), syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer d.Close() + + isDir, errno := d.IsDir() + require.EqualErrno(t, 0, errno) + require.True(t, isDir) + }) +} + +func TestFileReadAndPread(t *testing.T) { + dirFS, embedFS, mapFS := dirEmbedMapFS(t, t.TempDir()) + + tests := []struct { + name string + fs fs.FS + }{ + {name: "os.DirFS", fs: dirFS}, + {name: "embed.api.FS", fs: embedFS}, + {name: "fstest.MapFS", fs: mapFS}, + } + + buf := make([]byte, 3) + + for _, tc := range tests { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + f, errno := OpenFSFile(tc.fs, wazeroFile, syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer f.Close() + + // The file should be readable (base case) + requireRead(t, f, buf) + require.Equal(t, "waz", string(buf)) + buf = buf[:] + + // We should be able to pread from zero also + requirePread(t, f, buf, 0) + require.Equal(t, "waz", string(buf)) + buf = buf[:] + + // If the offset didn't change, read should expect the next three chars. + requireRead(t, f, buf) + require.Equal(t, "ero", string(buf)) + buf = buf[:] + + // We should also be able pread from any offset + requirePread(t, f, buf, 2) + require.Equal(t, "zer", string(buf)) + }) + } +} + +func TestFilePollRead(t *testing.T) { + // Test using os.Pipe as it is known to support poll. + r, w, err := os.Pipe() + require.NoError(t, err) + defer r.Close() + defer w.Close() + + rF, err := NewStdioFile(true, r) + require.NoError(t, err) + buf := make([]byte, 10) + timeout := time.Duration(0) // return immediately + + // When there's nothing in the pipe, it isn't ready. + ready, errno := rF.PollRead(&timeout) + if runtime.GOOS == "windows" { + require.EqualErrno(t, syscall.ENOSYS, errno) + t.Skip("TODO: windows File.PollRead") + } + require.EqualErrno(t, 0, errno) + require.False(t, ready) + + // Write to the pipe to make the data available + expected := []byte("wazero") + _, err = w.Write([]byte("wazero")) + require.NoError(t, err) + + // We should now be able to poll ready + ready, errno = rF.PollRead(&timeout) + require.EqualErrno(t, 0, errno) + require.True(t, ready) + + // We should now be able to read from the pipe + n, errno := rF.Read(buf) + require.EqualErrno(t, 0, errno) + require.Equal(t, len(expected), n) + require.Equal(t, expected, buf[:len(expected)]) +} + +func requireRead(t *testing.T, f fsapi.File, buf []byte) { + n, errno := f.Read(buf) + require.EqualErrno(t, 0, errno) + require.Equal(t, len(buf), n) +} + +func requirePread(t *testing.T, f fsapi.File, buf []byte, off int64) { + n, errno := f.Pread(buf, off) + require.EqualErrno(t, 0, errno) + require.Equal(t, len(buf), n) +} + +func TestFileRead_empty(t *testing.T) { + dirFS, embedFS, mapFS := dirEmbedMapFS(t, t.TempDir()) + + tests := []struct { + name string + fs fs.FS + }{ + {name: "os.DirFS", fs: dirFS}, + {name: "embed.api.FS", fs: embedFS}, + {name: "fstest.MapFS", fs: mapFS}, + } + + buf := make([]byte, 3) + + for _, tc := range tests { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + f, errno := OpenFSFile(tc.fs, emptyFile, syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer f.Close() + + t.Run("Read", func(t *testing.T) { + // We should be able to read an empty file + n, errno := f.Read(buf) + require.EqualErrno(t, 0, errno) + require.Zero(t, n) + }) + + t.Run("Pread", func(t *testing.T) { + n, errno := f.Pread(buf, 0) + require.EqualErrno(t, 0, errno) + require.Zero(t, n) + }) + }) + } +} + +type maskFS struct { + fs.FS +} + +func (m *maskFS) Open(name string) (fs.File, error) { + f, err := m.FS.Open(name) + return struct{ fs.File }{f}, err +} + +func TestFilePread_Unsupported(t *testing.T) { + embedFS, err := fs.Sub(testdata, "testdata") + require.NoError(t, err) + + f, errno := OpenFSFile(&maskFS{embedFS}, emptyFile, syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer f.Close() + + buf := make([]byte, 3) + _, errno = f.Pread(buf, 0) + require.EqualErrno(t, syscall.ENOSYS, errno) +} + +func TestFileRead_Errors(t *testing.T) { + // Create the file + path := path.Join(t.TempDir(), emptyFile) + + // Open the file write-only + flag := syscall.O_WRONLY | syscall.O_CREAT + f := requireOpenFile(t, path, flag, 0o600) + defer f.Close() + buf := make([]byte, 5) + + tests := []struct { + name string + fn func(fsapi.File) syscall.Errno + }{ + {name: "Read", fn: func(f fsapi.File) syscall.Errno { + _, errno := f.Read(buf) + return errno + }}, + {name: "Pread", fn: func(f fsapi.File) syscall.Errno { + _, errno := f.Pread(buf, 0) + return errno + }}, + } + + for _, tc := range tests { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + t.Run("EBADF when not open for reading", func(t *testing.T) { + // The descriptor exists, but not open for reading + errno := tc.fn(f) + require.EqualErrno(t, syscall.EBADF, errno) + }) + testEISDIR(t, tc.fn) + }) + } +} + +func TestFileSeek(t *testing.T) { + dirFS, embedFS, mapFS := dirEmbedMapFS(t, t.TempDir()) + + tests := []struct { + name string + fs fs.FS + }{ + {name: "os.DirFS", fs: dirFS}, + {name: "embed.api.FS", fs: embedFS}, + {name: "fstest.MapFS", fs: mapFS}, + } + + buf := make([]byte, 3) + + for _, tc := range tests { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + f, errno := OpenFSFile(tc.fs, wazeroFile, syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer f.Close() + + // Shouldn't be able to use an invalid whence + _, errno = f.Seek(0, io.SeekEnd+1) + require.EqualErrno(t, syscall.EINVAL, errno) + _, errno = f.Seek(0, -1) + require.EqualErrno(t, syscall.EINVAL, errno) + + // Shouldn't be able to seek before the file starts. + _, errno = f.Seek(-1, io.SeekStart) + require.EqualErrno(t, syscall.EINVAL, errno) + + requireRead(t, f, buf) // read 3 bytes + + // Seek to the start + newOffset, errno := f.Seek(0, io.SeekStart) + require.EqualErrno(t, 0, errno) + + // verify we can re-read from the beginning now. + require.Zero(t, newOffset) + requireRead(t, f, buf) // read 3 bytes again + require.Equal(t, "waz", string(buf)) + buf = buf[:] + + // Seek to the start with zero allows you to read it back. + newOffset, errno = f.Seek(0, io.SeekCurrent) + require.EqualErrno(t, 0, errno) + require.Equal(t, int64(3), newOffset) + + // Seek to the last two bytes + newOffset, errno = f.Seek(-2, io.SeekEnd) + require.EqualErrno(t, 0, errno) + + // verify we can read the last two bytes + require.Equal(t, int64(5), newOffset) + n, errno := f.Read(buf) + require.EqualErrno(t, 0, errno) + require.Equal(t, 2, n) + require.Equal(t, "o\n", string(buf[:2])) + + t.Run("directory seek to zero", func(t *testing.T) { + d, errno := OpenFSFile(tc.fs, ".", syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer d.Close() + + _, errno = d.Seek(0, io.SeekStart) + require.EqualErrno(t, 0, errno) + }) + }) + } + + t.Run("os.File directory seek to zero", func(t *testing.T) { + d := requireOpenFile(t, os.TempDir(), syscall.O_RDONLY|fsapi.O_DIRECTORY, 0o666) + defer d.Close() + + _, errno := d.Seek(0, io.SeekStart) + require.EqualErrno(t, 0, errno) + }) + + seekToZero := func(f fsapi.File) syscall.Errno { + _, errno := f.Seek(0, io.SeekStart) + return errno + } + testEBADFIfFileClosed(t, seekToZero) +} + +func requireSeek(t *testing.T, f fsapi.File, off int64, whence int) int64 { + n, errno := f.Seek(off, whence) + require.EqualErrno(t, 0, errno) + return n +} + +func TestFileSeek_empty(t *testing.T) { + dirFS, embedFS, mapFS := dirEmbedMapFS(t, t.TempDir()) + + tests := []struct { + name string + fs fs.FS + }{ + {name: "os.DirFS", fs: dirFS}, + {name: "embed.api.FS", fs: embedFS}, + {name: "fstest.MapFS", fs: mapFS}, + } + + for _, tc := range tests { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + f, errno := OpenFSFile(tc.fs, emptyFile, syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer f.Close() + + t.Run("Start", func(t *testing.T) { + require.Zero(t, requireSeek(t, f, 0, io.SeekStart)) + }) + + t.Run("Current", func(t *testing.T) { + require.Zero(t, requireSeek(t, f, 0, io.SeekCurrent)) + }) + + t.Run("End", func(t *testing.T) { + require.Zero(t, requireSeek(t, f, 0, io.SeekEnd)) + }) + }) + } +} + +func TestFileSeek_Unsupported(t *testing.T) { + embedFS, err := fs.Sub(testdata, "testdata") + require.NoError(t, err) + + f, errno := OpenFSFile(&maskFS{embedFS}, emptyFile, syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer f.Close() + + _, errno = f.Seek(0, io.SeekCurrent) + require.EqualErrno(t, syscall.ENOSYS, errno) +} + +func TestFileWriteAndPwrite(t *testing.T) { + // fsapi.FS doesn't support writes, and there is no other built-in + // implementation except os.File. + path := path.Join(t.TempDir(), wazeroFile) + f := requireOpenFile(t, path, syscall.O_RDWR|os.O_CREATE, 0o600) + defer f.Close() + + text := "wazero" + buf := make([]byte, 3) + copy(buf, text[:3]) + + // The file should be writeable + requireWrite(t, f, buf) + + // We should be able to pwrite at gap + requirePwrite(t, f, buf, 6) + + copy(buf, text[3:]) + + // If the offset didn't change, the next chars will write after the + // first + requireWrite(t, f, buf) + + // We should be able to pwrite the same bytes as above + requirePwrite(t, f, buf, 9) + + // We should also be able to pwrite past the above. + requirePwrite(t, f, buf, 12) + + b, err := os.ReadFile(path) + require.NoError(t, err) + + // We expect to have written the text two and a half times: + // 1. Write: (file offset 0) "waz" + // 2. Pwrite: offset 6 "waz" + // 3. Write: (file offset 3) "ero" + // 4. Pwrite: offset 9 "ero" + // 4. Pwrite: offset 12 "ero" + require.Equal(t, "wazerowazeroero", string(b)) +} + +func requireWrite(t *testing.T, f fsapi.File, buf []byte) { + n, errno := f.Write(buf) + require.EqualErrno(t, 0, errno) + require.Equal(t, len(buf), n) +} + +func requirePwrite(t *testing.T, f fsapi.File, buf []byte, off int64) { + n, errno := f.Pwrite(buf, off) + require.EqualErrno(t, 0, errno) + require.Equal(t, len(buf), n) +} + +func TestFileWrite_empty(t *testing.T) { + // fsapi.FS doesn't support writes, and there is no other built-in + // implementation except os.File. + path := path.Join(t.TempDir(), emptyFile) + f := requireOpenFile(t, path, syscall.O_RDWR|os.O_CREATE, 0o600) + defer f.Close() + + tests := []struct { + name string + fn func(fsapi.File, []byte) (int, syscall.Errno) + }{ + {name: "Write", fn: func(f fsapi.File, buf []byte) (int, syscall.Errno) { + return f.Write(buf) + }}, + {name: "Pwrite from zero", fn: func(f fsapi.File, buf []byte) (int, syscall.Errno) { + return f.Pwrite(buf, 0) + }}, + {name: "Pwrite from 3", fn: func(f fsapi.File, buf []byte) (int, syscall.Errno) { + return f.Pwrite(buf, 3) + }}, + } + + var emptyBuf []byte + + for _, tc := range tests { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + n, errno := tc.fn(f, emptyBuf) + require.EqualErrno(t, 0, errno) + require.Zero(t, n) + + // The file should be empty + b, err := os.ReadFile(path) + require.NoError(t, err) + require.Zero(t, len(b)) + }) + } +} + +func TestFileWrite_Unsupported(t *testing.T) { + embedFS, err := fs.Sub(testdata, "testdata") + require.NoError(t, err) + + // Use syscall.O_RDWR so that it fails due to type not flags + f, errno := OpenFSFile(&maskFS{embedFS}, wazeroFile, syscall.O_RDWR, 0) + require.EqualErrno(t, 0, errno) + defer f.Close() + + tests := []struct { + name string + fn func(fsapi.File, []byte) (int, syscall.Errno) + }{ + {name: "Write", fn: func(f fsapi.File, buf []byte) (int, syscall.Errno) { + return f.Write(buf) + }}, + {name: "Pwrite", fn: func(f fsapi.File, buf []byte) (int, syscall.Errno) { + return f.Pwrite(buf, 0) + }}, + } + + buf := []byte("wazero") + + for _, tc := range tests { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + _, errno := tc.fn(f, buf) + require.EqualErrno(t, syscall.ENOSYS, errno) + }) + } +} + +func TestFileWrite_Errors(t *testing.T) { + // Create the file + path := path.Join(t.TempDir(), emptyFile) + of, err := os.Create(path) + require.NoError(t, err) + require.NoError(t, of.Close()) + + // Open the file read-only + flag := syscall.O_RDONLY + f := requireOpenFile(t, path, flag, 0o600) + defer f.Close() + buf := []byte("wazero") + + tests := []struct { + name string + fn func(fsapi.File) syscall.Errno + }{ + {name: "Write", fn: func(f fsapi.File) syscall.Errno { + _, errno := f.Write(buf) + return errno + }}, + {name: "Pwrite", fn: func(f fsapi.File) syscall.Errno { + _, errno := f.Pwrite(buf, 0) + return errno + }}, + } + + for _, tc := range tests { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + t.Run("EBADF when not open for writing", func(t *testing.T) { + // The descriptor exists, but not open for writing + errno := tc.fn(f) + require.EqualErrno(t, syscall.EBADF, errno) + }) + testEISDIR(t, tc.fn) + }) + } +} + +func TestFileSync_NoError(t *testing.T) { + testSync_NoError(t, fsapi.File.Sync) +} + +func TestFileDatasync_NoError(t *testing.T) { + testSync_NoError(t, fsapi.File.Datasync) +} + +func testSync_NoError(t *testing.T, sync func(fsapi.File) syscall.Errno) { + roPath := "file_test.go" + ro, errno := OpenFSFile(embedFS, roPath, syscall.O_RDONLY, 0) + require.EqualErrno(t, 0, errno) + defer ro.Close() + + rwPath := path.Join(t.TempDir(), "datasync") + rw, errno := OpenOSFile(rwPath, syscall.O_CREAT|syscall.O_RDWR, 0o600) + require.EqualErrno(t, 0, errno) + defer rw.Close() + + tests := []struct { + name string + f fsapi.File + }{ + {name: "UnimplementedFile", f: fsapi.UnimplementedFile{}}, + {name: "File of read-only fs.File", f: ro}, + {name: "File of os.File", f: rw}, + } + + for _, tt := range tests { + tc := tt + + t.Run(tc.name, func(t *testing.T) { + require.EqualErrno(t, 0, sync(tc.f)) + }) + } +} + +func TestFileSync(t *testing.T) { + testSync(t, fsapi.File.Sync) +} + +func TestFileDatasync(t *testing.T) { + testSync(t, fsapi.File.Datasync) +} + +// testSync doesn't guarantee sync works because the operating system may +// sync anyway. There is no test in Go for syscall.Fdatasync, but closest is +// similar to below. Effectively, this only tests that things don't error. +func testSync(t *testing.T, sync func(fsapi.File) syscall.Errno) { + // Even though it is invalid, try to sync a directory + dPath := t.TempDir() + d := requireOpenFile(t, dPath, syscall.O_RDONLY, 0) + defer d.Close() + + errno := sync(d) + require.EqualErrno(t, 0, errno) + + fPath := path.Join(dPath, t.Name()) + + f := requireOpenFile(t, fPath, syscall.O_RDWR|os.O_CREATE, 0o600) + defer f.Close() + + expected := "hello world!" + + // Write the expected data + _, errno = f.Write([]byte(expected)) + require.EqualErrno(t, 0, errno) + + // Sync the data. + errno = sync(f) + require.EqualErrno(t, 0, errno) + + // Rewind while the file is still open. + _, errno = f.Seek(0, io.SeekStart) + require.EqualErrno(t, 0, errno) + + // Read data from the file + buf := make([]byte, 50) + n, errno := f.Read(buf) + require.EqualErrno(t, 0, errno) + + // It may be the case that sync worked. + require.Equal(t, expected, string(buf[:n])) + + // Windows allows you to sync a closed file + if runtime.GOOS != "windows" { + testEBADFIfFileClosed(t, sync) + testEBADFIfDirClosed(t, sync) + } +} + +func TestFileTruncate(t *testing.T) { + content := []byte("123456") + + tests := []struct { + name string + size int64 + expectedContent []byte + expectedErr error + }{ + { + name: "one less", + size: 5, + expectedContent: []byte("12345"), + }, + { + name: "same", + size: 6, + expectedContent: content, + }, + { + name: "zero", + size: 0, + expectedContent: []byte(""), + }, + { + name: "larger", + size: 106, + expectedContent: append(content, make([]byte, 100)...), + }, + } + + for _, tt := range tests { + tc := tt + t.Run(tc.name, func(t *testing.T) { + tmpDir := t.TempDir() + + fPath := path.Join(tmpDir, tc.name) + f := openForWrite(t, fPath, content) + defer f.Close() + + errno := f.Truncate(tc.size) + require.EqualErrno(t, 0, errno) + + actual, err := os.ReadFile(fPath) + require.NoError(t, err) + require.Equal(t, tc.expectedContent, actual) + }) + } + + truncateToZero := func(f fsapi.File) syscall.Errno { + return f.Truncate(0) + } + + if runtime.GOOS != "windows" { + // TODO: os.Truncate on windows passes even when closed + testEBADFIfFileClosed(t, truncateToZero) + } + + testEISDIR(t, truncateToZero) + + t.Run("negative", func(t *testing.T) { + tmpDir := t.TempDir() + + f := openForWrite(t, path.Join(tmpDir, "truncate"), content) + defer f.Close() + + errno := f.Truncate(-1) + require.EqualErrno(t, syscall.EINVAL, errno) + }) +} + +func TestFileUtimens(t *testing.T) { + switch runtime.GOOS { + case "linux", "darwin": // supported + case "freebsd": // TODO: support freebsd w/o CGO + case "windows": + if !platform.IsGo120 { + t.Skip("windows only works after Go 1.20") // TODO: possibly 1.19 ;) + } + default: // expect ENOSYS and callers need to fall back to Utimens + t.Skip("unsupported GOOS", runtime.GOOS) + } + + testUtimens(t, true) + + testEBADFIfFileClosed(t, func(f fsapi.File) syscall.Errno { + return f.Utimens(nil) + }) + testEBADFIfDirClosed(t, func(d fsapi.File) syscall.Errno { + return d.Utimens(nil) + }) +} + +func TestNewStdioFile(t *testing.T) { + // simulate regular file attached to stdin + f, err := os.CreateTemp(t.TempDir(), "somefile") + require.NoError(t, err) + defer f.Close() + + stdin, err := NewStdioFile(true, os.Stdin) + require.NoError(t, err) + stdinStat, err := os.Stdin.Stat() + require.NoError(t, err) + + stdinFile, err := NewStdioFile(true, f) + require.NoError(t, err) + + stdout, err := NewStdioFile(false, os.Stdout) + require.NoError(t, err) + stdoutStat, err := os.Stdout.Stat() + require.NoError(t, err) + + stdoutFile, err := NewStdioFile(false, f) + require.NoError(t, err) + + tests := []struct { + name string + f fsapi.File + // Depending on how the tests run, os.Stdin won't necessarily be a char + // device. We compare against an os.File, to account for this. + expectedType fs.FileMode + }{ + { + name: "stdin", + f: stdin, + expectedType: stdinStat.Mode().Type(), + }, + { + name: "stdin file", + f: stdinFile, + expectedType: 0, // normal file + }, + { + name: "stdout", + f: stdout, + expectedType: stdoutStat.Mode().Type(), + }, + { + name: "stdout file", + f: stdoutFile, + expectedType: 0, // normal file + }, + } + + for _, tt := range tests { + tc := tt + + t.Run(tc.name+" Stat", func(t *testing.T) { + st, errno := tc.f.Stat() + require.EqualErrno(t, 0, errno) + require.Equal(t, tc.expectedType, st.Mode&fs.ModeType) + require.Equal(t, uint64(1), st.Nlink) + + // Fake times are needed to pass wasi-testsuite. + // See https://github.com/WebAssembly/wasi-testsuite/blob/af57727/tests/rust/src/bin/fd_filestat_get.rs#L1-L19 + require.Zero(t, st.Ctim) + require.Zero(t, st.Mtim) + require.Zero(t, st.Atim) + }) + } +} + +func testEBADFIfDirClosed(t *testing.T, fn func(fsapi.File) syscall.Errno) bool { + return t.Run("EBADF if dir closed", func(t *testing.T) { + d := requireOpenFile(t, t.TempDir(), syscall.O_RDONLY, 0o755) + + // close the directory underneath + require.EqualErrno(t, 0, d.Close()) + + require.EqualErrno(t, syscall.EBADF, fn(d)) + }) +} + +func testEBADFIfFileClosed(t *testing.T, fn func(fsapi.File) syscall.Errno) bool { + return t.Run("EBADF if file closed", func(t *testing.T) { + tmpDir := t.TempDir() + + f := openForWrite(t, path.Join(tmpDir, "EBADF"), []byte{1, 2, 3, 4}) + + // close the file underneath + require.EqualErrno(t, 0, f.Close()) + + require.EqualErrno(t, syscall.EBADF, fn(f)) + }) +} + +func testEISDIR(t *testing.T, fn func(fsapi.File) syscall.Errno) bool { + return t.Run("EISDIR if directory", func(t *testing.T) { + f := requireOpenFile(t, os.TempDir(), syscall.O_RDONLY|fsapi.O_DIRECTORY, 0o666) + defer f.Close() + + require.EqualErrno(t, syscall.EISDIR, fn(f)) + }) +} + +func openForWrite(t *testing.T, path string, content []byte) fsapi.File { + require.NoError(t, os.WriteFile(path, content, 0o0666)) + f := requireOpenFile(t, path, syscall.O_RDWR, 0o666) + _, errno := f.Write(content) + require.EqualErrno(t, 0, errno) + return f +} + +func requireOpenFile(t *testing.T, path string, flag int, perm fs.FileMode) fsapi.File { + f, errno := OpenOSFile(path, flag, perm) + require.EqualErrno(t, 0, errno) + return f +} + +func dirEmbedMapFS(t *testing.T, tmpDir string) (fs.FS, fs.FS, fs.FS) { + embedFS, err := fs.Sub(testdata, "testdata") + require.NoError(t, err) + + f, err := embedFS.Open(wazeroFile) + require.NoError(t, err) + defer f.Close() + + bytes, err := io.ReadAll(f) + require.NoError(t, err) + + mapFS := gofstest.MapFS{ + emptyFile: &gofstest.MapFile{}, + wazeroFile: &gofstest.MapFile{Data: bytes}, + } + + // Write a file as can't open "testdata" in scratch tests because they + // can't read the original filesystem. + require.NoError(t, os.WriteFile(path.Join(tmpDir, emptyFile), nil, 0o600)) + require.NoError(t, os.WriteFile(path.Join(tmpDir, wazeroFile), bytes, 0o600)) + dirFS := os.DirFS(tmpDir) + return dirFS, embedFS, mapFS +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/file_unix.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/file_unix.go new file mode 100644 index 000000000..e451df820 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/file_unix.go @@ -0,0 +1,21 @@ +//go:build unix || darwin || linux + +package sysfs + +import ( + "syscall" + + "github.com/tetratelabs/wazero/internal/platform" +) + +const NonBlockingFileIoSupported = true + +// readFd exposes syscall.Read. +func readFd(fd uintptr, buf []byte) (int, syscall.Errno) { + if len(buf) == 0 { + return 0, 0 // Short-circuit 0-len reads. + } + n, err := syscall.Read(int(fd), buf) + errno := platform.UnwrapOSError(err) + return n, errno +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/file_unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/file_unsupported.go new file mode 100644 index 000000000..cb4bddb33 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/file_unsupported.go @@ -0,0 +1,12 @@ +//go:build !unix && !linux && !darwin + +package sysfs + +import "syscall" + +const NonBlockingFileIoSupported = false + +// readFd returns ENOSYS on unsupported platforms. +func readFd(fd uintptr, buf []byte) (int, syscall.Errno) { + return -1, syscall.ENOSYS +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens.go similarity index 77% rename from vendor/github.com/tetratelabs/wazero/internal/platform/futimens.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens.go index 0b1419c02..1c2bceadc 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens.go @@ -1,10 +1,12 @@ -package platform +package sysfs import ( - "io/fs" "syscall" "time" "unsafe" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" ) const ( @@ -33,38 +35,22 @@ const ( // // # Errors // -// The following errors are expected: +// A zero syscall.Errno is success. The below are expected otherwise: +// - syscall.ENOSYS: the implementation does not support this function. // - syscall.EINVAL: `path` is invalid. // - syscall.EEXIST: `path` exists and is a directory. // - syscall.ENOTDIR: `path` exists and is a file. // // # Notes // -// - This is similar to syscall.UtimesNano, except that doesn't have flags to -// control expansion of symbolic links. It also doesn't support special -// values UTIME_NOW or UTIME_NOW. -// - This is like `utimensat` with `AT_FDCWD` in POSIX. See -// https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html +// - This is like syscall.UtimesNano and `utimensat` with `AT_FDCWD` in +// POSIX. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html func Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.Errno { err := utimens(path, times, symlinkFollow) - return UnwrapOSError(err) + return platform.UnwrapOSError(err) } -// UtimensFile is like Utimens, except it works on a file, not a path. -// -// # Notes -// -// - Windows requires files to be open with syscall.O_RDWR, which means you -// cannot use this to update timestamps on a directory (syscall.EPERM). -// - This is like the function `futimens` in POSIX. See -// https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html -func UtimensFile(f fs.File, times *[2]syscall.Timespec) syscall.Errno { - if f, ok := f.(fdFile); ok { - err := futimens(f.Fd(), times) - return UnwrapOSError(err) - } - return syscall.ENOSYS -} +var _zero uintptr //nolint:unused func timesToPtr(times *[2]syscall.Timespec) unsafe.Pointer { //nolint:unused var _p0 unsafe.Pointer @@ -121,7 +107,7 @@ func normalizeTimespec(path string, times *[2]syscall.Timespec, i int) (ts sysca // stat to read-back the value to re-apply. // - https://github.com/golang/go/issues/32558. // - https://go-review.googlesource.com/c/go/+/219638 (unmerged) - var st Stat_t + var st fsapi.Stat_t if st, err = stat(path); err != 0 { return } diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens_darwin.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go similarity index 98% rename from vendor/github.com/tetratelabs/wazero/internal/platform/futimens_darwin.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go index 1dfd1326c..f4ede3377 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens_darwin.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go @@ -1,4 +1,4 @@ -package platform +package sysfs import ( "syscall" diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens_darwin.s b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.s similarity index 100% rename from vendor/github.com/tetratelabs/wazero/internal/platform/futimens_darwin.s rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.s diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens_linux.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_linux.go similarity index 98% rename from vendor/github.com/tetratelabs/wazero/internal/platform/futimens_linux.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_linux.go index 07ebf2e24..a7ae264d2 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens_linux.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_linux.go @@ -1,4 +1,4 @@ -package platform +package sysfs import ( "syscall" diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens_unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_unsupported.go similarity index 97% rename from vendor/github.com/tetratelabs/wazero/internal/platform/futimens_unsupported.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_unsupported.go index 3fb3c92bf..60860e6c4 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens_unsupported.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_unsupported.go @@ -1,6 +1,6 @@ //go:build !windows && !linux && !darwin -package platform +package sysfs import "syscall" diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens_windows.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_windows.go similarity index 95% rename from vendor/github.com/tetratelabs/wazero/internal/platform/futimens_windows.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_windows.go index c0bc03fa2..39696067e 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/futimens_windows.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_windows.go @@ -1,8 +1,10 @@ -package platform +package sysfs import ( "syscall" "time" + + "github.com/tetratelabs/wazero/internal/platform" ) // Define values even if not used except as sentinels. @@ -19,7 +21,7 @@ func utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) error func futimens(fd uintptr, times *[2]syscall.Timespec) error { // Before Go 1.20, ERROR_INVALID_HANDLE was returned for too many reasons. // Kick out so that callers can use path-based operations instead. - if !IsGo120 { + if !platform.IsGo120 { return syscall.ENOSYS } diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unix.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unix.go new file mode 100644 index 000000000..1ac13e539 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unix.go @@ -0,0 +1,9 @@ +//go:build !windows + +package sysfs + +import "syscall" + +func setNonblock(fd uintptr, enable bool) error { + return syscall.SetNonblock(int(fd), enable) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_windows.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_windows.go new file mode 100644 index 000000000..d4a29ac33 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_windows.go @@ -0,0 +1,9 @@ +//go:build windows + +package sysfs + +import "syscall" + +func setNonblock(fd uintptr, enable bool) error { + return syscall.SetNonblock(syscall.Handle(fd), enable) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file.go new file mode 100644 index 000000000..473f8ca63 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file.go @@ -0,0 +1,26 @@ +//go:build !windows && !js && !illumos && !solaris + +package sysfs + +import ( + "io/fs" + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" +) + +func newOsFile(openPath string, openFlag int, openPerm fs.FileMode, f *os.File) fsapi.File { + return newDefaultOsFile(openPath, openFlag, openPerm, f) +} + +// OpenFile is like os.OpenFile except it returns syscall.Errno. A zero +// syscall.Errno is success. +func openFile(path string, flag int, perm fs.FileMode) (*os.File, syscall.Errno) { + f, err := os.OpenFile(path, flag, perm) + // Note: This does not return a fsapi.File because fsapi.FS that returns + // one may want to hide the real OS path. For example, this is needed for + // pre-opens. + return f, platform.UnwrapOSError(err) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_js.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_js.go new file mode 100644 index 000000000..e473acbe4 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_js.go @@ -0,0 +1,19 @@ +package sysfs + +import ( + "io/fs" + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/platform" +) + +func newOsFile(openPath string, openFlag int, openPerm fs.FileMode, f *os.File) File { + return newDefaultOsFile(openPath, openFlag, openPerm, f) +} + +func openFile(path string, flag int, perm fs.FileMode) (*os.File, syscall.Errno) { + flag &= ^(O_DIRECTORY | O_NOFOLLOW) // erase placeholders + f, err := os.OpenFile(path, flag, perm) + return f, platform.UnwrapOSError(err) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_sun.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_sun.go new file mode 100644 index 000000000..e23b7185c --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_sun.go @@ -0,0 +1,21 @@ +//go:build illumos || solaris + +package sysfs + +import ( + "io/fs" + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" +) + +func newOsFile(openPath string, openFlag int, openPerm fs.FileMode, f *os.File) fsapi.File { + return newDefaultOsFile(openPath, openFlag, openPerm, f) +} + +func openFile(path string, flag int, perm fs.FileMode) (*os.File, syscall.Errno) { + f, err := os.OpenFile(path, flag, perm) + return f, platform.UnwrapOSError(err) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/open_file_windows.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_windows.go similarity index 69% rename from vendor/github.com/tetratelabs/wazero/internal/platform/open_file_windows.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_windows.go index c17853d1f..d9297d7e8 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/open_file_windows.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_windows.go @@ -1,4 +1,4 @@ -package platform +package sysfs import ( "io/fs" @@ -6,39 +6,20 @@ import ( "strings" "syscall" "unsafe" -) -// Windows does not have these constants, we declare placeholders which should -// not conflict with other open flags. These placeholders are not declared as -// value zero so code written in a way which expects them to be bit flags still -// works as expected. -// -// Since those placeholder are not interpreted by the open function, the unix -// features they represent are also not implemented on windows: -// -// - O_DIRECTORY allows programs to ensure that the opened file is a directory. -// This could be emulated by doing a stat call on the file after opening it -// to verify that it is in fact a directory, then closing it and returning an -// error if it is not. -// -// - O_NOFOLLOW allows programs to ensure that if the opened file is a symbolic -// link, the link itself is opened instead of its target. -const ( - O_DIRECTORY = 1 << 29 - O_NOFOLLOW = 1 << 30 + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" ) -func OpenFile(path string, flag int, perm fs.FileMode) (File, syscall.Errno) { - if f, errno := openFile(path, flag, perm); errno != 0 { - return nil, errno - } else { - return &windowsWrappedFile{File: f, path: path, flag: flag, perm: perm}, 0 +func newOsFile(openPath string, openFlag int, openPerm fs.FileMode, f *os.File) fsapi.File { + return &windowsOsFile{ + osFile: osFile{path: openPath, flag: openFlag, perm: openPerm, file: f, fd: f.Fd()}, } } func openFile(path string, flag int, perm fs.FileMode) (*os.File, syscall.Errno) { - isDir := flag&O_DIRECTORY > 0 - flag &= ^(O_DIRECTORY | O_NOFOLLOW) // erase placeholders + isDir := flag&fsapi.O_DIRECTORY > 0 + flag &= ^(fsapi.O_DIRECTORY | fsapi.O_NOFOLLOW) // erase placeholders // TODO: document why we are opening twice fd, err := open(path, flag|syscall.O_CLOEXEC, uint32(perm)) @@ -48,7 +29,7 @@ func openFile(path string, flag int, perm fs.FileMode) (*os.File, syscall.Errno) // TODO: Set FILE_SHARE_DELETE for directory as well. f, err := os.OpenFile(path, flag, perm) - errno := UnwrapOSError(err) + errno := platform.UnwrapOSError(err) if errno == 0 { return f, 0 } @@ -86,8 +67,14 @@ func isSymlink(path string) bool { return false } -// The following is lifted from syscall_windows.go to add support for setting FILE_SHARE_DELETE. -// https://github.com/golang/go/blob/go1.20/src/syscall/syscall_windows.go#L308-L379 +// # Differences from syscall.Open +// +// This code is based on syscall.Open from the below link with some differences +// https://github.com/golang/go/blame/go1.20/src/syscall/syscall_windows.go#L308-L379 +// +// - syscall.O_CREAT doesn't imply syscall.GENERIC_WRITE as that breaks +// flag expectations in wasi. +// - add support for setting FILE_SHARE_DELETE. func open(path string, mode int, perm uint32) (fd syscall.Handle, err error) { if len(path) == 0 { return syscall.InvalidHandle, syscall.ERROR_FILE_NOT_FOUND @@ -105,9 +92,6 @@ func open(path string, mode int, perm uint32) (fd syscall.Handle, err error) { case syscall.O_RDWR: access = syscall.GENERIC_READ | syscall.GENERIC_WRITE } - if mode&syscall.O_CREAT != 0 { - access |= syscall.GENERIC_WRITE - } if mode&syscall.O_APPEND != 0 { access &^= syscall.GENERIC_WRITE access |= syscall.FILE_APPEND_DATA @@ -158,7 +142,7 @@ func open(path string, mode int, perm uint32) (fd syscall.Handle, err error) { } } - if IsGo120 { + if platform.IsGo120 { // This shouldn't be included before 1.20 to have consistent behavior. // https://github.com/golang/go/commit/0f0aa5d8a6a0253627d58b3aa083b24a1091933f if createmode == syscall.OPEN_EXISTING && access == syscall.GENERIC_READ { @@ -170,3 +154,46 @@ func open(path string, mode int, perm uint32) (fd syscall.Handle, err error) { h, e := syscall.CreateFile(pathp, access, sharemode, sa, createmode, attrs, 0) return h, e } + +// windowsOsFile overrides osFile to special case directory handling in Windows. +type windowsOsFile struct { + osFile + + dirInitialized bool +} + +// Readdir implements File.Readdir +func (f *windowsOsFile) Readdir(n int) (dirents []fsapi.Dirent, errno syscall.Errno) { + if errno = f.maybeInitDir(); errno != 0 { + return + } + + return f.osFile.Readdir(n) +} + +func (f *windowsOsFile) maybeInitDir() syscall.Errno { + if f.dirInitialized { + return 0 + } + + if isDir, errno := f.IsDir(); errno != 0 { + return errno + } else if !isDir { + return syscall.ENOTDIR + } + + // On Windows, once the directory is opened, changes to the directory are + // not visible on ReadDir on that already-opened file handle. + // + // To provide consistent behavior with other platforms, we re-open it. + if errno := f.osFile.Close(); errno != 0 { + return errno + } + newW, errno := openFile(f.path, f.flag, f.perm) + if errno != 0 { + return errno + } + f.osFile.file = newW + f.dirInitialized = true + return 0 +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/osfile.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/osfile.go new file mode 100644 index 000000000..95798f482 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/osfile.go @@ -0,0 +1,268 @@ +package sysfs + +import ( + "io" + "io/fs" + "os" + "syscall" + "time" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" +) + +func newDefaultOsFile(openPath string, openFlag int, openPerm fs.FileMode, f *os.File) fsapi.File { + return &osFile{path: openPath, flag: openFlag, perm: openPerm, file: f, fd: f.Fd()} +} + +// osFile is a file opened with this package, and uses os.File or syscalls to +// implement api.File. +type osFile struct { + path string + flag int + perm fs.FileMode + file *os.File + fd uintptr + + // closed is true when closed was called. This ensures proper syscall.EBADF + closed bool + + // cachedStat includes fields that won't change while a file is open. + cachedSt *cachedStat +} + +// cachedStat returns the cacheable parts of platform.sys.Stat_t or an error if +// they couldn't be retrieved. +func (f *osFile) cachedStat() (fileType fs.FileMode, ino uint64, errno syscall.Errno) { + if f.cachedSt == nil { + if _, errno = f.Stat(); errno != 0 { + return + } + } + return f.cachedSt.fileType, f.cachedSt.ino, 0 +} + +// Ino implements the same method as documented on fsapi.File +func (f *osFile) Ino() (uint64, syscall.Errno) { + if _, ino, errno := f.cachedStat(); errno != 0 { + return 0, errno + } else { + return ino, 0 + } +} + +// IsAppend implements File.IsAppend +func (f *osFile) IsAppend() bool { + return f.flag&syscall.O_APPEND == syscall.O_APPEND +} + +// SetAppend implements the same method as documented on fsapi.File +func (f *osFile) SetAppend(enable bool) (errno syscall.Errno) { + if enable { + f.flag |= syscall.O_APPEND + } else { + f.flag &= ^syscall.O_APPEND + } + + // Clear any create flag, as we are re-opening, not re-creating. + f.flag &= ^syscall.O_CREAT + + // appendMode (bool) cannot be changed later, so we have to re-open the + // file. https://github.com/golang/go/blob/go1.20/src/os/file_unix.go#L60 + return fileError(f, f.closed, f.reopen()) +} + +func (f *osFile) reopen() (errno syscall.Errno) { + // Clear any create flag, as we are re-opening, not re-creating. + f.flag &= ^syscall.O_CREAT + + _ = f.close() + f.file, errno = OpenFile(f.path, f.flag, f.perm) + return +} + +// IsNonblock implements the same method as documented on fsapi.File +func (f *osFile) IsNonblock() bool { + return f.flag&fsapi.O_NONBLOCK == fsapi.O_NONBLOCK +} + +// SetNonblock implements the same method as documented on fsapi.File +func (f *osFile) SetNonblock(enable bool) (errno syscall.Errno) { + if enable { + f.flag |= fsapi.O_NONBLOCK + } else { + f.flag &= ^fsapi.O_NONBLOCK + } + if err := setNonblock(f.fd, enable); err != nil { + return fileError(f, f.closed, platform.UnwrapOSError(err)) + } + return 0 +} + +// IsDir implements the same method as documented on fsapi.File +func (f *osFile) IsDir() (bool, syscall.Errno) { + if ft, _, errno := f.cachedStat(); errno != 0 { + return false, errno + } else if ft.Type() == fs.ModeDir { + return true, 0 + } + return false, 0 +} + +// Stat implements the same method as documented on fsapi.File +func (f *osFile) Stat() (fsapi.Stat_t, syscall.Errno) { + if f.closed { + return fsapi.Stat_t{}, syscall.EBADF + } + + st, errno := statFile(f.file) + switch errno { + case 0: + f.cachedSt = &cachedStat{fileType: st.Mode & fs.ModeType, ino: st.Ino} + case syscall.EIO: + errno = syscall.EBADF + } + return st, errno +} + +// Read implements the same method as documented on fsapi.File +func (f *osFile) Read(buf []byte) (n int, errno syscall.Errno) { + if len(buf) == 0 { + return 0, 0 // Short-circuit 0-len reads. + } + if NonBlockingFileIoSupported && f.IsNonblock() { + n, errno = readFd(f.fd, buf) + } else { + n, errno = read(f.file, buf) + } + if errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + return +} + +// Pread implements the same method as documented on fsapi.File +func (f *osFile) Pread(buf []byte, off int64) (n int, errno syscall.Errno) { + if n, errno = pread(f.file, buf, off); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + return +} + +// Seek implements the same method as documented on fsapi.File +func (f *osFile) Seek(offset int64, whence int) (newOffset int64, errno syscall.Errno) { + if newOffset, errno = seek(f.file, offset, whence); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + + // If the error was trying to rewind a directory, re-open it. Notably, + // seeking to zero on a directory doesn't work on Windows with Go 1.18. + if errno == syscall.EISDIR && offset == 0 && whence == io.SeekStart { + return 0, f.reopen() + } + } + return +} + +// PollRead implements the same method as documented on fsapi.File +func (f *osFile) PollRead(timeout *time.Duration) (ready bool, errno syscall.Errno) { + fdSet := platform.FdSet{} + fd := int(f.fd) + fdSet.Set(fd) + nfds := fd + 1 // See https://man7.org/linux/man-pages/man2/select.2.html#:~:text=condition%20has%20occurred.-,nfds,-This%20argument%20should + count, err := _select(nfds, &fdSet, nil, nil, timeout) + if errno = platform.UnwrapOSError(err); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + return count > 0, errno +} + +// Readdir implements File.Readdir. Notably, this uses "Readdir", not +// "ReadDir", from os.File. +func (f *osFile) Readdir(n int) (dirents []fsapi.Dirent, errno syscall.Errno) { + if dirents, errno = readdir(f.file, f.path, n); errno != 0 { + errno = adjustReaddirErr(f, f.closed, errno) + } + return +} + +// Write implements the same method as documented on fsapi.File +func (f *osFile) Write(buf []byte) (n int, errno syscall.Errno) { + if n, errno = write(f.file, buf); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + return +} + +// Pwrite implements the same method as documented on fsapi.File +func (f *osFile) Pwrite(buf []byte, off int64) (n int, errno syscall.Errno) { + if n, errno = pwrite(f.file, buf, off); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + return +} + +// Truncate implements the same method as documented on fsapi.File +func (f *osFile) Truncate(size int64) (errno syscall.Errno) { + if errno = platform.UnwrapOSError(f.file.Truncate(size)); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + return +} + +// Sync implements the same method as documented on fsapi.File +func (f *osFile) Sync() syscall.Errno { + return fsync(f.file) +} + +// Datasync implements the same method as documented on fsapi.File +func (f *osFile) Datasync() syscall.Errno { + return datasync(f.file) +} + +// Chmod implements the same method as documented on fsapi.File +func (f *osFile) Chmod(mode fs.FileMode) syscall.Errno { + if f.closed { + return syscall.EBADF + } + + return platform.UnwrapOSError(f.file.Chmod(mode)) +} + +// Chown implements the same method as documented on fsapi.File +func (f *osFile) Chown(uid, gid int) syscall.Errno { + if f.closed { + return syscall.EBADF + } + + return fchown(f.fd, uid, gid) +} + +// Utimens implements the same method as documented on fsapi.File +func (f *osFile) Utimens(times *[2]syscall.Timespec) syscall.Errno { + if f.closed { + return syscall.EBADF + } + + err := futimens(f.fd, times) + return platform.UnwrapOSError(err) +} + +// Close implements the same method as documented on fsapi.File +func (f *osFile) Close() syscall.Errno { + if f.closed { + return 0 + } + f.closed = true + return f.close() +} + +func (f *osFile) close() syscall.Errno { + return platform.UnwrapOSError(f.file.Close()) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/readfs.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/readfs.go index bec2dc3d0..b83778f97 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/sysfs/readfs.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/readfs.go @@ -1,29 +1,29 @@ package sysfs import ( - "io" "io/fs" "os" "syscall" + "time" - "github.com/tetratelabs/wazero/internal/platform" + "github.com/tetratelabs/wazero/internal/fsapi" ) -// NewReadFS is used to mask an existing FS for reads. Notably, this allows +// NewReadFS is used to mask an existing api.FS for reads. Notably, this allows // the CLI to do read-only mounts of directories the host user can write, but // doesn't want the guest wasm to. For example, Python libraries shouldn't be // written to at runtime by the python wasm file. -func NewReadFS(fs FS) FS { +func NewReadFS(fs fsapi.FS) fsapi.FS { if _, ok := fs.(*readFS); ok { return fs - } else if _, ok = fs.(UnimplementedFS); ok { + } else if _, ok = fs.(fsapi.UnimplementedFS); ok { return fs // unimplemented is read-only } return &readFS{fs: fs} } type readFS struct { - fs FS + fs fsapi.FS } // String implements fmt.Stringer @@ -31,13 +31,8 @@ func (r *readFS) String() string { return r.fs.String() } -// Open implements the same method as documented on fs.FS -func (r *readFS) Open(name string) (fs.File, error) { - return fsOpen(r, name) -} - -// OpenFile implements FS.OpenFile -func (r *readFS) OpenFile(path string, flag int, perm fs.FileMode) (fs.File, syscall.Errno) { +// OpenFile implements the same method as documented on api.FS +func (r *readFS) OpenFile(path string, flag int, perm fs.FileMode) (fsapi.File, syscall.Errno) { // TODO: Once the real implementation is complete, move the below to // /RATIONALE.md. Doing this while the type is unstable creates // documentation drift as we expect a lot of reshaping meanwhile. @@ -59,153 +54,207 @@ func (r *readFS) OpenFile(path string, flag int, perm fs.FileMode) (fs.File, sys // check if they are the opposite of read or not. switch flag & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR) { case os.O_WRONLY, os.O_RDWR: + if flag&fsapi.O_DIRECTORY != 0 { + return nil, syscall.EISDIR + } return nil, syscall.ENOSYS - default: // os.O_RDONLY so we are ok! + default: // os.O_RDONLY (or no flag) so we are ok! } f, errno := r.fs.OpenFile(path, flag, perm) if errno != 0 { return nil, errno } - return maskForReads(f), 0 -} - -// maskForReads masks the file with read-only interfaces used by wazero. -// -// This technique was adapted from similar code in zipkin-go. -func maskForReads(f fs.File) fs.File { - // Handle the most common types - rf, ok := f.(platform.ReadFile) - pf, pok := f.(platform.PathFile) - switch { - case ok && !pok: - return struct { - platform.ReadFile - }{rf} - case ok && pok: - return struct { - platform.ReadFile - platform.PathFile - }{rf, pf} - } + return &readFile{f: f}, 0 +} + +// compile-time check to ensure readFile implements api.File. +var _ fsapi.File = (*readFile)(nil) + +type readFile struct { + f fsapi.File +} + +// Ino implements the same method as documented on fsapi.File. +func (r *readFile) Ino() (uint64, syscall.Errno) { + return r.f.Ino() +} + +// IsNonblock implements the same method as documented on fsapi.File. +func (r *readFile) IsNonblock() bool { + return r.f.IsNonblock() +} + +// SetNonblock implements the same method as documented on fsapi.File. +func (r *readFile) SetNonblock(enabled bool) syscall.Errno { + return r.f.SetNonblock(enabled) +} + +// IsAppend implements the same method as documented on fsapi.File. +func (r *readFile) IsAppend() bool { + return r.f.IsAppend() +} + +// SetAppend implements the same method as documented on fsapi.File. +func (r *readFile) SetAppend(enabled bool) syscall.Errno { + return r.f.SetAppend(enabled) +} + +// Stat implements the same method as documented on fsapi.File. +func (r *readFile) Stat() (fsapi.Stat_t, syscall.Errno) { + return r.f.Stat() +} + +// IsDir implements the same method as documented on fsapi.File. +func (r *readFile) IsDir() (bool, syscall.Errno) { + return r.f.IsDir() +} + +// Read implements the same method as documented on fsapi.File. +func (r *readFile) Read(buf []byte) (int, syscall.Errno) { + return r.f.Read(buf) +} + +// Pread implements the same method as documented on fsapi.File. +func (r *readFile) Pread(buf []byte, offset int64) (int, syscall.Errno) { + return r.f.Pread(buf, offset) +} - // The below are the types wazero casts into. - // Note: os.File implements this even for normal files. - d, i0 := f.(fs.ReadDirFile) - ra, i1 := f.(io.ReaderAt) - s, i2 := f.(io.Seeker) - - // Wrap any combination of the types above. - switch { - case !i0 && !i1 && !i2: // 0, 0, 0 - return struct{ fs.File }{f} - case !i0 && !i1 && i2: // 0, 0, 1 - return struct { - fs.File - io.Seeker - }{f, s} - case !i0 && i1 && !i2: // 0, 1, 0 - return struct { - fs.File - io.ReaderAt - }{f, ra} - case !i0 && i1 && i2: // 0, 1, 1 - return struct { - fs.File - io.ReaderAt - io.Seeker - }{f, ra, s} - case i0 && !i1 && !i2: // 1, 0, 0 - return struct { - fs.ReadDirFile - }{d} - case i0 && !i1 && i2: // 1, 0, 1 - return struct { - fs.ReadDirFile - io.Seeker - }{d, s} - case i0 && i1 && !i2: // 1, 1, 0 - return struct { - fs.ReadDirFile - io.ReaderAt - }{d, ra} - case i0 && i1 && i2: // 1, 1, 1 - return struct { - fs.ReadDirFile - io.ReaderAt - io.Seeker - }{d, ra, s} - default: - panic("BUG: unhandled pattern") +// Seek implements the same method as documented on fsapi.File. +func (r *readFile) Seek(offset int64, whence int) (int64, syscall.Errno) { + return r.f.Seek(offset, whence) +} + +// Readdir implements the same method as documented on fsapi.File. +func (r *readFile) Readdir(n int) (dirents []fsapi.Dirent, errno syscall.Errno) { + return r.f.Readdir(n) +} + +// Write implements the same method as documented on fsapi.File. +func (r *readFile) Write([]byte) (int, syscall.Errno) { + return 0, r.writeErr() +} + +// Pwrite implements the same method as documented on fsapi.File. +func (r *readFile) Pwrite([]byte, int64) (n int, errno syscall.Errno) { + return 0, r.writeErr() +} + +// Truncate implements the same method as documented on fsapi.File. +func (r *readFile) Truncate(int64) syscall.Errno { + return r.writeErr() +} + +// Sync implements the same method as documented on fsapi.File. +func (r *readFile) Sync() syscall.Errno { + return syscall.EBADF +} + +// Datasync implements the same method as documented on fsapi.File. +func (r *readFile) Datasync() syscall.Errno { + return syscall.EBADF +} + +// Chmod implements the same method as documented on fsapi.File. +func (r *readFile) Chmod(fs.FileMode) syscall.Errno { + return syscall.EBADF +} + +// Chown implements the same method as documented on fsapi.File. +func (r *readFile) Chown(int, int) syscall.Errno { + return syscall.EBADF +} + +// Utimens implements the same method as documented on fsapi.File. +func (r *readFile) Utimens(*[2]syscall.Timespec) syscall.Errno { + return syscall.EBADF +} + +func (r *readFile) writeErr() syscall.Errno { + if isDir, errno := r.IsDir(); errno != 0 { + return errno + } else if isDir { + return syscall.EISDIR } + return syscall.EBADF +} + +// Close implements the same method as documented on fsapi.File. +func (r *readFile) Close() syscall.Errno { + return r.f.Close() +} + +// PollRead implements File.PollRead +func (r *readFile) PollRead(timeout *time.Duration) (ready bool, errno syscall.Errno) { + return r.f.PollRead(timeout) } -// Lstat implements FS.Lstat -func (r *readFS) Lstat(path string) (platform.Stat_t, syscall.Errno) { +// Lstat implements the same method as documented on api.FS +func (r *readFS) Lstat(path string) (fsapi.Stat_t, syscall.Errno) { return r.fs.Lstat(path) } -// Stat implements FS.Stat -func (r *readFS) Stat(path string) (platform.Stat_t, syscall.Errno) { +// Stat implements the same method as documented on api.FS +func (r *readFS) Stat(path string) (fsapi.Stat_t, syscall.Errno) { return r.fs.Stat(path) } -// Readlink implements FS.Readlink +// Readlink implements the same method as documented on api.FS func (r *readFS) Readlink(path string) (dst string, err syscall.Errno) { return r.fs.Readlink(path) } -// Mkdir implements FS.Mkdir +// Mkdir implements the same method as documented on api.FS func (r *readFS) Mkdir(path string, perm fs.FileMode) syscall.Errno { return syscall.EROFS } -// Chmod implements FS.Chmod +// Chmod implements the same method as documented on api.FS func (r *readFS) Chmod(path string, perm fs.FileMode) syscall.Errno { return syscall.EROFS } -// Chown implements FS.Chown +// Chown implements the same method as documented on api.FS func (r *readFS) Chown(path string, uid, gid int) syscall.Errno { return syscall.EROFS } -// Lchown implements FS.Lchown +// Lchown implements the same method as documented on api.FS func (r *readFS) Lchown(path string, uid, gid int) syscall.Errno { return syscall.EROFS } -// Rename implements FS.Rename +// Rename implements the same method as documented on api.FS func (r *readFS) Rename(from, to string) syscall.Errno { return syscall.EROFS } -// Rmdir implements FS.Rmdir +// Rmdir implements the same method as documented on api.FS func (r *readFS) Rmdir(path string) syscall.Errno { return syscall.EROFS } -// Link implements FS.Link +// Link implements the same method as documented on api.FS func (r *readFS) Link(_, _ string) syscall.Errno { return syscall.EROFS } -// Symlink implements FS.Symlink +// Symlink implements the same method as documented on api.FS func (r *readFS) Symlink(_, _ string) syscall.Errno { return syscall.EROFS } -// Unlink implements FS.Unlink +// Unlink implements the same method as documented on api.FS func (r *readFS) Unlink(path string) syscall.Errno { return syscall.EROFS } -// Utimens implements FS.Utimens +// Utimens implements the same method as documented on api.FS func (r *readFS) Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.Errno { return syscall.EROFS } -// Truncate implements FS.Truncate +// Truncate implements the same method as documented on api.FS func (r *readFS) Truncate(string, int64) syscall.Errno { return syscall.EROFS } diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/rename.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/rename.go new file mode 100644 index 000000000..b107bc19d --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/rename.go @@ -0,0 +1,16 @@ +//go:build !windows + +package sysfs + +import ( + "syscall" + + "github.com/tetratelabs/wazero/internal/platform" +) + +func Rename(from, to string) syscall.Errno { + if from == to { + return 0 + } + return platform.UnwrapOSError(syscall.Rename(from, to)) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/rename_windows.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/rename_windows.go similarity index 77% rename from vendor/github.com/tetratelabs/wazero/internal/platform/rename_windows.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/rename_windows.go index c3b406e53..25e53d4ff 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/rename_windows.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/rename_windows.go @@ -1,9 +1,11 @@ -package platform +package sysfs import ( "errors" "os" "syscall" + + "github.com/tetratelabs/wazero/internal/platform" ) func Rename(from, to string) syscall.Errno { @@ -25,21 +27,21 @@ func Rename(from, to string) syscall.Errno { } else if !fromIsDir && !toIsDir { // file to file // Use os.Rename instead of syscall.Rename in order to allow the overrides of the existing file. // Underneath os.Rename, it uses MoveFileEx instead of MoveFile (used by syscall.Rename). - return UnwrapOSError(os.Rename(from, to)) + return platform.UnwrapOSError(os.Rename(from, to)) } else { // dir to dir if dirs, _ := os.ReadDir(to); len(dirs) == 0 { // On Windows, renaming to the empty dir will be rejected, // so first we remove the empty dir, and then rename to it. if err := os.Remove(to); err != nil { - return UnwrapOSError(err) + return platform.UnwrapOSError(err) } - return UnwrapOSError(syscall.Rename(from, to)) + return platform.UnwrapOSError(syscall.Rename(from, to)) } return syscall.ENOTEMPTY } } else if !errors.Is(err, syscall.ENOENT) { // Failed to stat the destination. - return UnwrapOSError(err) + return platform.UnwrapOSError(err) } else { // Destination not-exist. - return UnwrapOSError(syscall.Rename(from, to)) + return platform.UnwrapOSError(syscall.Rename(from, to)) } } diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/rootfs.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/rootfs.go index cdac5e76d..75bd839f4 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/sysfs/rootfs.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/rootfs.go @@ -6,15 +6,14 @@ import ( "io/fs" "strings" "syscall" - "time" - "github.com/tetratelabs/wazero/internal/platform" + "github.com/tetratelabs/wazero/internal/fsapi" ) -func NewRootFS(fs []FS, guestPaths []string) (FS, error) { +func NewRootFS(fs []fsapi.FS, guestPaths []string) (fsapi.FS, error) { switch len(fs) { case 0: - return UnimplementedFS{}, nil + return fsapi.UnimplementedFS{}, nil case 1: if StripPrefixesAndTrailingSlash(guestPaths[0]) == "" { return fs[0], nil @@ -23,7 +22,7 @@ func NewRootFS(fs []FS, guestPaths []string) (FS, error) { ret := &CompositeFS{ string: stringFS(fs, guestPaths), - fs: make([]FS, len(fs)), + fs: make([]fsapi.FS, len(fs)), guestPaths: make([]string, len(fs)), cleanedGuestPaths: make([]string, len(fs)), rootGuestPaths: map[string]int{}, @@ -62,11 +61,11 @@ func NewRootFS(fs []FS, guestPaths []string) (FS, error) { } type CompositeFS struct { - UnimplementedFS + fsapi.UnimplementedFS // string is cached for convenience. string string // fs is index-correlated with cleanedGuestPaths - fs []FS + fs []fsapi.FS // guestPaths are the original paths supplied by the end user, cleaned as // cleanedGuestPaths. guestPaths []string @@ -84,7 +83,7 @@ func (c *CompositeFS) String() string { return c.string } -func stringFS(fs []FS, guestPaths []string) string { +func stringFS(fs []fsapi.FS, guestPaths []string) string { var ret strings.Builder ret.WriteString("[") writeMount(&ret, fs[0], guestPaths[0]) @@ -96,7 +95,7 @@ func stringFS(fs []FS, guestPaths []string) string { return ret.String() } -func writeMount(ret *strings.Builder, f FS, guestPath string) { +func writeMount(ret *strings.Builder, f fsapi.FS, guestPath string) { ret.WriteString(f.String()) ret.WriteString(":") ret.WriteString(guestPath) @@ -111,19 +110,14 @@ func (c *CompositeFS) GuestPaths() (guestPaths []string) { } // FS returns the underlying filesystems in original order. -func (c *CompositeFS) FS() (fs []FS) { - fs = make([]FS, len(c.guestPaths)) +func (c *CompositeFS) FS() (fs []fsapi.FS) { + fs = make([]fsapi.FS, len(c.guestPaths)) copy(fs, c.fs) return } -// Open implements the same method as documented on fs.FS -func (c *CompositeFS) Open(name string) (fs.File, error) { - return fsOpen(c, name) -} - -// OpenFile implements FS.OpenFile -func (c *CompositeFS) OpenFile(path string, flag int, perm fs.FileMode) (f fs.File, err syscall.Errno) { +// OpenFile implements the same method as documented on api.FS +func (c *CompositeFS) OpenFile(path string, flag int, perm fs.FileMode) (f fsapi.File, err syscall.Errno) { matchIndex, relativePath := c.chooseFS(path) f, err = c.fs[matchIndex].OpenFile(relativePath, flag, perm) @@ -136,7 +130,7 @@ func (c *CompositeFS) OpenFile(path string, flag int, perm fs.FileMode) (f fs.Fi switch path { case ".", "/", "": if len(c.rootGuestPaths) > 0 { - f = &openRootDir{c: c, f: f.(fs.ReadDirFile)} + f = &openRootDir{path: path, c: c, f: f} } } } @@ -146,24 +140,64 @@ func (c *CompositeFS) OpenFile(path string, flag int, perm fs.FileMode) (f fs.Fi // An openRootDir is a root directory open for reading, which has mounts inside // of it. type openRootDir struct { + fsapi.DirFile + + path string c *CompositeFS - f fs.ReadDirFile // the directory file itself - dirents []fs.DirEntry // the directory contents + f fsapi.File // the directory file itself + dirents []fsapi.Dirent // the directory contents direntsI int // the read offset, an index into the files slice } -func (d *openRootDir) Close() error { return d.f.Close() } +// Ino implements the same method as documented on fsapi.File +func (d *openRootDir) Ino() (uint64, syscall.Errno) { + return d.f.Ino() +} -func (d *openRootDir) Stat() (fs.FileInfo, error) { return d.f.Stat() } +// Stat implements the same method as documented on fsapi.File +func (d *openRootDir) Stat() (fsapi.Stat_t, syscall.Errno) { + return d.f.Stat() +} -func (d *openRootDir) Read([]byte) (int, error) { - return 0, &fs.PathError{Op: "read", Path: "/", Err: syscall.EISDIR} +// Seek implements the same method as documented on fsapi.File +func (d *openRootDir) Seek(offset int64, whence int) (newOffset int64, errno syscall.Errno) { + if offset != 0 || whence != io.SeekStart { + errno = syscall.ENOSYS + return + } + d.dirents = nil + d.direntsI = 0 + return d.f.Seek(offset, whence) +} + +// Readdir implements the same method as documented on fsapi.File +func (d *openRootDir) Readdir(count int) (dirents []fsapi.Dirent, errno syscall.Errno) { + if d.dirents == nil { + if errno = d.readdir(); errno != 0 { + return + } + } + + // logic similar to go:embed + n := len(d.dirents) - d.direntsI + if n == 0 { + return + } + if count > 0 && n > count { + n = count + } + dirents = make([]fsapi.Dirent, n) + for i := range dirents { + dirents[i] = d.dirents[d.direntsI+i] + } + d.direntsI += n + return } -// readDir reads the directory fully into d.dirents, replacing any entries that -// correspond to prefix matches or appending them to the end. -func (d *openRootDir) readDir() (err error) { - if d.dirents, err = d.f.ReadDir(-1); err != nil { +func (d *openRootDir) readdir() (errno syscall.Errno) { + // readDir reads the directory fully into d.dirents, replacing any entries that + // correspond to prefix matches or appending them to the end. + if d.dirents, errno = d.f.Readdir(-1); errno != 0 { return } @@ -172,18 +206,19 @@ func (d *openRootDir) readDir() (err error) { remaining[k] = v } - for i, e := range d.dirents { - if fsI, ok := remaining[e.Name()]; ok { - if d.dirents[i], err = d.rootEntry(e.Name(), fsI); err != nil { + for i := range d.dirents { + e := d.dirents[i] + if fsI, ok := remaining[e.Name]; ok { + if d.dirents[i], errno = d.rootEntry(e.Name, fsI); errno != 0 { return } - delete(remaining, e.Name()) + delete(remaining, e.Name) } } - var di fs.DirEntry + var di fsapi.Dirent for n, fsI := range remaining { - if di, err = d.rootEntry(n, fsI); err != nil { + if di, errno = d.rootEntry(n, fsI); errno != 0 { return } d.dirents = append(d.dirents, di) @@ -191,97 +226,81 @@ func (d *openRootDir) readDir() (err error) { return } -func (d *openRootDir) rootEntry(name string, fsI int) (fs.DirEntry, error) { - if st, err := d.c.fs[fsI].Stat("."); err != 0 { - return nil, err - } else { - return &dirInfo{name, st}, nil - } +// Sync implements the same method as documented on fsapi.File +func (d *openRootDir) Sync() syscall.Errno { + return d.f.Sync() } -// dirInfo is a DirEntry based on a FileInfo. -type dirInfo struct { - // name is needed to retain the stat info for a mount, knowing the - // directory is masked. For example, we don't want to leak the underlying - // host directory name. - name string - stat platform.Stat_t +// Datasync implements the same method as documented on fsapi.File +func (d *openRootDir) Datasync() syscall.Errno { + return d.f.Datasync() } -func (i *dirInfo) Name() string { return i.name } -func (i *dirInfo) Type() fs.FileMode { return i.stat.Mode.Type() } -func (i *dirInfo) Info() (fs.FileInfo, error) { return i, nil } -func (i *dirInfo) Size() int64 { return i.stat.Size } -func (i *dirInfo) Mode() fs.FileMode { return i.stat.Mode } -func (i *dirInfo) ModTime() time.Time { - return time.Unix(i.stat.Mtim/1e9, i.stat.Mtim%1e9) +// Chmod implements the same method as documented on fsapi.File +func (d *openRootDir) Chmod(fs.FileMode) syscall.Errno { + return syscall.ENOSYS } -func (i *dirInfo) IsDir() bool { return i.stat.Mode.IsDir() } -func (i *dirInfo) Sys() interface{} { return nil } -func (d *openRootDir) ReadDir(count int) ([]fs.DirEntry, error) { - if d.dirents == nil { - if err := d.readDir(); err != nil { - return nil, err - } - } +// Chown implements the same method as documented on fsapi.File +func (d *openRootDir) Chown(int, int) syscall.Errno { + return syscall.ENOSYS +} - // logic similar to go:embed - n := len(d.dirents) - d.direntsI - if n == 0 { - if count <= 0 { - return nil, nil - } - return nil, io.EOF - } - if count > 0 && n > count { - n = count - } - list := make([]fs.DirEntry, n) - for i := range list { - list[i] = d.dirents[d.direntsI+i] +// Utimens implements the same method as documented on fsapi.File +func (d *openRootDir) Utimens(*[2]syscall.Timespec) syscall.Errno { + return syscall.ENOSYS +} + +// Close implements fs.File +func (d *openRootDir) Close() syscall.Errno { + return d.f.Close() +} + +func (d *openRootDir) rootEntry(name string, fsI int) (fsapi.Dirent, syscall.Errno) { + if st, errno := d.c.fs[fsI].Stat("."); errno != 0 { + return fsapi.Dirent{}, errno + } else { + return fsapi.Dirent{Name: name, Ino: st.Ino, Type: st.Mode.Type()}, 0 } - d.direntsI += n - return list, nil } -// Lstat implements FS.Lstat -func (c *CompositeFS) Lstat(path string) (platform.Stat_t, syscall.Errno) { +// Lstat implements the same method as documented on api.FS +func (c *CompositeFS) Lstat(path string) (fsapi.Stat_t, syscall.Errno) { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Lstat(relativePath) } -// Stat implements FS.Stat -func (c *CompositeFS) Stat(path string) (platform.Stat_t, syscall.Errno) { +// Stat implements the same method as documented on api.FS +func (c *CompositeFS) Stat(path string) (fsapi.Stat_t, syscall.Errno) { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Stat(relativePath) } -// Mkdir implements FS.Mkdir +// Mkdir implements the same method as documented on api.FS func (c *CompositeFS) Mkdir(path string, perm fs.FileMode) syscall.Errno { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Mkdir(relativePath, perm) } -// Chmod implements FS.Chmod +// Chmod implements the same method as documented on api.FS func (c *CompositeFS) Chmod(path string, perm fs.FileMode) syscall.Errno { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Chmod(relativePath, perm) } -// Chown implements FS.Chown +// Chown implements the same method as documented on api.FS func (c *CompositeFS) Chown(path string, uid, gid int) syscall.Errno { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Chown(relativePath, uid, gid) } -// Lchown implements FS.Lchown +// Lchown implements the same method as documented on api.FS func (c *CompositeFS) Lchown(path string, uid, gid int) syscall.Errno { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Lchown(relativePath, uid, gid) } -// Rename implements FS.Rename +// Rename implements the same method as documented on api.FS func (c *CompositeFS) Rename(from, to string) syscall.Errno { fromFS, fromPath := c.chooseFS(from) toFS, toPath := c.chooseFS(to) @@ -291,13 +310,13 @@ func (c *CompositeFS) Rename(from, to string) syscall.Errno { return c.fs[fromFS].Rename(fromPath, toPath) } -// Readlink implements FS.Readlink +// Readlink implements the same method as documented on api.FS func (c *CompositeFS) Readlink(path string) (string, syscall.Errno) { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Readlink(relativePath) } -// Link implements FS.Link. +// Link implements the same method as documented on api.FS func (c *CompositeFS) Link(oldName, newName string) syscall.Errno { fromFS, oldNamePath := c.chooseFS(oldName) toFS, newNamePath := c.chooseFS(newName) @@ -307,13 +326,13 @@ func (c *CompositeFS) Link(oldName, newName string) syscall.Errno { return c.fs[fromFS].Link(oldNamePath, newNamePath) } -// Utimens implements FS.Utimens +// Utimens implements the same method as documented on api.FS func (c *CompositeFS) Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.Errno { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Utimens(relativePath, times, symlinkFollow) } -// Symlink implements FS.Symlink +// Symlink implements the same method as documented on api.FS func (c *CompositeFS) Symlink(oldName, link string) (err syscall.Errno) { fromFS, oldNamePath := c.chooseFS(oldName) toFS, linkPath := c.chooseFS(link) @@ -323,19 +342,19 @@ func (c *CompositeFS) Symlink(oldName, link string) (err syscall.Errno) { return c.fs[fromFS].Symlink(oldNamePath, linkPath) } -// Truncate implements FS.Truncate +// Truncate implements the same method as documented on api.FS func (c *CompositeFS) Truncate(path string, size int64) syscall.Errno { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Truncate(relativePath, size) } -// Rmdir implements FS.Rmdir +// Rmdir implements the same method as documented on api.FS func (c *CompositeFS) Rmdir(path string) syscall.Errno { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Rmdir(relativePath) } -// Unlink implements FS.Unlink +// Unlink implements the same method as documented on api.FS func (c *CompositeFS) Unlink(path string) syscall.Errno { matchIndex, relativePath := c.chooseFS(path) return c.fs[matchIndex].Unlink(relativePath) @@ -353,7 +372,8 @@ func (c *CompositeFS) chooseFS(path string) (matchIndex int, relativePath string prefix := c.cleanedGuestPaths[i] if eq, match := hasPathPrefix(path, pathI, pathLen, prefix); eq { // When the input equals the prefix, there cannot be a longer match - // later. The relative path is the FS root, so return empty string. + // later. The relative path is the fsapi.FS root, so return empty + // string. matchIndex = i relativePath = "" return @@ -476,10 +496,12 @@ loop: return } -type fakeRootFS struct{ UnimplementedFS } +type fakeRootFS struct { + fsapi.UnimplementedFS +} -// OpenFile implements FS.OpenFile -func (*fakeRootFS) OpenFile(path string, flag int, perm fs.FileMode) (fs.File, syscall.Errno) { +// OpenFile implements the same method as documented on api.FS +func (fakeRootFS) OpenFile(path string, flag int, perm fs.FileMode) (fsapi.File, syscall.Errno) { switch path { case ".", "/", "": return fakeRootDir{}, 0 @@ -487,22 +509,51 @@ func (*fakeRootFS) OpenFile(path string, flag int, perm fs.FileMode) (fs.File, s return nil, syscall.ENOENT } -type fakeRootDir struct{} +type fakeRootDir struct { + fsapi.DirFile +} + +// Ino implements the same method as documented on fsapi.File +func (fakeRootDir) Ino() (uint64, syscall.Errno) { + return 0, 0 +} + +// Stat implements the same method as documented on fsapi.File +func (fakeRootDir) Stat() (fsapi.Stat_t, syscall.Errno) { + return fsapi.Stat_t{Mode: fs.ModeDir, Nlink: 1}, 0 +} + +// Readdir implements the same method as documented on fsapi.File +func (fakeRootDir) Readdir(int) (dirents []fsapi.Dirent, errno syscall.Errno) { + return // empty +} -func (fakeRootDir) Close() (err error) { return } +// Sync implements the same method as documented on fsapi.File +func (fakeRootDir) Sync() syscall.Errno { + return 0 +} -func (fakeRootDir) Stat() (fs.FileInfo, error) { return fakeRootDirInfo{}, nil } +// Datasync implements the same method as documented on fsapi.File +func (fakeRootDir) Datasync() syscall.Errno { + return 0 +} -func (fakeRootDir) Read([]byte) (int, error) { - return 0, &fs.PathError{Op: "read", Path: "/", Err: syscall.EISDIR} +// Chmod implements the same method as documented on fsapi.File +func (fakeRootDir) Chmod(fs.FileMode) syscall.Errno { + return syscall.ENOSYS } -type fakeRootDirInfo struct{} +// Chown implements the same method as documented on fsapi.File +func (fakeRootDir) Chown(int, int) syscall.Errno { + return syscall.ENOSYS +} -func (fakeRootDirInfo) Name() string { return "/" } -func (fakeRootDirInfo) Size() int64 { return 0 } -func (fakeRootDirInfo) Mode() fs.FileMode { return fs.ModeDir | 0o500 } -func (fakeRootDirInfo) ModTime() time.Time { return time.Unix(0, 0) } -func (fakeRootDirInfo) IsDir() bool { return true } -func (fakeRootDirInfo) Sys() interface{} { return nil } -func (fakeRootDir) ReadDir(int) (dirents []fs.DirEntry, err error) { return } +// Utimens implements the same method as documented on fsapi.File +func (fakeRootDir) Utimens(*[2]syscall.Timespec) syscall.Errno { + return syscall.ENOSYS +} + +// Close implements the same method as documented on fsapi.File +func (fakeRootDir) Close() syscall.Errno { + return 0 +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/select.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select.go similarity index 79% rename from vendor/github.com/tetratelabs/wazero/internal/platform/select.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/select.go index 752f4eaa4..ac0861fda 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/select.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select.go @@ -1,8 +1,13 @@ -package platform +package sysfs -import "time" +import ( + "time" -// Select exposes the select(2) syscall. + "github.com/tetratelabs/wazero/internal/platform" +) + +// _select exposes the select(2) syscall. This is named as such to avoid +// colliding with they keyword select while not exporting the function. // // # Notes on Parameters // @@ -26,6 +31,6 @@ import "time" // e.g. the read-end of a pipe or an eventfd on Linux. // When the context is canceled, we may unblock a Select call by writing to the fd, causing it to return immediately. // This however requires to do a bit of housekeeping to hide the "special" FD from the end-user. -func Select(n int, r, w, e *FdSet, timeout *time.Duration) (int, error) { +func _select(n int, r, w, e *platform.FdSet, timeout *time.Duration) (int, error) { return syscall_select(n, r, w, e, timeout) } diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/select_darwin.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select_darwin.go similarity index 88% rename from vendor/github.com/tetratelabs/wazero/internal/platform/select_darwin.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/select_darwin.go index 9e29fca76..eabf4f455 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/select_darwin.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select_darwin.go @@ -1,15 +1,17 @@ -package platform +package sysfs import ( "syscall" "time" "unsafe" + + "github.com/tetratelabs/wazero/internal/platform" ) // syscall_select invokes select on Darwin, with the given timeout Duration. // We implement our own version instead of relying on syscall.Select because the latter // only returns the error and discards the result. -func syscall_select(n int, r, w, e *FdSet, timeout *time.Duration) (int, error) { +func syscall_select(n int, r, w, e *platform.FdSet, timeout *time.Duration) (int, error) { var t *syscall.Timeval if timeout != nil { tv := syscall.NsecToTimeval(timeout.Nanoseconds()) diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/select_darwin.s b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select_darwin.s similarity index 100% rename from vendor/github.com/tetratelabs/wazero/internal/platform/select_darwin.s rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/select_darwin.s diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/select_linux.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select_linux.go similarity index 67% rename from vendor/github.com/tetratelabs/wazero/internal/platform/select_linux.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/select_linux.go index 8a38bec00..aae5e48f6 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/select_linux.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select_linux.go @@ -1,12 +1,14 @@ -package platform +package sysfs import ( "syscall" "time" + + "github.com/tetratelabs/wazero/internal/platform" ) // syscall_select invokes select on Unix (unless Darwin), with the given timeout Duration. -func syscall_select(n int, r, w, e *FdSet, timeout *time.Duration) (int, error) { +func syscall_select(n int, r, w, e *platform.FdSet, timeout *time.Duration) (int, error) { var t *syscall.Timeval if timeout != nil { tv := syscall.NsecToTimeval(timeout.Nanoseconds()) diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/select_unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select_unsupported.go new file mode 100644 index 000000000..5244374b3 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select_unsupported.go @@ -0,0 +1,14 @@ +//go:build !darwin && !linux && !windows + +package sysfs + +import ( + "syscall" + "time" + + "github.com/tetratelabs/wazero/internal/platform" +) + +func syscall_select(n int, r, w, e *platform.FdSet, timeout *time.Duration) (int, error) { + return -1, syscall.ENOSYS +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/select_windows.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select_windows.go similarity index 84% rename from vendor/github.com/tetratelabs/wazero/internal/platform/select_windows.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/select_windows.go index 55f9751d0..811c648d6 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/select_windows.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/select_windows.go @@ -1,10 +1,12 @@ -package platform +package sysfs import ( "context" "syscall" "time" "unsafe" + + "github.com/tetratelabs/wazero/internal/platform" ) // wasiFdStdin is the constant value for stdin on Wasi. @@ -14,6 +16,8 @@ const wasiFdStdin = 0 // pollInterval is the interval between each calls to peekNamedPipe in pollNamedPipe const pollInterval = 100 * time.Millisecond +var kernel32 = syscall.NewLazyDLL("kernel32.dll") + // procPeekNamedPipe is the syscall.LazyProc in kernel32 for PeekNamedPipe var procPeekNamedPipe = kernel32.NewProc("PeekNamedPipe") @@ -29,7 +33,7 @@ var procPeekNamedPipe = kernel32.NewProc("PeekNamedPipe") // PeekNamedPipe: https://learn.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-peeknamedpipe // "GetFileType can assist in determining what device type the handle refers to. A console handle presents as FILE_TYPE_CHAR." // https://learn.microsoft.com/en-us/windows/console/console-handles -func syscall_select(n int, r, w, e *FdSet, timeout *time.Duration) (int, error) { +func syscall_select(n int, r, w, e *platform.FdSet, timeout *time.Duration) (int, error) { if n == 0 { // Don't block indefinitely. if timeout == nil { @@ -108,14 +112,14 @@ func pollNamedPipe(ctx context.Context, pipeHandle syscall.Handle, duration *tim // see https://learn.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-peeknamedpipe func peekNamedPipe(handle syscall.Handle) (bool, error) { var totalBytesAvail uint32 - totalBytesPtr := uintptr(unsafe.Pointer(&totalBytesAvail)) + totalBytesPtr := unsafe.Pointer(&totalBytesAvail) _, _, err := procPeekNamedPipe.Call( - uintptr(handle), // [in] HANDLE hNamedPipe, - 0, // [out, optional] LPVOID lpBuffer, - 0, // [in] DWORD nBufferSize, - 0, // [out, optional] LPDWORD lpBytesRead - totalBytesPtr, // [out, optional] LPDWORD lpTotalBytesAvail, - 0) // [out, optional] LPDWORD lpBytesLeftThisMessage + uintptr(handle), // [in] HANDLE hNamedPipe, + 0, // [out, optional] LPVOID lpBuffer, + 0, // [in] DWORD nBufferSize, + 0, // [out, optional] LPDWORD lpBytesRead + uintptr(totalBytesPtr), // [out, optional] LPDWORD lpTotalBytesAvail, + 0) // [out, optional] LPDWORD lpBytesLeftThisMessage if err == syscall.Errno(0) { return totalBytesAvail > 0, nil } diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock.go new file mode 100644 index 000000000..62bef426f --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock.go @@ -0,0 +1,37 @@ +package sysfs + +import ( + "net" + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" + socketapi "github.com/tetratelabs/wazero/internal/sock" +) + +// NewTCPListenerFile creates a socketapi.TCPSock for a given *net.TCPListener. +func NewTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock { + return newTCPListenerFile(tl) +} + +// baseSockFile implements base behavior for all TCPSock, TCPConn files, +// regardless the platform. +type baseSockFile struct { + fsapi.UnimplementedFile +} + +var _ fsapi.File = (*baseSockFile)(nil) + +// IsDir implements the same method as documented on File.IsDir +func (*baseSockFile) IsDir() (bool, syscall.Errno) { + // We need to override this method because WASI-libc prestats the FD + // and the default impl returns ENOSYS otherwise. + return false, 0 +} + +// Stat implements the same method as documented on File.Stat +func (f *baseSockFile) Stat() (fs fsapi.Stat_t, errno syscall.Errno) { + // The mode is not really important, but it should be neither a regular file nor a directory. + fs.Mode = os.ModeIrregular + return +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go new file mode 100644 index 000000000..aa3d3bb59 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go @@ -0,0 +1,155 @@ +//go:build linux || darwin + +package sysfs + +import ( + "net" + "syscall" + + "github.com/tetratelabs/wazero/internal/platform" + socketapi "github.com/tetratelabs/wazero/internal/sock" +) + +// MSG_PEEK is the constant syscall.MSG_PEEK +const MSG_PEEK = syscall.MSG_PEEK + +// newTCPListenerFile is a constructor for a socketapi.TCPSock. +// +// Note: the implementation of socketapi.TCPSock goes straight +// to the syscall layer, bypassing most of the Go library. +// For an alternative approach, consider winTcpListenerFile +// where most APIs are implemented with regular Go std-lib calls. +func newTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock { + conn, err := tl.File() + if err != nil { + panic(err) + } + fd := conn.Fd() + // We need to duplicate this file handle, or the lifecycle will be tied + // to the TCPListener. We rely on the TCPListener only to set up + // the connection correctly and parse/resolve the TCP Address + // (notice we actually rely on the listener in the Windows implementation). + sysfd, err := syscall.Dup(int(fd)) + if err != nil { + panic(err) + } + return &tcpListenerFile{fd: uintptr(sysfd), addr: tl.Addr().(*net.TCPAddr)} +} + +var _ socketapi.TCPSock = (*tcpListenerFile)(nil) + +type tcpListenerFile struct { + baseSockFile + + fd uintptr + addr *net.TCPAddr +} + +// Accept implements the same method as documented on socketapi.TCPSock +func (f *tcpListenerFile) Accept() (socketapi.TCPConn, syscall.Errno) { + nfd, _, err := syscall.Accept(int(f.fd)) + errno := platform.UnwrapOSError(err) + if errno != 0 { + return nil, errno + } + return &tcpConnFile{fd: uintptr(nfd)}, 0 +} + +// SetNonblock implements the same method as documented on fsapi.File +func (f *tcpListenerFile) SetNonblock(enabled bool) syscall.Errno { + return platform.UnwrapOSError(setNonblock(f.fd, enabled)) +} + +// Close implements the same method as documented on fsapi.File +func (f *tcpListenerFile) Close() syscall.Errno { + return platform.UnwrapOSError(syscall.Close(int(f.fd))) +} + +// Addr is exposed for testing. +func (f *tcpListenerFile) Addr() *net.TCPAddr { + return f.addr +} + +var _ socketapi.TCPConn = (*tcpConnFile)(nil) + +type tcpConnFile struct { + baseSockFile + + fd uintptr + + // closed is true when closed was called. This ensures proper syscall.EBADF + closed bool +} + +func newTcpConn(tc *net.TCPConn) socketapi.TCPConn { + f, err := tc.File() + if err != nil { + panic(err) + } + return &tcpConnFile{fd: f.Fd()} +} + +// SetNonblock implements the same method as documented on fsapi.File +func (f *tcpConnFile) SetNonblock(enabled bool) (errno syscall.Errno) { + return platform.UnwrapOSError(setNonblock(f.fd, enabled)) +} + +// Read implements the same method as documented on fsapi.File +func (f *tcpConnFile) Read(buf []byte) (n int, errno syscall.Errno) { + n, err := syscall.Read(int(f.fd), buf) + if err != nil { + // Defer validation overhead until we've already had an error. + errno = platform.UnwrapOSError(err) + errno = fileError(f, f.closed, errno) + } + return n, errno +} + +// Write implements the same method as documented on fsapi.File +func (f *tcpConnFile) Write(buf []byte) (n int, errno syscall.Errno) { + n, err := syscall.Write(int(f.fd), buf) + if err != nil { + // Defer validation overhead until we've already had an error. + errno = platform.UnwrapOSError(err) + errno = fileError(f, f.closed, errno) + } + return n, errno +} + +// Recvfrom implements the same method as documented on socketapi.TCPConn +func (f *tcpConnFile) Recvfrom(p []byte, flags int) (n int, errno syscall.Errno) { + if flags != MSG_PEEK { + errno = syscall.EINVAL + return + } + n, _, recvfromErr := syscall.Recvfrom(int(f.fd), p, MSG_PEEK) + errno = platform.UnwrapOSError(recvfromErr) + return n, errno +} + +// Shutdown implements the same method as documented on fsapi.Conn +func (f *tcpConnFile) Shutdown(how int) syscall.Errno { + var err error + switch how { + case syscall.SHUT_RD, syscall.SHUT_WR: + err = syscall.Shutdown(int(f.fd), how) + case syscall.SHUT_RDWR: + return f.close() + default: + return syscall.EINVAL + } + return platform.UnwrapOSError(err) +} + +// Close implements the same method as documented on fsapi.File +func (f *tcpConnFile) Close() syscall.Errno { + return f.close() +} + +func (f *tcpConnFile) close() syscall.Errno { + if f.closed { + return 0 + } + f.closed = true + return platform.UnwrapOSError(syscall.Shutdown(int(f.fd), syscall.SHUT_RDWR)) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unsupported.go new file mode 100644 index 000000000..57e8eb10a --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unsupported.go @@ -0,0 +1,26 @@ +//go:build !linux && !darwin && !windows + +package sysfs + +import ( + "net" + "syscall" + + socketapi "github.com/tetratelabs/wazero/internal/sock" +) + +// MSG_PEEK is a filler value. +const MSG_PEEK = 0x2 + +func newTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock { + return &unsupportedSockFile{} +} + +type unsupportedSockFile struct { + baseSockFile +} + +// Accept implements the same method as documented on socketapi.TCPSock +func (f *unsupportedSockFile) Accept() (socketapi.TCPConn, syscall.Errno) { + return nil, syscall.ENOSYS +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_windows.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_windows.go new file mode 100644 index 000000000..9f3b46913 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_windows.go @@ -0,0 +1,192 @@ +//go:build windows + +package sysfs + +import ( + "net" + "syscall" + "unsafe" + + "github.com/tetratelabs/wazero/internal/platform" + socketapi "github.com/tetratelabs/wazero/internal/sock" +) + +// MSG_PEEK is the flag PEEK for syscall.Recvfrom on Windows. +// This constant is not exported on this platform. +const MSG_PEEK = 0x2 + +var ( + // modws2_32 is WinSock. + modws2_32 = syscall.NewLazyDLL("ws2_32.dll") + // procrecvfrom exposes recvfrom from WinSock. + procrecvfrom = modws2_32.NewProc("recvfrom") +) + +// recvfrom exposes the underlying syscall in Windows. +// +// Note: since we are only using this to expose MSG_PEEK, +// we do not need really need all the parameters that are actually +// allowed in WinSock. +// We ignore `from *sockaddr` and `fromlen *int`. +func recvfrom(s syscall.Handle, buf []byte, flags int32) (n int, errno syscall.Errno) { + var _p0 *byte + if len(buf) > 0 { + _p0 = &buf[0] + } + r0, _, e1 := syscall.SyscallN( + procrecvfrom.Addr(), + uintptr(s), + uintptr(unsafe.Pointer(_p0)), + uintptr(len(buf)), + uintptr(flags), + 0, // from *sockaddr (optional) + 0) // fromlen *int (optional) + return int(r0), e1 +} + +// newTCPListenerFile is a constructor for a socketapi.TCPSock. +// +// Note: currently the Windows implementation of socketapi.TCPSock +// returns a winTcpListenerFile, which is a specialized TCPSock +// that delegates to a .net.TCPListener. +// The current strategy is to delegate most behavior to the Go +// standard library, instead of invoke syscalls/Win32 APIs +// because they are sensibly different from Unix's. +func newTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock { + return &winTcpListenerFile{tl: tl} +} + +var _ socketapi.TCPSock = (*winTcpListenerFile)(nil) + +type winTcpListenerFile struct { + baseSockFile + + tl *net.TCPListener +} + +// Accept implements the same method as documented on socketapi.TCPSock +func (f *winTcpListenerFile) Accept() (socketapi.TCPConn, syscall.Errno) { + conn, err := f.tl.Accept() + if err != nil { + return nil, platform.UnwrapOSError(err) + } + return &winTcpConnFile{tc: conn.(*net.TCPConn)}, 0 +} + +// SetNonblock implements the same method as documented on fsapi.File +func (f *winTcpListenerFile) SetNonblock(enabled bool) syscall.Errno { + return 0 // setNonblock() is a no-op on Windows +} + +// Close implements the same method as documented on fsapi.File +func (f *winTcpListenerFile) Close() syscall.Errno { + return platform.UnwrapOSError(f.tl.Close()) +} + +// Addr is exposed for testing. +func (f *winTcpListenerFile) Addr() *net.TCPAddr { + return f.tl.Addr().(*net.TCPAddr) +} + +var _ socketapi.TCPConn = (*winTcpConnFile)(nil) + +type winTcpConnFile struct { + baseSockFile + + tc *net.TCPConn + + // closed is true when closed was called. This ensures proper syscall.EBADF + closed bool +} + +func newTcpConn(tc *net.TCPConn) socketapi.TCPConn { + return &winTcpConnFile{tc: tc} +} + +// SetNonblock implements the same method as documented on fsapi.File +func (f *winTcpConnFile) SetNonblock(enabled bool) (errno syscall.Errno) { + syscallConn, err := f.tc.SyscallConn() + if err != nil { + return platform.UnwrapOSError(err) + } + + // Prioritize the error from setNonblock over Control + if controlErr := syscallConn.Control(func(fd uintptr) { + errno = platform.UnwrapOSError(setNonblock(fd, enabled)) + }); errno == 0 { + errno = platform.UnwrapOSError(controlErr) + } + return +} + +// Read implements the same method as documented on fsapi.File +func (f *winTcpConnFile) Read(buf []byte) (n int, errno syscall.Errno) { + if n, errno = read(f.tc, buf); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + return +} + +// Write implements the same method as documented on fsapi.File +func (f *winTcpConnFile) Write(buf []byte) (n int, errno syscall.Errno) { + if n, errno = write(f.tc, buf); errno != 0 { + // Defer validation overhead until we've already had an error. + errno = fileError(f, f.closed, errno) + } + return +} + +// Recvfrom implements the same method as documented on socketapi.TCPConn +func (f *winTcpConnFile) Recvfrom(p []byte, flags int) (n int, errno syscall.Errno) { + if flags != MSG_PEEK { + errno = syscall.EINVAL + return + } + conn := f.tc + syscallConn, err := conn.SyscallConn() + if err != nil { + errno = platform.UnwrapOSError(err) + return + } + + // Prioritize the error from recvfrom over Control + if controlErr := syscallConn.Control(func(fd uintptr) { + var recvfromErr error + n, recvfromErr = recvfrom(syscall.Handle(fd), p, MSG_PEEK) + errno = platform.UnwrapOSError(recvfromErr) + }); errno == 0 { + errno = platform.UnwrapOSError(controlErr) + } + return +} + +// Shutdown implements the same method as documented on fsapi.Conn +func (f *winTcpConnFile) Shutdown(how int) syscall.Errno { + // FIXME: can userland shutdown listeners? + var err error + switch how { + case syscall.SHUT_RD: + err = f.tc.CloseRead() + case syscall.SHUT_WR: + err = f.tc.CloseWrite() + case syscall.SHUT_RDWR: + return f.close() + default: + return syscall.EINVAL + } + return platform.UnwrapOSError(err) +} + +// Close implements the same method as documented on fsapi.File +func (f *winTcpConnFile) Close() syscall.Errno { + return f.close() +} + +func (f *winTcpConnFile) close() syscall.Errno { + if f.closed { + return 0 + } + f.closed = true + return f.Shutdown(syscall.SHUT_RDWR) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat.go new file mode 100644 index 000000000..60690fd90 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat.go @@ -0,0 +1,32 @@ +package sysfs + +import ( + "io/fs" + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" +) + +func defaultStatFile(f *os.File) (fsapi.Stat_t, syscall.Errno) { + if t, err := f.Stat(); err != nil { + return fsapi.Stat_t{}, platform.UnwrapOSError(err) + } else { + return statFromFileInfo(t), 0 + } +} + +func StatFromDefaultFileInfo(t fs.FileInfo) fsapi.Stat_t { + st := fsapi.Stat_t{} + st.Ino = 0 + st.Dev = 0 + st.Mode = t.Mode() + st.Nlink = 1 + st.Size = t.Size() + mtim := t.ModTime().UnixNano() // Set all times to the mod time + st.Atim = mtim + st.Mtim = mtim + st.Ctim = mtim + return st +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/stat_bsd.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_bsd.go similarity index 57% rename from vendor/github.com/tetratelabs/wazero/internal/platform/stat_bsd.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_bsd.go index 90959f8f7..8297e8502 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/stat_bsd.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_bsd.go @@ -1,43 +1,46 @@ //go:build (amd64 || arm64) && (darwin || freebsd) -package platform +package sysfs import ( "io/fs" "os" "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" ) -func lstat(path string) (Stat_t, syscall.Errno) { +func lstat(path string) (fsapi.Stat_t, syscall.Errno) { if t, err := os.Lstat(path); err != nil { - return Stat_t{}, UnwrapOSError(err) + return fsapi.Stat_t{}, platform.UnwrapOSError(err) } else { return statFromFileInfo(t), 0 } } -func stat(path string) (Stat_t, syscall.Errno) { +func stat(path string) (fsapi.Stat_t, syscall.Errno) { if t, err := os.Stat(path); err != nil { - return Stat_t{}, UnwrapOSError(err) + return fsapi.Stat_t{}, platform.UnwrapOSError(err) } else { return statFromFileInfo(t), 0 } } -func statFile(f fs.File) (Stat_t, syscall.Errno) { +func statFile(f *os.File) (fsapi.Stat_t, syscall.Errno) { return defaultStatFile(f) } -func inoFromFileInfo(_ readdirFile, t fs.FileInfo) (ino uint64, err syscall.Errno) { +func inoFromFileInfo(_ string, t fs.FileInfo) (ino uint64, err syscall.Errno) { if d, ok := t.Sys().(*syscall.Stat_t); ok { ino = d.Ino } return } -func statFromFileInfo(t fs.FileInfo) Stat_t { +func statFromFileInfo(t fs.FileInfo) fsapi.Stat_t { if d, ok := t.Sys().(*syscall.Stat_t); ok { - st := Stat_t{} + st := fsapi.Stat_t{} st.Dev = uint64(d.Dev) st.Ino = d.Ino st.Uid = d.Uid @@ -53,5 +56,5 @@ func statFromFileInfo(t fs.FileInfo) Stat_t { st.Ctim = ctime.Sec*1e9 + ctime.Nsec return st } - return statFromDefaultFileInfo(t) + return StatFromDefaultFileInfo(t) } diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/stat_linux.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_linux.go similarity index 61% rename from vendor/github.com/tetratelabs/wazero/internal/platform/stat_linux.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_linux.go index 136081ef2..e90f29b51 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/stat_linux.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_linux.go @@ -3,44 +3,47 @@ // Note: This expression is not the same as compiler support, even if it looks // similar. Platform functions here are used in interpreter mode as well. -package platform +package sysfs import ( "io/fs" "os" "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" ) -func lstat(path string) (Stat_t, syscall.Errno) { +func lstat(path string) (fsapi.Stat_t, syscall.Errno) { if t, err := os.Lstat(path); err != nil { - return Stat_t{}, UnwrapOSError(err) + return fsapi.Stat_t{}, platform.UnwrapOSError(err) } else { return statFromFileInfo(t), 0 } } -func stat(path string) (Stat_t, syscall.Errno) { +func stat(path string) (fsapi.Stat_t, syscall.Errno) { if t, err := os.Stat(path); err != nil { - return Stat_t{}, UnwrapOSError(err) + return fsapi.Stat_t{}, platform.UnwrapOSError(err) } else { return statFromFileInfo(t), 0 } } -func statFile(f fs.File) (Stat_t, syscall.Errno) { +func statFile(f *os.File) (fsapi.Stat_t, syscall.Errno) { return defaultStatFile(f) } -func inoFromFileInfo(_ readdirFile, t fs.FileInfo) (ino uint64, err syscall.Errno) { +func inoFromFileInfo(_ string, t fs.FileInfo) (ino uint64, err syscall.Errno) { if d, ok := t.Sys().(*syscall.Stat_t); ok { ino = d.Ino } return } -func statFromFileInfo(t fs.FileInfo) Stat_t { +func statFromFileInfo(t fs.FileInfo) fsapi.Stat_t { if d, ok := t.Sys().(*syscall.Stat_t); ok { - st := Stat_t{} + st := fsapi.Stat_t{} st.Dev = uint64(d.Dev) st.Ino = uint64(d.Ino) st.Uid = d.Uid @@ -56,5 +59,5 @@ func statFromFileInfo(t fs.FileInfo) Stat_t { st.Ctim = ctime.Sec*1e9 + ctime.Nsec return st } - return statFromDefaultFileInfo(t) + return StatFromDefaultFileInfo(t) } diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_unsupported.go new file mode 100644 index 000000000..4c2b70550 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_unsupported.go @@ -0,0 +1,42 @@ +//go:build (!((amd64 || arm64 || riscv64) && linux) && !((amd64 || arm64) && (darwin || freebsd)) && !((amd64 || arm64) && windows)) || js + +package sysfs + +import ( + "io/fs" + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" +) + +func lstat(path string) (fsapi.Stat_t, syscall.Errno) { + t, err := os.Lstat(path) + if errno := platform.UnwrapOSError(err); errno == 0 { + return statFromFileInfo(t), 0 + } else { + return fsapi.Stat_t{}, errno + } +} + +func stat(path string) (fsapi.Stat_t, syscall.Errno) { + t, err := os.Stat(path) + if errno := platform.UnwrapOSError(err); errno == 0 { + return statFromFileInfo(t), 0 + } else { + return fsapi.Stat_t{}, errno + } +} + +func statFile(f *os.File) (fsapi.Stat_t, syscall.Errno) { + return defaultStatFile(f) +} + +func inoFromFileInfo(_ string, t fs.FileInfo) (ino uint64, err syscall.Errno) { + return +} + +func statFromFileInfo(t fs.FileInfo) fsapi.Stat_t { + return StatFromDefaultFileInfo(t) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/stat_windows.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_windows.go similarity index 62% rename from vendor/github.com/tetratelabs/wazero/internal/platform/stat_windows.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_windows.go index 289b95fae..4b05727e1 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/stat_windows.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/stat_windows.go @@ -1,14 +1,18 @@ //go:build (amd64 || arm64) && windows -package platform +package sysfs import ( "io/fs" + "os" "path" "syscall" + + "github.com/tetratelabs/wazero/internal/fsapi" + "github.com/tetratelabs/wazero/internal/platform" ) -func lstat(path string) (Stat_t, syscall.Errno) { +func lstat(path string) (fsapi.Stat_t, syscall.Errno) { attrs := uint32(syscall.FILE_FLAG_BACKUP_SEMANTICS) // Use FILE_FLAG_OPEN_REPARSE_POINT, otherwise CreateFile will follow symlink. // See https://docs.microsoft.com/en-us/windows/desktop/FileIO/symbolic-link-effects-on-file-systems-functions#createfile-and-createfiletransacted @@ -16,18 +20,18 @@ func lstat(path string) (Stat_t, syscall.Errno) { return statPath(attrs, path) } -func stat(path string) (Stat_t, syscall.Errno) { +func stat(path string) (fsapi.Stat_t, syscall.Errno) { attrs := uint32(syscall.FILE_FLAG_BACKUP_SEMANTICS) return statPath(attrs, path) } -func statPath(createFileAttrs uint32, path string) (Stat_t, syscall.Errno) { +func statPath(createFileAttrs uint32, path string) (fsapi.Stat_t, syscall.Errno) { if len(path) == 0 { - return Stat_t{}, syscall.ENOENT + return fsapi.Stat_t{}, syscall.ENOENT } pathp, err := syscall.UTF16PtrFromString(path) if err != nil { - return Stat_t{}, syscall.EINVAL + return fsapi.Stat_t{}, syscall.EINVAL } // open the file handle @@ -39,45 +43,47 @@ func statPath(createFileAttrs uint32, path string) (Stat_t, syscall.Errno) { if err == syscall.ENOTDIR { err = syscall.ENOENT } - return Stat_t{}, UnwrapOSError(err) + return fsapi.Stat_t{}, platform.UnwrapOSError(err) } defer syscall.CloseHandle(h) return statHandle(h) } -func statFile(f fs.File) (Stat_t, syscall.Errno) { - if of, ok := f.(fdFile); ok { - // Attempt to get the stat by handle, which works for normal files - st, err := statHandle(syscall.Handle(of.Fd())) - - // ERROR_INVALID_HANDLE happens before Go 1.20. Don't fail as we only - // use that approach to fill in inode data, which is not critical. - // - // Note: statHandle uses UnwrapOSError which coerces - // ERROR_INVALID_HANDLE to EBADF. - if err != syscall.EBADF { - return st, err - } +func statFile(f *os.File) (fsapi.Stat_t, syscall.Errno) { + // Attempt to get the stat by handle, which works for normal files + st, err := statHandle(syscall.Handle(f.Fd())) + + // ERROR_INVALID_HANDLE happens before Go 1.20. Don't fail as we only + // use that approach to fill in inode data, which is not critical. + // + // Note: statHandle uses UnwrapOSError which coerces + // ERROR_INVALID_HANDLE to EBADF. + if err != syscall.EBADF { + return st, err } return defaultStatFile(f) } // inoFromFileInfo uses stat to get the inode information of the file. -func inoFromFileInfo(f readdirFile, t fs.FileInfo) (ino uint64, errno syscall.Errno) { - if pf, ok := f.(PathFile); ok { - inoPath := path.Clean(path.Join(pf.Path(), t.Name())) - var st Stat_t - if st, errno = Lstat(inoPath); errno == 0 { - ino = st.Ino - } +func inoFromFileInfo(filePath string, t fs.FileInfo) (ino uint64, errno syscall.Errno) { + if filePath == "" { + // This is a fs.File backed implementation which doesn't have access to + // the original file path. + return + } + // ino is no not in Win32FileAttributeData + inoPath := path.Clean(path.Join(filePath, t.Name())) + var st fsapi.Stat_t + if st, errno = lstat(inoPath); errno == 0 { + ino = st.Ino } - return // not in Win32FileAttributeData + return } -func statFromFileInfo(t fs.FileInfo) Stat_t { +func statFromFileInfo(t fs.FileInfo) fsapi.Stat_t { if d, ok := t.Sys().(*syscall.Win32FileAttributeData); ok { - st := Stat_t{} + st := fsapi.Stat_t{} st.Ino = 0 // not in Win32FileAttributeData st.Dev = 0 // not in Win32FileAttributeData st.Mode = t.Mode() @@ -88,19 +94,19 @@ func statFromFileInfo(t fs.FileInfo) Stat_t { st.Ctim = d.CreationTime.Nanoseconds() return st } else { - return statFromDefaultFileInfo(t) + return StatFromDefaultFileInfo(t) } } -func statHandle(h syscall.Handle) (Stat_t, syscall.Errno) { +func statHandle(h syscall.Handle) (fsapi.Stat_t, syscall.Errno) { winFt, err := syscall.GetFileType(h) if err != nil { - return Stat_t{}, UnwrapOSError(err) + return fsapi.Stat_t{}, platform.UnwrapOSError(err) } var fi syscall.ByHandleFileInformation if err = syscall.GetFileInformationByHandle(h, &fi); err != nil { - return Stat_t{}, UnwrapOSError(err) + return fsapi.Stat_t{}, platform.UnwrapOSError(err) } var m fs.FileMode @@ -121,7 +127,7 @@ func statHandle(h syscall.Handle) (Stat_t, syscall.Errno) { m |= fs.ModeDir | 0o111 // e.g. 0o444 -> 0o555 } - st := Stat_t{} + st := fsapi.Stat_t{} // FileIndex{High,Low} can be combined and used as a unique identifier like inode. // https://learn.microsoft.com/en-us/windows/win32/api/fileapi/ns-fileapi-by_handle_file_information st.Dev = uint64(fi.VolumeSerialNumber) diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/sync.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sync.go new file mode 100644 index 000000000..ba336c8d5 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sync.go @@ -0,0 +1,14 @@ +//go:build !windows + +package sysfs + +import ( + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/platform" +) + +func fsync(f *os.File) syscall.Errno { + return platform.UnwrapOSError(f.Sync()) +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/sync_windows.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sync_windows.go new file mode 100644 index 000000000..e83dc3044 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sync_windows.go @@ -0,0 +1,21 @@ +package sysfs + +import ( + "os" + "syscall" + + "github.com/tetratelabs/wazero/internal/platform" +) + +func fsync(f *os.File) syscall.Errno { + errno := platform.UnwrapOSError(f.Sync()) + // Coerce error performing stat on a directory to 0, as it won't work + // on Windows. + switch errno { + case syscall.EACCES /* Go 1.20 */, syscall.EBADF /* Go 1.18 */ : + if st, err := f.Stat(); err == nil && st.IsDir() { + errno = 0 + } + } + return errno +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/syscall6_darwin.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/syscall6_darwin.go similarity index 95% rename from vendor/github.com/tetratelabs/wazero/internal/platform/syscall6_darwin.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/syscall6_darwin.go index 273fb7dd7..9fde5baa5 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/syscall6_darwin.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/syscall6_darwin.go @@ -1,4 +1,4 @@ -package platform +package sysfs import ( "syscall" diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/sysfs.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sysfs.go index 41869723d..e0ebfe5b9 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/sysfs/sysfs.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/sysfs.go @@ -4,431 +4,3 @@ // The name sysfs was chosen because wazero's public API has a "sys" package, // which was named after https://github.com/golang/sys. package sysfs - -import ( - "io" - "io/fs" - "syscall" - - "github.com/tetratelabs/wazero/internal/platform" -) - -// FS is a writeable fs.FS bridge backed by syscall functions needed for ABI -// including WASI and runtime.GOOS=js. -// -// Implementations should embed UnimplementedFS for forward compatability. Any -// unsupported method or parameter should return syscall.ENOSYS. -// -// # Errors -// -// All methods that can return an error return a syscall.Errno, which is zero -// on success. -// -// Restricting to syscall.Errno matches current WebAssembly host functions, -// which are constrained to well-known error codes. For example, `GOOS=js` maps -// hard coded values and panics otherwise. More commonly, WASI maps syscall -// errors to u32 numeric values. -// -// # Notes -// -// A writable filesystem abstraction is not yet implemented as of Go 1.20. See -// https://github.com/golang/go/issues/45757 -type FS interface { - // String should return a human-readable format of the filesystem - // - // For example, if this filesystem is backed by the real directory - // "/tmp/wasm", the expected value is "/tmp/wasm". - // - // When the host filesystem isn't a real filesystem, substitute a symbolic, - // human-readable name. e.g. "virtual" - String() string - - // OpenFile is similar to os.OpenFile, except the path is relative to this - // file system, and syscall.Errno are returned instead of an os.PathError. - // A zero syscall.Errno is success. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `path` or `flag` is invalid. - // - syscall.ENOENT: `path` doesn't exist and `flag` doesn't contain - // os.O_CREATE. - // - // # Constraints on the returned file - // - // Implementations that can read flags should enforce them regardless of - // the type returned. For example, while os.File implements io.Writer, - // attempts to write to a directory or a file opened with os.O_RDONLY fail - // with a syscall.EBADF. - // - // Some implementations choose whether to enforce read-only opens, namely - // fs.FS. While fs.FS is supported (Adapt), wazero cannot runtime enforce - // open flags. Instead, we encourage good behavior and test our built-in - // implementations. - // - // # Notes - // - // - flag are the same as OpenFile, for example, os.O_CREATE. - // - Implications of permissions when os.O_CREATE are described in Chmod - // notes. - OpenFile(path string, flag int, perm fs.FileMode) (fs.File, syscall.Errno) - // ^^ TODO: Consider syscall.Open, though this implies defining and - // coercing flags and perms similar to what is done in os.OpenFile. - - // Lstat is similar to syscall.Lstat, except the path is relative to this - // file system. - // - // # Errors - // - // The following errors are expected: - // - syscall.ENOENT: `path` doesn't exist. - // - // # Notes - // - // - An fs.FileInfo backed implementation sets atim, mtim and ctim to the - // same value. - // - When the path is a symbolic link, the stat returned is for the link, - // not the file it refers to. - Lstat(path string) (platform.Stat_t, syscall.Errno) - - // Stat is similar to syscall.Stat, except the path is relative to this - // file system. - // - // # Errors - // - // The following errors are expected: - // - syscall.ENOENT: `path` doesn't exist. - // - // # Notes - // - // - An fs.FileInfo backed implementation sets atim, mtim and ctim to the - // same value. - // - When the path is a symbolic link, the stat returned is for the file - // it refers to. - Stat(path string) (platform.Stat_t, syscall.Errno) - - // Mkdir is similar to os.Mkdir, except the path is relative to this file - // system, and syscall.Errno are returned instead of a os.PathError. A zero - // syscall.Errno is success. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `path` is invalid. - // - syscall.EEXIST: `path` exists and is a directory. - // - syscall.ENOTDIR: `path` exists and is a file. - // - // # Notes - // - // - Implications of permissions are described in Chmod notes. - Mkdir(path string, perm fs.FileMode) syscall.Errno - // ^^ TODO: Consider syscall.Mkdir, though this implies defining and - // coercing flags and perms similar to what is done in os.Mkdir. - - // Chmod is similar to os.Chmod, except the path is relative to this file - // system, and syscall.Errno are returned instead of a os.PathError. A zero - // syscall.Errno is success. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `path` is invalid. - // - syscall.ENOENT: `path` does not exist. - // - // # Notes - // - // - Windows ignores the execute bit, and any permissions come back as - // group and world. For example, chmod of 0400 reads back as 0444, and - // 0700 0666. Also, permissions on directories aren't supported at all. - Chmod(path string, perm fs.FileMode) syscall.Errno - // ^^ TODO: Consider syscall.Chmod, though this implies defining and - // coercing flags and perms similar to what is done in os.Chmod. - - // Chown is like os.Chown except the path is relative to this file - // system, and syscall.Errno are returned instead of an os.PathError. - // A zero syscall.Errno is success. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `path` is invalid. - // - syscall.ENOENT: `path` does not exist. - // - // # Notes - // - // - Windows will always return syscall.ENOSYS - // - This is similar to https://linux.die.net/man/3/chown - Chown(path string, uid, gid int) syscall.Errno - - // Lchown is like os.Lchown except the path is relative to this file - // system, and syscall.Errno are returned instead of an os.PathError. A - // zero syscall.Errno is success. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `path` is invalid. - // - syscall.ENOENT: `path` does not exist. - // - // # Notes - // - // - Windows will always return syscall.ENOSYS - // - This is similar to https://linux.die.net/man/3/lchown - Lchown(path string, uid, gid int) syscall.Errno - - // Rename is similar to syscall.Rename, except the path is relative to this - // file system. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `from` or `to` is invalid. - // - syscall.ENOENT: `from` or `to` don't exist. - // - syscall.ENOTDIR: `from` is a directory and `to` exists as a file. - // - syscall.EISDIR: `from` is a file and `to` exists as a directory. - // - syscall.ENOTEMPTY: `both from` and `to` are existing directory, but - // `to` is not empty. - // - // # Notes - // - // - Windows doesn't let you overwrite an existing directory. - Rename(from, to string) syscall.Errno - - // Rmdir is similar to syscall.Rmdir, except the path is relative to this - // file system. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `path` is invalid. - // - syscall.ENOENT: `path` doesn't exist. - // - syscall.ENOTDIR: `path` exists, but isn't a directory. - // - syscall.ENOTEMPTY: `path` exists, but isn't empty. - // - // # Notes - // - // - As of Go 1.19, Windows maps syscall.ENOTDIR to syscall.ENOENT. - Rmdir(path string) syscall.Errno - - // Unlink is similar to syscall.Unlink, except the path is relative to this - // file system. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `path` is invalid. - // - syscall.ENOENT: `path` doesn't exist. - // - syscall.EISDIR: `path` exists, but is a directory. - // - // # Notes - // - // - On Windows, syscall.Unlink doesn't delete symlink to directory unlike other platforms. Implementations might - // want to combine syscall.RemoveDirectory with syscall.Unlink in order to delete such links on Windows. - // See https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-removedirectorya - Unlink(path string) syscall.Errno - - // Link is similar to syscall.Link, except the path is relative to this - // file system. This creates "hard" link from oldPath to newPath, in - // contrast to soft link as in Symlink. - // - // # Errors - // - // The following errors are expected: - // - syscall.EPERM: `oldPath` is invalid. - // - syscall.ENOENT: `oldPath` doesn't exist. - // - syscall.EISDIR: `newPath` exists, but is a directory. - Link(oldPath, newPath string) syscall.Errno - - // Symlink is similar to syscall.Symlink, except the `oldPath` is relative - // to this file system. This creates "soft" link from oldPath to newPath, - // in contrast to hard link as in Link. - // - // # Errors - // - // The following errors are expected: - // - syscall.EPERM: `oldPath` or `newPath` is invalid. - // - syscall.EEXIST: `newPath` exists. - // - // # Notes - // - // - Only `newPath` is relative to this file system and `oldPath` is kept - // as-is. That is because the link is only resolved relative to the - // directory when dereferencing it (e.g. ReadLink). - // See https://github.com/bytecodealliance/cap-std/blob/v1.0.4/cap-std/src/fs/dir.rs#L404-L409 - // for how others implement this. - // - Symlinks in Windows requires `SeCreateSymbolicLinkPrivilege`. - // Otherwise, syscall.EPERM results. - // See https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links - Symlink(oldPath, linkName string) syscall.Errno - - // Readlink is similar to syscall.Readlink, except the path is relative to - // this file system. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `path` is invalid. - // - // # Notes - // - On Windows, the path separator is different from other platforms, - // but to provide consistent results to Wasm, this normalizes to a "/" - // separator. - Readlink(path string) (string, syscall.Errno) - - // Truncate is similar to syscall.Truncate, except the path is relative to - // this file system. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `path` is invalid or size is negative. - // - syscall.ENOENT: `path` doesn't exist - // - syscall.EACCES: `path` doesn't have write access. - Truncate(path string, size int64) syscall.Errno - - // Utimens set file access and modification times on a path relative to - // this file system, at nanosecond precision. - // - // # Parameters - // - // The `times` parameter includes the access and modification timestamps to - // assign. Special syscall.Timespec NSec values UTIME_NOW and UTIME_OMIT may be - // specified instead of real timestamps. A nil `times` parameter behaves the - // same as if both were set to UTIME_NOW. - // - // When the `symlinkFollow` parameter is true and the path is a symbolic link, - // the target of expanding that link is updated. - // - // # Errors - // - // The following errors are expected: - // - syscall.EINVAL: `path` is invalid. - // - syscall.EEXIST: `path` exists and is a directory. - // - syscall.ENOTDIR: `path` exists and is a file. - // - // # Notes - // - // - This is similar to syscall.Utimens, except that doesn't have flags to - // control expansion of symbolic links. It also doesn't support special - // values UTIME_NOW or UTIME_NOW. - // - This is like `utimensat` with `AT_FDCWD` in POSIX. See - // https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html - Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.Errno -} - -// ReaderAtOffset gets an io.Reader from a fs.File that reads from an offset, -// yet doesn't affect the underlying position. This is used to implement -// syscall.Pread. -// -// Note: The file accessed shouldn't be used concurrently, but wasm isn't safe -// to use concurrently anyway. Hence, we don't do any locking against parallel -// reads. -func ReaderAtOffset(f fs.File, offset int64) io.Reader { - if ret, ok := f.(io.ReaderAt); ok { - return &readerAtOffset{ret, offset} - } else if ret, ok := f.(io.ReadSeeker); ok { - return &seekToOffsetReader{ret, offset} - } else { - return enosysReader{} - } -} - -// FileDatasync is like syscall.Fdatasync except that's only defined in linux. -func FileDatasync(f fs.File) (err syscall.Errno) { - return platform.Fdatasync(f) -} - -type enosysReader struct{} - -// enosysReader implements io.Reader -func (rs enosysReader) Read([]byte) (n int, err error) { - return 0, syscall.ENOSYS -} - -type readerAtOffset struct { - r io.ReaderAt - offset int64 -} - -// Read implements io.Reader -func (r *readerAtOffset) Read(p []byte) (int, error) { - if len(p) == 0 { - return 0, nil // less overhead on zero-length reads. - } - - n, err := r.r.ReadAt(p, r.offset) - r.offset += int64(n) - return n, err -} - -// seekToOffsetReader implements io.Reader that seeks to an offset and reverts -// to its initial offset after each call to Read. -// -// See /RATIONALE.md "fd_pread: io.Seeker fallback when io.ReaderAt is not supported" -type seekToOffsetReader struct { - s io.ReadSeeker - offset int64 -} - -// Read implements io.Reader -func (rs *seekToOffsetReader) Read(p []byte) (int, error) { - if len(p) == 0 { - return 0, nil // less overhead on zero-length reads. - } - - // Determine the current position in the file, as we need to revert it. - currentOffset, err := rs.s.Seek(0, io.SeekCurrent) - if err != nil { - return 0, err - } - - // Put the read position back when complete. - defer func() { _, _ = rs.s.Seek(currentOffset, io.SeekStart) }() - - // If the current offset isn't in sync with this reader, move it. - if rs.offset != currentOffset { - _, err := rs.s.Seek(rs.offset, io.SeekStart) - if err != nil { - return 0, err - } - } - - // Perform the read, updating the offset. - n, err := rs.s.Read(p) - rs.offset += int64(n) - return n, err -} - -// WriterAtOffset gets an io.Writer from a fs.File that writes to an offset, -// yet doesn't affect the underlying position. This is used to implement -// syscall.Pwrite. -func WriterAtOffset(f fs.File, offset int64) io.Writer { - if ret, ok := f.(io.WriterAt); ok { - return &writerAtOffset{ret, offset} - } else { - return enosysWriter{} - } -} - -type enosysWriter struct{} - -// enosysWriter implements io.Writer -func (rs enosysWriter) Write([]byte) (n int, err error) { - return 0, syscall.ENOSYS -} - -type writerAtOffset struct { - r io.WriterAt - offset int64 -} - -// Write implements io.Writer -func (r *writerAtOffset) Write(p []byte) (int, error) { - if len(p) == 0 { - return 0, nil // less overhead on zero-length writes. - } - - n, err := r.r.WriteAt(p, r.offset) - r.offset += int64(n) - return n, err -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/unlink.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/unlink.go new file mode 100644 index 000000000..37b74e182 --- /dev/null +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/unlink.go @@ -0,0 +1,17 @@ +//go:build !windows + +package sysfs + +import ( + "syscall" + + "github.com/tetratelabs/wazero/internal/platform" +) + +func Unlink(name string) (errno syscall.Errno) { + err := syscall.Unlink(name) + if errno = platform.UnwrapOSError(err); errno == syscall.EPERM { + errno = syscall.EISDIR + } + return errno +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/platform/unlink_windows.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_windows.go similarity index 62% rename from vendor/github.com/tetratelabs/wazero/internal/platform/unlink_windows.go rename to vendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_windows.go index 9831e10bd..410ea8444 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/platform/unlink_windows.go +++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_windows.go @@ -1,10 +1,12 @@ //go:build windows -package platform +package sysfs import ( "os" "syscall" + + "github.com/tetratelabs/wazero/internal/platform" ) func Unlink(name string) syscall.Errno { @@ -12,11 +14,11 @@ func Unlink(name string) syscall.Errno { if err == nil { return 0 } - errno := UnwrapOSError(err) - if errno == syscall.EPERM { + errno := platform.UnwrapOSError(err) + if errno == syscall.EBADF { lstat, errLstat := os.Lstat(name) if errLstat == nil && lstat.Mode()&os.ModeSymlink != 0 { - errno = UnwrapOSError(os.Remove(name)) + errno = platform.UnwrapOSError(os.Remove(name)) } else { errno = syscall.EISDIR } diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/unsupported.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/unsupported.go deleted file mode 100644 index 6fb9114fa..000000000 --- a/vendor/github.com/tetratelabs/wazero/internal/sysfs/unsupported.go +++ /dev/null @@ -1,97 +0,0 @@ -package sysfs - -import ( - "io/fs" - "syscall" - - "github.com/tetratelabs/wazero/internal/platform" -) - -// UnimplementedFS is an FS that returns syscall.ENOSYS for all functions, -// This should be embedded to have forward compatible implementations. -type UnimplementedFS struct{} - -// String implements fmt.Stringer -func (UnimplementedFS) String() string { - return "Unimplemented:/" -} - -// Open implements the same method as documented on fs.FS -func (UnimplementedFS) Open(name string) (fs.File, error) { - return nil, &fs.PathError{Op: "open", Path: name, Err: syscall.ENOSYS} -} - -// OpenFile implements FS.OpenFile -func (UnimplementedFS) OpenFile(path string, flag int, perm fs.FileMode) (fs.File, syscall.Errno) { - return nil, syscall.ENOSYS -} - -// Lstat implements FS.Lstat -func (UnimplementedFS) Lstat(path string) (platform.Stat_t, syscall.Errno) { - return platform.Stat_t{}, syscall.ENOSYS -} - -// Stat implements FS.Stat -func (UnimplementedFS) Stat(path string) (platform.Stat_t, syscall.Errno) { - return platform.Stat_t{}, syscall.ENOSYS -} - -// Readlink implements FS.Readlink -func (UnimplementedFS) Readlink(path string) (string, syscall.Errno) { - return "", syscall.ENOSYS -} - -// Mkdir implements FS.Mkdir -func (UnimplementedFS) Mkdir(path string, perm fs.FileMode) syscall.Errno { - return syscall.ENOSYS -} - -// Chmod implements FS.Chmod -func (UnimplementedFS) Chmod(path string, perm fs.FileMode) syscall.Errno { - return syscall.ENOSYS -} - -// Chown implements FS.Chown -func (UnimplementedFS) Chown(path string, uid, gid int) syscall.Errno { - return syscall.ENOSYS -} - -// Lchown implements FS.Lchown -func (UnimplementedFS) Lchown(path string, uid, gid int) syscall.Errno { - return syscall.ENOSYS -} - -// Rename implements FS.Rename -func (UnimplementedFS) Rename(from, to string) syscall.Errno { - return syscall.ENOSYS -} - -// Rmdir implements FS.Rmdir -func (UnimplementedFS) Rmdir(path string) syscall.Errno { - return syscall.ENOSYS -} - -// Link implements FS.Link -func (UnimplementedFS) Link(_, _ string) syscall.Errno { - return syscall.ENOSYS -} - -// Symlink implements FS.Symlink -func (UnimplementedFS) Symlink(_, _ string) syscall.Errno { - return syscall.ENOSYS -} - -// Unlink implements FS.Unlink -func (UnimplementedFS) Unlink(path string) syscall.Errno { - return syscall.ENOSYS -} - -// Utimens implements FS.Utimens -func (UnimplementedFS) Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.Errno { - return syscall.ENOSYS -} - -// Truncate implements FS.Truncate -func (UnimplementedFS) Truncate(string, int64) syscall.Errno { - return syscall.ENOSYS -} diff --git a/vendor/github.com/tetratelabs/wazero/internal/version/version.go b/vendor/github.com/tetratelabs/wazero/internal/version/version.go index ab0b465a2..9261df0f7 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/version/version.go +++ b/vendor/github.com/tetratelabs/wazero/internal/version/version.go @@ -5,6 +5,9 @@ import ( "strings" ) +// Default is the default version value used when none was found. +const Default = "dev" + // version holds the current version from the go.mod of downstream users or set by ldflag for wazero CLI. var version string @@ -36,7 +39,7 @@ func GetWazeroVersion() (ret string) { } } if versionMissing(ret) { - return "dev" // don't return parens + return Default // don't return parens } // Cache for the subsequent calls. diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasip1/errno.go b/vendor/github.com/tetratelabs/wazero/internal/wasip1/errno.go index 7df2eabac..b4ec34eb7 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasip1/errno.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasip1/errno.go @@ -297,6 +297,8 @@ func ToErrno(errno syscall.Errno) Errno { return ErrnoNotdir case syscall.ENOTEMPTY: return ErrnoNotempty + case syscall.ENOTSOCK: + return ErrnoNotsock case syscall.ENOTSUP: return ErrnoNotsup case syscall.EPERM: diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasip1/sock.go b/vendor/github.com/tetratelabs/wazero/internal/wasip1/sock.go index a6adf56a4..90d33ece8 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasip1/sock.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasip1/sock.go @@ -1,8 +1,71 @@ package wasip1 +import "strconv" + const ( SockAcceptName = "sock_accept" SockRecvName = "sock_recv" SockSendName = "sock_send" SockShutdownName = "sock_shutdown" ) + +// SD Flags indicate which channels on a socket to shut down. +// https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-sdflags-flagsu8 +const ( + // SD_RD disables further receive operations. + SD_RD uint8 = 1 << iota //nolint + // SD_WR disables further send operations. + SD_WR +) + +func SdFlagsString(sdflags int) string { + return flagsString(sdflagNames[:], sdflags) +} + +var sdflagNames = [...]string{ + "RD", + "WR", +} + +// SI Flags are flags provided to sock_send. As there are currently no flags defined, it must be set to zero. +// https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-siflags-u16 + +func SiFlagsString(siflags int) string { + if siflags == 0 { + return "" + } + return strconv.Itoa(siflags) +} + +// RI Flags are flags provided to sock_recv. +// https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-riflags-flagsu16 +const ( + // RI_RECV_PEEK returns the message without removing it from the socket's receive queue + RI_RECV_PEEK uint8 = 1 << iota //nolint + // RI_RECV_WAITALL on byte-stream sockets, block until the full amount of data can be returned. + RI_RECV_WAITALL +) + +func RiFlagsString(riflags int) string { + return flagsString(riflagNames[:], riflags) +} + +var riflagNames = [...]string{ + "RECV_PEEK", + "RECV_WAITALL", +} + +// RO Flags are flags returned by sock_recv. +// https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-roflags-flagsu16 +const ( + // RO_RECV_DATA_TRUNCATED is returned by sock_recv when message data has been truncated. + RO_RECV_DATA_TRUNCATED uint8 = 1 << iota //nolint +) + +func RoFlagsString(roflags int) string { + return flagsString(roflagNames[:], roflags) +} + +var roflagNames = [...]string{ + "RECV_DATA_TRUNCATED", +} diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/binary/element.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/binary/element.go index a969fcc5a..538b98343 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/binary/element.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/binary/element.go @@ -33,6 +33,10 @@ func decodeElementInitValueVector(r *bytes.Reader) ([]wasm.Index, error) { if err != nil { return nil, fmt.Errorf("read function index: %w", err) } + + if u32 >= wasm.MaximumFunctionIndex { + return nil, fmt.Errorf("too large function index in Element init: %d", u32) + } vec[i] = u32 } return vec, nil @@ -56,6 +60,9 @@ func decodeElementConstExprVector(r *bytes.Reader, elemType wasm.RefType, enable return nil, fmt.Errorf("element type mismatch: want %s, but constexpr has funcref", wasm.RefTypeName(elemType)) } v, _, _ := leb128.LoadUint32(expr.Data) + if v >= wasm.MaximumFunctionIndex { + return nil, fmt.Errorf("too large function index in Element init: %d", v) + } vec[i] = v case wasm.OpcodeRefNull: if elemType != expr.Data[0] { @@ -63,6 +70,14 @@ func decodeElementConstExprVector(r *bytes.Reader, elemType wasm.RefType, enable wasm.RefTypeName(elemType), wasm.RefTypeName(expr.Data[0])) } vec[i] = wasm.ElementInitNullReference + case wasm.OpcodeGlobalGet: + i32, _, _ := leb128.LoadInt32(expr.Data) + if elemType != wasm.RefTypeFuncref { + return nil, fmt.Errorf("element type mismatch: want %s, but requires funcref", wasm.RefTypeName(elemType)) + } + // Resolving the function index is done at instantiation phase. See the comment on + // wasm.ElementInitImportedGlobalFunctionReference. + vec[i] = wasm.ElementInitImportedGlobalFunctionReference | wasm.Index(i32) default: return nil, fmt.Errorf("const expr must be either ref.null or ref.func but was %s", wasm.InstructionName(expr.Opcode)) } diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/engine.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/engine.go index c11e4f373..0d0324328 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/engine.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/engine.go @@ -45,8 +45,8 @@ type ModuleEngine interface { // - `importedModuleEngine` is the ModuleEngine for the imported ModuleInstance. ResolveImportedFunction(index, indexInImportedModule Index, importedModuleEngine ModuleEngine) - // LookupFunction returns the index of the function in the function table. - LookupFunction(t *TableInstance, typeId FunctionTypeID, tableOffset Index) (Index, error) + // LookupFunction returns the api.Function created from the function in the function table at the given offset. + LookupFunction(t *TableInstance, typeId FunctionTypeID, tableOffset Index) (api.Function, error) // FunctionInstanceReference returns Reference for the given Index for a FunctionInstance. The returned values are used by // the initialization via ElementSegment. diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/function_definition.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/function_definition.go index 24bb895b2..c5f6e9121 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/function_definition.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/function_definition.go @@ -10,11 +10,8 @@ import ( // // Note: Unlike ExportedFunctions, there is no unique constraint on imports. func (m *Module) ImportedFunctions() (ret []api.FunctionDefinition) { - for i := range m.FunctionDefinitionSection { - d := &m.FunctionDefinitionSection[i] - if d.importDesc != nil { - ret = append(ret, d) - } + for i := uint32(0); i < m.ImportFunctionCount; i++ { + ret = append(ret, m.FunctionDefinition(i)) } return } @@ -22,21 +19,30 @@ func (m *Module) ImportedFunctions() (ret []api.FunctionDefinition) { // ExportedFunctions returns the definitions of each exported function. func (m *Module) ExportedFunctions() map[string]api.FunctionDefinition { ret := map[string]api.FunctionDefinition{} - for i := range m.FunctionDefinitionSection { - d := &m.FunctionDefinitionSection[i] - for _, e := range d.exportNames { - ret[e] = d + for i := range m.ExportSection { + exp := &m.ExportSection[i] + if exp.Type == ExternTypeFunc { + d := m.FunctionDefinition(exp.Index) + ret[exp.Name] = d } } return ret } -// BuildFunctionDefinitions generates function metadata that can be parsed from +// FunctionDefinition returns the FunctionDefinition for the given `index`. +func (m *Module) FunctionDefinition(index Index) *FunctionDefinition { + // TODO: function initialization is lazy, but bulk. Make it per function. + m.buildFunctionDefinitions() + return &m.FunctionDefinitionSection[index] +} + +// buildFunctionDefinitions generates function metadata that can be parsed from // the module. This must be called after all validation. -// -// Note: This is exported for tests who don't use wazero.Runtime or -// NewHostModule to compile the module. -func (m *Module) BuildFunctionDefinitions() { +func (m *Module) buildFunctionDefinitions() { + m.functionDefinitionSectionInitOnce.Do(m.buildFunctionDefinitionsOnce) +} + +func (m *Module) buildFunctionDefinitionsOnce() { var moduleName string var functionNames NameMap var localNames, resultNames IndirectNameMap @@ -60,7 +66,7 @@ func (m *Module) BuildFunctionDefinitions() { def := &m.FunctionDefinitionSection[importFuncIdx] def.importDesc = imp def.index = importFuncIdx - def.funcType = &m.TypeSection[imp.DescFunc] + def.Functype = &m.TypeSection[imp.DescFunc] importFuncIdx++ } @@ -69,7 +75,7 @@ func (m *Module) BuildFunctionDefinitions() { idx := importFuncIdx + Index(codeIndex) def := &m.FunctionDefinitionSection[idx] def.index = idx - def.funcType = &m.TypeSection[typeIndex] + def.Functype = &m.TypeSection[typeIndex] def.goFunc = code.GoFunc } @@ -92,9 +98,9 @@ func (m *Module) BuildFunctionDefinitions() { d.moduleName = moduleName d.name = funcName - d.debugName = wasmdebug.FuncName(moduleName, funcName, funcIdx) - d.paramNames = paramNames(localNames, funcIdx, len(d.funcType.Params)) - d.resultNames = paramNames(resultNames, funcIdx, len(d.funcType.Results)) + d.Debugname = wasmdebug.FuncName(moduleName, funcName, funcIdx) + d.paramNames = paramNames(localNames, funcIdx, len(d.Functype.Params)) + d.resultNames = paramNames(resultNames, funcIdx, len(d.Functype.Results)) for i := range m.ExportSection { e := &m.ExportSection[i] @@ -108,12 +114,14 @@ func (m *Module) BuildFunctionDefinitions() { // FunctionDefinition implements api.FunctionDefinition type FunctionDefinition struct { internalapi.WazeroOnlyType - moduleName string - index Index - name string - debugName string - goFunc interface{} - funcType *FunctionType + moduleName string + index Index + name string + // Debugname is exported for testing purpose. + Debugname string + goFunc interface{} + // Functype is exported for testing purpose. + Functype *FunctionType importDesc *Import exportNames []string paramNames []string @@ -137,7 +145,7 @@ func (f *FunctionDefinition) Name() string { // DebugName implements the same method as documented on api.FunctionDefinition. func (f *FunctionDefinition) DebugName() string { - return f.debugName + return f.Debugname } // Import implements the same method as documented on api.FunctionDefinition. @@ -161,7 +169,7 @@ func (f *FunctionDefinition) GoFunction() interface{} { // ParamTypes implements api.FunctionDefinition ParamTypes. func (f *FunctionDefinition) ParamTypes() []ValueType { - return f.funcType.Params + return f.Functype.Params } // ParamNames implements the same method as documented on api.FunctionDefinition. @@ -171,7 +179,7 @@ func (f *FunctionDefinition) ParamNames() []string { // ResultTypes implements api.FunctionDefinition ResultTypes. func (f *FunctionDefinition) ResultTypes() []ValueType { - return f.funcType.Results + return f.Functype.Results } // ResultNames implements the same method as documented on api.FunctionDefinition. diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/host.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/host.go index 400bcea3d..bb9c40f59 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/host.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/host.go @@ -73,7 +73,6 @@ func NewHostModule( // TODO: refactor engines so that we can properly cache compiled machine codes for host modules. m.AssignModuleID([]byte(fmt.Sprintf("@@@@@@@@%p", m)), // @@@@@@@@ = any 8 bytes different from Wasm header. false, false) - m.BuildFunctionDefinitions() return } diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go index c882b0f06..e2d994f9c 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go @@ -111,7 +111,7 @@ func (m *MemoryInstance) ReadFloat64Le(offset uint32) (float64, bool) { // Read implements the same method as documented on api.Memory. func (m *MemoryInstance) Read(offset, byteCount uint32) ([]byte, bool) { - if !m.hasSize(offset, byteCount) { + if !m.hasSize(offset, uint64(byteCount)) { return nil, false } return m.Buffer[offset : offset+byteCount : offset+byteCount], true @@ -157,7 +157,7 @@ func (m *MemoryInstance) WriteFloat64Le(offset uint32, v float64) bool { // Write implements the same method as documented on api.Memory. func (m *MemoryInstance) Write(offset uint32, val []byte) bool { - if !m.hasSize(offset, uint32(len(val))) { + if !m.hasSize(offset, uint64(len(val))) { return false } copy(m.Buffer[offset:], val) @@ -166,7 +166,7 @@ func (m *MemoryInstance) Write(offset uint32, val []byte) bool { // WriteString implements the same method as documented on api.Memory. func (m *MemoryInstance) WriteString(offset uint32, val string) bool { - if !m.hasSize(offset, uint32(len(val))) { + if !m.hasSize(offset, uint64(len(val))) { return false } copy(m.Buffer[offset:], val) @@ -243,8 +243,8 @@ func (m *MemoryInstance) size() uint32 { // hasSize returns true if Len is sufficient for byteCount at the given offset. // // Note: This is always fine, because memory can grow, but never shrink. -func (m *MemoryInstance) hasSize(offset uint32, byteCount uint32) bool { - return uint64(offset)+uint64(byteCount) <= uint64(len(m.Buffer)) // uint64 prevents overflow on add +func (m *MemoryInstance) hasSize(offset uint32, byteCount uint64) bool { + return uint64(offset)+byteCount <= uint64(len(m.Buffer)) // uint64 prevents overflow on add } // readUint32Le implements ReadUint32Le without using a context. This is extracted as both ints and floats are stored in diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/module.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/module.go index 57063bec7..ba2c032ac 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/module.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/module.go @@ -8,6 +8,7 @@ import ( "io" "sort" "strings" + "sync" "github.com/tetratelabs/wazero/api" "github.com/tetratelabs/wazero/internal/ieee754" @@ -169,10 +170,13 @@ type Module struct { // IsHostModule true if this is the host module, false otherwise. IsHostModule bool - // FunctionDefinitionSection is a wazero-specific section built on Validate. + // functionDefinitionSectionInitOnce guards FunctionDefinitionSection so that it is initialized exactly once. + functionDefinitionSectionInitOnce sync.Once + + // FunctionDefinitionSection is a wazero-specific section. FunctionDefinitionSection []FunctionDefinition - // MemoryDefinitionSection is a wazero-specific section built on Validate. + // MemoryDefinitionSection is a wazero-specific section. MemoryDefinitionSection []MemoryDefinition // DWARFLines is used to emit DWARF based stack trace. This is created from the multiple custom sections @@ -212,28 +216,28 @@ func boolToByte(b bool) (ret byte) { return } -// TypeOfFunction returns the wasm.SectionIDType index for the given function space index or nil. -// Note: The function index is preceded by imported functions. -// TODO: Returning nil should be impossible when decode results are validated. Validate decode before back-filling tests. -func (m *Module) TypeOfFunction(funcIdx Index) *FunctionType { - typeSectionLength := uint32(len(m.TypeSection)) - if typeSectionLength == 0 { - return nil - } - funcImportCount := Index(0) - for i := range m.ImportSection { - imp := &m.ImportSection[i] - if imp.Type == ExternTypeFunc { - if funcIdx == funcImportCount { +// typeOfFunction returns the wasm.FunctionType for the given function space index or nil. +func (m *Module) typeOfFunction(funcIdx Index) *FunctionType { + typeSectionLength, importedFunctionCount := uint32(len(m.TypeSection)), m.ImportFunctionCount + if funcIdx < importedFunctionCount { + // Imports are not exclusively functions. This is the current function index in the loop. + cur := Index(0) + for i := range m.ImportSection { + imp := &m.ImportSection[i] + if imp.Type != ExternTypeFunc { + continue + } + if funcIdx == cur { if imp.DescFunc >= typeSectionLength { return nil } return &m.TypeSection[imp.DescFunc] } - funcImportCount++ + cur++ } } - funcSectionIdx := funcIdx - funcImportCount + + funcSectionIdx := funcIdx - m.ImportFunctionCount if funcSectionIdx >= uint32(len(m.FunctionSection)) { return nil } @@ -296,7 +300,7 @@ func (m *Module) validateStartSection() error { // TODO: this should be verified during decode so that errors have the correct source positions if m.StartSection != nil { startIndex := *m.StartSection - ft := m.TypeOfFunction(startIndex) + ft := m.typeOfFunction(startIndex) if ft == nil { // TODO: move this check to decoder so that a module can never be decoded invalidly return fmt.Errorf("invalid start function: func[%d] has an invalid type", startIndex) } diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/module_instance.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/module_instance.go index a11e9a83f..20cdcd96a 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/module_instance.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/module_instance.go @@ -203,7 +203,7 @@ func (m *ModuleInstance) ExportedFunctionDefinitions() map[string]api.FunctionDe result := map[string]api.FunctionDefinition{} for name, exp := range m.Exports { if exp.Type == ExternTypeFunc { - result[name] = &m.Definitions[exp.Index] + result[name] = m.Source.FunctionDefinition(exp.Index) } } return result diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/store.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/store.go index 2ad16b152..70af5e6fa 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/store.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/store.go @@ -122,13 +122,8 @@ type ( s *Store // prev and next hold the nodes in the linked list of ModuleInstance held by Store. prev, next *ModuleInstance - // aliases holds the module names that are aliases of this module registered in the store. - // Access to this field must be guarded by s.mux. - // - // Note: This is currently only used for spectests and will be nil in most cases. - aliases []string - // Definitions is derived from *Module, and is constructed during compilation phrase. - Definitions []FunctionDefinition + // Source is a pointer to the Module from which this ModuleInstance derives. + Source *Module } // DataInstance holds bytes corresponding to the data segment in a module. @@ -218,10 +213,19 @@ func (m *ModuleInstance) applyElements(elems []ElementSegment) { references[offset+uint32(i)] = Reference(0) } } else { - for i, fnIndex := range elem.Init { - if fnIndex != ElementInitNullReference { - references[offset+uint32(i)] = m.Engine.FunctionInstanceReference(fnIndex) + for i, init := range elem.Init { + if init == ElementInitNullReference { + continue + } + + var ref Reference + if index, ok := unwrapElementInitGlobalReference(init); ok { + global := m.Globals[index] + ref = Reference(global.Val) + } else { + ref = m.Engine.FunctionInstanceReference(index) } + references[offset+uint32(i)] = ref } } } @@ -321,7 +325,7 @@ func (s *Store) instantiate( sysCtx *internalsys.Context, typeIDs []FunctionTypeID, ) (m *ModuleInstance, err error) { - m = &ModuleInstance{ModuleName: name, TypeIDs: typeIDs, Sys: sysCtx, s: s, Definitions: module.FunctionDefinitionSection} + m = &ModuleInstance{ModuleName: name, TypeIDs: typeIDs, Sys: sysCtx, s: s, Source: module} m.Tables = make([]*TableInstance, int(module.ImportTableCount)+len(module.TableSection)) m.Globals = make([]*GlobalInstance, int(module.ImportGlobalCount)+len(module.GlobalSection)) @@ -396,9 +400,10 @@ func (m *ModuleInstance) resolveImports(module *Module) (err error) { switch i.Type { case ExternTypeFunc: expectedType := &module.TypeSection[i.DescFunc] - actual := &importedModule.Definitions[imported.Index] - if !actual.funcType.EqualsSignature(expectedType.Params, expectedType.Results) { - err = errorInvalidImport(i, fmt.Errorf("signature mismatch: %s != %s", expectedType, actual.funcType)) + src := importedModule.Source + actual := src.typeOfFunction(imported.Index) + if !actual.EqualsSignature(expectedType.Params, expectedType.Results) { + err = errorInvalidImport(i, fmt.Errorf("signature mismatch: %s != %s", expectedType, actual)) return } diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go index bdfbbdec9..17c63e38e 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go @@ -30,12 +30,6 @@ func (s *Store) deleteModule(m *ModuleInstance) error { if m.ModuleName != "" { delete(s.nameToModule, m.ModuleName) - // Under normal circumstances, m.aliases will be nil this loop will not - // be entered unless aliases have been created. See `*store.AliasModule` - for _, alias := range m.aliases { - delete(s.nameToModule, alias) - } - // Shrink the map if it's allocated more than twice the size of the list newCap := len(s.nameToModule) if newCap < nameToModuleShrinkThreshold { @@ -93,27 +87,6 @@ func (s *Store) registerModule(m *ModuleInstance) error { return nil } -// AliasModule aliases the instantiated module named `src` as `dst`. -// -// Note: This is only used for spectests. -func (s *Store) AliasModule(src, dst string) error { - s.mux.Lock() - defer s.mux.Unlock() - if _, ok := s.nameToModule[dst]; ok { - return nil - } - m, ok := s.nameToModule[src] - if !ok { - return nil - } - m.aliases = append(m.aliases, dst) - s.nameToModule[dst] = m - if len(s.nameToModule) > s.nameToModuleCap { - s.nameToModuleCap = len(s.nameToModule) - } - return nil -} - // Module implements wazero.Runtime Module func (s *Store) Module(moduleName string) api.Module { m, err := s.module(moduleName) diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/table.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/table.go index cd20fec07..b202e8af0 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/table.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/table.go @@ -76,12 +76,32 @@ type ElementSegment struct { Mode ElementMode } -// ElementInitNullReference represents the null reference in ElementSegment's Init. -// In Wasm spec, an init item represents either Function's Index or null reference, -// and in wazero, we limit the maximum number of functions available in a module to -// MaximumFunctionIndex. Therefore, it is safe to use math.MaxUint32 to represent the null -// reference in Element segments. -const ElementInitNullReference Index = math.MaxUint32 +const ( + // ElementInitNullReference represents the null reference in ElementSegment's Init. + // In Wasm spec, an init item represents either Function's Index or null reference, + // and in wazero, we limit the maximum number of functions available in a module to + // MaximumFunctionIndex. Therefore, it is safe to use 1 << 31 to represent the null + // reference in Element segments. + ElementInitNullReference Index = 1 << 31 + // ElementInitImportedGlobalFunctionReference represents an init item which is resolved via an imported global constexpr. + // The actual function reference stored at Global is only known at instantiation-time, so we set this flag + // to items of ElementSegment.Init at binary decoding, and unwrap this flag at instantiation to resolve the value. + // + // This might collide the init element resolved via ref.func instruction which is resolved with the func index at decoding, + // but in practice, that is not allowed in wazero thanks to our limit MaximumFunctionIndex. Thus, it is safe to set this flag + // in init element to indicate as such. + ElementInitImportedGlobalFunctionReference Index = 1 << 30 +) + +// unwrapElementInitGlobalReference takes an item of the init vector of an ElementSegment, +// and returns the Global index if it is supposed to get generated from a global. +// ok is true if the given init item is as such. +func unwrapElementInitGlobalReference(init Index) (_ Index, ok bool) { + if init&ElementInitImportedGlobalFunctionReference == ElementInitImportedGlobalFunctionReference { + return init &^ ElementInitImportedGlobalFunctionReference, true + } + return init, false +} // IsActive returns true if the element segment is "active" mode which requires the runtime to initialize table // with the contents in .Init field. @@ -135,6 +155,7 @@ func (m *Module) validateTable(enabledFeatures api.CoreFeatures, tables []Table, // Create bounds checks as these can err prior to instantiation funcCount := m.ImportFunctionCount + m.SectionElementCount(SectionIDFunction) + globalsCount := m.ImportGlobalCount + m.SectionElementCount(SectionIDGlobal) // Now, we have to figure out which table elements can be resolved before instantiation and also fail early if there // are any imported globals that are known to be invalid by their declarations. @@ -145,9 +166,19 @@ func (m *Module) validateTable(enabledFeatures api.CoreFeatures, tables []Table, if elem.Type == RefTypeFuncref { // Any offset applied is to the element, not the function index: validate here if the funcidx is sound. - for ei, funcIdx := range elem.Init { - if funcIdx != ElementInitNullReference && funcIdx >= funcCount { - return fmt.Errorf("%s[%d].init[%d] funcidx %d out of range", SectionIDName(SectionIDElement), idx, ei, funcIdx) + for ei, init := range elem.Init { + if init == ElementInitNullReference { + continue + } + index, ok := unwrapElementInitGlobalReference(init) + if ok { + if index >= globalsCount { + return fmt.Errorf("%s[%d].init[%d] globalidx %d out of range", SectionIDName(SectionIDElement), idx, ei, index) + } + } else { + if index >= funcCount { + return fmt.Errorf("%s[%d].init[%d] funcidx %d out of range", SectionIDName(SectionIDElement), idx, ei, index) + } } } } else { diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasmdebug/dwarf.go b/vendor/github.com/tetratelabs/wazero/internal/wasmdebug/dwarf.go index 9b7b27be5..3b0d3a7a6 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasmdebug/dwarf.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasmdebug/dwarf.go @@ -33,6 +33,19 @@ func NewDWARFLines(d *dwarf.Data) *DWARFLines { return &DWARFLines{d: d, linesPerEntry: map[dwarf.Offset][]line{}} } +// isTombstoneAddr returns true if the given address is invalid a.k.a tombstone address which was made no longer valid +// by linker. According to the DWARF spec[1], the value is encoded as 0xffffffff for Wasm (as 32-bit target), +// but some tools encode it either in -1, -2 [2] or 1<<32 (This might not be by tools, but by debug/dwarf package's bug). +// +// [1] https://dwarfstd.org/issues/200609.1.html +// [2] https://github.com/WebAssembly/binaryen/blob/97178d08d4a20d2a5e3a6be813fc6a7079ef86e1/src/wasm/wasm-debug.cpp#L651-L660 +// [3] https://reviews.llvm.org/D81784 +func isTombstoneAddr(addr uint64) bool { + addr32 := int32(addr) + return addr32 == -1 || addr32 == -2 || + addr32 == 0 // This covers 1 <<32. +} + // Line returns the line information for the given instructionOffset which is an offset in // the code section of the original Wasm binary. Returns empty string if the info is not found. func (d *DWARFLines) Line(instructionOffset uint64) (ret []string) { @@ -76,7 +89,11 @@ entry: continue } for _, pcs := range ranges { - if pcs[0] <= instructionOffset && instructionOffset < pcs[1] { + start, end := pcs[0], pcs[1] + if isTombstoneAddr(start) || isTombstoneAddr(end) { + continue + } + if start <= instructionOffset && instructionOffset < end { switch ent.Tag { case dwarf.TagCompileUnit: cu = ent @@ -122,6 +139,8 @@ entry: } else if err != nil { return } + // TODO: Maybe we should ignore tombstone addresses by using isTombstoneAddr, + // but not sure if that would be an issue in practice. lines = append(lines, line{addr: le.Address, pos: pos}) } sort.Slice(lines, func(i, j int) bool { return lines[i].addr < lines[j].addr }) diff --git a/vendor/github.com/tetratelabs/wazero/netlify.toml b/vendor/github.com/tetratelabs/wazero/netlify.toml index b0dbd2fea..6c4751a15 100644 --- a/vendor/github.com/tetratelabs/wazero/netlify.toml +++ b/vendor/github.com/tetratelabs/wazero/netlify.toml @@ -3,7 +3,7 @@ publish = "public" [build.environment] - HUGO_VERSION = "0.111.3" + HUGO_VERSION = "0.112.5" [context.production] command = "git submodule update --init && hugo --gc --minify" diff --git a/vendor/github.com/tetratelabs/wazero/runtime.go b/vendor/github.com/tetratelabs/wazero/runtime.go index 9047ba299..0a944175e 100644 --- a/vendor/github.com/tetratelabs/wazero/runtime.go +++ b/vendor/github.com/tetratelabs/wazero/runtime.go @@ -7,6 +7,7 @@ import ( "github.com/tetratelabs/wazero/api" experimentalapi "github.com/tetratelabs/wazero/experimental" + internalsock "github.com/tetratelabs/wazero/internal/sock" internalsys "github.com/tetratelabs/wazero/internal/sys" "github.com/tetratelabs/wazero/internal/wasm" binaryformat "github.com/tetratelabs/wazero/internal/wasm/binary" @@ -215,8 +216,8 @@ func (r *runtime) CompileModule(ctx context.Context, binary []byte) (CompiledMod return nil, err } - // Now that the module is validated, cache the function and memory definitions. - internal.BuildFunctionDefinitions() + // Now that the module is validated, cache the memory definitions. + // TODO: lazy initialization of memory definition. internal.BuildMemoryDefinitions() c := &compiledModule{module: internal, compiledEngine: r.store.Engine} @@ -228,7 +229,7 @@ func (r *runtime) CompileModule(ctx context.Context, binary []byte) (CompiledMod } c.typeIDs = typeIDs - listeners, err := buildListeners(ctx, internal) + listeners, err := buildFunctionListeners(ctx, internal) if err != nil { return nil, err } @@ -239,7 +240,7 @@ func (r *runtime) CompileModule(ctx context.Context, binary []byte) (CompiledMod return c, nil } -func buildListeners(ctx context.Context, internal *wasm.Module) ([]experimentalapi.FunctionListener, error) { +func buildFunctionListeners(ctx context.Context, internal *wasm.Module) ([]experimentalapi.FunctionListener, error) { // Test to see if internal code are using an experimental feature. fnlf := ctx.Value(experimentalapi.FunctionListenerFactoryKey{}) if fnlf == nil { @@ -249,7 +250,7 @@ func buildListeners(ctx context.Context, internal *wasm.Module) ([]experimentala importCount := internal.ImportFunctionCount listeners := make([]experimentalapi.FunctionListener, len(internal.FunctionSection)) for i := 0; i < len(listeners); i++ { - listeners[i] = factory.NewListener(&internal.FunctionDefinitionSection[uint32(i)+importCount]) + listeners[i] = factory.NewFunctionListener(internal.FunctionDefinition(uint32(i) + importCount)) } return listeners, nil } @@ -290,6 +291,14 @@ func (r *runtime) InstantiateModule( code := compiled.(*compiledModule) config := mConfig.(*moduleConfig) + // Only build listeners on a guest module. A host module doesn't have + // memory, and a guest without memory can't use listeners anyway. + if !code.module.IsHostModule { + if sockConfig, ok := ctx.Value(internalsock.ConfigKey{}).(*internalsock.Config); ok { + config.sockConfig = sockConfig + } + } + var sysCtx *internalsys.Context if sysCtx, err = config.toSysContext(); err != nil { return diff --git a/vendor/github.com/vbatts/tar-split/LICENSE b/vendor/github.com/vbatts/tar-split/LICENSE new file mode 100644 index 000000000..ca03685b1 --- /dev/null +++ b/vendor/github.com/vbatts/tar-split/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2015 Vincent Batts, Raleigh, NC, USA + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. 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. + +3. Neither the name of the copyright holder 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 HOLDER 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/vbatts/tar-split/archive/tar/common.go b/vendor/github.com/vbatts/tar-split/archive/tar/common.go new file mode 100644 index 000000000..dee9e47e4 --- /dev/null +++ b/vendor/github.com/vbatts/tar-split/archive/tar/common.go @@ -0,0 +1,723 @@ +// Copyright 2009 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 tar implements access to tar archives. +// +// Tape archives (tar) are a file format for storing a sequence of files that +// can be read and written in a streaming manner. +// This package aims to cover most variations of the format, +// including those produced by GNU and BSD tar tools. +package tar + +import ( + "errors" + "fmt" + "math" + "os" + "path" + "reflect" + "strconv" + "strings" + "time" +) + +// BUG: Use of the Uid and Gid fields in Header could overflow on 32-bit +// architectures. If a large value is encountered when decoding, the result +// stored in Header will be the truncated version. + +var ( + ErrHeader = errors.New("archive/tar: invalid tar header") + ErrWriteTooLong = errors.New("archive/tar: write too long") + ErrFieldTooLong = errors.New("archive/tar: header field too long") + ErrWriteAfterClose = errors.New("archive/tar: write after close") + errMissData = errors.New("archive/tar: sparse file references non-existent data") + errUnrefData = errors.New("archive/tar: sparse file contains unreferenced data") + errWriteHole = errors.New("archive/tar: write non-NUL byte in sparse hole") +) + +type headerError []string + +func (he headerError) Error() string { + const prefix = "archive/tar: cannot encode header" + var ss []string + for _, s := range he { + if s != "" { + ss = append(ss, s) + } + } + if len(ss) == 0 { + return prefix + } + return fmt.Sprintf("%s: %v", prefix, strings.Join(ss, "; and ")) +} + +// Type flags for Header.Typeflag. +const ( + // Type '0' indicates a regular file. + TypeReg = '0' + TypeRegA = '\x00' // Deprecated: Use TypeReg instead. + + // Type '1' to '6' are header-only flags and may not have a data body. + TypeLink = '1' // Hard link + TypeSymlink = '2' // Symbolic link + TypeChar = '3' // Character device node + TypeBlock = '4' // Block device node + TypeDir = '5' // Directory + TypeFifo = '6' // FIFO node + + // Type '7' is reserved. + TypeCont = '7' + + // Type 'x' is used by the PAX format to store key-value records that + // are only relevant to the next file. + // This package transparently handles these types. + TypeXHeader = 'x' + + // Type 'g' is used by the PAX format to store key-value records that + // are relevant to all subsequent files. + // This package only supports parsing and composing such headers, + // but does not currently support persisting the global state across files. + TypeXGlobalHeader = 'g' + + // Type 'S' indicates a sparse file in the GNU format. + TypeGNUSparse = 'S' + + // Types 'L' and 'K' are used by the GNU format for a meta file + // used to store the path or link name for the next file. + // This package transparently handles these types. + TypeGNULongName = 'L' + TypeGNULongLink = 'K' +) + +// Keywords for PAX extended header records. +const ( + paxNone = "" // Indicates that no PAX key is suitable + paxPath = "path" + paxLinkpath = "linkpath" + paxSize = "size" + paxUid = "uid" + paxGid = "gid" + paxUname = "uname" + paxGname = "gname" + paxMtime = "mtime" + paxAtime = "atime" + paxCtime = "ctime" // Removed from later revision of PAX spec, but was valid + paxCharset = "charset" // Currently unused + paxComment = "comment" // Currently unused + + paxSchilyXattr = "SCHILY.xattr." + + // Keywords for GNU sparse files in a PAX extended header. + paxGNUSparse = "GNU.sparse." + paxGNUSparseNumBlocks = "GNU.sparse.numblocks" + paxGNUSparseOffset = "GNU.sparse.offset" + paxGNUSparseNumBytes = "GNU.sparse.numbytes" + paxGNUSparseMap = "GNU.sparse.map" + paxGNUSparseName = "GNU.sparse.name" + paxGNUSparseMajor = "GNU.sparse.major" + paxGNUSparseMinor = "GNU.sparse.minor" + paxGNUSparseSize = "GNU.sparse.size" + paxGNUSparseRealSize = "GNU.sparse.realsize" +) + +// basicKeys is a set of the PAX keys for which we have built-in support. +// This does not contain "charset" or "comment", which are both PAX-specific, +// so adding them as first-class features of Header is unlikely. +// Users can use the PAXRecords field to set it themselves. +var basicKeys = map[string]bool{ + paxPath: true, paxLinkpath: true, paxSize: true, paxUid: true, paxGid: true, + paxUname: true, paxGname: true, paxMtime: true, paxAtime: true, paxCtime: true, +} + +// A Header represents a single header in a tar archive. +// Some fields may not be populated. +// +// For forward compatibility, users that retrieve a Header from Reader.Next, +// mutate it in some ways, and then pass it back to Writer.WriteHeader +// should do so by creating a new Header and copying the fields +// that they are interested in preserving. +type Header struct { + // Typeflag is the type of header entry. + // The zero value is automatically promoted to either TypeReg or TypeDir + // depending on the presence of a trailing slash in Name. + Typeflag byte + + Name string // Name of file entry + Linkname string // Target name of link (valid for TypeLink or TypeSymlink) + + Size int64 // Logical file size in bytes + Mode int64 // Permission and mode bits + Uid int // User ID of owner + Gid int // Group ID of owner + Uname string // User name of owner + Gname string // Group name of owner + + // If the Format is unspecified, then Writer.WriteHeader rounds ModTime + // to the nearest second and ignores the AccessTime and ChangeTime fields. + // + // To use AccessTime or ChangeTime, specify the Format as PAX or GNU. + // To use sub-second resolution, specify the Format as PAX. + ModTime time.Time // Modification time + AccessTime time.Time // Access time (requires either PAX or GNU support) + ChangeTime time.Time // Change time (requires either PAX or GNU support) + + Devmajor int64 // Major device number (valid for TypeChar or TypeBlock) + Devminor int64 // Minor device number (valid for TypeChar or TypeBlock) + + // Xattrs stores extended attributes as PAX records under the + // "SCHILY.xattr." namespace. + // + // The following are semantically equivalent: + // h.Xattrs[key] = value + // h.PAXRecords["SCHILY.xattr."+key] = value + // + // When Writer.WriteHeader is called, the contents of Xattrs will take + // precedence over those in PAXRecords. + // + // Deprecated: Use PAXRecords instead. + Xattrs map[string]string + + // PAXRecords is a map of PAX extended header records. + // + // User-defined records should have keys of the following form: + // VENDOR.keyword + // Where VENDOR is some namespace in all uppercase, and keyword may + // not contain the '=' character (e.g., "GOLANG.pkg.version"). + // The key and value should be non-empty UTF-8 strings. + // + // When Writer.WriteHeader is called, PAX records derived from the + // other fields in Header take precedence over PAXRecords. + PAXRecords map[string]string + + // Format specifies the format of the tar header. + // + // This is set by Reader.Next as a best-effort guess at the format. + // Since the Reader liberally reads some non-compliant files, + // it is possible for this to be FormatUnknown. + // + // If the format is unspecified when Writer.WriteHeader is called, + // then it uses the first format (in the order of USTAR, PAX, GNU) + // capable of encoding this Header (see Format). + Format Format +} + +// sparseEntry represents a Length-sized fragment at Offset in the file. +type sparseEntry struct{ Offset, Length int64 } + +func (s sparseEntry) endOffset() int64 { return s.Offset + s.Length } + +// A sparse file can be represented as either a sparseDatas or a sparseHoles. +// As long as the total size is known, they are equivalent and one can be +// converted to the other form and back. The various tar formats with sparse +// file support represent sparse files in the sparseDatas form. That is, they +// specify the fragments in the file that has data, and treat everything else as +// having zero bytes. As such, the encoding and decoding logic in this package +// deals with sparseDatas. +// +// However, the external API uses sparseHoles instead of sparseDatas because the +// zero value of sparseHoles logically represents a normal file (i.e., there are +// no holes in it). On the other hand, the zero value of sparseDatas implies +// that the file has no data in it, which is rather odd. +// +// As an example, if the underlying raw file contains the 10-byte data: +// var compactFile = "abcdefgh" +// +// And the sparse map has the following entries: +// var spd sparseDatas = []sparseEntry{ +// {Offset: 2, Length: 5}, // Data fragment for 2..6 +// {Offset: 18, Length: 3}, // Data fragment for 18..20 +// } +// var sph sparseHoles = []sparseEntry{ +// {Offset: 0, Length: 2}, // Hole fragment for 0..1 +// {Offset: 7, Length: 11}, // Hole fragment for 7..17 +// {Offset: 21, Length: 4}, // Hole fragment for 21..24 +// } +// +// Then the content of the resulting sparse file with a Header.Size of 25 is: +// var sparseFile = "\x00"*2 + "abcde" + "\x00"*11 + "fgh" + "\x00"*4 +type ( + sparseDatas []sparseEntry + sparseHoles []sparseEntry +) + +// validateSparseEntries reports whether sp is a valid sparse map. +// It does not matter whether sp represents data fragments or hole fragments. +func validateSparseEntries(sp []sparseEntry, size int64) bool { + // Validate all sparse entries. These are the same checks as performed by + // the BSD tar utility. + if size < 0 { + return false + } + var pre sparseEntry + for _, cur := range sp { + switch { + case cur.Offset < 0 || cur.Length < 0: + return false // Negative values are never okay + case cur.Offset > math.MaxInt64-cur.Length: + return false // Integer overflow with large length + case cur.endOffset() > size: + return false // Region extends beyond the actual size + case pre.endOffset() > cur.Offset: + return false // Regions cannot overlap and must be in order + } + pre = cur + } + return true +} + +// alignSparseEntries mutates src and returns dst where each fragment's +// starting offset is aligned up to the nearest block edge, and each +// ending offset is aligned down to the nearest block edge. +// +// Even though the Go tar Reader and the BSD tar utility can handle entries +// with arbitrary offsets and lengths, the GNU tar utility can only handle +// offsets and lengths that are multiples of blockSize. +func alignSparseEntries(src []sparseEntry, size int64) []sparseEntry { + dst := src[:0] + for _, s := range src { + pos, end := s.Offset, s.endOffset() + pos += blockPadding(+pos) // Round-up to nearest blockSize + if end != size { + end -= blockPadding(-end) // Round-down to nearest blockSize + } + if pos < end { + dst = append(dst, sparseEntry{Offset: pos, Length: end - pos}) + } + } + return dst +} + +// invertSparseEntries converts a sparse map from one form to the other. +// If the input is sparseHoles, then it will output sparseDatas and vice-versa. +// The input must have been already validated. +// +// This function mutates src and returns a normalized map where: +// * adjacent fragments are coalesced together +// * only the last fragment may be empty +// * the endOffset of the last fragment is the total size +func invertSparseEntries(src []sparseEntry, size int64) []sparseEntry { + dst := src[:0] + var pre sparseEntry + for _, cur := range src { + if cur.Length == 0 { + continue // Skip empty fragments + } + pre.Length = cur.Offset - pre.Offset + if pre.Length > 0 { + dst = append(dst, pre) // Only add non-empty fragments + } + pre.Offset = cur.endOffset() + } + pre.Length = size - pre.Offset // Possibly the only empty fragment + return append(dst, pre) +} + +// fileState tracks the number of logical (includes sparse holes) and physical +// (actual in tar archive) bytes remaining for the current file. +// +// Invariant: LogicalRemaining >= PhysicalRemaining +type fileState interface { + LogicalRemaining() int64 + PhysicalRemaining() int64 +} + +// allowedFormats determines which formats can be used. +// The value returned is the logical OR of multiple possible formats. +// If the value is FormatUnknown, then the input Header cannot be encoded +// and an error is returned explaining why. +// +// As a by-product of checking the fields, this function returns paxHdrs, which +// contain all fields that could not be directly encoded. +// A value receiver ensures that this method does not mutate the source Header. +func (h Header) allowedFormats() (format Format, paxHdrs map[string]string, err error) { + format = FormatUSTAR | FormatPAX | FormatGNU + paxHdrs = make(map[string]string) + + var whyNoUSTAR, whyNoPAX, whyNoGNU string + var preferPAX bool // Prefer PAX over USTAR + verifyString := func(s string, size int, name, paxKey string) { + // NUL-terminator is optional for path and linkpath. + // Technically, it is required for uname and gname, + // but neither GNU nor BSD tar checks for it. + tooLong := len(s) > size + allowLongGNU := paxKey == paxPath || paxKey == paxLinkpath + if hasNUL(s) || (tooLong && !allowLongGNU) { + whyNoGNU = fmt.Sprintf("GNU cannot encode %s=%q", name, s) + format.mustNotBe(FormatGNU) + } + if !isASCII(s) || tooLong { + canSplitUSTAR := paxKey == paxPath + if _, _, ok := splitUSTARPath(s); !canSplitUSTAR || !ok { + whyNoUSTAR = fmt.Sprintf("USTAR cannot encode %s=%q", name, s) + format.mustNotBe(FormatUSTAR) + } + if paxKey == paxNone { + whyNoPAX = fmt.Sprintf("PAX cannot encode %s=%q", name, s) + format.mustNotBe(FormatPAX) + } else { + paxHdrs[paxKey] = s + } + } + if v, ok := h.PAXRecords[paxKey]; ok && v == s { + paxHdrs[paxKey] = v + } + } + verifyNumeric := func(n int64, size int, name, paxKey string) { + if !fitsInBase256(size, n) { + whyNoGNU = fmt.Sprintf("GNU cannot encode %s=%d", name, n) + format.mustNotBe(FormatGNU) + } + if !fitsInOctal(size, n) { + whyNoUSTAR = fmt.Sprintf("USTAR cannot encode %s=%d", name, n) + format.mustNotBe(FormatUSTAR) + if paxKey == paxNone { + whyNoPAX = fmt.Sprintf("PAX cannot encode %s=%d", name, n) + format.mustNotBe(FormatPAX) + } else { + paxHdrs[paxKey] = strconv.FormatInt(n, 10) + } + } + if v, ok := h.PAXRecords[paxKey]; ok && v == strconv.FormatInt(n, 10) { + paxHdrs[paxKey] = v + } + } + verifyTime := func(ts time.Time, size int, name, paxKey string) { + if ts.IsZero() { + return // Always okay + } + if !fitsInBase256(size, ts.Unix()) { + whyNoGNU = fmt.Sprintf("GNU cannot encode %s=%v", name, ts) + format.mustNotBe(FormatGNU) + } + isMtime := paxKey == paxMtime + fitsOctal := fitsInOctal(size, ts.Unix()) + if (isMtime && !fitsOctal) || !isMtime { + whyNoUSTAR = fmt.Sprintf("USTAR cannot encode %s=%v", name, ts) + format.mustNotBe(FormatUSTAR) + } + needsNano := ts.Nanosecond() != 0 + if !isMtime || !fitsOctal || needsNano { + preferPAX = true // USTAR may truncate sub-second measurements + if paxKey == paxNone { + whyNoPAX = fmt.Sprintf("PAX cannot encode %s=%v", name, ts) + format.mustNotBe(FormatPAX) + } else { + paxHdrs[paxKey] = formatPAXTime(ts) + } + } + if v, ok := h.PAXRecords[paxKey]; ok && v == formatPAXTime(ts) { + paxHdrs[paxKey] = v + } + } + + // Check basic fields. + var blk block + v7 := blk.V7() + ustar := blk.USTAR() + gnu := blk.GNU() + verifyString(h.Name, len(v7.Name()), "Name", paxPath) + verifyString(h.Linkname, len(v7.LinkName()), "Linkname", paxLinkpath) + verifyString(h.Uname, len(ustar.UserName()), "Uname", paxUname) + verifyString(h.Gname, len(ustar.GroupName()), "Gname", paxGname) + verifyNumeric(h.Mode, len(v7.Mode()), "Mode", paxNone) + verifyNumeric(int64(h.Uid), len(v7.UID()), "Uid", paxUid) + verifyNumeric(int64(h.Gid), len(v7.GID()), "Gid", paxGid) + verifyNumeric(h.Size, len(v7.Size()), "Size", paxSize) + verifyNumeric(h.Devmajor, len(ustar.DevMajor()), "Devmajor", paxNone) + verifyNumeric(h.Devminor, len(ustar.DevMinor()), "Devminor", paxNone) + verifyTime(h.ModTime, len(v7.ModTime()), "ModTime", paxMtime) + verifyTime(h.AccessTime, len(gnu.AccessTime()), "AccessTime", paxAtime) + verifyTime(h.ChangeTime, len(gnu.ChangeTime()), "ChangeTime", paxCtime) + + // Check for header-only types. + var whyOnlyPAX, whyOnlyGNU string + switch h.Typeflag { + case TypeReg, TypeChar, TypeBlock, TypeFifo, TypeGNUSparse: + // Exclude TypeLink and TypeSymlink, since they may reference directories. + if strings.HasSuffix(h.Name, "/") { + return FormatUnknown, nil, headerError{"filename may not have trailing slash"} + } + case TypeXHeader, TypeGNULongName, TypeGNULongLink: + return FormatUnknown, nil, headerError{"cannot manually encode TypeXHeader, TypeGNULongName, or TypeGNULongLink headers"} + case TypeXGlobalHeader: + h2 := Header{Name: h.Name, Typeflag: h.Typeflag, Xattrs: h.Xattrs, PAXRecords: h.PAXRecords, Format: h.Format} + if !reflect.DeepEqual(h, h2) { + return FormatUnknown, nil, headerError{"only PAXRecords should be set for TypeXGlobalHeader"} + } + whyOnlyPAX = "only PAX supports TypeXGlobalHeader" + format.mayOnlyBe(FormatPAX) + } + if !isHeaderOnlyType(h.Typeflag) && h.Size < 0 { + return FormatUnknown, nil, headerError{"negative size on header-only type"} + } + + // Check PAX records. + if len(h.Xattrs) > 0 { + for k, v := range h.Xattrs { + paxHdrs[paxSchilyXattr+k] = v + } + whyOnlyPAX = "only PAX supports Xattrs" + format.mayOnlyBe(FormatPAX) + } + if len(h.PAXRecords) > 0 { + for k, v := range h.PAXRecords { + switch _, exists := paxHdrs[k]; { + case exists: + continue // Do not overwrite existing records + case h.Typeflag == TypeXGlobalHeader: + paxHdrs[k] = v // Copy all records + case !basicKeys[k] && !strings.HasPrefix(k, paxGNUSparse): + paxHdrs[k] = v // Ignore local records that may conflict + } + } + whyOnlyPAX = "only PAX supports PAXRecords" + format.mayOnlyBe(FormatPAX) + } + for k, v := range paxHdrs { + if !validPAXRecord(k, v) { + return FormatUnknown, nil, headerError{fmt.Sprintf("invalid PAX record: %q", k+" = "+v)} + } + } + + // TODO(dsnet): Re-enable this when adding sparse support. + // See https://golang.org/issue/22735 + /* + // Check sparse files. + if len(h.SparseHoles) > 0 || h.Typeflag == TypeGNUSparse { + if isHeaderOnlyType(h.Typeflag) { + return FormatUnknown, nil, headerError{"header-only type cannot be sparse"} + } + if !validateSparseEntries(h.SparseHoles, h.Size) { + return FormatUnknown, nil, headerError{"invalid sparse holes"} + } + if h.Typeflag == TypeGNUSparse { + whyOnlyGNU = "only GNU supports TypeGNUSparse" + format.mayOnlyBe(FormatGNU) + } else { + whyNoGNU = "GNU supports sparse files only with TypeGNUSparse" + format.mustNotBe(FormatGNU) + } + whyNoUSTAR = "USTAR does not support sparse files" + format.mustNotBe(FormatUSTAR) + } + */ + + // Check desired format. + if wantFormat := h.Format; wantFormat != FormatUnknown { + if wantFormat.has(FormatPAX) && !preferPAX { + wantFormat.mayBe(FormatUSTAR) // PAX implies USTAR allowed too + } + format.mayOnlyBe(wantFormat) // Set union of formats allowed and format wanted + } + if format == FormatUnknown { + switch h.Format { + case FormatUSTAR: + err = headerError{"Format specifies USTAR", whyNoUSTAR, whyOnlyPAX, whyOnlyGNU} + case FormatPAX: + err = headerError{"Format specifies PAX", whyNoPAX, whyOnlyGNU} + case FormatGNU: + err = headerError{"Format specifies GNU", whyNoGNU, whyOnlyPAX} + default: + err = headerError{whyNoUSTAR, whyNoPAX, whyNoGNU, whyOnlyPAX, whyOnlyGNU} + } + } + return format, paxHdrs, err +} + +// FileInfo returns an os.FileInfo for the Header. +func (h *Header) FileInfo() os.FileInfo { + return headerFileInfo{h} +} + +// headerFileInfo implements os.FileInfo. +type headerFileInfo struct { + h *Header +} + +func (fi headerFileInfo) Size() int64 { return fi.h.Size } +func (fi headerFileInfo) IsDir() bool { return fi.Mode().IsDir() } +func (fi headerFileInfo) ModTime() time.Time { return fi.h.ModTime } +func (fi headerFileInfo) Sys() interface{} { return fi.h } + +// Name returns the base name of the file. +func (fi headerFileInfo) Name() string { + if fi.IsDir() { + return path.Base(path.Clean(fi.h.Name)) + } + return path.Base(fi.h.Name) +} + +// Mode returns the permission and mode bits for the headerFileInfo. +func (fi headerFileInfo) Mode() (mode os.FileMode) { + // Set file permission bits. + mode = os.FileMode(fi.h.Mode).Perm() + + // Set setuid, setgid and sticky bits. + if fi.h.Mode&c_ISUID != 0 { + mode |= os.ModeSetuid + } + if fi.h.Mode&c_ISGID != 0 { + mode |= os.ModeSetgid + } + if fi.h.Mode&c_ISVTX != 0 { + mode |= os.ModeSticky + } + + // Set file mode bits; clear perm, setuid, setgid, and sticky bits. + switch m := os.FileMode(fi.h.Mode) &^ 07777; m { + case c_ISDIR: + mode |= os.ModeDir + case c_ISFIFO: + mode |= os.ModeNamedPipe + case c_ISLNK: + mode |= os.ModeSymlink + case c_ISBLK: + mode |= os.ModeDevice + case c_ISCHR: + mode |= os.ModeDevice + mode |= os.ModeCharDevice + case c_ISSOCK: + mode |= os.ModeSocket + } + + switch fi.h.Typeflag { + case TypeSymlink: + mode |= os.ModeSymlink + case TypeChar: + mode |= os.ModeDevice + mode |= os.ModeCharDevice + case TypeBlock: + mode |= os.ModeDevice + case TypeDir: + mode |= os.ModeDir + case TypeFifo: + mode |= os.ModeNamedPipe + } + + return mode +} + +// sysStat, if non-nil, populates h from system-dependent fields of fi. +var sysStat func(fi os.FileInfo, h *Header) error + +const ( + // Mode constants from the USTAR spec: + // See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_06 + c_ISUID = 04000 // Set uid + c_ISGID = 02000 // Set gid + c_ISVTX = 01000 // Save text (sticky bit) + + // Common Unix mode constants; these are not defined in any common tar standard. + // Header.FileInfo understands these, but FileInfoHeader will never produce these. + c_ISDIR = 040000 // Directory + c_ISFIFO = 010000 // FIFO + c_ISREG = 0100000 // Regular file + c_ISLNK = 0120000 // Symbolic link + c_ISBLK = 060000 // Block special file + c_ISCHR = 020000 // Character special file + c_ISSOCK = 0140000 // Socket +) + +// FileInfoHeader creates a partially-populated Header from fi. +// If fi describes a symlink, FileInfoHeader records link as the link target. +// If fi describes a directory, a slash is appended to the name. +// +// Since os.FileInfo's Name method only returns the base name of +// the file it describes, it may be necessary to modify Header.Name +// to provide the full path name of the file. +func FileInfoHeader(fi os.FileInfo, link string) (*Header, error) { + if fi == nil { + return nil, errors.New("archive/tar: FileInfo is nil") + } + fm := fi.Mode() + h := &Header{ + Name: fi.Name(), + ModTime: fi.ModTime(), + Mode: int64(fm.Perm()), // or'd with c_IS* constants later + } + switch { + case fm.IsRegular(): + h.Typeflag = TypeReg + h.Size = fi.Size() + case fi.IsDir(): + h.Typeflag = TypeDir + h.Name += "/" + case fm&os.ModeSymlink != 0: + h.Typeflag = TypeSymlink + h.Linkname = link + case fm&os.ModeDevice != 0: + if fm&os.ModeCharDevice != 0 { + h.Typeflag = TypeChar + } else { + h.Typeflag = TypeBlock + } + case fm&os.ModeNamedPipe != 0: + h.Typeflag = TypeFifo + case fm&os.ModeSocket != 0: + return nil, fmt.Errorf("archive/tar: sockets not supported") + default: + return nil, fmt.Errorf("archive/tar: unknown file mode %v", fm) + } + if fm&os.ModeSetuid != 0 { + h.Mode |= c_ISUID + } + if fm&os.ModeSetgid != 0 { + h.Mode |= c_ISGID + } + if fm&os.ModeSticky != 0 { + h.Mode |= c_ISVTX + } + // If possible, populate additional fields from OS-specific + // FileInfo fields. + if sys, ok := fi.Sys().(*Header); ok { + // This FileInfo came from a Header (not the OS). Use the + // original Header to populate all remaining fields. + h.Uid = sys.Uid + h.Gid = sys.Gid + h.Uname = sys.Uname + h.Gname = sys.Gname + h.AccessTime = sys.AccessTime + h.ChangeTime = sys.ChangeTime + if sys.Xattrs != nil { + h.Xattrs = make(map[string]string) + for k, v := range sys.Xattrs { + h.Xattrs[k] = v + } + } + if sys.Typeflag == TypeLink { + // hard link + h.Typeflag = TypeLink + h.Size = 0 + h.Linkname = sys.Linkname + } + if sys.PAXRecords != nil { + h.PAXRecords = make(map[string]string) + for k, v := range sys.PAXRecords { + h.PAXRecords[k] = v + } + } + } + if sysStat != nil { + return h, sysStat(fi, h) + } + return h, nil +} + +// isHeaderOnlyType checks if the given type flag is of the type that has no +// data section even if a size is specified. +func isHeaderOnlyType(flag byte) bool { + switch flag { + case TypeLink, TypeSymlink, TypeChar, TypeBlock, TypeDir, TypeFifo: + return true + default: + return false + } +} + +func min(a, b int64) int64 { + if a < b { + return a + } + return b +} diff --git a/vendor/github.com/vbatts/tar-split/archive/tar/format.go b/vendor/github.com/vbatts/tar-split/archive/tar/format.go new file mode 100644 index 000000000..1f89d0c59 --- /dev/null +++ b/vendor/github.com/vbatts/tar-split/archive/tar/format.go @@ -0,0 +1,303 @@ +// 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 tar + +import "strings" + +// Format represents the tar archive format. +// +// The original tar format was introduced in Unix V7. +// Since then, there have been multiple competing formats attempting to +// standardize or extend the V7 format to overcome its limitations. +// The most common formats are the USTAR, PAX, and GNU formats, +// each with their own advantages and limitations. +// +// The following table captures the capabilities of each format: +// +// | USTAR | PAX | GNU +// ------------------+--------+-----------+---------- +// Name | 256B | unlimited | unlimited +// Linkname | 100B | unlimited | unlimited +// Size | uint33 | unlimited | uint89 +// Mode | uint21 | uint21 | uint57 +// Uid/Gid | uint21 | unlimited | uint57 +// Uname/Gname | 32B | unlimited | 32B +// ModTime | uint33 | unlimited | int89 +// AccessTime | n/a | unlimited | int89 +// ChangeTime | n/a | unlimited | int89 +// Devmajor/Devminor | uint21 | uint21 | uint57 +// ------------------+--------+-----------+---------- +// string encoding | ASCII | UTF-8 | binary +// sub-second times | no | yes | no +// sparse files | no | yes | yes +// +// The table's upper portion shows the Header fields, where each format reports +// the maximum number of bytes allowed for each string field and +// the integer type used to store each numeric field +// (where timestamps are stored as the number of seconds since the Unix epoch). +// +// The table's lower portion shows specialized features of each format, +// such as supported string encodings, support for sub-second timestamps, +// or support for sparse files. +// +// The Writer currently provides no support for sparse files. +type Format int + +// Constants to identify various tar formats. +const ( + // Deliberately hide the meaning of constants from public API. + _ Format = (1 << iota) / 4 // Sequence of 0, 0, 1, 2, 4, 8, etc... + + // FormatUnknown indicates that the format is unknown. + FormatUnknown + + // The format of the original Unix V7 tar tool prior to standardization. + formatV7 + + // FormatUSTAR represents the USTAR header format defined in POSIX.1-1988. + // + // While this format is compatible with most tar readers, + // the format has several limitations making it unsuitable for some usages. + // Most notably, it cannot support sparse files, files larger than 8GiB, + // filenames larger than 256 characters, and non-ASCII filenames. + // + // Reference: + // http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_06 + FormatUSTAR + + // FormatPAX represents the PAX header format defined in POSIX.1-2001. + // + // PAX extends USTAR by writing a special file with Typeflag TypeXHeader + // preceding the original header. This file contains a set of key-value + // records, which are used to overcome USTAR's shortcomings, in addition to + // providing the ability to have sub-second resolution for timestamps. + // + // Some newer formats add their own extensions to PAX by defining their + // own keys and assigning certain semantic meaning to the associated values. + // For example, sparse file support in PAX is implemented using keys + // defined by the GNU manual (e.g., "GNU.sparse.map"). + // + // Reference: + // http://pubs.opengroup.org/onlinepubs/009695399/utilities/pax.html + FormatPAX + + // FormatGNU represents the GNU header format. + // + // The GNU header format is older than the USTAR and PAX standards and + // is not compatible with them. The GNU format supports + // arbitrary file sizes, filenames of arbitrary encoding and length, + // sparse files, and other features. + // + // It is recommended that PAX be chosen over GNU unless the target + // application can only parse GNU formatted archives. + // + // Reference: + // https://www.gnu.org/software/tar/manual/html_node/Standard.html + FormatGNU + + // Schily's tar format, which is incompatible with USTAR. + // This does not cover STAR extensions to the PAX format; these fall under + // the PAX format. + formatSTAR + + formatMax +) + +func (f Format) has(f2 Format) bool { return f&f2 != 0 } +func (f *Format) mayBe(f2 Format) { *f |= f2 } +func (f *Format) mayOnlyBe(f2 Format) { *f &= f2 } +func (f *Format) mustNotBe(f2 Format) { *f &^= f2 } + +var formatNames = map[Format]string{ + formatV7: "V7", FormatUSTAR: "USTAR", FormatPAX: "PAX", FormatGNU: "GNU", formatSTAR: "STAR", +} + +func (f Format) String() string { + var ss []string + for f2 := Format(1); f2 < formatMax; f2 <<= 1 { + if f.has(f2) { + ss = append(ss, formatNames[f2]) + } + } + switch len(ss) { + case 0: + return "" + case 1: + return ss[0] + default: + return "(" + strings.Join(ss, " | ") + ")" + } +} + +// Magics used to identify various formats. +const ( + magicGNU, versionGNU = "ustar ", " \x00" + magicUSTAR, versionUSTAR = "ustar\x00", "00" + trailerSTAR = "tar\x00" +) + +// Size constants from various tar specifications. +const ( + blockSize = 512 // Size of each block in a tar stream + nameSize = 100 // Max length of the name field in USTAR format + prefixSize = 155 // Max length of the prefix field in USTAR format +) + +// blockPadding computes the number of bytes needed to pad offset up to the +// nearest block edge where 0 <= n < blockSize. +func blockPadding(offset int64) (n int64) { + return -offset & (blockSize - 1) +} + +var zeroBlock block + +type block [blockSize]byte + +// Convert block to any number of formats. +func (b *block) V7() *headerV7 { return (*headerV7)(b) } +func (b *block) GNU() *headerGNU { return (*headerGNU)(b) } +func (b *block) STAR() *headerSTAR { return (*headerSTAR)(b) } +func (b *block) USTAR() *headerUSTAR { return (*headerUSTAR)(b) } +func (b *block) Sparse() sparseArray { return (sparseArray)(b[:]) } + +// GetFormat checks that the block is a valid tar header based on the checksum. +// It then attempts to guess the specific format based on magic values. +// If the checksum fails, then FormatUnknown is returned. +func (b *block) GetFormat() Format { + // Verify checksum. + var p parser + value := p.parseOctal(b.V7().Chksum()) + chksum1, chksum2 := b.ComputeChecksum() + if p.err != nil || (value != chksum1 && value != chksum2) { + return FormatUnknown + } + + // Guess the magic values. + magic := string(b.USTAR().Magic()) + version := string(b.USTAR().Version()) + trailer := string(b.STAR().Trailer()) + switch { + case magic == magicUSTAR && trailer == trailerSTAR: + return formatSTAR + case magic == magicUSTAR: + return FormatUSTAR | FormatPAX + case magic == magicGNU && version == versionGNU: + return FormatGNU + default: + return formatV7 + } +} + +// SetFormat writes the magic values necessary for specified format +// and then updates the checksum accordingly. +func (b *block) SetFormat(format Format) { + // Set the magic values. + switch { + case format.has(formatV7): + // Do nothing. + case format.has(FormatGNU): + copy(b.GNU().Magic(), magicGNU) + copy(b.GNU().Version(), versionGNU) + case format.has(formatSTAR): + copy(b.STAR().Magic(), magicUSTAR) + copy(b.STAR().Version(), versionUSTAR) + copy(b.STAR().Trailer(), trailerSTAR) + case format.has(FormatUSTAR | FormatPAX): + copy(b.USTAR().Magic(), magicUSTAR) + copy(b.USTAR().Version(), versionUSTAR) + default: + panic("invalid format") + } + + // Update checksum. + // This field is special in that it is terminated by a NULL then space. + var f formatter + field := b.V7().Chksum() + chksum, _ := b.ComputeChecksum() // Possible values are 256..128776 + f.formatOctal(field[:7], chksum) // Never fails since 128776 < 262143 + field[7] = ' ' +} + +// ComputeChecksum computes the checksum for the header block. +// POSIX specifies a sum of the unsigned byte values, but the Sun tar used +// signed byte values. +// We compute and return both. +func (b *block) ComputeChecksum() (unsigned, signed int64) { + for i, c := range b { + if 148 <= i && i < 156 { + c = ' ' // Treat the checksum field itself as all spaces. + } + unsigned += int64(c) + signed += int64(int8(c)) + } + return unsigned, signed +} + +// Reset clears the block with all zeros. +func (b *block) Reset() { + *b = block{} +} + +type headerV7 [blockSize]byte + +func (h *headerV7) Name() []byte { return h[000:][:100] } +func (h *headerV7) Mode() []byte { return h[100:][:8] } +func (h *headerV7) UID() []byte { return h[108:][:8] } +func (h *headerV7) GID() []byte { return h[116:][:8] } +func (h *headerV7) Size() []byte { return h[124:][:12] } +func (h *headerV7) ModTime() []byte { return h[136:][:12] } +func (h *headerV7) Chksum() []byte { return h[148:][:8] } +func (h *headerV7) TypeFlag() []byte { return h[156:][:1] } +func (h *headerV7) LinkName() []byte { return h[157:][:100] } + +type headerGNU [blockSize]byte + +func (h *headerGNU) V7() *headerV7 { return (*headerV7)(h) } +func (h *headerGNU) Magic() []byte { return h[257:][:6] } +func (h *headerGNU) Version() []byte { return h[263:][:2] } +func (h *headerGNU) UserName() []byte { return h[265:][:32] } +func (h *headerGNU) GroupName() []byte { return h[297:][:32] } +func (h *headerGNU) DevMajor() []byte { return h[329:][:8] } +func (h *headerGNU) DevMinor() []byte { return h[337:][:8] } +func (h *headerGNU) AccessTime() []byte { return h[345:][:12] } +func (h *headerGNU) ChangeTime() []byte { return h[357:][:12] } +func (h *headerGNU) Sparse() sparseArray { return (sparseArray)(h[386:][:24*4+1]) } +func (h *headerGNU) RealSize() []byte { return h[483:][:12] } + +type headerSTAR [blockSize]byte + +func (h *headerSTAR) V7() *headerV7 { return (*headerV7)(h) } +func (h *headerSTAR) Magic() []byte { return h[257:][:6] } +func (h *headerSTAR) Version() []byte { return h[263:][:2] } +func (h *headerSTAR) UserName() []byte { return h[265:][:32] } +func (h *headerSTAR) GroupName() []byte { return h[297:][:32] } +func (h *headerSTAR) DevMajor() []byte { return h[329:][:8] } +func (h *headerSTAR) DevMinor() []byte { return h[337:][:8] } +func (h *headerSTAR) Prefix() []byte { return h[345:][:131] } +func (h *headerSTAR) AccessTime() []byte { return h[476:][:12] } +func (h *headerSTAR) ChangeTime() []byte { return h[488:][:12] } +func (h *headerSTAR) Trailer() []byte { return h[508:][:4] } + +type headerUSTAR [blockSize]byte + +func (h *headerUSTAR) V7() *headerV7 { return (*headerV7)(h) } +func (h *headerUSTAR) Magic() []byte { return h[257:][:6] } +func (h *headerUSTAR) Version() []byte { return h[263:][:2] } +func (h *headerUSTAR) UserName() []byte { return h[265:][:32] } +func (h *headerUSTAR) GroupName() []byte { return h[297:][:32] } +func (h *headerUSTAR) DevMajor() []byte { return h[329:][:8] } +func (h *headerUSTAR) DevMinor() []byte { return h[337:][:8] } +func (h *headerUSTAR) Prefix() []byte { return h[345:][:155] } + +type sparseArray []byte + +func (s sparseArray) Entry(i int) sparseElem { return (sparseElem)(s[i*24:]) } +func (s sparseArray) IsExtended() []byte { return s[24*s.MaxEntries():][:1] } +func (s sparseArray) MaxEntries() int { return len(s) / 24 } + +type sparseElem []byte + +func (s sparseElem) Offset() []byte { return s[00:][:12] } +func (s sparseElem) Length() []byte { return s[12:][:12] } diff --git a/vendor/github.com/vbatts/tar-split/archive/tar/reader.go b/vendor/github.com/vbatts/tar-split/archive/tar/reader.go new file mode 100644 index 000000000..fcf321553 --- /dev/null +++ b/vendor/github.com/vbatts/tar-split/archive/tar/reader.go @@ -0,0 +1,925 @@ +// Copyright 2009 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 tar + +import ( + "bytes" + "io" + "io/ioutil" + "strconv" + "strings" + "time" +) + +// Reader provides sequential access to the contents of a tar archive. +// Reader.Next advances to the next file in the archive (including the first), +// and then Reader can be treated as an io.Reader to access the file's data. +type Reader struct { + r io.Reader + pad int64 // Amount of padding (ignored) after current file entry + curr fileReader // Reader for current file entry + blk block // Buffer to use as temporary local storage + + // err is a persistent error. + // It is only the responsibility of every exported method of Reader to + // ensure that this error is sticky. + err error + + RawAccounting bool // Whether to enable the access needed to reassemble the tar from raw bytes. Some performance/memory hit for this. + rawBytes *bytes.Buffer // last raw bits +} + +type fileReader interface { + io.Reader + fileState + + WriteTo(io.Writer) (int64, error) +} + +// RawBytes accesses the raw bytes of the archive, apart from the file payload itself. +// This includes the header and padding. +// +// # This call resets the current rawbytes buffer +// +// Only when RawAccounting is enabled, otherwise this returns nil +func (tr *Reader) RawBytes() []byte { + if !tr.RawAccounting { + return nil + } + if tr.rawBytes == nil { + tr.rawBytes = bytes.NewBuffer(nil) + } + defer tr.rawBytes.Reset() // if we've read them, then flush them. + + return tr.rawBytes.Bytes() + +} + +// NewReader creates a new Reader reading from r. +func NewReader(r io.Reader) *Reader { + return &Reader{r: r, curr: ®FileReader{r, 0}} +} + +// Next advances to the next entry in the tar archive. +// The Header.Size determines how many bytes can be read for the next file. +// Any remaining data in the current file is automatically discarded. +// +// io.EOF is returned at the end of the input. +func (tr *Reader) Next() (*Header, error) { + if tr.err != nil { + return nil, tr.err + } + hdr, err := tr.next() + tr.err = err + return hdr, err +} + +func (tr *Reader) next() (*Header, error) { + var paxHdrs map[string]string + var gnuLongName, gnuLongLink string + + if tr.RawAccounting { + if tr.rawBytes == nil { + tr.rawBytes = bytes.NewBuffer(nil) + } else { + tr.rawBytes.Reset() + } + } + + // Externally, Next iterates through the tar archive as if it is a series of + // files. Internally, the tar format often uses fake "files" to add meta + // data that describes the next file. These meta data "files" should not + // normally be visible to the outside. As such, this loop iterates through + // one or more "header files" until it finds a "normal file". + format := FormatUSTAR | FormatPAX | FormatGNU + for { + // Discard the remainder of the file and any padding. + if err := discard(tr, tr.curr.PhysicalRemaining()); err != nil { + return nil, err + } + n, err := tryReadFull(tr.r, tr.blk[:tr.pad]) + if err != nil { + return nil, err + } + if tr.RawAccounting { + tr.rawBytes.Write(tr.blk[:n]) + } + tr.pad = 0 + + hdr, rawHdr, err := tr.readHeader() + if err != nil { + return nil, err + } + if err := tr.handleRegularFile(hdr); err != nil { + return nil, err + } + format.mayOnlyBe(hdr.Format) + + // Check for PAX/GNU special headers and files. + switch hdr.Typeflag { + case TypeXHeader, TypeXGlobalHeader: + format.mayOnlyBe(FormatPAX) + paxHdrs, err = parsePAX(tr) + if err != nil { + return nil, err + } + if hdr.Typeflag == TypeXGlobalHeader { + if err = mergePAX(hdr, paxHdrs); err != nil { + return nil, err + } + return &Header{ + Name: hdr.Name, + Typeflag: hdr.Typeflag, + Xattrs: hdr.Xattrs, + PAXRecords: hdr.PAXRecords, + Format: format, + }, nil + } + continue // This is a meta header affecting the next header + case TypeGNULongName, TypeGNULongLink: + format.mayOnlyBe(FormatGNU) + realname, err := ioutil.ReadAll(tr) + if err != nil { + return nil, err + } + + if tr.RawAccounting { + tr.rawBytes.Write(realname) + } + + var p parser + switch hdr.Typeflag { + case TypeGNULongName: + gnuLongName = p.parseString(realname) + case TypeGNULongLink: + gnuLongLink = p.parseString(realname) + } + continue // This is a meta header affecting the next header + default: + // The old GNU sparse format is handled here since it is technically + // just a regular file with additional attributes. + + if err := mergePAX(hdr, paxHdrs); err != nil { + return nil, err + } + if gnuLongName != "" { + hdr.Name = gnuLongName + } + if gnuLongLink != "" { + hdr.Linkname = gnuLongLink + } + if hdr.Typeflag == TypeRegA { + if strings.HasSuffix(hdr.Name, "/") { + hdr.Typeflag = TypeDir // Legacy archives use trailing slash for directories + } else { + hdr.Typeflag = TypeReg + } + } + + // The extended headers may have updated the size. + // Thus, setup the regFileReader again after merging PAX headers. + if err := tr.handleRegularFile(hdr); err != nil { + return nil, err + } + + // Sparse formats rely on being able to read from the logical data + // section; there must be a preceding call to handleRegularFile. + if err := tr.handleSparseFile(hdr, rawHdr); err != nil { + return nil, err + } + + // Set the final guess at the format. + if format.has(FormatUSTAR) && format.has(FormatPAX) { + format.mayOnlyBe(FormatUSTAR) + } + hdr.Format = format + return hdr, nil // This is a file, so stop + } + } +} + +// handleRegularFile sets up the current file reader and padding such that it +// can only read the following logical data section. It will properly handle +// special headers that contain no data section. +func (tr *Reader) handleRegularFile(hdr *Header) error { + nb := hdr.Size + if isHeaderOnlyType(hdr.Typeflag) { + nb = 0 + } + if nb < 0 { + return ErrHeader + } + + tr.pad = blockPadding(nb) + tr.curr = ®FileReader{r: tr.r, nb: nb} + return nil +} + +// handleSparseFile checks if the current file is a sparse format of any type +// and sets the curr reader appropriately. +func (tr *Reader) handleSparseFile(hdr *Header, rawHdr *block) error { + var spd sparseDatas + var err error + if hdr.Typeflag == TypeGNUSparse { + spd, err = tr.readOldGNUSparseMap(hdr, rawHdr) + } else { + spd, err = tr.readGNUSparsePAXHeaders(hdr) + } + + // If sp is non-nil, then this is a sparse file. + // Note that it is possible for len(sp) == 0. + if err == nil && spd != nil { + if isHeaderOnlyType(hdr.Typeflag) || !validateSparseEntries(spd, hdr.Size) { + return ErrHeader + } + sph := invertSparseEntries(spd, hdr.Size) + tr.curr = &sparseFileReader{tr.curr, sph, 0} + } + return err +} + +// readGNUSparsePAXHeaders checks the PAX headers for GNU sparse headers. +// If they are found, then this function reads the sparse map and returns it. +// This assumes that 0.0 headers have already been converted to 0.1 headers +// by the PAX header parsing logic. +func (tr *Reader) readGNUSparsePAXHeaders(hdr *Header) (sparseDatas, error) { + // Identify the version of GNU headers. + var is1x0 bool + major, minor := hdr.PAXRecords[paxGNUSparseMajor], hdr.PAXRecords[paxGNUSparseMinor] + switch { + case major == "0" && (minor == "0" || minor == "1"): + is1x0 = false + case major == "1" && minor == "0": + is1x0 = true + case major != "" || minor != "": + return nil, nil // Unknown GNU sparse PAX version + case hdr.PAXRecords[paxGNUSparseMap] != "": + is1x0 = false // 0.0 and 0.1 did not have explicit version records, so guess + default: + return nil, nil // Not a PAX format GNU sparse file. + } + hdr.Format.mayOnlyBe(FormatPAX) + + // Update hdr from GNU sparse PAX headers. + if name := hdr.PAXRecords[paxGNUSparseName]; name != "" { + hdr.Name = name + } + size := hdr.PAXRecords[paxGNUSparseSize] + if size == "" { + size = hdr.PAXRecords[paxGNUSparseRealSize] + } + if size != "" { + n, err := strconv.ParseInt(size, 10, 64) + if err != nil { + return nil, ErrHeader + } + hdr.Size = n + } + + // Read the sparse map according to the appropriate format. + if is1x0 { + return readGNUSparseMap1x0(tr.curr) + } + return readGNUSparseMap0x1(hdr.PAXRecords) +} + +// mergePAX merges paxHdrs into hdr for all relevant fields of Header. +func mergePAX(hdr *Header, paxHdrs map[string]string) (err error) { + for k, v := range paxHdrs { + if v == "" { + continue // Keep the original USTAR value + } + var id64 int64 + switch k { + case paxPath: + hdr.Name = v + case paxLinkpath: + hdr.Linkname = v + case paxUname: + hdr.Uname = v + case paxGname: + hdr.Gname = v + case paxUid: + id64, err = strconv.ParseInt(v, 10, 64) + hdr.Uid = int(id64) // Integer overflow possible + case paxGid: + id64, err = strconv.ParseInt(v, 10, 64) + hdr.Gid = int(id64) // Integer overflow possible + case paxAtime: + hdr.AccessTime, err = parsePAXTime(v) + case paxMtime: + hdr.ModTime, err = parsePAXTime(v) + case paxCtime: + hdr.ChangeTime, err = parsePAXTime(v) + case paxSize: + hdr.Size, err = strconv.ParseInt(v, 10, 64) + default: + if strings.HasPrefix(k, paxSchilyXattr) { + if hdr.Xattrs == nil { + hdr.Xattrs = make(map[string]string) + } + hdr.Xattrs[k[len(paxSchilyXattr):]] = v + } + } + if err != nil { + return ErrHeader + } + } + hdr.PAXRecords = paxHdrs + return nil +} + +// parsePAX parses PAX headers. +// If an extended header (type 'x') is invalid, ErrHeader is returned +func parsePAX(r io.Reader) (map[string]string, error) { + buf, err := ioutil.ReadAll(r) + if err != nil { + return nil, err + } + // leaving this function for io.Reader makes it more testable + if tr, ok := r.(*Reader); ok && tr.RawAccounting { + if _, err = tr.rawBytes.Write(buf); err != nil { + return nil, err + } + } + sbuf := string(buf) + + // For GNU PAX sparse format 0.0 support. + // This function transforms the sparse format 0.0 headers into format 0.1 + // headers since 0.0 headers were not PAX compliant. + var sparseMap []string + + paxHdrs := make(map[string]string) + for len(sbuf) > 0 { + key, value, residual, err := parsePAXRecord(sbuf) + if err != nil { + return nil, ErrHeader + } + sbuf = residual + + switch key { + case paxGNUSparseOffset, paxGNUSparseNumBytes: + // Validate sparse header order and value. + if (len(sparseMap)%2 == 0 && key != paxGNUSparseOffset) || + (len(sparseMap)%2 == 1 && key != paxGNUSparseNumBytes) || + strings.Contains(value, ",") { + return nil, ErrHeader + } + sparseMap = append(sparseMap, value) + default: + paxHdrs[key] = value + } + } + if len(sparseMap) > 0 { + paxHdrs[paxGNUSparseMap] = strings.Join(sparseMap, ",") + } + return paxHdrs, nil +} + +// readHeader reads the next block header and assumes that the underlying reader +// is already aligned to a block boundary. It returns the raw block of the +// header in case further processing is required. +// +// The err will be set to io.EOF only when one of the following occurs: +// - Exactly 0 bytes are read and EOF is hit. +// - Exactly 1 block of zeros is read and EOF is hit. +// - At least 2 blocks of zeros are read. +func (tr *Reader) readHeader() (*Header, *block, error) { + // Two blocks of zero bytes marks the end of the archive. + n, err := io.ReadFull(tr.r, tr.blk[:]) + if tr.RawAccounting && (err == nil || err == io.EOF) { + tr.rawBytes.Write(tr.blk[:n]) + } + if err != nil { + return nil, nil, err // EOF is okay here; exactly 0 bytes read + } + + if bytes.Equal(tr.blk[:], zeroBlock[:]) { + n, err = io.ReadFull(tr.r, tr.blk[:]) + if tr.RawAccounting && (err == nil || err == io.EOF) { + tr.rawBytes.Write(tr.blk[:n]) + } + if err != nil { + return nil, nil, err // EOF is okay here; exactly 1 block of zeros read + } + if bytes.Equal(tr.blk[:], zeroBlock[:]) { + return nil, nil, io.EOF // normal EOF; exactly 2 block of zeros read + } + return nil, nil, ErrHeader // Zero block and then non-zero block + } + + // Verify the header matches a known format. + format := tr.blk.GetFormat() + if format == FormatUnknown { + return nil, nil, ErrHeader + } + + var p parser + hdr := new(Header) + + // Unpack the V7 header. + v7 := tr.blk.V7() + hdr.Typeflag = v7.TypeFlag()[0] + hdr.Name = p.parseString(v7.Name()) + hdr.Linkname = p.parseString(v7.LinkName()) + hdr.Size = p.parseNumeric(v7.Size()) + hdr.Mode = p.parseNumeric(v7.Mode()) + hdr.Uid = int(p.parseNumeric(v7.UID())) + hdr.Gid = int(p.parseNumeric(v7.GID())) + hdr.ModTime = time.Unix(p.parseNumeric(v7.ModTime()), 0) + + // Unpack format specific fields. + if format > formatV7 { + ustar := tr.blk.USTAR() + hdr.Uname = p.parseString(ustar.UserName()) + hdr.Gname = p.parseString(ustar.GroupName()) + hdr.Devmajor = p.parseNumeric(ustar.DevMajor()) + hdr.Devminor = p.parseNumeric(ustar.DevMinor()) + + var prefix string + switch { + case format.has(FormatUSTAR | FormatPAX): + hdr.Format = format + ustar := tr.blk.USTAR() + prefix = p.parseString(ustar.Prefix()) + + // For Format detection, check if block is properly formatted since + // the parser is more liberal than what USTAR actually permits. + notASCII := func(r rune) bool { return r >= 0x80 } + if bytes.IndexFunc(tr.blk[:], notASCII) >= 0 { + hdr.Format = FormatUnknown // Non-ASCII characters in block. + } + nul := func(b []byte) bool { return int(b[len(b)-1]) == 0 } + if !(nul(v7.Size()) && nul(v7.Mode()) && nul(v7.UID()) && nul(v7.GID()) && + nul(v7.ModTime()) && nul(ustar.DevMajor()) && nul(ustar.DevMinor())) { + hdr.Format = FormatUnknown // Numeric fields must end in NUL + } + case format.has(formatSTAR): + star := tr.blk.STAR() + prefix = p.parseString(star.Prefix()) + hdr.AccessTime = time.Unix(p.parseNumeric(star.AccessTime()), 0) + hdr.ChangeTime = time.Unix(p.parseNumeric(star.ChangeTime()), 0) + case format.has(FormatGNU): + hdr.Format = format + var p2 parser + gnu := tr.blk.GNU() + if b := gnu.AccessTime(); b[0] != 0 { + hdr.AccessTime = time.Unix(p2.parseNumeric(b), 0) + } + if b := gnu.ChangeTime(); b[0] != 0 { + hdr.ChangeTime = time.Unix(p2.parseNumeric(b), 0) + } + + // Prior to Go1.8, the Writer had a bug where it would output + // an invalid tar file in certain rare situations because the logic + // incorrectly believed that the old GNU format had a prefix field. + // This is wrong and leads to an output file that mangles the + // atime and ctime fields, which are often left unused. + // + // In order to continue reading tar files created by former, buggy + // versions of Go, we skeptically parse the atime and ctime fields. + // If we are unable to parse them and the prefix field looks like + // an ASCII string, then we fallback on the pre-Go1.8 behavior + // of treating these fields as the USTAR prefix field. + // + // Note that this will not use the fallback logic for all possible + // files generated by a pre-Go1.8 toolchain. If the generated file + // happened to have a prefix field that parses as valid + // atime and ctime fields (e.g., when they are valid octal strings), + // then it is impossible to distinguish between an valid GNU file + // and an invalid pre-Go1.8 file. + // + // See https://golang.org/issues/12594 + // See https://golang.org/issues/21005 + if p2.err != nil { + hdr.AccessTime, hdr.ChangeTime = time.Time{}, time.Time{} + ustar := tr.blk.USTAR() + if s := p.parseString(ustar.Prefix()); isASCII(s) { + prefix = s + } + hdr.Format = FormatUnknown // Buggy file is not GNU + } + } + if len(prefix) > 0 { + hdr.Name = prefix + "/" + hdr.Name + } + } + return hdr, &tr.blk, p.err +} + +// readOldGNUSparseMap reads the sparse map from the old GNU sparse format. +// The sparse map is stored in the tar header if it's small enough. +// If it's larger than four entries, then one or more extension headers are used +// to store the rest of the sparse map. +// +// The Header.Size does not reflect the size of any extended headers used. +// Thus, this function will read from the raw io.Reader to fetch extra headers. +// This method mutates blk in the process. +func (tr *Reader) readOldGNUSparseMap(hdr *Header, blk *block) (sparseDatas, error) { + // Make sure that the input format is GNU. + // Unfortunately, the STAR format also has a sparse header format that uses + // the same type flag but has a completely different layout. + if blk.GetFormat() != FormatGNU { + return nil, ErrHeader + } + hdr.Format.mayOnlyBe(FormatGNU) + + var p parser + hdr.Size = p.parseNumeric(blk.GNU().RealSize()) + if p.err != nil { + return nil, p.err + } + s := blk.GNU().Sparse() + spd := make(sparseDatas, 0, s.MaxEntries()) + for { + for i := 0; i < s.MaxEntries(); i++ { + // This termination condition is identical to GNU and BSD tar. + if s.Entry(i).Offset()[0] == 0x00 { + break // Don't return, need to process extended headers (even if empty) + } + offset := p.parseNumeric(s.Entry(i).Offset()) + length := p.parseNumeric(s.Entry(i).Length()) + if p.err != nil { + return nil, p.err + } + spd = append(spd, sparseEntry{Offset: offset, Length: length}) + } + + if s.IsExtended()[0] > 0 { + // There are more entries. Read an extension header and parse its entries. + if _, err := mustReadFull(tr.r, blk[:]); err != nil { + return nil, err + } + if tr.RawAccounting { + tr.rawBytes.Write(blk[:]) + } + s = blk.Sparse() + continue + } + return spd, nil // Done + } +} + +// readGNUSparseMap1x0 reads the sparse map as stored in GNU's PAX sparse format +// version 1.0. The format of the sparse map consists of a series of +// newline-terminated numeric fields. The first field is the number of entries +// and is always present. Following this are the entries, consisting of two +// fields (offset, length). This function must stop reading at the end +// boundary of the block containing the last newline. +// +// Note that the GNU manual says that numeric values should be encoded in octal +// format. However, the GNU tar utility itself outputs these values in decimal. +// As such, this library treats values as being encoded in decimal. +func readGNUSparseMap1x0(r io.Reader) (sparseDatas, error) { + var ( + cntNewline int64 + buf bytes.Buffer + blk block + ) + + // feedTokens copies data in blocks from r into buf until there are + // at least cnt newlines in buf. It will not read more blocks than needed. + feedTokens := func(n int64) error { + for cntNewline < n { + if _, err := mustReadFull(r, blk[:]); err != nil { + return err + } + buf.Write(blk[:]) + for _, c := range blk { + if c == '\n' { + cntNewline++ + } + } + } + return nil + } + + // nextToken gets the next token delimited by a newline. This assumes that + // at least one newline exists in the buffer. + nextToken := func() string { + cntNewline-- + tok, _ := buf.ReadString('\n') + return strings.TrimRight(tok, "\n") + } + + // Parse for the number of entries. + // Use integer overflow resistant math to check this. + if err := feedTokens(1); err != nil { + return nil, err + } + numEntries, err := strconv.ParseInt(nextToken(), 10, 0) // Intentionally parse as native int + if err != nil || numEntries < 0 || int(2*numEntries) < int(numEntries) { + return nil, ErrHeader + } + + // Parse for all member entries. + // numEntries is trusted after this since a potential attacker must have + // committed resources proportional to what this library used. + if err := feedTokens(2 * numEntries); err != nil { + return nil, err + } + spd := make(sparseDatas, 0, numEntries) + for i := int64(0); i < numEntries; i++ { + offset, err1 := strconv.ParseInt(nextToken(), 10, 64) + length, err2 := strconv.ParseInt(nextToken(), 10, 64) + if err1 != nil || err2 != nil { + return nil, ErrHeader + } + spd = append(spd, sparseEntry{Offset: offset, Length: length}) + } + return spd, nil +} + +// readGNUSparseMap0x1 reads the sparse map as stored in GNU's PAX sparse format +// version 0.1. The sparse map is stored in the PAX headers. +func readGNUSparseMap0x1(paxHdrs map[string]string) (sparseDatas, error) { + // Get number of entries. + // Use integer overflow resistant math to check this. + numEntriesStr := paxHdrs[paxGNUSparseNumBlocks] + numEntries, err := strconv.ParseInt(numEntriesStr, 10, 0) // Intentionally parse as native int + if err != nil || numEntries < 0 || int(2*numEntries) < int(numEntries) { + return nil, ErrHeader + } + + // There should be two numbers in sparseMap for each entry. + sparseMap := strings.Split(paxHdrs[paxGNUSparseMap], ",") + if len(sparseMap) == 1 && sparseMap[0] == "" { + sparseMap = sparseMap[:0] + } + if int64(len(sparseMap)) != 2*numEntries { + return nil, ErrHeader + } + + // Loop through the entries in the sparse map. + // numEntries is trusted now. + spd := make(sparseDatas, 0, numEntries) + for len(sparseMap) >= 2 { + offset, err1 := strconv.ParseInt(sparseMap[0], 10, 64) + length, err2 := strconv.ParseInt(sparseMap[1], 10, 64) + if err1 != nil || err2 != nil { + return nil, ErrHeader + } + spd = append(spd, sparseEntry{Offset: offset, Length: length}) + sparseMap = sparseMap[2:] + } + return spd, nil +} + +// Read reads from the current file in the tar archive. +// It returns (0, io.EOF) when it reaches the end of that file, +// until Next is called to advance to the next file. +// +// If the current file is sparse, then the regions marked as a hole +// are read back as NUL-bytes. +// +// Calling Read on special types like TypeLink, TypeSymlink, TypeChar, +// TypeBlock, TypeDir, and TypeFifo returns (0, io.EOF) regardless of what +// the Header.Size claims. +func (tr *Reader) Read(b []byte) (int, error) { + if tr.err != nil { + return 0, tr.err + } + n, err := tr.curr.Read(b) + if err != nil && err != io.EOF { + tr.err = err + } + return n, err +} + +// writeTo writes the content of the current file to w. +// The bytes written matches the number of remaining bytes in the current file. +// +// If the current file is sparse and w is an io.WriteSeeker, +// then writeTo uses Seek to skip past holes defined in Header.SparseHoles, +// assuming that skipped regions are filled with NULs. +// This always writes the last byte to ensure w is the right size. +// +// TODO(dsnet): Re-export this when adding sparse file support. +// See https://golang.org/issue/22735 +func (tr *Reader) writeTo(w io.Writer) (int64, error) { + if tr.err != nil { + return 0, tr.err + } + n, err := tr.curr.WriteTo(w) + if err != nil { + tr.err = err + } + return n, err +} + +// regFileReader is a fileReader for reading data from a regular file entry. +type regFileReader struct { + r io.Reader // Underlying Reader + nb int64 // Number of remaining bytes to read +} + +func (fr *regFileReader) Read(b []byte) (n int, err error) { + if int64(len(b)) > fr.nb { + b = b[:fr.nb] + } + if len(b) > 0 { + n, err = fr.r.Read(b) + fr.nb -= int64(n) + } + switch { + case err == io.EOF && fr.nb > 0: + return n, io.ErrUnexpectedEOF + case err == nil && fr.nb == 0: + return n, io.EOF + default: + return n, err + } +} + +func (fr *regFileReader) WriteTo(w io.Writer) (int64, error) { + return io.Copy(w, struct{ io.Reader }{fr}) +} + +func (fr regFileReader) LogicalRemaining() int64 { + return fr.nb +} + +func (fr regFileReader) PhysicalRemaining() int64 { + return fr.nb +} + +// sparseFileReader is a fileReader for reading data from a sparse file entry. +type sparseFileReader struct { + fr fileReader // Underlying fileReader + sp sparseHoles // Normalized list of sparse holes + pos int64 // Current position in sparse file +} + +func (sr *sparseFileReader) Read(b []byte) (n int, err error) { + finished := int64(len(b)) >= sr.LogicalRemaining() + if finished { + b = b[:sr.LogicalRemaining()] + } + + b0 := b + endPos := sr.pos + int64(len(b)) + for endPos > sr.pos && err == nil { + var nf int // Bytes read in fragment + holeStart, holeEnd := sr.sp[0].Offset, sr.sp[0].endOffset() + if sr.pos < holeStart { // In a data fragment + bf := b[:min(int64(len(b)), holeStart-sr.pos)] + nf, err = tryReadFull(sr.fr, bf) + } else { // In a hole fragment + bf := b[:min(int64(len(b)), holeEnd-sr.pos)] + nf, err = tryReadFull(zeroReader{}, bf) + } + b = b[nf:] + sr.pos += int64(nf) + if sr.pos >= holeEnd && len(sr.sp) > 1 { + sr.sp = sr.sp[1:] // Ensure last fragment always remains + } + } + + n = len(b0) - len(b) + switch { + case err == io.EOF: + return n, errMissData // Less data in dense file than sparse file + case err != nil: + return n, err + case sr.LogicalRemaining() == 0 && sr.PhysicalRemaining() > 0: + return n, errUnrefData // More data in dense file than sparse file + case finished: + return n, io.EOF + default: + return n, nil + } +} + +func (sr *sparseFileReader) WriteTo(w io.Writer) (n int64, err error) { + ws, ok := w.(io.WriteSeeker) + if ok { + if _, err := ws.Seek(0, io.SeekCurrent); err != nil { + ok = false // Not all io.Seeker can really seek + } + } + if !ok { + return io.Copy(w, struct{ io.Reader }{sr}) + } + + var writeLastByte bool + pos0 := sr.pos + for sr.LogicalRemaining() > 0 && !writeLastByte && err == nil { + var nf int64 // Size of fragment + holeStart, holeEnd := sr.sp[0].Offset, sr.sp[0].endOffset() + if sr.pos < holeStart { // In a data fragment + nf = holeStart - sr.pos + nf, err = io.CopyN(ws, sr.fr, nf) + } else { // In a hole fragment + nf = holeEnd - sr.pos + if sr.PhysicalRemaining() == 0 { + writeLastByte = true + nf-- + } + _, err = ws.Seek(nf, io.SeekCurrent) + } + sr.pos += nf + if sr.pos >= holeEnd && len(sr.sp) > 1 { + sr.sp = sr.sp[1:] // Ensure last fragment always remains + } + } + + // If the last fragment is a hole, then seek to 1-byte before EOF, and + // write a single byte to ensure the file is the right size. + if writeLastByte && err == nil { + _, err = ws.Write([]byte{0}) + sr.pos++ + } + + n = sr.pos - pos0 + switch { + case err == io.EOF: + return n, errMissData // Less data in dense file than sparse file + case err != nil: + return n, err + case sr.LogicalRemaining() == 0 && sr.PhysicalRemaining() > 0: + return n, errUnrefData // More data in dense file than sparse file + default: + return n, nil + } +} + +func (sr sparseFileReader) LogicalRemaining() int64 { + return sr.sp[len(sr.sp)-1].endOffset() - sr.pos +} +func (sr sparseFileReader) PhysicalRemaining() int64 { + return sr.fr.PhysicalRemaining() +} + +type zeroReader struct{} + +func (zeroReader) Read(b []byte) (int, error) { + for i := range b { + b[i] = 0 + } + return len(b), nil +} + +// mustReadFull is like io.ReadFull except it returns +// io.ErrUnexpectedEOF when io.EOF is hit before len(b) bytes are read. +func mustReadFull(r io.Reader, b []byte) (int, error) { + n, err := tryReadFull(r, b) + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + return n, err +} + +// tryReadFull is like io.ReadFull except it returns +// io.EOF when it is hit before len(b) bytes are read. +func tryReadFull(r io.Reader, b []byte) (n int, err error) { + for len(b) > n && err == nil { + var nn int + nn, err = r.Read(b[n:]) + n += nn + } + if len(b) == n && err == io.EOF { + err = nil + } + return n, err +} + +// discard skips n bytes in r, reporting an error if unable to do so. +func discard(tr *Reader, n int64) error { + var seekSkipped, copySkipped int64 + var err error + r := tr.r + if tr.RawAccounting { + + copySkipped, err = io.CopyN(tr.rawBytes, tr.r, n) + goto out + } + + // If possible, Seek to the last byte before the end of the data section. + // Do this because Seek is often lazy about reporting errors; this will mask + // the fact that the stream may be truncated. We can rely on the + // io.CopyN done shortly afterwards to trigger any IO errors. + if sr, ok := r.(io.Seeker); ok && n > 1 { + // Not all io.Seeker can actually Seek. For example, os.Stdin implements + // io.Seeker, but calling Seek always returns an error and performs + // no action. Thus, we try an innocent seek to the current position + // to see if Seek is really supported. + pos1, err := sr.Seek(0, io.SeekCurrent) + if pos1 >= 0 && err == nil { + // Seek seems supported, so perform the real Seek. + pos2, err := sr.Seek(n-1, io.SeekCurrent) + if pos2 < 0 || err != nil { + return err + } + seekSkipped = pos2 - pos1 + } + } + + copySkipped, err = io.CopyN(ioutil.Discard, r, n-seekSkipped) +out: + if err == io.EOF && seekSkipped+copySkipped < n { + err = io.ErrUnexpectedEOF + } + return err +} diff --git a/vendor/github.com/vbatts/tar-split/archive/tar/stat_actime1.go b/vendor/github.com/vbatts/tar-split/archive/tar/stat_actime1.go new file mode 100644 index 000000000..cf9cc79c5 --- /dev/null +++ b/vendor/github.com/vbatts/tar-split/archive/tar/stat_actime1.go @@ -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. + +// +build linux dragonfly openbsd solaris + +package tar + +import ( + "syscall" + "time" +) + +func statAtime(st *syscall.Stat_t) time.Time { + return time.Unix(st.Atim.Unix()) +} + +func statCtime(st *syscall.Stat_t) time.Time { + return time.Unix(st.Ctim.Unix()) +} diff --git a/vendor/github.com/vbatts/tar-split/archive/tar/stat_actime2.go b/vendor/github.com/vbatts/tar-split/archive/tar/stat_actime2.go new file mode 100644 index 000000000..6f17dbe30 --- /dev/null +++ b/vendor/github.com/vbatts/tar-split/archive/tar/stat_actime2.go @@ -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. + +// +build darwin freebsd netbsd + +package tar + +import ( + "syscall" + "time" +) + +func statAtime(st *syscall.Stat_t) time.Time { + return time.Unix(st.Atimespec.Unix()) +} + +func statCtime(st *syscall.Stat_t) time.Time { + return time.Unix(st.Ctimespec.Unix()) +} diff --git a/vendor/github.com/vbatts/tar-split/archive/tar/stat_unix.go b/vendor/github.com/vbatts/tar-split/archive/tar/stat_unix.go new file mode 100644 index 000000000..868105f33 --- /dev/null +++ b/vendor/github.com/vbatts/tar-split/archive/tar/stat_unix.go @@ -0,0 +1,96 @@ +// 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 linux darwin dragonfly freebsd openbsd netbsd solaris + +package tar + +import ( + "os" + "os/user" + "runtime" + "strconv" + "sync" + "syscall" +) + +func init() { + sysStat = statUnix +} + +// userMap and groupMap caches UID and GID lookups for performance reasons. +// The downside is that renaming uname or gname by the OS never takes effect. +var userMap, groupMap sync.Map // map[int]string + +func statUnix(fi os.FileInfo, h *Header) error { + sys, ok := fi.Sys().(*syscall.Stat_t) + if !ok { + return nil + } + h.Uid = int(sys.Uid) + h.Gid = int(sys.Gid) + + // Best effort at populating Uname and Gname. + // The os/user functions may fail for any number of reasons + // (not implemented on that platform, cgo not enabled, etc). + if u, ok := userMap.Load(h.Uid); ok { + h.Uname = u.(string) + } else if u, err := user.LookupId(strconv.Itoa(h.Uid)); err == nil { + h.Uname = u.Username + userMap.Store(h.Uid, h.Uname) + } + if g, ok := groupMap.Load(h.Gid); ok { + h.Gname = g.(string) + } else if g, err := user.LookupGroupId(strconv.Itoa(h.Gid)); err == nil { + h.Gname = g.Name + groupMap.Store(h.Gid, h.Gname) + } + + h.AccessTime = statAtime(sys) + h.ChangeTime = statCtime(sys) + + // Best effort at populating Devmajor and Devminor. + if h.Typeflag == TypeChar || h.Typeflag == TypeBlock { + dev := uint64(sys.Rdev) // May be int32 or uint32 + switch runtime.GOOS { + case "linux": + // Copied from golang.org/x/sys/unix/dev_linux.go. + major := uint32((dev & 0x00000000000fff00) >> 8) + major |= uint32((dev & 0xfffff00000000000) >> 32) + minor := uint32((dev & 0x00000000000000ff) >> 0) + minor |= uint32((dev & 0x00000ffffff00000) >> 12) + h.Devmajor, h.Devminor = int64(major), int64(minor) + case "darwin": + // Copied from golang.org/x/sys/unix/dev_darwin.go. + major := uint32((dev >> 24) & 0xff) + minor := uint32(dev & 0xffffff) + h.Devmajor, h.Devminor = int64(major), int64(minor) + case "dragonfly": + // Copied from golang.org/x/sys/unix/dev_dragonfly.go. + major := uint32((dev >> 8) & 0xff) + minor := uint32(dev & 0xffff00ff) + h.Devmajor, h.Devminor = int64(major), int64(minor) + case "freebsd": + // Copied from golang.org/x/sys/unix/dev_freebsd.go. + major := uint32((dev >> 8) & 0xff) + minor := uint32(dev & 0xffff00ff) + h.Devmajor, h.Devminor = int64(major), int64(minor) + case "netbsd": + // Copied from golang.org/x/sys/unix/dev_netbsd.go. + major := uint32((dev & 0x000fff00) >> 8) + minor := uint32((dev & 0x000000ff) >> 0) + minor |= uint32((dev & 0xfff00000) >> 12) + h.Devmajor, h.Devminor = int64(major), int64(minor) + case "openbsd": + // Copied from golang.org/x/sys/unix/dev_openbsd.go. + major := uint32((dev & 0x0000ff00) >> 8) + minor := uint32((dev & 0x000000ff) >> 0) + minor |= uint32((dev & 0xffff0000) >> 8) + h.Devmajor, h.Devminor = int64(major), int64(minor) + default: + // TODO: Implement solaris (see https://golang.org/issue/8106) + } + } + return nil +} diff --git a/vendor/github.com/vbatts/tar-split/archive/tar/strconv.go b/vendor/github.com/vbatts/tar-split/archive/tar/strconv.go new file mode 100644 index 000000000..d144485a4 --- /dev/null +++ b/vendor/github.com/vbatts/tar-split/archive/tar/strconv.go @@ -0,0 +1,326 @@ +// 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 tar + +import ( + "bytes" + "fmt" + "strconv" + "strings" + "time" +) + +// hasNUL reports whether the NUL character exists within s. +func hasNUL(s string) bool { + return strings.IndexByte(s, 0) >= 0 +} + +// isASCII reports whether the input is an ASCII C-style string. +func isASCII(s string) bool { + for _, c := range s { + if c >= 0x80 || c == 0x00 { + return false + } + } + return true +} + +// toASCII converts the input to an ASCII C-style string. +// This a best effort conversion, so invalid characters are dropped. +func toASCII(s string) string { + if isASCII(s) { + return s + } + b := make([]byte, 0, len(s)) + for _, c := range s { + if c < 0x80 && c != 0x00 { + b = append(b, byte(c)) + } + } + return string(b) +} + +type parser struct { + err error // Last error seen +} + +type formatter struct { + err error // Last error seen +} + +// parseString parses bytes as a NUL-terminated C-style string. +// If a NUL byte is not found then the whole slice is returned as a string. +func (*parser) parseString(b []byte) string { + if i := bytes.IndexByte(b, 0); i >= 0 { + return string(b[:i]) + } + return string(b) +} + +// formatString copies s into b, NUL-terminating if possible. +func (f *formatter) formatString(b []byte, s string) { + if len(s) > len(b) { + f.err = ErrFieldTooLong + } + copy(b, s) + if len(s) < len(b) { + b[len(s)] = 0 + } + + // Some buggy readers treat regular files with a trailing slash + // in the V7 path field as a directory even though the full path + // recorded elsewhere (e.g., via PAX record) contains no trailing slash. + if len(s) > len(b) && b[len(b)-1] == '/' { + n := len(strings.TrimRight(s[:len(b)], "/")) + b[n] = 0 // Replace trailing slash with NUL terminator + } +} + +// fitsInBase256 reports whether x can be encoded into n bytes using base-256 +// encoding. Unlike octal encoding, base-256 encoding does not require that the +// string ends with a NUL character. Thus, all n bytes are available for output. +// +// If operating in binary mode, this assumes strict GNU binary mode; which means +// that the first byte can only be either 0x80 or 0xff. Thus, the first byte is +// equivalent to the sign bit in two's complement form. +func fitsInBase256(n int, x int64) bool { + binBits := uint(n-1) * 8 + return n >= 9 || (x >= -1< 0 && b[0]&0x80 != 0 { + // Handling negative numbers relies on the following identity: + // -a-1 == ^a + // + // If the number is negative, we use an inversion mask to invert the + // data bytes and treat the value as an unsigned number. + var inv byte // 0x00 if positive or zero, 0xff if negative + if b[0]&0x40 != 0 { + inv = 0xff + } + + var x uint64 + for i, c := range b { + c ^= inv // Inverts c only if inv is 0xff, otherwise does nothing + if i == 0 { + c &= 0x7f // Ignore signal bit in first byte + } + if (x >> 56) > 0 { + p.err = ErrHeader // Integer overflow + return 0 + } + x = x<<8 | uint64(c) + } + if (x >> 63) > 0 { + p.err = ErrHeader // Integer overflow + return 0 + } + if inv == 0xff { + return ^int64(x) + } + return int64(x) + } + + // Normal case is base-8 (octal) format. + return p.parseOctal(b) +} + +// formatNumeric encodes x into b using base-8 (octal) encoding if possible. +// Otherwise it will attempt to use base-256 (binary) encoding. +func (f *formatter) formatNumeric(b []byte, x int64) { + if fitsInOctal(len(b), x) { + f.formatOctal(b, x) + return + } + + if fitsInBase256(len(b), x) { + for i := len(b) - 1; i >= 0; i-- { + b[i] = byte(x) + x >>= 8 + } + b[0] |= 0x80 // Highest bit indicates binary format + return + } + + f.formatOctal(b, 0) // Last resort, just write zero + f.err = ErrFieldTooLong +} + +func (p *parser) parseOctal(b []byte) int64 { + // Because unused fields are filled with NULs, we need + // to skip leading NULs. Fields may also be padded with + // spaces or NULs. + // So we remove leading and trailing NULs and spaces to + // be sure. + b = bytes.Trim(b, " \x00") + + if len(b) == 0 { + return 0 + } + x, perr := strconv.ParseUint(p.parseString(b), 8, 64) + if perr != nil { + p.err = ErrHeader + } + return int64(x) +} + +func (f *formatter) formatOctal(b []byte, x int64) { + if !fitsInOctal(len(b), x) { + x = 0 // Last resort, just write zero + f.err = ErrFieldTooLong + } + + s := strconv.FormatInt(x, 8) + // Add leading zeros, but leave room for a NUL. + if n := len(b) - len(s) - 1; n > 0 { + s = strings.Repeat("0", n) + s + } + f.formatString(b, s) +} + +// fitsInOctal reports whether the integer x fits in a field n-bytes long +// using octal encoding with the appropriate NUL terminator. +func fitsInOctal(n int, x int64) bool { + octBits := uint(n-1) * 3 + return x >= 0 && (n >= 22 || x < 1<= 0 { + ss, sn = s[:pos], s[pos+1:] + } + + // Parse the seconds. + secs, err := strconv.ParseInt(ss, 10, 64) + if err != nil { + return time.Time{}, ErrHeader + } + if len(sn) == 0 { + return time.Unix(secs, 0), nil // No sub-second values + } + + // Parse the nanoseconds. + if strings.Trim(sn, "0123456789") != "" { + return time.Time{}, ErrHeader + } + if len(sn) < maxNanoSecondDigits { + sn += strings.Repeat("0", maxNanoSecondDigits-len(sn)) // Right pad + } else { + sn = sn[:maxNanoSecondDigits] // Right truncate + } + nsecs, _ := strconv.ParseInt(sn, 10, 64) // Must succeed + if len(ss) > 0 && ss[0] == '-' { + return time.Unix(secs, -1*nsecs), nil // Negative correction + } + return time.Unix(secs, nsecs), nil +} + +// formatPAXTime converts ts into a time of the form %d.%d as described in the +// PAX specification. This function is capable of negative timestamps. +func formatPAXTime(ts time.Time) (s string) { + secs, nsecs := ts.Unix(), ts.Nanosecond() + if nsecs == 0 { + return strconv.FormatInt(secs, 10) + } + + // If seconds is negative, then perform correction. + sign := "" + if secs < 0 { + sign = "-" // Remember sign + secs = -(secs + 1) // Add a second to secs + nsecs = -(nsecs - 1E9) // Take that second away from nsecs + } + return strings.TrimRight(fmt.Sprintf("%s%d.%09d", sign, secs, nsecs), "0") +} + +// parsePAXRecord parses the input PAX record string into a key-value pair. +// If parsing is successful, it will slice off the currently read record and +// return the remainder as r. +func parsePAXRecord(s string) (k, v, r string, err error) { + // The size field ends at the first space. + sp := strings.IndexByte(s, ' ') + if sp == -1 { + return "", "", s, ErrHeader + } + + // Parse the first token as a decimal integer. + n, perr := strconv.ParseInt(s[:sp], 10, 0) // Intentionally parse as native int + if perr != nil || n < 5 || int64(len(s)) < n { + return "", "", s, ErrHeader + } + + // Extract everything between the space and the final newline. + rec, nl, rem := s[sp+1:n-1], s[n-1:n], s[n:] + if nl != "\n" { + return "", "", s, ErrHeader + } + + // The first equals separates the key from the value. + eq := strings.IndexByte(rec, '=') + if eq == -1 { + return "", "", s, ErrHeader + } + k, v = rec[:eq], rec[eq+1:] + + if !validPAXRecord(k, v) { + return "", "", s, ErrHeader + } + return k, v, rem, nil +} + +// formatPAXRecord formats a single PAX record, prefixing it with the +// appropriate length. +func formatPAXRecord(k, v string) (string, error) { + if !validPAXRecord(k, v) { + return "", ErrHeader + } + + const padding = 3 // Extra padding for ' ', '=', and '\n' + size := len(k) + len(v) + padding + size += len(strconv.Itoa(size)) + record := strconv.Itoa(size) + " " + k + "=" + v + "\n" + + // Final adjustment if adding size field increased the record size. + if len(record) != size { + size = len(record) + record = strconv.Itoa(size) + " " + k + "=" + v + "\n" + } + return record, nil +} + +// validPAXRecord reports whether the key-value pair is valid where each +// record is formatted as: +// "%d %s=%s\n" % (size, key, value) +// +// Keys and values should be UTF-8, but the number of bad writers out there +// forces us to be a more liberal. +// Thus, we only reject all keys with NUL, and only reject NULs in values +// for the PAX version of the USTAR string fields. +// The key must not contain an '=' character. +func validPAXRecord(k, v string) bool { + if k == "" || strings.IndexByte(k, '=') >= 0 { + return false + } + switch k { + case paxPath, paxLinkpath, paxUname, paxGname: + return !hasNUL(v) + default: + return !hasNUL(k) + } +} diff --git a/vendor/github.com/vbatts/tar-split/archive/tar/writer.go b/vendor/github.com/vbatts/tar-split/archive/tar/writer.go new file mode 100644 index 000000000..e80498d03 --- /dev/null +++ b/vendor/github.com/vbatts/tar-split/archive/tar/writer.go @@ -0,0 +1,653 @@ +// Copyright 2009 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 tar + +import ( + "fmt" + "io" + "path" + "sort" + "strings" + "time" +) + +// Writer provides sequential writing of a tar archive. +// Write.WriteHeader begins a new file with the provided Header, +// and then Writer can be treated as an io.Writer to supply that file's data. +type Writer struct { + w io.Writer + pad int64 // Amount of padding to write after current file entry + curr fileWriter // Writer for current file entry + hdr Header // Shallow copy of Header that is safe for mutations + blk block // Buffer to use as temporary local storage + + // err is a persistent error. + // It is only the responsibility of every exported method of Writer to + // ensure that this error is sticky. + err error +} + +// NewWriter creates a new Writer writing to w. +func NewWriter(w io.Writer) *Writer { + return &Writer{w: w, curr: ®FileWriter{w, 0}} +} + +type fileWriter interface { + io.Writer + fileState + + ReadFrom(io.Reader) (int64, error) +} + +// Flush finishes writing the current file's block padding. +// The current file must be fully written before Flush can be called. +// +// This is unnecessary as the next call to WriteHeader or Close +// will implicitly flush out the file's padding. +func (tw *Writer) Flush() error { + if tw.err != nil { + return tw.err + } + if nb := tw.curr.LogicalRemaining(); nb > 0 { + return fmt.Errorf("archive/tar: missed writing %d bytes", nb) + } + if _, tw.err = tw.w.Write(zeroBlock[:tw.pad]); tw.err != nil { + return tw.err + } + tw.pad = 0 + return nil +} + +// WriteHeader writes hdr and prepares to accept the file's contents. +// The Header.Size determines how many bytes can be written for the next file. +// If the current file is not fully written, then this returns an error. +// This implicitly flushes any padding necessary before writing the header. +func (tw *Writer) WriteHeader(hdr *Header) error { + if err := tw.Flush(); err != nil { + return err + } + tw.hdr = *hdr // Shallow copy of Header + + // Avoid usage of the legacy TypeRegA flag, and automatically promote + // it to use TypeReg or TypeDir. + if tw.hdr.Typeflag == TypeRegA { + if strings.HasSuffix(tw.hdr.Name, "/") { + tw.hdr.Typeflag = TypeDir + } else { + tw.hdr.Typeflag = TypeReg + } + } + + // Round ModTime and ignore AccessTime and ChangeTime unless + // the format is explicitly chosen. + // This ensures nominal usage of WriteHeader (without specifying the format) + // does not always result in the PAX format being chosen, which + // causes a 1KiB increase to every header. + if tw.hdr.Format == FormatUnknown { + tw.hdr.ModTime = tw.hdr.ModTime.Round(time.Second) + tw.hdr.AccessTime = time.Time{} + tw.hdr.ChangeTime = time.Time{} + } + + allowedFormats, paxHdrs, err := tw.hdr.allowedFormats() + switch { + case allowedFormats.has(FormatUSTAR): + tw.err = tw.writeUSTARHeader(&tw.hdr) + return tw.err + case allowedFormats.has(FormatPAX): + tw.err = tw.writePAXHeader(&tw.hdr, paxHdrs) + return tw.err + case allowedFormats.has(FormatGNU): + tw.err = tw.writeGNUHeader(&tw.hdr) + return tw.err + default: + return err // Non-fatal error + } +} + +func (tw *Writer) writeUSTARHeader(hdr *Header) error { + // Check if we can use USTAR prefix/suffix splitting. + var namePrefix string + if prefix, suffix, ok := splitUSTARPath(hdr.Name); ok { + namePrefix, hdr.Name = prefix, suffix + } + + // Pack the main header. + var f formatter + blk := tw.templateV7Plus(hdr, f.formatString, f.formatOctal) + f.formatString(blk.USTAR().Prefix(), namePrefix) + blk.SetFormat(FormatUSTAR) + if f.err != nil { + return f.err // Should never happen since header is validated + } + return tw.writeRawHeader(blk, hdr.Size, hdr.Typeflag) +} + +func (tw *Writer) writePAXHeader(hdr *Header, paxHdrs map[string]string) error { + realName, realSize := hdr.Name, hdr.Size + + // TODO(dsnet): Re-enable this when adding sparse support. + // See https://golang.org/issue/22735 + /* + // Handle sparse files. + var spd sparseDatas + var spb []byte + if len(hdr.SparseHoles) > 0 { + sph := append([]sparseEntry{}, hdr.SparseHoles...) // Copy sparse map + sph = alignSparseEntries(sph, hdr.Size) + spd = invertSparseEntries(sph, hdr.Size) + + // Format the sparse map. + hdr.Size = 0 // Replace with encoded size + spb = append(strconv.AppendInt(spb, int64(len(spd)), 10), '\n') + for _, s := range spd { + hdr.Size += s.Length + spb = append(strconv.AppendInt(spb, s.Offset, 10), '\n') + spb = append(strconv.AppendInt(spb, s.Length, 10), '\n') + } + pad := blockPadding(int64(len(spb))) + spb = append(spb, zeroBlock[:pad]...) + hdr.Size += int64(len(spb)) // Accounts for encoded sparse map + + // Add and modify appropriate PAX records. + dir, file := path.Split(realName) + hdr.Name = path.Join(dir, "GNUSparseFile.0", file) + paxHdrs[paxGNUSparseMajor] = "1" + paxHdrs[paxGNUSparseMinor] = "0" + paxHdrs[paxGNUSparseName] = realName + paxHdrs[paxGNUSparseRealSize] = strconv.FormatInt(realSize, 10) + paxHdrs[paxSize] = strconv.FormatInt(hdr.Size, 10) + delete(paxHdrs, paxPath) // Recorded by paxGNUSparseName + } + */ + _ = realSize + + // Write PAX records to the output. + isGlobal := hdr.Typeflag == TypeXGlobalHeader + if len(paxHdrs) > 0 || isGlobal { + // Sort keys for deterministic ordering. + var keys []string + for k := range paxHdrs { + keys = append(keys, k) + } + sort.Strings(keys) + + // Write each record to a buffer. + var buf strings.Builder + for _, k := range keys { + rec, err := formatPAXRecord(k, paxHdrs[k]) + if err != nil { + return err + } + buf.WriteString(rec) + } + + // Write the extended header file. + var name string + var flag byte + if isGlobal { + name = realName + if name == "" { + name = "GlobalHead.0.0" + } + flag = TypeXGlobalHeader + } else { + dir, file := path.Split(realName) + name = path.Join(dir, "PaxHeaders.0", file) + flag = TypeXHeader + } + data := buf.String() + if err := tw.writeRawFile(name, data, flag, FormatPAX); err != nil || isGlobal { + return err // Global headers return here + } + } + + // Pack the main header. + var f formatter // Ignore errors since they are expected + fmtStr := func(b []byte, s string) { f.formatString(b, toASCII(s)) } + blk := tw.templateV7Plus(hdr, fmtStr, f.formatOctal) + blk.SetFormat(FormatPAX) + if err := tw.writeRawHeader(blk, hdr.Size, hdr.Typeflag); err != nil { + return err + } + + // TODO(dsnet): Re-enable this when adding sparse support. + // See https://golang.org/issue/22735 + /* + // Write the sparse map and setup the sparse writer if necessary. + if len(spd) > 0 { + // Use tw.curr since the sparse map is accounted for in hdr.Size. + if _, err := tw.curr.Write(spb); err != nil { + return err + } + tw.curr = &sparseFileWriter{tw.curr, spd, 0} + } + */ + return nil +} + +func (tw *Writer) writeGNUHeader(hdr *Header) error { + // Use long-link files if Name or Linkname exceeds the field size. + const longName = "././@LongLink" + if len(hdr.Name) > nameSize { + data := hdr.Name + "\x00" + if err := tw.writeRawFile(longName, data, TypeGNULongName, FormatGNU); err != nil { + return err + } + } + if len(hdr.Linkname) > nameSize { + data := hdr.Linkname + "\x00" + if err := tw.writeRawFile(longName, data, TypeGNULongLink, FormatGNU); err != nil { + return err + } + } + + // Pack the main header. + var f formatter // Ignore errors since they are expected + var spd sparseDatas + var spb []byte + blk := tw.templateV7Plus(hdr, f.formatString, f.formatNumeric) + if !hdr.AccessTime.IsZero() { + f.formatNumeric(blk.GNU().AccessTime(), hdr.AccessTime.Unix()) + } + if !hdr.ChangeTime.IsZero() { + f.formatNumeric(blk.GNU().ChangeTime(), hdr.ChangeTime.Unix()) + } + // TODO(dsnet): Re-enable this when adding sparse support. + // See https://golang.org/issue/22735 + /* + if hdr.Typeflag == TypeGNUSparse { + sph := append([]sparseEntry{}, hdr.SparseHoles...) // Copy sparse map + sph = alignSparseEntries(sph, hdr.Size) + spd = invertSparseEntries(sph, hdr.Size) + + // Format the sparse map. + formatSPD := func(sp sparseDatas, sa sparseArray) sparseDatas { + for i := 0; len(sp) > 0 && i < sa.MaxEntries(); i++ { + f.formatNumeric(sa.Entry(i).Offset(), sp[0].Offset) + f.formatNumeric(sa.Entry(i).Length(), sp[0].Length) + sp = sp[1:] + } + if len(sp) > 0 { + sa.IsExtended()[0] = 1 + } + return sp + } + sp2 := formatSPD(spd, blk.GNU().Sparse()) + for len(sp2) > 0 { + var spHdr block + sp2 = formatSPD(sp2, spHdr.Sparse()) + spb = append(spb, spHdr[:]...) + } + + // Update size fields in the header block. + realSize := hdr.Size + hdr.Size = 0 // Encoded size; does not account for encoded sparse map + for _, s := range spd { + hdr.Size += s.Length + } + copy(blk.V7().Size(), zeroBlock[:]) // Reset field + f.formatNumeric(blk.V7().Size(), hdr.Size) + f.formatNumeric(blk.GNU().RealSize(), realSize) + } + */ + blk.SetFormat(FormatGNU) + if err := tw.writeRawHeader(blk, hdr.Size, hdr.Typeflag); err != nil { + return err + } + + // Write the extended sparse map and setup the sparse writer if necessary. + if len(spd) > 0 { + // Use tw.w since the sparse map is not accounted for in hdr.Size. + if _, err := tw.w.Write(spb); err != nil { + return err + } + tw.curr = &sparseFileWriter{tw.curr, spd, 0} + } + return nil +} + +type ( + stringFormatter func([]byte, string) + numberFormatter func([]byte, int64) +) + +// templateV7Plus fills out the V7 fields of a block using values from hdr. +// It also fills out fields (uname, gname, devmajor, devminor) that are +// shared in the USTAR, PAX, and GNU formats using the provided formatters. +// +// The block returned is only valid until the next call to +// templateV7Plus or writeRawFile. +func (tw *Writer) templateV7Plus(hdr *Header, fmtStr stringFormatter, fmtNum numberFormatter) *block { + tw.blk.Reset() + + modTime := hdr.ModTime + if modTime.IsZero() { + modTime = time.Unix(0, 0) + } + + v7 := tw.blk.V7() + v7.TypeFlag()[0] = hdr.Typeflag + fmtStr(v7.Name(), hdr.Name) + fmtStr(v7.LinkName(), hdr.Linkname) + fmtNum(v7.Mode(), hdr.Mode) + fmtNum(v7.UID(), int64(hdr.Uid)) + fmtNum(v7.GID(), int64(hdr.Gid)) + fmtNum(v7.Size(), hdr.Size) + fmtNum(v7.ModTime(), modTime.Unix()) + + ustar := tw.blk.USTAR() + fmtStr(ustar.UserName(), hdr.Uname) + fmtStr(ustar.GroupName(), hdr.Gname) + fmtNum(ustar.DevMajor(), hdr.Devmajor) + fmtNum(ustar.DevMinor(), hdr.Devminor) + + return &tw.blk +} + +// writeRawFile writes a minimal file with the given name and flag type. +// It uses format to encode the header format and will write data as the body. +// It uses default values for all of the other fields (as BSD and GNU tar does). +func (tw *Writer) writeRawFile(name, data string, flag byte, format Format) error { + tw.blk.Reset() + + // Best effort for the filename. + name = toASCII(name) + if len(name) > nameSize { + name = name[:nameSize] + } + name = strings.TrimRight(name, "/") + + var f formatter + v7 := tw.blk.V7() + v7.TypeFlag()[0] = flag + f.formatString(v7.Name(), name) + f.formatOctal(v7.Mode(), 0) + f.formatOctal(v7.UID(), 0) + f.formatOctal(v7.GID(), 0) + f.formatOctal(v7.Size(), int64(len(data))) // Must be < 8GiB + f.formatOctal(v7.ModTime(), 0) + tw.blk.SetFormat(format) + if f.err != nil { + return f.err // Only occurs if size condition is violated + } + + // Write the header and data. + if err := tw.writeRawHeader(&tw.blk, int64(len(data)), flag); err != nil { + return err + } + _, err := io.WriteString(tw, data) + return err +} + +// writeRawHeader writes the value of blk, regardless of its value. +// It sets up the Writer such that it can accept a file of the given size. +// If the flag is a special header-only flag, then the size is treated as zero. +func (tw *Writer) writeRawHeader(blk *block, size int64, flag byte) error { + if err := tw.Flush(); err != nil { + return err + } + if _, err := tw.w.Write(blk[:]); err != nil { + return err + } + if isHeaderOnlyType(flag) { + size = 0 + } + tw.curr = ®FileWriter{tw.w, size} + tw.pad = blockPadding(size) + return nil +} + +// splitUSTARPath splits a path according to USTAR prefix and suffix rules. +// If the path is not splittable, then it will return ("", "", false). +func splitUSTARPath(name string) (prefix, suffix string, ok bool) { + length := len(name) + if length <= nameSize || !isASCII(name) { + return "", "", false + } else if length > prefixSize+1 { + length = prefixSize + 1 + } else if name[length-1] == '/' { + length-- + } + + i := strings.LastIndex(name[:length], "/") + nlen := len(name) - i - 1 // nlen is length of suffix + plen := i // plen is length of prefix + if i <= 0 || nlen > nameSize || nlen == 0 || plen > prefixSize { + return "", "", false + } + return name[:i], name[i+1:], true +} + +// Write writes to the current file in the tar archive. +// Write returns the error ErrWriteTooLong if more than +// Header.Size bytes are written after WriteHeader. +// +// Calling Write on special types like TypeLink, TypeSymlink, TypeChar, +// TypeBlock, TypeDir, and TypeFifo returns (0, ErrWriteTooLong) regardless +// of what the Header.Size claims. +func (tw *Writer) Write(b []byte) (int, error) { + if tw.err != nil { + return 0, tw.err + } + n, err := tw.curr.Write(b) + if err != nil && err != ErrWriteTooLong { + tw.err = err + } + return n, err +} + +// readFrom populates the content of the current file by reading from r. +// The bytes read must match the number of remaining bytes in the current file. +// +// If the current file is sparse and r is an io.ReadSeeker, +// then readFrom uses Seek to skip past holes defined in Header.SparseHoles, +// assuming that skipped regions are all NULs. +// This always reads the last byte to ensure r is the right size. +// +// TODO(dsnet): Re-export this when adding sparse file support. +// See https://golang.org/issue/22735 +func (tw *Writer) readFrom(r io.Reader) (int64, error) { + if tw.err != nil { + return 0, tw.err + } + n, err := tw.curr.ReadFrom(r) + if err != nil && err != ErrWriteTooLong { + tw.err = err + } + return n, err +} + +// Close closes the tar archive by flushing the padding, and writing the footer. +// If the current file (from a prior call to WriteHeader) is not fully written, +// then this returns an error. +func (tw *Writer) Close() error { + if tw.err == ErrWriteAfterClose { + return nil + } + if tw.err != nil { + return tw.err + } + + // Trailer: two zero blocks. + err := tw.Flush() + for i := 0; i < 2 && err == nil; i++ { + _, err = tw.w.Write(zeroBlock[:]) + } + + // Ensure all future actions are invalid. + tw.err = ErrWriteAfterClose + return err // Report IO errors +} + +// regFileWriter is a fileWriter for writing data to a regular file entry. +type regFileWriter struct { + w io.Writer // Underlying Writer + nb int64 // Number of remaining bytes to write +} + +func (fw *regFileWriter) Write(b []byte) (n int, err error) { + overwrite := int64(len(b)) > fw.nb + if overwrite { + b = b[:fw.nb] + } + if len(b) > 0 { + n, err = fw.w.Write(b) + fw.nb -= int64(n) + } + switch { + case err != nil: + return n, err + case overwrite: + return n, ErrWriteTooLong + default: + return n, nil + } +} + +func (fw *regFileWriter) ReadFrom(r io.Reader) (int64, error) { + return io.Copy(struct{ io.Writer }{fw}, r) +} + +func (fw regFileWriter) LogicalRemaining() int64 { + return fw.nb +} +func (fw regFileWriter) PhysicalRemaining() int64 { + return fw.nb +} + +// sparseFileWriter is a fileWriter for writing data to a sparse file entry. +type sparseFileWriter struct { + fw fileWriter // Underlying fileWriter + sp sparseDatas // Normalized list of data fragments + pos int64 // Current position in sparse file +} + +func (sw *sparseFileWriter) Write(b []byte) (n int, err error) { + overwrite := int64(len(b)) > sw.LogicalRemaining() + if overwrite { + b = b[:sw.LogicalRemaining()] + } + + b0 := b + endPos := sw.pos + int64(len(b)) + for endPos > sw.pos && err == nil { + var nf int // Bytes written in fragment + dataStart, dataEnd := sw.sp[0].Offset, sw.sp[0].endOffset() + if sw.pos < dataStart { // In a hole fragment + bf := b[:min(int64(len(b)), dataStart-sw.pos)] + nf, err = zeroWriter{}.Write(bf) + } else { // In a data fragment + bf := b[:min(int64(len(b)), dataEnd-sw.pos)] + nf, err = sw.fw.Write(bf) + } + b = b[nf:] + sw.pos += int64(nf) + if sw.pos >= dataEnd && len(sw.sp) > 1 { + sw.sp = sw.sp[1:] // Ensure last fragment always remains + } + } + + n = len(b0) - len(b) + switch { + case err == ErrWriteTooLong: + return n, errMissData // Not possible; implies bug in validation logic + case err != nil: + return n, err + case sw.LogicalRemaining() == 0 && sw.PhysicalRemaining() > 0: + return n, errUnrefData // Not possible; implies bug in validation logic + case overwrite: + return n, ErrWriteTooLong + default: + return n, nil + } +} + +func (sw *sparseFileWriter) ReadFrom(r io.Reader) (n int64, err error) { + rs, ok := r.(io.ReadSeeker) + if ok { + if _, err := rs.Seek(0, io.SeekCurrent); err != nil { + ok = false // Not all io.Seeker can really seek + } + } + if !ok { + return io.Copy(struct{ io.Writer }{sw}, r) + } + + var readLastByte bool + pos0 := sw.pos + for sw.LogicalRemaining() > 0 && !readLastByte && err == nil { + var nf int64 // Size of fragment + dataStart, dataEnd := sw.sp[0].Offset, sw.sp[0].endOffset() + if sw.pos < dataStart { // In a hole fragment + nf = dataStart - sw.pos + if sw.PhysicalRemaining() == 0 { + readLastByte = true + nf-- + } + _, err = rs.Seek(nf, io.SeekCurrent) + } else { // In a data fragment + nf = dataEnd - sw.pos + nf, err = io.CopyN(sw.fw, rs, nf) + } + sw.pos += nf + if sw.pos >= dataEnd && len(sw.sp) > 1 { + sw.sp = sw.sp[1:] // Ensure last fragment always remains + } + } + + // If the last fragment is a hole, then seek to 1-byte before EOF, and + // read a single byte to ensure the file is the right size. + if readLastByte && err == nil { + _, err = mustReadFull(rs, []byte{0}) + sw.pos++ + } + + n = sw.pos - pos0 + switch { + case err == io.EOF: + return n, io.ErrUnexpectedEOF + case err == ErrWriteTooLong: + return n, errMissData // Not possible; implies bug in validation logic + case err != nil: + return n, err + case sw.LogicalRemaining() == 0 && sw.PhysicalRemaining() > 0: + return n, errUnrefData // Not possible; implies bug in validation logic + default: + return n, ensureEOF(rs) + } +} + +func (sw sparseFileWriter) LogicalRemaining() int64 { + return sw.sp[len(sw.sp)-1].endOffset() - sw.pos +} +func (sw sparseFileWriter) PhysicalRemaining() int64 { + return sw.fw.PhysicalRemaining() +} + +// zeroWriter may only be written with NULs, otherwise it returns errWriteHole. +type zeroWriter struct{} + +func (zeroWriter) Write(b []byte) (int, error) { + for i, c := range b { + if c != 0 { + return i, errWriteHole + } + } + return len(b), nil +} + +// ensureEOF checks whether r is at EOF, reporting ErrWriteTooLong if not so. +func ensureEOF(r io.Reader) error { + n, err := tryReadFull(r, []byte{0}) + switch { + case n > 0: + return ErrWriteTooLong + case err == io.EOF: + return nil + default: + return err + } +} diff --git a/vendor/github.com/yusufpapurcu/wmi/README.md b/vendor/github.com/yusufpapurcu/wmi/README.md index c4a432d6d..426d1a46b 100644 --- a/vendor/github.com/yusufpapurcu/wmi/README.md +++ b/vendor/github.com/yusufpapurcu/wmi/README.md @@ -4,10 +4,3 @@ wmi Package wmi provides a WQL interface to Windows WMI. Note: It interfaces with WMI on the local machine, therefore it only runs on Windows. - ---- - -NOTE: This project is no longer being actively maintained. If you would like -to become its new owner, please contact tlimoncelli at stack over flow dot com. - ---- diff --git a/vendor/github.com/yusufpapurcu/wmi/swbemservices.go b/vendor/github.com/yusufpapurcu/wmi/swbemservices.go index 3ff875630..a250c846d 100644 --- a/vendor/github.com/yusufpapurcu/wmi/swbemservices.go +++ b/vendor/github.com/yusufpapurcu/wmi/swbemservices.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package wmi diff --git a/vendor/github.com/yusufpapurcu/wmi/wmi.go b/vendor/github.com/yusufpapurcu/wmi/wmi.go index b4bb4f090..26c3581c9 100644 --- a/vendor/github.com/yusufpapurcu/wmi/wmi.go +++ b/vendor/github.com/yusufpapurcu/wmi/wmi.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows /* @@ -20,7 +21,6 @@ Example code to print names of running processes: println(i, v.Name) } } - */ package wmi @@ -338,11 +338,6 @@ func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismat f := v.Field(i) of := f isPtr := f.Kind() == reflect.Ptr - if isPtr { - ptr := reflect.New(f.Type().Elem()) - f.Set(ptr) - f = f.Elem() - } n := v.Type().Field(i).Name if n[0] < 'A' || n[0] > 'Z' { continue @@ -367,6 +362,12 @@ func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismat } defer prop.Clear() + if isPtr && !(c.PtrNil && prop.VT == 0x1) { + ptr := reflect.New(f.Type().Elem()) + f.Set(ptr) + f = f.Elem() + } + if prop.VT == 0x1 { //VT_NULL continue } diff --git a/vendor/go.opentelemetry.io/otel/metric/noop/noop.go b/vendor/go.opentelemetry.io/otel/metric/noop/noop.go new file mode 100644 index 000000000..acc9a670b --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/metric/noop/noop.go @@ -0,0 +1,264 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package noop provides an implementation of the OpenTelemetry metric API that +// produces no telemetry and minimizes used computation resources. +// +// Using this package to implement the OpenTelemetry metric API will +// effectively disable OpenTelemetry. +// +// This implementation can be embedded in other implementations of the +// OpenTelemetry metric API. Doing so will mean the implementation defaults to +// no operation for methods it does not implement. +package noop // import "go.opentelemetry.io/otel/metric/noop" + +import ( + "context" + + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/embedded" +) + +var ( + // Compile-time check this implements the OpenTelemetry API. + + _ metric.MeterProvider = MeterProvider{} + _ metric.Meter = Meter{} + _ metric.Observer = Observer{} + _ metric.Registration = Registration{} + _ metric.Int64Counter = Int64Counter{} + _ metric.Float64Counter = Float64Counter{} + _ metric.Int64UpDownCounter = Int64UpDownCounter{} + _ metric.Float64UpDownCounter = Float64UpDownCounter{} + _ metric.Int64Histogram = Int64Histogram{} + _ metric.Float64Histogram = Float64Histogram{} + _ metric.Int64ObservableCounter = Int64ObservableCounter{} + _ metric.Float64ObservableCounter = Float64ObservableCounter{} + _ metric.Int64ObservableGauge = Int64ObservableGauge{} + _ metric.Float64ObservableGauge = Float64ObservableGauge{} + _ metric.Int64ObservableUpDownCounter = Int64ObservableUpDownCounter{} + _ metric.Float64ObservableUpDownCounter = Float64ObservableUpDownCounter{} + _ metric.Int64Observer = Int64Observer{} + _ metric.Float64Observer = Float64Observer{} +) + +// MeterProvider is an OpenTelemetry No-Op MeterProvider. +type MeterProvider struct{ embedded.MeterProvider } + +// NewMeterProvider returns a MeterProvider that does not record any telemetry. +func NewMeterProvider() MeterProvider { + return MeterProvider{} +} + +// Meter returns an OpenTelemetry Meter that does not record any telemetry. +func (MeterProvider) Meter(string, ...metric.MeterOption) metric.Meter { + return Meter{} +} + +// Meter is an OpenTelemetry No-Op Meter. +type Meter struct{ embedded.Meter } + +// Int64Counter returns a Counter used to record int64 measurements that +// produces no telemetry. +func (Meter) Int64Counter(string, ...metric.Int64CounterOption) (metric.Int64Counter, error) { + return Int64Counter{}, nil +} + +// Int64UpDownCounter returns an UpDownCounter used to record int64 +// measurements that produces no telemetry. +func (Meter) Int64UpDownCounter(string, ...metric.Int64UpDownCounterOption) (metric.Int64UpDownCounter, error) { + return Int64UpDownCounter{}, nil +} + +// Int64Histogram returns a Histogram used to record int64 measurements that +// produces no telemetry. +func (Meter) Int64Histogram(string, ...metric.Int64HistogramOption) (metric.Int64Histogram, error) { + return Int64Histogram{}, nil +} + +// Int64ObservableCounter returns an ObservableCounter used to record int64 +// measurements that produces no telemetry. +func (Meter) Int64ObservableCounter(string, ...metric.Int64ObservableCounterOption) (metric.Int64ObservableCounter, error) { + return Int64ObservableCounter{}, nil +} + +// Int64ObservableUpDownCounter returns an ObservableUpDownCounter used to +// record int64 measurements that produces no telemetry. +func (Meter) Int64ObservableUpDownCounter(string, ...metric.Int64ObservableUpDownCounterOption) (metric.Int64ObservableUpDownCounter, error) { + return Int64ObservableUpDownCounter{}, nil +} + +// Int64ObservableGauge returns an ObservableGauge used to record int64 +// measurements that produces no telemetry. +func (Meter) Int64ObservableGauge(string, ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) { + return Int64ObservableGauge{}, nil +} + +// Float64Counter returns a Counter used to record int64 measurements that +// produces no telemetry. +func (Meter) Float64Counter(string, ...metric.Float64CounterOption) (metric.Float64Counter, error) { + return Float64Counter{}, nil +} + +// Float64UpDownCounter returns an UpDownCounter used to record int64 +// measurements that produces no telemetry. +func (Meter) Float64UpDownCounter(string, ...metric.Float64UpDownCounterOption) (metric.Float64UpDownCounter, error) { + return Float64UpDownCounter{}, nil +} + +// Float64Histogram returns a Histogram used to record int64 measurements that +// produces no telemetry. +func (Meter) Float64Histogram(string, ...metric.Float64HistogramOption) (metric.Float64Histogram, error) { + return Float64Histogram{}, nil +} + +// Float64ObservableCounter returns an ObservableCounter used to record int64 +// measurements that produces no telemetry. +func (Meter) Float64ObservableCounter(string, ...metric.Float64ObservableCounterOption) (metric.Float64ObservableCounter, error) { + return Float64ObservableCounter{}, nil +} + +// Float64ObservableUpDownCounter returns an ObservableUpDownCounter used to +// record int64 measurements that produces no telemetry. +func (Meter) Float64ObservableUpDownCounter(string, ...metric.Float64ObservableUpDownCounterOption) (metric.Float64ObservableUpDownCounter, error) { + return Float64ObservableUpDownCounter{}, nil +} + +// Float64ObservableGauge returns an ObservableGauge used to record int64 +// measurements that produces no telemetry. +func (Meter) Float64ObservableGauge(string, ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) { + return Float64ObservableGauge{}, nil +} + +// RegisterCallback performs no operation. +func (Meter) RegisterCallback(metric.Callback, ...metric.Observable) (metric.Registration, error) { + return Registration{}, nil +} + +// Observer acts as a recorder of measurements for multiple instruments in a +// Callback, it performing no operation. +type Observer struct{ embedded.Observer } + +// ObserveFloat64 performs no operation. +func (Observer) ObserveFloat64(metric.Float64Observable, float64, ...metric.ObserveOption) { +} + +// ObserveInt64 performs no operation. +func (Observer) ObserveInt64(metric.Int64Observable, int64, ...metric.ObserveOption) { +} + +// Registration is the registration of a Callback with a No-Op Meter. +type Registration struct{ embedded.Registration } + +// Unregister unregisters the Callback the Registration represents with the +// No-Op Meter. This will always return nil because the No-Op Meter performs no +// operation, including hold any record of registrations. +func (Registration) Unregister() error { return nil } + +// Int64Counter is an OpenTelemetry Counter used to record int64 measurements. +// It produces no telemetry. +type Int64Counter struct{ embedded.Int64Counter } + +// Add performs no operation. +func (Int64Counter) Add(context.Context, int64, ...metric.AddOption) {} + +// Float64Counter is an OpenTelemetry Counter used to record float64 +// measurements. It produces no telemetry. +type Float64Counter struct{ embedded.Float64Counter } + +// Add performs no operation. +func (Float64Counter) Add(context.Context, float64, ...metric.AddOption) {} + +// Int64UpDownCounter is an OpenTelemetry UpDownCounter used to record int64 +// measurements. It produces no telemetry. +type Int64UpDownCounter struct{ embedded.Int64UpDownCounter } + +// Add performs no operation. +func (Int64UpDownCounter) Add(context.Context, int64, ...metric.AddOption) {} + +// Float64UpDownCounter is an OpenTelemetry UpDownCounter used to record +// float64 measurements. It produces no telemetry. +type Float64UpDownCounter struct{ embedded.Float64UpDownCounter } + +// Add performs no operation. +func (Float64UpDownCounter) Add(context.Context, float64, ...metric.AddOption) {} + +// Int64Histogram is an OpenTelemetry Histogram used to record int64 +// measurements. It produces no telemetry. +type Int64Histogram struct{ embedded.Int64Histogram } + +// Record performs no operation. +func (Int64Histogram) Record(context.Context, int64, ...metric.RecordOption) {} + +// Float64Histogram is an OpenTelemetry Histogram used to record float64 +// measurements. It produces no telemetry. +type Float64Histogram struct{ embedded.Float64Histogram } + +// Record performs no operation. +func (Float64Histogram) Record(context.Context, float64, ...metric.RecordOption) {} + +// Int64ObservableCounter is an OpenTelemetry ObservableCounter used to record +// int64 measurements. It produces no telemetry. +type Int64ObservableCounter struct { + metric.Int64Observable + embedded.Int64ObservableCounter +} + +// Float64ObservableCounter is an OpenTelemetry ObservableCounter used to record +// float64 measurements. It produces no telemetry. +type Float64ObservableCounter struct { + metric.Float64Observable + embedded.Float64ObservableCounter +} + +// Int64ObservableGauge is an OpenTelemetry ObservableGauge used to record +// int64 measurements. It produces no telemetry. +type Int64ObservableGauge struct { + metric.Int64Observable + embedded.Int64ObservableGauge +} + +// Float64ObservableGauge is an OpenTelemetry ObservableGauge used to record +// float64 measurements. It produces no telemetry. +type Float64ObservableGauge struct { + metric.Float64Observable + embedded.Float64ObservableGauge +} + +// Int64ObservableUpDownCounter is an OpenTelemetry ObservableUpDownCounter +// used to record int64 measurements. It produces no telemetry. +type Int64ObservableUpDownCounter struct { + metric.Int64Observable + embedded.Int64ObservableUpDownCounter +} + +// Float64ObservableUpDownCounter is an OpenTelemetry ObservableUpDownCounter +// used to record float64 measurements. It produces no telemetry. +type Float64ObservableUpDownCounter struct { + metric.Float64Observable + embedded.Float64ObservableUpDownCounter +} + +// Int64Observer is a recorder of int64 measurements that performs no operation. +type Int64Observer struct{ embedded.Int64Observer } + +// Observe performs no operation. +func (Int64Observer) Observe(int64, ...metric.ObserveOption) {} + +// Float64Observer is a recorder of float64 measurements that performs no +// operation. +type Float64Observer struct{ embedded.Float64Observer } + +// Observe performs no operation. +func (Float64Observer) Observe(float64, ...metric.ObserveOption) {} diff --git a/vendor/go.opentelemetry.io/otel/semconv/internal/http.go b/vendor/go.opentelemetry.io/otel/semconv/internal/http.go new file mode 100644 index 000000000..19c394c69 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/internal/http.go @@ -0,0 +1,338 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal // import "go.opentelemetry.io/otel/semconv/internal" + +import ( + "fmt" + "net" + "net/http" + "strconv" + "strings" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/trace" +) + +// SemanticConventions are the semantic convention values defined for a +// version of the OpenTelemetry specification. +type SemanticConventions struct { + EnduserIDKey attribute.Key + HTTPClientIPKey attribute.Key + HTTPFlavorKey attribute.Key + HTTPHostKey attribute.Key + HTTPMethodKey attribute.Key + HTTPRequestContentLengthKey attribute.Key + HTTPRouteKey attribute.Key + HTTPSchemeHTTP attribute.KeyValue + HTTPSchemeHTTPS attribute.KeyValue + HTTPServerNameKey attribute.Key + HTTPStatusCodeKey attribute.Key + HTTPTargetKey attribute.Key + HTTPURLKey attribute.Key + HTTPUserAgentKey attribute.Key + NetHostIPKey attribute.Key + NetHostNameKey attribute.Key + NetHostPortKey attribute.Key + NetPeerIPKey attribute.Key + NetPeerNameKey attribute.Key + NetPeerPortKey attribute.Key + NetTransportIP attribute.KeyValue + NetTransportOther attribute.KeyValue + NetTransportTCP attribute.KeyValue + NetTransportUDP attribute.KeyValue + NetTransportUnix attribute.KeyValue +} + +// NetAttributesFromHTTPRequest generates attributes of the net +// namespace as specified by the OpenTelemetry specification for a +// span. The network parameter is a string that net.Dial function +// from standard library can understand. +func (sc *SemanticConventions) NetAttributesFromHTTPRequest(network string, request *http.Request) []attribute.KeyValue { + attrs := []attribute.KeyValue{} + + switch network { + case "tcp", "tcp4", "tcp6": + attrs = append(attrs, sc.NetTransportTCP) + case "udp", "udp4", "udp6": + attrs = append(attrs, sc.NetTransportUDP) + case "ip", "ip4", "ip6": + attrs = append(attrs, sc.NetTransportIP) + case "unix", "unixgram", "unixpacket": + attrs = append(attrs, sc.NetTransportUnix) + default: + attrs = append(attrs, sc.NetTransportOther) + } + + peerIP, peerName, peerPort := hostIPNamePort(request.RemoteAddr) + if peerIP != "" { + attrs = append(attrs, sc.NetPeerIPKey.String(peerIP)) + } + if peerName != "" { + attrs = append(attrs, sc.NetPeerNameKey.String(peerName)) + } + if peerPort != 0 { + attrs = append(attrs, sc.NetPeerPortKey.Int(peerPort)) + } + + hostIP, hostName, hostPort := "", "", 0 + for _, someHost := range []string{request.Host, request.Header.Get("Host"), request.URL.Host} { + hostIP, hostName, hostPort = hostIPNamePort(someHost) + if hostIP != "" || hostName != "" || hostPort != 0 { + break + } + } + if hostIP != "" { + attrs = append(attrs, sc.NetHostIPKey.String(hostIP)) + } + if hostName != "" { + attrs = append(attrs, sc.NetHostNameKey.String(hostName)) + } + if hostPort != 0 { + attrs = append(attrs, sc.NetHostPortKey.Int(hostPort)) + } + + return attrs +} + +// hostIPNamePort extracts the IP address, name and (optional) port from hostWithPort. +// It handles both IPv4 and IPv6 addresses. If the host portion is not recognized +// as a valid IPv4 or IPv6 address, the `ip` result will be empty and the +// host portion will instead be returned in `name`. +func hostIPNamePort(hostWithPort string) (ip string, name string, port int) { + var ( + hostPart, portPart string + parsedPort uint64 + err error + ) + if hostPart, portPart, err = net.SplitHostPort(hostWithPort); err != nil { + hostPart, portPart = hostWithPort, "" + } + if parsedIP := net.ParseIP(hostPart); parsedIP != nil { + ip = parsedIP.String() + } else { + name = hostPart + } + if parsedPort, err = strconv.ParseUint(portPart, 10, 16); err == nil { + port = int(parsedPort) + } + return +} + +// EndUserAttributesFromHTTPRequest generates attributes of the +// enduser namespace as specified by the OpenTelemetry specification +// for a span. +func (sc *SemanticConventions) EndUserAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { + if username, _, ok := request.BasicAuth(); ok { + return []attribute.KeyValue{sc.EnduserIDKey.String(username)} + } + return nil +} + +// HTTPClientAttributesFromHTTPRequest generates attributes of the +// http namespace as specified by the OpenTelemetry specification for +// a span on the client side. +func (sc *SemanticConventions) HTTPClientAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { + attrs := []attribute.KeyValue{} + + // remove any username/password info that may be in the URL + // before adding it to the attributes + userinfo := request.URL.User + request.URL.User = nil + + attrs = append(attrs, sc.HTTPURLKey.String(request.URL.String())) + + // restore any username/password info that was removed + request.URL.User = userinfo + + return append(attrs, sc.httpCommonAttributesFromHTTPRequest(request)...) +} + +func (sc *SemanticConventions) httpCommonAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { + attrs := []attribute.KeyValue{} + if ua := request.UserAgent(); ua != "" { + attrs = append(attrs, sc.HTTPUserAgentKey.String(ua)) + } + if request.ContentLength > 0 { + attrs = append(attrs, sc.HTTPRequestContentLengthKey.Int64(request.ContentLength)) + } + + return append(attrs, sc.httpBasicAttributesFromHTTPRequest(request)...) +} + +func (sc *SemanticConventions) httpBasicAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { + // as these attributes are used by HTTPServerMetricAttributesFromHTTPRequest, they should be low-cardinality + attrs := []attribute.KeyValue{} + + if request.TLS != nil { + attrs = append(attrs, sc.HTTPSchemeHTTPS) + } else { + attrs = append(attrs, sc.HTTPSchemeHTTP) + } + + if request.Host != "" { + attrs = append(attrs, sc.HTTPHostKey.String(request.Host)) + } else if request.URL != nil && request.URL.Host != "" { + attrs = append(attrs, sc.HTTPHostKey.String(request.URL.Host)) + } + + flavor := "" + if request.ProtoMajor == 1 { + flavor = fmt.Sprintf("1.%d", request.ProtoMinor) + } else if request.ProtoMajor == 2 { + flavor = "2" + } + if flavor != "" { + attrs = append(attrs, sc.HTTPFlavorKey.String(flavor)) + } + + if request.Method != "" { + attrs = append(attrs, sc.HTTPMethodKey.String(request.Method)) + } else { + attrs = append(attrs, sc.HTTPMethodKey.String(http.MethodGet)) + } + + return attrs +} + +// HTTPServerMetricAttributesFromHTTPRequest generates low-cardinality attributes +// to be used with server-side HTTP metrics. +func (sc *SemanticConventions) HTTPServerMetricAttributesFromHTTPRequest(serverName string, request *http.Request) []attribute.KeyValue { + attrs := []attribute.KeyValue{} + if serverName != "" { + attrs = append(attrs, sc.HTTPServerNameKey.String(serverName)) + } + return append(attrs, sc.httpBasicAttributesFromHTTPRequest(request)...) +} + +// HTTPServerAttributesFromHTTPRequest generates attributes of the +// http namespace as specified by the OpenTelemetry specification for +// a span on the server side. Currently, only basic authentication is +// supported. +func (sc *SemanticConventions) HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http.Request) []attribute.KeyValue { + attrs := []attribute.KeyValue{ + sc.HTTPTargetKey.String(request.RequestURI), + } + + if serverName != "" { + attrs = append(attrs, sc.HTTPServerNameKey.String(serverName)) + } + if route != "" { + attrs = append(attrs, sc.HTTPRouteKey.String(route)) + } + if values := request.Header["X-Forwarded-For"]; len(values) > 0 { + addr := values[0] + if i := strings.Index(addr, ","); i > 0 { + addr = addr[:i] + } + attrs = append(attrs, sc.HTTPClientIPKey.String(addr)) + } + + return append(attrs, sc.httpCommonAttributesFromHTTPRequest(request)...) +} + +// HTTPAttributesFromHTTPStatusCode generates attributes of the http +// namespace as specified by the OpenTelemetry specification for a +// span. +func (sc *SemanticConventions) HTTPAttributesFromHTTPStatusCode(code int) []attribute.KeyValue { + attrs := []attribute.KeyValue{ + sc.HTTPStatusCodeKey.Int(code), + } + return attrs +} + +type codeRange struct { + fromInclusive int + toInclusive int +} + +func (r codeRange) contains(code int) bool { + return r.fromInclusive <= code && code <= r.toInclusive +} + +var validRangesPerCategory = map[int][]codeRange{ + 1: { + {http.StatusContinue, http.StatusEarlyHints}, + }, + 2: { + {http.StatusOK, http.StatusAlreadyReported}, + {http.StatusIMUsed, http.StatusIMUsed}, + }, + 3: { + {http.StatusMultipleChoices, http.StatusUseProxy}, + {http.StatusTemporaryRedirect, http.StatusPermanentRedirect}, + }, + 4: { + {http.StatusBadRequest, http.StatusTeapot}, // yes, teapot is so useful… + {http.StatusMisdirectedRequest, http.StatusUpgradeRequired}, + {http.StatusPreconditionRequired, http.StatusTooManyRequests}, + {http.StatusRequestHeaderFieldsTooLarge, http.StatusRequestHeaderFieldsTooLarge}, + {http.StatusUnavailableForLegalReasons, http.StatusUnavailableForLegalReasons}, + }, + 5: { + {http.StatusInternalServerError, http.StatusLoopDetected}, + {http.StatusNotExtended, http.StatusNetworkAuthenticationRequired}, + }, +} + +// SpanStatusFromHTTPStatusCode generates a status code and a message +// as specified by the OpenTelemetry specification for a span. +func SpanStatusFromHTTPStatusCode(code int) (codes.Code, string) { + spanCode, valid := validateHTTPStatusCode(code) + if !valid { + return spanCode, fmt.Sprintf("Invalid HTTP status code %d", code) + } + return spanCode, "" +} + +// SpanStatusFromHTTPStatusCodeAndSpanKind generates a status code and a message +// as specified by the OpenTelemetry specification for a span. +// Exclude 4xx for SERVER to set the appropriate status. +func SpanStatusFromHTTPStatusCodeAndSpanKind(code int, spanKind trace.SpanKind) (codes.Code, string) { + spanCode, valid := validateHTTPStatusCode(code) + if !valid { + return spanCode, fmt.Sprintf("Invalid HTTP status code %d", code) + } + category := code / 100 + if spanKind == trace.SpanKindServer && category == 4 { + return codes.Unset, "" + } + return spanCode, "" +} + +// validateHTTPStatusCode validates the HTTP status code and returns +// corresponding span status code. If the `code` is not a valid HTTP status +// code, returns span status Error and false. +func validateHTTPStatusCode(code int) (codes.Code, bool) { + category := code / 100 + ranges, ok := validRangesPerCategory[category] + if !ok { + return codes.Error, false + } + ok = false + for _, crange := range ranges { + ok = crange.contains(code) + if ok { + break + } + } + if !ok { + return codes.Error, false + } + if category > 0 && category < 4 { + return codes.Unset, true + } + return codes.Error, true +} diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/doc.go b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/doc.go new file mode 100644 index 000000000..181fcc9c5 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/doc.go @@ -0,0 +1,20 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package semconv implements OpenTelemetry semantic conventions. +// +// OpenTelemetry semantic conventions are agreed standardized naming +// patterns for OpenTelemetry things. This package represents the conventions +// as of the v1.12.0 version of the OpenTelemetry specification. +package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/exception.go b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/exception.go new file mode 100644 index 000000000..d68927094 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/exception.go @@ -0,0 +1,20 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" + +const ( + // ExceptionEventName is the name of the Span event representing an exception. + ExceptionEventName = "exception" +) diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/http.go b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/http.go new file mode 100644 index 000000000..4b4f3cbaf --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/http.go @@ -0,0 +1,114 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" + +import ( + "net/http" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/semconv/internal" + "go.opentelemetry.io/otel/trace" +) + +// HTTP scheme attributes. +var ( + HTTPSchemeHTTP = HTTPSchemeKey.String("http") + HTTPSchemeHTTPS = HTTPSchemeKey.String("https") +) + +var sc = &internal.SemanticConventions{ + EnduserIDKey: EnduserIDKey, + HTTPClientIPKey: HTTPClientIPKey, + HTTPFlavorKey: HTTPFlavorKey, + HTTPHostKey: HTTPHostKey, + HTTPMethodKey: HTTPMethodKey, + HTTPRequestContentLengthKey: HTTPRequestContentLengthKey, + HTTPRouteKey: HTTPRouteKey, + HTTPSchemeHTTP: HTTPSchemeHTTP, + HTTPSchemeHTTPS: HTTPSchemeHTTPS, + HTTPServerNameKey: HTTPServerNameKey, + HTTPStatusCodeKey: HTTPStatusCodeKey, + HTTPTargetKey: HTTPTargetKey, + HTTPURLKey: HTTPURLKey, + HTTPUserAgentKey: HTTPUserAgentKey, + NetHostIPKey: NetHostIPKey, + NetHostNameKey: NetHostNameKey, + NetHostPortKey: NetHostPortKey, + NetPeerIPKey: NetPeerIPKey, + NetPeerNameKey: NetPeerNameKey, + NetPeerPortKey: NetPeerPortKey, + NetTransportIP: NetTransportIP, + NetTransportOther: NetTransportOther, + NetTransportTCP: NetTransportTCP, + NetTransportUDP: NetTransportUDP, + NetTransportUnix: NetTransportUnix, +} + +// NetAttributesFromHTTPRequest generates attributes of the net +// namespace as specified by the OpenTelemetry specification for a +// span. The network parameter is a string that net.Dial function +// from standard library can understand. +func NetAttributesFromHTTPRequest(network string, request *http.Request) []attribute.KeyValue { + return sc.NetAttributesFromHTTPRequest(network, request) +} + +// EndUserAttributesFromHTTPRequest generates attributes of the +// enduser namespace as specified by the OpenTelemetry specification +// for a span. +func EndUserAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { + return sc.EndUserAttributesFromHTTPRequest(request) +} + +// HTTPClientAttributesFromHTTPRequest generates attributes of the +// http namespace as specified by the OpenTelemetry specification for +// a span on the client side. +func HTTPClientAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { + return sc.HTTPClientAttributesFromHTTPRequest(request) +} + +// HTTPServerMetricAttributesFromHTTPRequest generates low-cardinality attributes +// to be used with server-side HTTP metrics. +func HTTPServerMetricAttributesFromHTTPRequest(serverName string, request *http.Request) []attribute.KeyValue { + return sc.HTTPServerMetricAttributesFromHTTPRequest(serverName, request) +} + +// HTTPServerAttributesFromHTTPRequest generates attributes of the +// http namespace as specified by the OpenTelemetry specification for +// a span on the server side. Currently, only basic authentication is +// supported. +func HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http.Request) []attribute.KeyValue { + return sc.HTTPServerAttributesFromHTTPRequest(serverName, route, request) +} + +// HTTPAttributesFromHTTPStatusCode generates attributes of the http +// namespace as specified by the OpenTelemetry specification for a +// span. +func HTTPAttributesFromHTTPStatusCode(code int) []attribute.KeyValue { + return sc.HTTPAttributesFromHTTPStatusCode(code) +} + +// SpanStatusFromHTTPStatusCode generates a status code and a message +// as specified by the OpenTelemetry specification for a span. +func SpanStatusFromHTTPStatusCode(code int) (codes.Code, string) { + return internal.SpanStatusFromHTTPStatusCode(code) +} + +// SpanStatusFromHTTPStatusCodeAndSpanKind generates a status code and a message +// as specified by the OpenTelemetry specification for a span. +// Exclude 4xx for SERVER to set the appropriate status. +func SpanStatusFromHTTPStatusCodeAndSpanKind(code int, spanKind trace.SpanKind) (codes.Code, string) { + return internal.SpanStatusFromHTTPStatusCodeAndSpanKind(code, spanKind) +} diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/resource.go b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/resource.go new file mode 100644 index 000000000..b2155676f --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/resource.go @@ -0,0 +1,1042 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated from semantic convention specification. DO NOT EDIT. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" + +import "go.opentelemetry.io/otel/attribute" + +// The web browser in which the application represented by the resource is running. The `browser.*` attributes MUST be used only for resources that represent applications running in a web browser (regardless of whether running on a mobile or desktop device). +const ( + // Array of brand name and version separated by a space + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: ' Not A;Brand 99', 'Chromium 99', 'Chrome 99' + // Note: This value is intended to be taken from the [UA client hints + // API](https://wicg.github.io/ua-client-hints/#interface) + // (navigator.userAgentData.brands). + BrowserBrandsKey = attribute.Key("browser.brands") + // The platform on which the browser is running + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Windows', 'macOS', 'Android' + // Note: This value is intended to be taken from the [UA client hints + // API](https://wicg.github.io/ua-client-hints/#interface) + // (navigator.userAgentData.platform). If unavailable, the legacy + // `navigator.platform` API SHOULD NOT be used instead and this attribute SHOULD + // be left unset in order for the values to be consistent. + // The list of possible values is defined in the [W3C User-Agent Client Hints + // specification](https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform). + // Note that some (but not all) of these values can overlap with values in the + // [os.type and os.name attributes](./os.md). However, for consistency, the values + // in the `browser.platform` attribute should capture the exact value that the + // user agent provides. + BrowserPlatformKey = attribute.Key("browser.platform") + // Full user-agent string provided by the browser + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 + // (KHTML, ' + // 'like Gecko) Chrome/95.0.4638.54 Safari/537.36' + // Note: The user-agent value SHOULD be provided only from browsers that do not + // have a mechanism to retrieve brands and platform individually from the User- + // Agent Client Hints API. To retrieve the value, the legacy `navigator.userAgent` + // API can be used. + BrowserUserAgentKey = attribute.Key("browser.user_agent") +) + +// A cloud environment (e.g. GCP, Azure, AWS) +const ( + // Name of the cloud provider. + // + // Type: Enum + // Required: No + // Stability: stable + CloudProviderKey = attribute.Key("cloud.provider") + // The cloud account ID the resource is assigned to. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '111111111111', 'opentelemetry' + CloudAccountIDKey = attribute.Key("cloud.account.id") + // The geographical region the resource is running. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'us-central1', 'us-east-1' + // Note: Refer to your provider's docs to see the available regions, for example + // [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc- + // detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global- + // infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/en- + // us/global-infrastructure/geographies/), [Google Cloud + // regions](https://cloud.google.com/about/locations), or [Tencent Cloud + // regions](https://intl.cloud.tencent.com/document/product/213/6091). + CloudRegionKey = attribute.Key("cloud.region") + // Cloud regions often have multiple, isolated locations known as zones to + // increase availability. Availability zone represents the zone where the resource + // is running. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'us-east-1c' + // Note: Availability zones are called "zones" on Alibaba Cloud and Google Cloud. + CloudAvailabilityZoneKey = attribute.Key("cloud.availability_zone") + // The cloud platform in use. + // + // Type: Enum + // Required: No + // Stability: stable + // Note: The prefix of the service SHOULD match the one specified in + // `cloud.provider`. + CloudPlatformKey = attribute.Key("cloud.platform") +) + +var ( + // Alibaba Cloud + CloudProviderAlibabaCloud = CloudProviderKey.String("alibaba_cloud") + // Amazon Web Services + CloudProviderAWS = CloudProviderKey.String("aws") + // Microsoft Azure + CloudProviderAzure = CloudProviderKey.String("azure") + // Google Cloud Platform + CloudProviderGCP = CloudProviderKey.String("gcp") + // Tencent Cloud + CloudProviderTencentCloud = CloudProviderKey.String("tencent_cloud") +) + +var ( + // Alibaba Cloud Elastic Compute Service + CloudPlatformAlibabaCloudECS = CloudPlatformKey.String("alibaba_cloud_ecs") + // Alibaba Cloud Function Compute + CloudPlatformAlibabaCloudFc = CloudPlatformKey.String("alibaba_cloud_fc") + // AWS Elastic Compute Cloud + CloudPlatformAWSEC2 = CloudPlatformKey.String("aws_ec2") + // AWS Elastic Container Service + CloudPlatformAWSECS = CloudPlatformKey.String("aws_ecs") + // AWS Elastic Kubernetes Service + CloudPlatformAWSEKS = CloudPlatformKey.String("aws_eks") + // AWS Lambda + CloudPlatformAWSLambda = CloudPlatformKey.String("aws_lambda") + // AWS Elastic Beanstalk + CloudPlatformAWSElasticBeanstalk = CloudPlatformKey.String("aws_elastic_beanstalk") + // AWS App Runner + CloudPlatformAWSAppRunner = CloudPlatformKey.String("aws_app_runner") + // Azure Virtual Machines + CloudPlatformAzureVM = CloudPlatformKey.String("azure_vm") + // Azure Container Instances + CloudPlatformAzureContainerInstances = CloudPlatformKey.String("azure_container_instances") + // Azure Kubernetes Service + CloudPlatformAzureAKS = CloudPlatformKey.String("azure_aks") + // Azure Functions + CloudPlatformAzureFunctions = CloudPlatformKey.String("azure_functions") + // Azure App Service + CloudPlatformAzureAppService = CloudPlatformKey.String("azure_app_service") + // Google Cloud Compute Engine (GCE) + CloudPlatformGCPComputeEngine = CloudPlatformKey.String("gcp_compute_engine") + // Google Cloud Run + CloudPlatformGCPCloudRun = CloudPlatformKey.String("gcp_cloud_run") + // Google Cloud Kubernetes Engine (GKE) + CloudPlatformGCPKubernetesEngine = CloudPlatformKey.String("gcp_kubernetes_engine") + // Google Cloud Functions (GCF) + CloudPlatformGCPCloudFunctions = CloudPlatformKey.String("gcp_cloud_functions") + // Google Cloud App Engine (GAE) + CloudPlatformGCPAppEngine = CloudPlatformKey.String("gcp_app_engine") + // Tencent Cloud Cloud Virtual Machine (CVM) + CloudPlatformTencentCloudCvm = CloudPlatformKey.String("tencent_cloud_cvm") + // Tencent Cloud Elastic Kubernetes Service (EKS) + CloudPlatformTencentCloudEKS = CloudPlatformKey.String("tencent_cloud_eks") + // Tencent Cloud Serverless Cloud Function (SCF) + CloudPlatformTencentCloudScf = CloudPlatformKey.String("tencent_cloud_scf") +) + +// Resources used by AWS Elastic Container Service (ECS). +const ( + // The Amazon Resource Name (ARN) of an [ECS container instance](https://docs.aws. + // amazon.com/AmazonECS/latest/developerguide/ECS_instances.html). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'arn:aws:ecs:us- + // west-1:123456789123:container/32624152-9086-4f0e-acae-1a75b14fe4d9' + AWSECSContainerARNKey = attribute.Key("aws.ecs.container.arn") + // The ARN of an [ECS cluster](https://docs.aws.amazon.com/AmazonECS/latest/develo + // perguide/clusters.html). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'arn:aws:ecs:us-west-2:123456789123:cluster/my-cluster' + AWSECSClusterARNKey = attribute.Key("aws.ecs.cluster.arn") + // The [launch type](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/l + // aunch_types.html) for an ECS task. + // + // Type: Enum + // Required: No + // Stability: stable + AWSECSLaunchtypeKey = attribute.Key("aws.ecs.launchtype") + // The ARN of an [ECS task definition](https://docs.aws.amazon.com/AmazonECS/lates + // t/developerguide/task_definitions.html). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'arn:aws:ecs:us- + // west-1:123456789123:task/10838bed-421f-43ef-870a-f43feacbbb5b' + AWSECSTaskARNKey = attribute.Key("aws.ecs.task.arn") + // The task definition family this task definition is a member of. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry-family' + AWSECSTaskFamilyKey = attribute.Key("aws.ecs.task.family") + // The revision for this task definition. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '8', '26' + AWSECSTaskRevisionKey = attribute.Key("aws.ecs.task.revision") +) + +var ( + // ec2 + AWSECSLaunchtypeEC2 = AWSECSLaunchtypeKey.String("ec2") + // fargate + AWSECSLaunchtypeFargate = AWSECSLaunchtypeKey.String("fargate") +) + +// Resources used by AWS Elastic Kubernetes Service (EKS). +const ( + // The ARN of an EKS cluster. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'arn:aws:ecs:us-west-2:123456789123:cluster/my-cluster' + AWSEKSClusterARNKey = attribute.Key("aws.eks.cluster.arn") +) + +// Resources specific to Amazon Web Services. +const ( + // The name(s) of the AWS log group(s) an application is writing to. + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: '/aws/lambda/my-function', 'opentelemetry-service' + // Note: Multiple log groups must be supported for cases like multi-container + // applications, where a single application has sidecar containers, and each write + // to their own log group. + AWSLogGroupNamesKey = attribute.Key("aws.log.group.names") + // The Amazon Resource Name(s) (ARN) of the AWS log group(s). + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: 'arn:aws:logs:us-west-1:123456789012:log-group:/aws/my/group:*' + // Note: See the [log group ARN format + // documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam- + // access-control-overview-cwl.html#CWL_ARN_Format). + AWSLogGroupARNsKey = attribute.Key("aws.log.group.arns") + // The name(s) of the AWS log stream(s) an application is writing to. + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: 'logs/main/10838bed-421f-43ef-870a-f43feacbbb5b' + AWSLogStreamNamesKey = attribute.Key("aws.log.stream.names") + // The ARN(s) of the AWS log stream(s). + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: 'arn:aws:logs:us-west-1:123456789012:log-group:/aws/my/group:log- + // stream:logs/main/10838bed-421f-43ef-870a-f43feacbbb5b' + // Note: See the [log stream ARN format + // documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam- + // access-control-overview-cwl.html#CWL_ARN_Format). One log group can contain + // several log streams, so these ARNs necessarily identify both a log group and a + // log stream. + AWSLogStreamARNsKey = attribute.Key("aws.log.stream.arns") +) + +// A container instance. +const ( + // Container name used by container runtime. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry-autoconf' + ContainerNameKey = attribute.Key("container.name") + // Container ID. Usually a UUID, as for example used to [identify Docker + // containers](https://docs.docker.com/engine/reference/run/#container- + // identification). The UUID might be abbreviated. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'a3bf90e006b2' + ContainerIDKey = attribute.Key("container.id") + // The container runtime managing this container. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'docker', 'containerd', 'rkt' + ContainerRuntimeKey = attribute.Key("container.runtime") + // Name of the image the container was built on. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'gcr.io/opentelemetry/operator' + ContainerImageNameKey = attribute.Key("container.image.name") + // Container image tag. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '0.1' + ContainerImageTagKey = attribute.Key("container.image.tag") +) + +// The software deployment. +const ( + // Name of the [deployment + // environment](https://en.wikipedia.org/wiki/Deployment_environment) (aka + // deployment tier). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'staging', 'production' + DeploymentEnvironmentKey = attribute.Key("deployment.environment") +) + +// The device on which the process represented by this resource is running. +const ( + // A unique identifier representing the device + // + // Type: string + // Required: No + // Stability: stable + // Examples: '2ab2916d-a51f-4ac8-80ee-45ac31a28092' + // Note: The device identifier MUST only be defined using the values outlined + // below. This value is not an advertising identifier and MUST NOT be used as + // such. On iOS (Swift or Objective-C), this value MUST be equal to the [vendor id + // entifier](https://developer.apple.com/documentation/uikit/uidevice/1620059-iden + // tifierforvendor). On Android (Java or Kotlin), this value MUST be equal to the + // Firebase Installation ID or a globally unique UUID which is persisted across + // sessions in your application. More information can be found + // [here](https://developer.android.com/training/articles/user-data-ids) on best + // practices and exact implementation details. Caution should be taken when + // storing personal data or anything which can identify a user. GDPR and data + // protection laws may apply, ensure you do your own due diligence. + DeviceIDKey = attribute.Key("device.id") + // The model identifier for the device + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'iPhone3,4', 'SM-G920F' + // Note: It's recommended this value represents a machine readable version of the + // model identifier rather than the market or consumer-friendly name of the + // device. + DeviceModelIdentifierKey = attribute.Key("device.model.identifier") + // The marketing name for the device model + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'iPhone 6s Plus', 'Samsung Galaxy S6' + // Note: It's recommended this value represents a human readable version of the + // device model rather than a machine readable alternative. + DeviceModelNameKey = attribute.Key("device.model.name") + // The name of the device manufacturer + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Apple', 'Samsung' + // Note: The Android OS provides this field via + // [Build](https://developer.android.com/reference/android/os/Build#MANUFACTURER). + // iOS apps SHOULD hardcode the value `Apple`. + DeviceManufacturerKey = attribute.Key("device.manufacturer") +) + +// A serverless instance. +const ( + // The name of the single function that this runtime instance executes. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'my-function', 'myazurefunctionapp/some-function-name' + // Note: This is the name of the function as configured/deployed on the FaaS + // platform and is usually different from the name of the callback + // function (which may be stored in the + // [`code.namespace`/`code.function`](../../trace/semantic_conventions/span- + // general.md#source-code-attributes) + // span attributes). + + // For some cloud providers, the above definition is ambiguous. The following + // definition of function name MUST be used for this attribute + // (and consequently the span name) for the listed cloud providers/products: + + // * **Azure:** The full name `/`, i.e., function app name + // followed by a forward slash followed by the function name (this form + // can also be seen in the resource JSON for the function). + // This means that a span attribute MUST be used, as an Azure function + // app can host multiple functions that would usually share + // a TracerProvider (see also the `faas.id` attribute). + FaaSNameKey = attribute.Key("faas.name") + // The unique ID of the single function that this runtime instance executes. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'arn:aws:lambda:us-west-2:123456789012:function:my-function' + // Note: On some cloud providers, it may not be possible to determine the full ID + // at startup, + // so consider setting `faas.id` as a span attribute instead. + + // The exact value to use for `faas.id` depends on the cloud provider: + + // * **AWS Lambda:** The function + // [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and- + // namespaces.html). + // Take care not to use the "invoked ARN" directly but replace any + // [alias suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration- + // aliases.html) + // with the resolved function version, as the same runtime instance may be + // invokable with + // multiple different aliases. + // * **GCP:** The [URI of the resource](https://cloud.google.com/iam/docs/full- + // resource-names) + // * **Azure:** The [Fully Qualified Resource ID](https://docs.microsoft.com/en- + // us/rest/api/resources/resources/get-by-id) of the invoked function, + // *not* the function app, having the form + // `/subscriptions//resourceGroups//providers/Microsoft.We + // b/sites//functions/`. + // This means that a span attribute MUST be used, as an Azure function app can + // host multiple functions that would usually share + // a TracerProvider. + FaaSIDKey = attribute.Key("faas.id") + // The immutable version of the function being executed. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '26', 'pinkfroid-00002' + // Note: Depending on the cloud provider and platform, use: + + // * **AWS Lambda:** The [function + // version](https://docs.aws.amazon.com/lambda/latest/dg/configuration- + // versions.html) + // (an integer represented as a decimal string). + // * **Google Cloud Run:** The + // [revision](https://cloud.google.com/run/docs/managing/revisions) + // (i.e., the function name plus the revision suffix). + // * **Google Cloud Functions:** The value of the + // [`K_REVISION` environment + // variable](https://cloud.google.com/functions/docs/env- + // var#runtime_environment_variables_set_automatically). + // * **Azure Functions:** Not applicable. Do not set this attribute. + FaaSVersionKey = attribute.Key("faas.version") + // The execution environment ID as a string, that will be potentially reused for + // other invocations to the same function/function version. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de' + // Note: * **AWS Lambda:** Use the (full) log stream name. + FaaSInstanceKey = attribute.Key("faas.instance") + // The amount of memory available to the serverless function in MiB. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 128 + // Note: It's recommended to set this attribute since e.g. too little memory can + // easily stop a Java AWS Lambda function from working correctly. On AWS Lambda, + // the environment variable `AWS_LAMBDA_FUNCTION_MEMORY_SIZE` provides this + // information. + FaaSMaxMemoryKey = attribute.Key("faas.max_memory") +) + +// A host is defined as a general computing instance. +const ( + // Unique host ID. For Cloud, this must be the instance_id assigned by the cloud + // provider. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry-test' + HostIDKey = attribute.Key("host.id") + // Name of the host. On Unix systems, it may contain what the hostname command + // returns, or the fully qualified hostname, or another name specified by the + // user. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry-test' + HostNameKey = attribute.Key("host.name") + // Type of host. For Cloud, this must be the machine type. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'n1-standard-1' + HostTypeKey = attribute.Key("host.type") + // The CPU architecture the host system is running on. + // + // Type: Enum + // Required: No + // Stability: stable + HostArchKey = attribute.Key("host.arch") + // Name of the VM image or OS install the host was instantiated from. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'infra-ami-eks-worker-node-7d4ec78312', 'CentOS-8-x86_64-1905' + HostImageNameKey = attribute.Key("host.image.name") + // VM image ID. For Cloud, this value is from the provider. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'ami-07b06b442921831e5' + HostImageIDKey = attribute.Key("host.image.id") + // The version string of the VM image as defined in [Version + // Attributes](README.md#version-attributes). + // + // Type: string + // Required: No + // Stability: stable + // Examples: '0.1' + HostImageVersionKey = attribute.Key("host.image.version") +) + +var ( + // AMD64 + HostArchAMD64 = HostArchKey.String("amd64") + // ARM32 + HostArchARM32 = HostArchKey.String("arm32") + // ARM64 + HostArchARM64 = HostArchKey.String("arm64") + // Itanium + HostArchIA64 = HostArchKey.String("ia64") + // 32-bit PowerPC + HostArchPPC32 = HostArchKey.String("ppc32") + // 64-bit PowerPC + HostArchPPC64 = HostArchKey.String("ppc64") + // IBM z/Architecture + HostArchS390x = HostArchKey.String("s390x") + // 32-bit x86 + HostArchX86 = HostArchKey.String("x86") +) + +// A Kubernetes Cluster. +const ( + // The name of the cluster. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry-cluster' + K8SClusterNameKey = attribute.Key("k8s.cluster.name") +) + +// A Kubernetes Node object. +const ( + // The name of the Node. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'node-1' + K8SNodeNameKey = attribute.Key("k8s.node.name") + // The UID of the Node. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '1eb3a0c6-0477-4080-a9cb-0cb7db65c6a2' + K8SNodeUIDKey = attribute.Key("k8s.node.uid") +) + +// A Kubernetes Namespace. +const ( + // The name of the namespace that the pod is running in. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'default' + K8SNamespaceNameKey = attribute.Key("k8s.namespace.name") +) + +// A Kubernetes Pod object. +const ( + // The UID of the Pod. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SPodUIDKey = attribute.Key("k8s.pod.uid") + // The name of the Pod. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry-pod-autoconf' + K8SPodNameKey = attribute.Key("k8s.pod.name") +) + +// A container in a [PodTemplate](https://kubernetes.io/docs/concepts/workloads/pods/#pod-templates). +const ( + // The name of the Container from Pod specification, must be unique within a Pod. + // Container runtime usually uses different globally unique name + // (`container.name`). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'redis' + K8SContainerNameKey = attribute.Key("k8s.container.name") + // Number of times the container was restarted. This attribute can be used to + // identify a particular container (running or stopped) within a container spec. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 0, 2 + K8SContainerRestartCountKey = attribute.Key("k8s.container.restart_count") +) + +// A Kubernetes ReplicaSet object. +const ( + // The UID of the ReplicaSet. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SReplicaSetUIDKey = attribute.Key("k8s.replicaset.uid") + // The name of the ReplicaSet. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry' + K8SReplicaSetNameKey = attribute.Key("k8s.replicaset.name") +) + +// A Kubernetes Deployment object. +const ( + // The UID of the Deployment. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SDeploymentUIDKey = attribute.Key("k8s.deployment.uid") + // The name of the Deployment. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry' + K8SDeploymentNameKey = attribute.Key("k8s.deployment.name") +) + +// A Kubernetes StatefulSet object. +const ( + // The UID of the StatefulSet. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SStatefulSetUIDKey = attribute.Key("k8s.statefulset.uid") + // The name of the StatefulSet. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry' + K8SStatefulSetNameKey = attribute.Key("k8s.statefulset.name") +) + +// A Kubernetes DaemonSet object. +const ( + // The UID of the DaemonSet. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SDaemonSetUIDKey = attribute.Key("k8s.daemonset.uid") + // The name of the DaemonSet. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry' + K8SDaemonSetNameKey = attribute.Key("k8s.daemonset.name") +) + +// A Kubernetes Job object. +const ( + // The UID of the Job. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SJobUIDKey = attribute.Key("k8s.job.uid") + // The name of the Job. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry' + K8SJobNameKey = attribute.Key("k8s.job.name") +) + +// A Kubernetes CronJob object. +const ( + // The UID of the CronJob. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SCronJobUIDKey = attribute.Key("k8s.cronjob.uid") + // The name of the CronJob. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry' + K8SCronJobNameKey = attribute.Key("k8s.cronjob.name") +) + +// The operating system (OS) on which the process represented by this resource is running. +const ( + // The operating system type. + // + // Type: Enum + // Required: Always + // Stability: stable + OSTypeKey = attribute.Key("os.type") + // Human readable (not intended to be parsed) OS version information, like e.g. + // reported by `ver` or `lsb_release -a` commands. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Microsoft Windows [Version 10.0.18363.778]', 'Ubuntu 18.04.1 LTS' + OSDescriptionKey = attribute.Key("os.description") + // Human readable operating system name. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'iOS', 'Android', 'Ubuntu' + OSNameKey = attribute.Key("os.name") + // The version string of the operating system as defined in [Version + // Attributes](../../resource/semantic_conventions/README.md#version-attributes). + // + // Type: string + // Required: No + // Stability: stable + // Examples: '14.2.1', '18.04.1' + OSVersionKey = attribute.Key("os.version") +) + +var ( + // Microsoft Windows + OSTypeWindows = OSTypeKey.String("windows") + // Linux + OSTypeLinux = OSTypeKey.String("linux") + // Apple Darwin + OSTypeDarwin = OSTypeKey.String("darwin") + // FreeBSD + OSTypeFreeBSD = OSTypeKey.String("freebsd") + // NetBSD + OSTypeNetBSD = OSTypeKey.String("netbsd") + // OpenBSD + OSTypeOpenBSD = OSTypeKey.String("openbsd") + // DragonFly BSD + OSTypeDragonflyBSD = OSTypeKey.String("dragonflybsd") + // HP-UX (Hewlett Packard Unix) + OSTypeHPUX = OSTypeKey.String("hpux") + // AIX (Advanced Interactive eXecutive) + OSTypeAIX = OSTypeKey.String("aix") + // SunOS, Oracle Solaris + OSTypeSolaris = OSTypeKey.String("solaris") + // IBM z/OS + OSTypeZOS = OSTypeKey.String("z_os") +) + +// An operating system process. +const ( + // Process identifier (PID). + // + // Type: int + // Required: No + // Stability: stable + // Examples: 1234 + ProcessPIDKey = attribute.Key("process.pid") + // The name of the process executable. On Linux based systems, can be set to the + // `Name` in `proc/[pid]/status`. On Windows, can be set to the base name of + // `GetProcessImageFileNameW`. + // + // Type: string + // Required: See below + // Stability: stable + // Examples: 'otelcol' + ProcessExecutableNameKey = attribute.Key("process.executable.name") + // The full path to the process executable. On Linux based systems, can be set to + // the target of `proc/[pid]/exe`. On Windows, can be set to the result of + // `GetProcessImageFileNameW`. + // + // Type: string + // Required: See below + // Stability: stable + // Examples: '/usr/bin/cmd/otelcol' + ProcessExecutablePathKey = attribute.Key("process.executable.path") + // The command used to launch the process (i.e. the command name). On Linux based + // systems, can be set to the zeroth string in `proc/[pid]/cmdline`. On Windows, + // can be set to the first parameter extracted from `GetCommandLineW`. + // + // Type: string + // Required: See below + // Stability: stable + // Examples: 'cmd/otelcol' + ProcessCommandKey = attribute.Key("process.command") + // The full command used to launch the process as a single string representing the + // full command. On Windows, can be set to the result of `GetCommandLineW`. Do not + // set this if you have to assemble it just for monitoring; use + // `process.command_args` instead. + // + // Type: string + // Required: See below + // Stability: stable + // Examples: 'C:\\cmd\\otecol --config="my directory\\config.yaml"' + ProcessCommandLineKey = attribute.Key("process.command_line") + // All the command arguments (including the command/executable itself) as received + // by the process. On Linux-based systems (and some other Unixoid systems + // supporting procfs), can be set according to the list of null-delimited strings + // extracted from `proc/[pid]/cmdline`. For libc-based executables, this would be + // the full argv vector passed to `main`. + // + // Type: string[] + // Required: See below + // Stability: stable + // Examples: 'cmd/otecol', '--config=config.yaml' + ProcessCommandArgsKey = attribute.Key("process.command_args") + // The username of the user that owns the process. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'root' + ProcessOwnerKey = attribute.Key("process.owner") +) + +// The single (language) runtime instance which is monitored. +const ( + // The name of the runtime of this process. For compiled native binaries, this + // SHOULD be the name of the compiler. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'OpenJDK Runtime Environment' + ProcessRuntimeNameKey = attribute.Key("process.runtime.name") + // The version of the runtime of this process, as returned by the runtime without + // modification. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '14.0.2' + ProcessRuntimeVersionKey = attribute.Key("process.runtime.version") + // An additional description about the runtime of the process, for example a + // specific vendor customization of the runtime environment. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Eclipse OpenJ9 Eclipse OpenJ9 VM openj9-0.21.0' + ProcessRuntimeDescriptionKey = attribute.Key("process.runtime.description") +) + +// A service instance. +const ( + // Logical name of the service. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'shoppingcart' + // Note: MUST be the same for all instances of horizontally scaled services. If + // the value was not specified, SDKs MUST fallback to `unknown_service:` + // concatenated with [`process.executable.name`](process.md#process), e.g. + // `unknown_service:bash`. If `process.executable.name` is not available, the + // value MUST be set to `unknown_service`. + ServiceNameKey = attribute.Key("service.name") + // A namespace for `service.name`. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Shop' + // Note: A string value having a meaning that helps to distinguish a group of + // services, for example the team name that owns a group of services. + // `service.name` is expected to be unique within the same namespace. If + // `service.namespace` is not specified in the Resource then `service.name` is + // expected to be unique for all services that have no explicit namespace defined + // (so the empty/unspecified namespace is simply one more valid namespace). Zero- + // length namespace string is assumed equal to unspecified namespace. + ServiceNamespaceKey = attribute.Key("service.namespace") + // The string ID of the service instance. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '627cc493-f310-47de-96bd-71410b7dec09' + // Note: MUST be unique for each instance of the same + // `service.namespace,service.name` pair (in other words + // `service.namespace,service.name,service.instance.id` triplet MUST be globally + // unique). The ID helps to distinguish instances of the same service that exist + // at the same time (e.g. instances of a horizontally scaled service). It is + // preferable for the ID to be persistent and stay the same for the lifetime of + // the service instance, however it is acceptable that the ID is ephemeral and + // changes during important lifetime events for the service (e.g. service + // restarts). If the service has no inherent unique ID that can be used as the + // value of this attribute it is recommended to generate a random Version 1 or + // Version 4 RFC 4122 UUID (services aiming for reproducible UUIDs may also use + // Version 5, see RFC 4122 for more recommendations). + ServiceInstanceIDKey = attribute.Key("service.instance.id") + // The version string of the service API or implementation. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '2.0.0' + ServiceVersionKey = attribute.Key("service.version") +) + +// The telemetry SDK used to capture data recorded by the instrumentation libraries. +const ( + // The name of the telemetry SDK as defined above. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'opentelemetry' + TelemetrySDKNameKey = attribute.Key("telemetry.sdk.name") + // The language of the telemetry SDK. + // + // Type: Enum + // Required: No + // Stability: stable + TelemetrySDKLanguageKey = attribute.Key("telemetry.sdk.language") + // The version string of the telemetry SDK. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '1.2.3' + TelemetrySDKVersionKey = attribute.Key("telemetry.sdk.version") + // The version string of the auto instrumentation agent, if used. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '1.2.3' + TelemetryAutoVersionKey = attribute.Key("telemetry.auto.version") +) + +var ( + // cpp + TelemetrySDKLanguageCPP = TelemetrySDKLanguageKey.String("cpp") + // dotnet + TelemetrySDKLanguageDotnet = TelemetrySDKLanguageKey.String("dotnet") + // erlang + TelemetrySDKLanguageErlang = TelemetrySDKLanguageKey.String("erlang") + // go + TelemetrySDKLanguageGo = TelemetrySDKLanguageKey.String("go") + // java + TelemetrySDKLanguageJava = TelemetrySDKLanguageKey.String("java") + // nodejs + TelemetrySDKLanguageNodejs = TelemetrySDKLanguageKey.String("nodejs") + // php + TelemetrySDKLanguagePHP = TelemetrySDKLanguageKey.String("php") + // python + TelemetrySDKLanguagePython = TelemetrySDKLanguageKey.String("python") + // ruby + TelemetrySDKLanguageRuby = TelemetrySDKLanguageKey.String("ruby") + // webjs + TelemetrySDKLanguageWebjs = TelemetrySDKLanguageKey.String("webjs") + // swift + TelemetrySDKLanguageSwift = TelemetrySDKLanguageKey.String("swift") +) + +// Resource describing the packaged software running the application code. Web engines are typically executed using process.runtime. +const ( + // The name of the web engine. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'WildFly' + WebEngineNameKey = attribute.Key("webengine.name") + // The version of the web engine. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '21.0.0' + WebEngineVersionKey = attribute.Key("webengine.version") + // Additional description of the web engine (e.g. detailed version and edition + // information). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'WildFly Full 21.0.0.Final (WildFly Core 13.0.1.Final) - 2.2.2.Final' + WebEngineDescriptionKey = attribute.Key("webengine.description") +) diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/schema.go b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/schema.go new file mode 100644 index 000000000..2f2a019e4 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/schema.go @@ -0,0 +1,20 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" + +// SchemaURL is the schema URL that matches the version of the semantic conventions +// that this package defines. Semconv packages starting from v1.4.0 must declare +// non-empty schema URL in the form https://opentelemetry.io/schemas/ +const SchemaURL = "https://opentelemetry.io/schemas/1.12.0" diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/trace.go b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/trace.go new file mode 100644 index 000000000..047d8e95c --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/trace.go @@ -0,0 +1,1704 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated from semantic convention specification. DO NOT EDIT. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" + +import "go.opentelemetry.io/otel/attribute" + +// Span attributes used by AWS Lambda (in addition to general `faas` attributes). +const ( + // The full invoked ARN as provided on the `Context` passed to the function + // (`Lambda-Runtime-Invoked-Function-ARN` header on the `/runtime/invocation/next` + // applicable). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'arn:aws:lambda:us-east-1:123456:function:myfunction:myalias' + // Note: This may be different from `faas.id` if an alias is involved. + AWSLambdaInvokedARNKey = attribute.Key("aws.lambda.invoked_arn") +) + +// This document defines attributes for CloudEvents. CloudEvents is a specification on how to define event data in a standard way. These attributes can be attached to spans when performing operations with CloudEvents, regardless of the protocol being used. +const ( + // The [event_id](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec + // .md#id) uniquely identifies the event. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: '123e4567-e89b-12d3-a456-426614174000', '0001' + CloudeventsEventIDKey = attribute.Key("cloudevents.event_id") + // The [source](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.m + // d#source-1) identifies the context in which an event happened. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'https://github.com/cloudevents', '/cloudevents/spec/pull/123', 'my- + // service' + CloudeventsEventSourceKey = attribute.Key("cloudevents.event_source") + // The [version of the CloudEvents specification](https://github.com/cloudevents/s + // pec/blob/v1.0.2/cloudevents/spec.md#specversion) which the event uses. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: '1.0' + CloudeventsEventSpecVersionKey = attribute.Key("cloudevents.event_spec_version") + // The [event_type](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/sp + // ec.md#type) contains a value describing the type of event related to the + // originating occurrence. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'com.github.pull_request.opened', 'com.example.object.deleted.v2' + CloudeventsEventTypeKey = attribute.Key("cloudevents.event_type") + // The [subject](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec. + // md#subject) of the event in the context of the event producer (identified by + // source). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'mynewfile.jpg' + CloudeventsEventSubjectKey = attribute.Key("cloudevents.event_subject") +) + +// This document defines semantic conventions for the OpenTracing Shim +const ( + // Parent-child Reference type + // + // Type: Enum + // Required: No + // Stability: stable + // Note: The causal relationship between a child Span and a parent Span. + OpentracingRefTypeKey = attribute.Key("opentracing.ref_type") +) + +var ( + // The parent Span depends on the child Span in some capacity + OpentracingRefTypeChildOf = OpentracingRefTypeKey.String("child_of") + // The parent Span does not depend in any way on the result of the child Span + OpentracingRefTypeFollowsFrom = OpentracingRefTypeKey.String("follows_from") +) + +// This document defines the attributes used to perform database client calls. +const ( + // An identifier for the database management system (DBMS) product being used. See + // below for a list of well-known identifiers. + // + // Type: Enum + // Required: Always + // Stability: stable + DBSystemKey = attribute.Key("db.system") + // The connection string used to connect to the database. It is recommended to + // remove embedded credentials. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Server=(localdb)\\v11.0;Integrated Security=true;' + DBConnectionStringKey = attribute.Key("db.connection_string") + // Username for accessing the database. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'readonly_user', 'reporting_user' + DBUserKey = attribute.Key("db.user") + // The fully-qualified class name of the [Java Database Connectivity + // (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver + // used to connect. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'org.postgresql.Driver', + // 'com.microsoft.sqlserver.jdbc.SQLServerDriver' + DBJDBCDriverClassnameKey = attribute.Key("db.jdbc.driver_classname") + // This attribute is used to report the name of the database being accessed. For + // commands that switch the database, this should be set to the target database + // (even if the command fails). + // + // Type: string + // Required: Required, if applicable. + // Stability: stable + // Examples: 'customers', 'main' + // Note: In some SQL databases, the database name to be used is called "schema + // name". In case there are multiple layers that could be considered for database + // name (e.g. Oracle instance name and schema name), the database name to be used + // is the more specific layer (e.g. Oracle schema name). + DBNameKey = attribute.Key("db.name") + // The database statement being executed. + // + // Type: string + // Required: Required if applicable and not explicitly disabled via + // instrumentation configuration. + // Stability: stable + // Examples: 'SELECT * FROM wuser_table', 'SET mykey "WuValue"' + // Note: The value may be sanitized to exclude sensitive information. + DBStatementKey = attribute.Key("db.statement") + // The name of the operation being executed, e.g. the [MongoDB command + // name](https://docs.mongodb.com/manual/reference/command/#database-operations) + // such as `findAndModify`, or the SQL keyword. + // + // Type: string + // Required: Required, if `db.statement` is not applicable. + // Stability: stable + // Examples: 'findAndModify', 'HMSET', 'SELECT' + // Note: When setting this to an SQL keyword, it is not recommended to attempt any + // client-side parsing of `db.statement` just to get this property, but it should + // be set if the operation name is provided by the library being instrumented. If + // the SQL statement has an ambiguous operation, or performs more than one + // operation, this value may be omitted. + DBOperationKey = attribute.Key("db.operation") +) + +var ( + // Some other SQL database. Fallback only. See notes + DBSystemOtherSQL = DBSystemKey.String("other_sql") + // Microsoft SQL Server + DBSystemMSSQL = DBSystemKey.String("mssql") + // MySQL + DBSystemMySQL = DBSystemKey.String("mysql") + // Oracle Database + DBSystemOracle = DBSystemKey.String("oracle") + // IBM DB2 + DBSystemDB2 = DBSystemKey.String("db2") + // PostgreSQL + DBSystemPostgreSQL = DBSystemKey.String("postgresql") + // Amazon Redshift + DBSystemRedshift = DBSystemKey.String("redshift") + // Apache Hive + DBSystemHive = DBSystemKey.String("hive") + // Cloudscape + DBSystemCloudscape = DBSystemKey.String("cloudscape") + // HyperSQL DataBase + DBSystemHSQLDB = DBSystemKey.String("hsqldb") + // Progress Database + DBSystemProgress = DBSystemKey.String("progress") + // SAP MaxDB + DBSystemMaxDB = DBSystemKey.String("maxdb") + // SAP HANA + DBSystemHanaDB = DBSystemKey.String("hanadb") + // Ingres + DBSystemIngres = DBSystemKey.String("ingres") + // FirstSQL + DBSystemFirstSQL = DBSystemKey.String("firstsql") + // EnterpriseDB + DBSystemEDB = DBSystemKey.String("edb") + // InterSystems Caché + DBSystemCache = DBSystemKey.String("cache") + // Adabas (Adaptable Database System) + DBSystemAdabas = DBSystemKey.String("adabas") + // Firebird + DBSystemFirebird = DBSystemKey.String("firebird") + // Apache Derby + DBSystemDerby = DBSystemKey.String("derby") + // FileMaker + DBSystemFilemaker = DBSystemKey.String("filemaker") + // Informix + DBSystemInformix = DBSystemKey.String("informix") + // InstantDB + DBSystemInstantDB = DBSystemKey.String("instantdb") + // InterBase + DBSystemInterbase = DBSystemKey.String("interbase") + // MariaDB + DBSystemMariaDB = DBSystemKey.String("mariadb") + // Netezza + DBSystemNetezza = DBSystemKey.String("netezza") + // Pervasive PSQL + DBSystemPervasive = DBSystemKey.String("pervasive") + // PointBase + DBSystemPointbase = DBSystemKey.String("pointbase") + // SQLite + DBSystemSqlite = DBSystemKey.String("sqlite") + // Sybase + DBSystemSybase = DBSystemKey.String("sybase") + // Teradata + DBSystemTeradata = DBSystemKey.String("teradata") + // Vertica + DBSystemVertica = DBSystemKey.String("vertica") + // H2 + DBSystemH2 = DBSystemKey.String("h2") + // ColdFusion IMQ + DBSystemColdfusion = DBSystemKey.String("coldfusion") + // Apache Cassandra + DBSystemCassandra = DBSystemKey.String("cassandra") + // Apache HBase + DBSystemHBase = DBSystemKey.String("hbase") + // MongoDB + DBSystemMongoDB = DBSystemKey.String("mongodb") + // Redis + DBSystemRedis = DBSystemKey.String("redis") + // Couchbase + DBSystemCouchbase = DBSystemKey.String("couchbase") + // CouchDB + DBSystemCouchDB = DBSystemKey.String("couchdb") + // Microsoft Azure Cosmos DB + DBSystemCosmosDB = DBSystemKey.String("cosmosdb") + // Amazon DynamoDB + DBSystemDynamoDB = DBSystemKey.String("dynamodb") + // Neo4j + DBSystemNeo4j = DBSystemKey.String("neo4j") + // Apache Geode + DBSystemGeode = DBSystemKey.String("geode") + // Elasticsearch + DBSystemElasticsearch = DBSystemKey.String("elasticsearch") + // Memcached + DBSystemMemcached = DBSystemKey.String("memcached") + // CockroachDB + DBSystemCockroachdb = DBSystemKey.String("cockroachdb") +) + +// Connection-level attributes for Microsoft SQL Server +const ( + // The Microsoft SQL Server [instance name](https://docs.microsoft.com/en- + // us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15) + // connecting to. This name is used to determine the port of a named instance. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'MSSQLSERVER' + // Note: If setting a `db.mssql.instance_name`, `net.peer.port` is no longer + // required (but still recommended if non-standard). + DBMSSQLInstanceNameKey = attribute.Key("db.mssql.instance_name") +) + +// Call-level attributes for Cassandra +const ( + // The fetch size used for paging, i.e. how many rows will be returned at once. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 5000 + DBCassandraPageSizeKey = attribute.Key("db.cassandra.page_size") + // The consistency level of the query. Based on consistency values from + // [CQL](https://docs.datastax.com/en/cassandra- + // oss/3.0/cassandra/dml/dmlConfigConsistency.html). + // + // Type: Enum + // Required: No + // Stability: stable + DBCassandraConsistencyLevelKey = attribute.Key("db.cassandra.consistency_level") + // The name of the primary table that the operation is acting upon, including the + // keyspace name (if applicable). + // + // Type: string + // Required: Recommended if available. + // Stability: stable + // Examples: 'mytable' + // Note: This mirrors the db.sql.table attribute but references cassandra rather + // than sql. It is not recommended to attempt any client-side parsing of + // `db.statement` just to get this property, but it should be set if it is + // provided by the library being instrumented. If the operation is acting upon an + // anonymous table, or more than one table, this value MUST NOT be set. + DBCassandraTableKey = attribute.Key("db.cassandra.table") + // Whether or not the query is idempotent. + // + // Type: boolean + // Required: No + // Stability: stable + DBCassandraIdempotenceKey = attribute.Key("db.cassandra.idempotence") + // The number of times a query was speculatively executed. Not set or `0` if the + // query was not executed speculatively. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 0, 2 + DBCassandraSpeculativeExecutionCountKey = attribute.Key("db.cassandra.speculative_execution_count") + // The ID of the coordinating node for a query. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'be13faa2-8574-4d71-926d-27f16cf8a7af' + DBCassandraCoordinatorIDKey = attribute.Key("db.cassandra.coordinator.id") + // The data center of the coordinating node for a query. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'us-west-2' + DBCassandraCoordinatorDCKey = attribute.Key("db.cassandra.coordinator.dc") +) + +var ( + // all + DBCassandraConsistencyLevelAll = DBCassandraConsistencyLevelKey.String("all") + // each_quorum + DBCassandraConsistencyLevelEachQuorum = DBCassandraConsistencyLevelKey.String("each_quorum") + // quorum + DBCassandraConsistencyLevelQuorum = DBCassandraConsistencyLevelKey.String("quorum") + // local_quorum + DBCassandraConsistencyLevelLocalQuorum = DBCassandraConsistencyLevelKey.String("local_quorum") + // one + DBCassandraConsistencyLevelOne = DBCassandraConsistencyLevelKey.String("one") + // two + DBCassandraConsistencyLevelTwo = DBCassandraConsistencyLevelKey.String("two") + // three + DBCassandraConsistencyLevelThree = DBCassandraConsistencyLevelKey.String("three") + // local_one + DBCassandraConsistencyLevelLocalOne = DBCassandraConsistencyLevelKey.String("local_one") + // any + DBCassandraConsistencyLevelAny = DBCassandraConsistencyLevelKey.String("any") + // serial + DBCassandraConsistencyLevelSerial = DBCassandraConsistencyLevelKey.String("serial") + // local_serial + DBCassandraConsistencyLevelLocalSerial = DBCassandraConsistencyLevelKey.String("local_serial") +) + +// Call-level attributes for Redis +const ( + // The index of the database being accessed as used in the [`SELECT` + // command](https://redis.io/commands/select), provided as an integer. To be used + // instead of the generic `db.name` attribute. + // + // Type: int + // Required: Required, if other than the default database (`0`). + // Stability: stable + // Examples: 0, 1, 15 + DBRedisDBIndexKey = attribute.Key("db.redis.database_index") +) + +// Call-level attributes for MongoDB +const ( + // The collection being accessed within the database stated in `db.name`. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'customers', 'products' + DBMongoDBCollectionKey = attribute.Key("db.mongodb.collection") +) + +// Call-level attributes for SQL databases +const ( + // The name of the primary table that the operation is acting upon, including the + // database name (if applicable). + // + // Type: string + // Required: Recommended if available. + // Stability: stable + // Examples: 'public.users', 'customers' + // Note: It is not recommended to attempt any client-side parsing of + // `db.statement` just to get this property, but it should be set if it is + // provided by the library being instrumented. If the operation is acting upon an + // anonymous table, or more than one table, this value MUST NOT be set. + DBSQLTableKey = attribute.Key("db.sql.table") +) + +// This document defines the attributes used to report a single exception associated with a span. +const ( + // The type of the exception (its fully-qualified class name, if applicable). The + // dynamic type of the exception should be preferred over the static type in + // languages that support it. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'java.net.ConnectException', 'OSError' + ExceptionTypeKey = attribute.Key("exception.type") + // The exception message. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Division by zero', "Can't convert 'int' object to str implicitly" + ExceptionMessageKey = attribute.Key("exception.message") + // A stacktrace as a string in the natural representation for the language + // runtime. The representation is to be determined and documented by each language + // SIG. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Exception in thread "main" java.lang.RuntimeException: Test + // exception\\n at ' + // 'com.example.GenerateTrace.methodB(GenerateTrace.java:13)\\n at ' + // 'com.example.GenerateTrace.methodA(GenerateTrace.java:9)\\n at ' + // 'com.example.GenerateTrace.main(GenerateTrace.java:5)' + ExceptionStacktraceKey = attribute.Key("exception.stacktrace") + // SHOULD be set to true if the exception event is recorded at a point where it is + // known that the exception is escaping the scope of the span. + // + // Type: boolean + // Required: No + // Stability: stable + // Note: An exception is considered to have escaped (or left) the scope of a span, + // if that span is ended while the exception is still logically "in flight". + // This may be actually "in flight" in some languages (e.g. if the exception + // is passed to a Context manager's `__exit__` method in Python) but will + // usually be caught at the point of recording the exception in most languages. + + // It is usually not possible to determine at the point where an exception is + // thrown + // whether it will escape the scope of a span. + // However, it is trivial to know that an exception + // will escape, if one checks for an active exception just before ending the span, + // as done in the [example above](#recording-an-exception). + + // It follows that an exception may still escape the scope of the span + // even if the `exception.escaped` attribute was not set or set to false, + // since the event might have been recorded at a time where it was not + // clear whether the exception will escape. + ExceptionEscapedKey = attribute.Key("exception.escaped") +) + +// This semantic convention describes an instance of a function that runs without provisioning or managing of servers (also known as serverless functions or Function as a Service (FaaS)) with spans. +const ( + // Type of the trigger which caused this function execution. + // + // Type: Enum + // Required: No + // Stability: stable + // Note: For the server/consumer span on the incoming side, + // `faas.trigger` MUST be set. + + // Clients invoking FaaS instances usually cannot set `faas.trigger`, + // since they would typically need to look in the payload to determine + // the event type. If clients set it, it should be the same as the + // trigger that corresponding incoming would have (i.e., this has + // nothing to do with the underlying transport used to make the API + // call to invoke the lambda, which is often HTTP). + FaaSTriggerKey = attribute.Key("faas.trigger") + // The execution ID of the current function execution. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'af9d5aa4-a685-4c5f-a22b-444f80b3cc28' + FaaSExecutionKey = attribute.Key("faas.execution") +) + +var ( + // A response to some data source operation such as a database or filesystem read/write + FaaSTriggerDatasource = FaaSTriggerKey.String("datasource") + // To provide an answer to an inbound HTTP request + FaaSTriggerHTTP = FaaSTriggerKey.String("http") + // A function is set to be executed when messages are sent to a messaging system + FaaSTriggerPubsub = FaaSTriggerKey.String("pubsub") + // A function is scheduled to be executed regularly + FaaSTriggerTimer = FaaSTriggerKey.String("timer") + // If none of the others apply + FaaSTriggerOther = FaaSTriggerKey.String("other") +) + +// Semantic Convention for FaaS triggered as a response to some data source operation such as a database or filesystem read/write. +const ( + // The name of the source on which the triggering operation was performed. For + // example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos + // DB to the database name. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'myBucketName', 'myDBName' + FaaSDocumentCollectionKey = attribute.Key("faas.document.collection") + // Describes the type of the operation that was performed on the data. + // + // Type: Enum + // Required: Always + // Stability: stable + FaaSDocumentOperationKey = attribute.Key("faas.document.operation") + // A string containing the time when the data was accessed in the [ISO + // 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed + // in [UTC](https://www.w3.org/TR/NOTE-datetime). + // + // Type: string + // Required: Always + // Stability: stable + // Examples: '2020-01-23T13:47:06Z' + FaaSDocumentTimeKey = attribute.Key("faas.document.time") + // The document name/table subjected to the operation. For example, in Cloud + // Storage or S3 is the name of the file, and in Cosmos DB the table name. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'myFile.txt', 'myTableName' + FaaSDocumentNameKey = attribute.Key("faas.document.name") +) + +var ( + // When a new object is created + FaaSDocumentOperationInsert = FaaSDocumentOperationKey.String("insert") + // When an object is modified + FaaSDocumentOperationEdit = FaaSDocumentOperationKey.String("edit") + // When an object is deleted + FaaSDocumentOperationDelete = FaaSDocumentOperationKey.String("delete") +) + +// Semantic Convention for FaaS scheduled to be executed regularly. +const ( + // A string containing the function invocation time in the [ISO + // 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed + // in [UTC](https://www.w3.org/TR/NOTE-datetime). + // + // Type: string + // Required: Always + // Stability: stable + // Examples: '2020-01-23T13:47:06Z' + FaaSTimeKey = attribute.Key("faas.time") + // A string containing the schedule period as [Cron Expression](https://docs.oracl + // e.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm). + // + // Type: string + // Required: No + // Stability: stable + // Examples: '0/5 * * * ? *' + FaaSCronKey = attribute.Key("faas.cron") +) + +// Contains additional attributes for incoming FaaS spans. +const ( + // A boolean that is true if the serverless function is executed for the first + // time (aka cold-start). + // + // Type: boolean + // Required: No + // Stability: stable + FaaSColdstartKey = attribute.Key("faas.coldstart") +) + +// Contains additional attributes for outgoing FaaS spans. +const ( + // The name of the invoked function. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'my-function' + // Note: SHOULD be equal to the `faas.name` resource attribute of the invoked + // function. + FaaSInvokedNameKey = attribute.Key("faas.invoked_name") + // The cloud provider of the invoked function. + // + // Type: Enum + // Required: Always + // Stability: stable + // Note: SHOULD be equal to the `cloud.provider` resource attribute of the invoked + // function. + FaaSInvokedProviderKey = attribute.Key("faas.invoked_provider") + // The cloud region of the invoked function. + // + // Type: string + // Required: For some cloud providers, like AWS or GCP, the region in which a + // function is hosted is essential to uniquely identify the function and also part + // of its endpoint. Since it's part of the endpoint being called, the region is + // always known to clients. In these cases, `faas.invoked_region` MUST be set + // accordingly. If the region is unknown to the client or not required for + // identifying the invoked function, setting `faas.invoked_region` is optional. + // Stability: stable + // Examples: 'eu-central-1' + // Note: SHOULD be equal to the `cloud.region` resource attribute of the invoked + // function. + FaaSInvokedRegionKey = attribute.Key("faas.invoked_region") +) + +var ( + // Alibaba Cloud + FaaSInvokedProviderAlibabaCloud = FaaSInvokedProviderKey.String("alibaba_cloud") + // Amazon Web Services + FaaSInvokedProviderAWS = FaaSInvokedProviderKey.String("aws") + // Microsoft Azure + FaaSInvokedProviderAzure = FaaSInvokedProviderKey.String("azure") + // Google Cloud Platform + FaaSInvokedProviderGCP = FaaSInvokedProviderKey.String("gcp") + // Tencent Cloud + FaaSInvokedProviderTencentCloud = FaaSInvokedProviderKey.String("tencent_cloud") +) + +// These attributes may be used for any network related operation. +const ( + // Transport protocol used. See note below. + // + // Type: Enum + // Required: No + // Stability: stable + NetTransportKey = attribute.Key("net.transport") + // Remote address of the peer (dotted decimal for IPv4 or + // [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6) + // + // Type: string + // Required: No + // Stability: stable + // Examples: '127.0.0.1' + NetPeerIPKey = attribute.Key("net.peer.ip") + // Remote port number. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 80, 8080, 443 + NetPeerPortKey = attribute.Key("net.peer.port") + // Remote hostname or similar, see note below. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'example.com' + // Note: `net.peer.name` SHOULD NOT be set if capturing it would require an extra + // DNS lookup. + NetPeerNameKey = attribute.Key("net.peer.name") + // Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '192.168.0.1' + NetHostIPKey = attribute.Key("net.host.ip") + // Like `net.peer.port` but for the host port. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 35555 + NetHostPortKey = attribute.Key("net.host.port") + // Local hostname or similar, see note below. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'localhost' + NetHostNameKey = attribute.Key("net.host.name") + // The internet connection type currently being used by the host. + // + // Type: Enum + // Required: No + // Stability: stable + // Examples: 'wifi' + NetHostConnectionTypeKey = attribute.Key("net.host.connection.type") + // This describes more details regarding the connection.type. It may be the type + // of cell technology connection, but it could be used for describing details + // about a wifi connection. + // + // Type: Enum + // Required: No + // Stability: stable + // Examples: 'LTE' + NetHostConnectionSubtypeKey = attribute.Key("net.host.connection.subtype") + // The name of the mobile carrier. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'sprint' + NetHostCarrierNameKey = attribute.Key("net.host.carrier.name") + // The mobile carrier country code. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '310' + NetHostCarrierMccKey = attribute.Key("net.host.carrier.mcc") + // The mobile carrier network code. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '001' + NetHostCarrierMncKey = attribute.Key("net.host.carrier.mnc") + // The ISO 3166-1 alpha-2 2-character country code associated with the mobile + // carrier network. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'DE' + NetHostCarrierIccKey = attribute.Key("net.host.carrier.icc") +) + +var ( + // ip_tcp + NetTransportTCP = NetTransportKey.String("ip_tcp") + // ip_udp + NetTransportUDP = NetTransportKey.String("ip_udp") + // Another IP-based protocol + NetTransportIP = NetTransportKey.String("ip") + // Unix Domain socket. See below + NetTransportUnix = NetTransportKey.String("unix") + // Named or anonymous pipe. See note below + NetTransportPipe = NetTransportKey.String("pipe") + // In-process communication + NetTransportInProc = NetTransportKey.String("inproc") + // Something else (non IP-based) + NetTransportOther = NetTransportKey.String("other") +) + +var ( + // wifi + NetHostConnectionTypeWifi = NetHostConnectionTypeKey.String("wifi") + // wired + NetHostConnectionTypeWired = NetHostConnectionTypeKey.String("wired") + // cell + NetHostConnectionTypeCell = NetHostConnectionTypeKey.String("cell") + // unavailable + NetHostConnectionTypeUnavailable = NetHostConnectionTypeKey.String("unavailable") + // unknown + NetHostConnectionTypeUnknown = NetHostConnectionTypeKey.String("unknown") +) + +var ( + // GPRS + NetHostConnectionSubtypeGprs = NetHostConnectionSubtypeKey.String("gprs") + // EDGE + NetHostConnectionSubtypeEdge = NetHostConnectionSubtypeKey.String("edge") + // UMTS + NetHostConnectionSubtypeUmts = NetHostConnectionSubtypeKey.String("umts") + // CDMA + NetHostConnectionSubtypeCdma = NetHostConnectionSubtypeKey.String("cdma") + // EVDO Rel. 0 + NetHostConnectionSubtypeEvdo0 = NetHostConnectionSubtypeKey.String("evdo_0") + // EVDO Rev. A + NetHostConnectionSubtypeEvdoA = NetHostConnectionSubtypeKey.String("evdo_a") + // CDMA2000 1XRTT + NetHostConnectionSubtypeCdma20001xrtt = NetHostConnectionSubtypeKey.String("cdma2000_1xrtt") + // HSDPA + NetHostConnectionSubtypeHsdpa = NetHostConnectionSubtypeKey.String("hsdpa") + // HSUPA + NetHostConnectionSubtypeHsupa = NetHostConnectionSubtypeKey.String("hsupa") + // HSPA + NetHostConnectionSubtypeHspa = NetHostConnectionSubtypeKey.String("hspa") + // IDEN + NetHostConnectionSubtypeIden = NetHostConnectionSubtypeKey.String("iden") + // EVDO Rev. B + NetHostConnectionSubtypeEvdoB = NetHostConnectionSubtypeKey.String("evdo_b") + // LTE + NetHostConnectionSubtypeLte = NetHostConnectionSubtypeKey.String("lte") + // EHRPD + NetHostConnectionSubtypeEhrpd = NetHostConnectionSubtypeKey.String("ehrpd") + // HSPAP + NetHostConnectionSubtypeHspap = NetHostConnectionSubtypeKey.String("hspap") + // GSM + NetHostConnectionSubtypeGsm = NetHostConnectionSubtypeKey.String("gsm") + // TD-SCDMA + NetHostConnectionSubtypeTdScdma = NetHostConnectionSubtypeKey.String("td_scdma") + // IWLAN + NetHostConnectionSubtypeIwlan = NetHostConnectionSubtypeKey.String("iwlan") + // 5G NR (New Radio) + NetHostConnectionSubtypeNr = NetHostConnectionSubtypeKey.String("nr") + // 5G NRNSA (New Radio Non-Standalone) + NetHostConnectionSubtypeNrnsa = NetHostConnectionSubtypeKey.String("nrnsa") + // LTE CA + NetHostConnectionSubtypeLteCa = NetHostConnectionSubtypeKey.String("lte_ca") +) + +// Operations that access some remote service. +const ( + // The [`service.name`](../../resource/semantic_conventions/README.md#service) of + // the remote service. SHOULD be equal to the actual `service.name` resource + // attribute of the remote service if any. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'AuthTokenCache' + PeerServiceKey = attribute.Key("peer.service") +) + +// These attributes may be used for any operation with an authenticated and/or authorized enduser. +const ( + // Username or client_id extracted from the access token or + // [Authorization](https://tools.ietf.org/html/rfc7235#section-4.2) header in the + // inbound request from outside the system. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'username' + EnduserIDKey = attribute.Key("enduser.id") + // Actual/assumed role the client is making the request under extracted from token + // or application security context. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'admin' + EnduserRoleKey = attribute.Key("enduser.role") + // Scopes or granted authorities the client currently possesses extracted from + // token or application security context. The value would come from the scope + // associated with an [OAuth 2.0 Access + // Token](https://tools.ietf.org/html/rfc6749#section-3.3) or an attribute value + // in a [SAML 2.0 Assertion](http://docs.oasis- + // open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'read:message, write:files' + EnduserScopeKey = attribute.Key("enduser.scope") +) + +// These attributes may be used for any operation to store information about a thread that started a span. +const ( + // Current "managed" thread ID (as opposed to OS thread ID). + // + // Type: int + // Required: No + // Stability: stable + // Examples: 42 + ThreadIDKey = attribute.Key("thread.id") + // Current thread name. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'main' + ThreadNameKey = attribute.Key("thread.name") +) + +// These attributes allow to report this unit of code and therefore to provide more context about the span. +const ( + // The method or function name, or equivalent (usually rightmost part of the code + // unit's name). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'serveRequest' + CodeFunctionKey = attribute.Key("code.function") + // The "namespace" within which `code.function` is defined. Usually the qualified + // class or module name, such that `code.namespace` + some separator + + // `code.function` form a unique identifier for the code unit. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'com.example.MyHTTPService' + CodeNamespaceKey = attribute.Key("code.namespace") + // The source code file name that identifies the code unit as uniquely as possible + // (preferably an absolute file path). + // + // Type: string + // Required: No + // Stability: stable + // Examples: '/usr/local/MyApplication/content_root/app/index.php' + CodeFilepathKey = attribute.Key("code.filepath") + // The line number in `code.filepath` best representing the operation. It SHOULD + // point within the code unit named in `code.function`. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 42 + CodeLineNumberKey = attribute.Key("code.lineno") +) + +// This document defines semantic conventions for HTTP client and server Spans. +const ( + // HTTP request method. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'GET', 'POST', 'HEAD' + HTTPMethodKey = attribute.Key("http.method") + // Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. + // Usually the fragment is not transmitted over HTTP, but if it is known, it + // should be included nevertheless. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'https://www.foo.bar/search?q=OpenTelemetry#SemConv' + // Note: `http.url` MUST NOT contain credentials passed via URL in form of + // `https://username:password@www.example.com/`. In such case the attribute's + // value should be `https://www.example.com/`. + HTTPURLKey = attribute.Key("http.url") + // The full request target as passed in a HTTP request line or equivalent. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '/path/12314/?q=ddds#123' + HTTPTargetKey = attribute.Key("http.target") + // The value of the [HTTP host + // header](https://tools.ietf.org/html/rfc7230#section-5.4). An empty Host header + // should also be reported, see note. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'www.example.org' + // Note: When the header is present but empty the attribute SHOULD be set to the + // empty string. Note that this is a valid situation that is expected in certain + // cases, according the aforementioned [section of RFC + // 7230](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is not + // set the attribute MUST NOT be set. + HTTPHostKey = attribute.Key("http.host") + // The URI scheme identifying the used protocol. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'http', 'https' + HTTPSchemeKey = attribute.Key("http.scheme") + // [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). + // + // Type: int + // Required: If and only if one was received/sent. + // Stability: stable + // Examples: 200 + HTTPStatusCodeKey = attribute.Key("http.status_code") + // Kind of HTTP protocol used. + // + // Type: Enum + // Required: No + // Stability: stable + // Note: If `net.transport` is not specified, it can be assumed to be `IP.TCP` + // except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. + HTTPFlavorKey = attribute.Key("http.flavor") + // Value of the [HTTP User- + // Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the + // client. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'CERN-LineMode/2.15 libwww/2.17b3' + HTTPUserAgentKey = attribute.Key("http.user_agent") + // The size of the request payload body in bytes. This is the number of bytes + // transferred excluding headers and is often, but not always, present as the + // [Content-Length](https://tools.ietf.org/html/rfc7230#section-3.3.2) header. For + // requests using transport encoding, this should be the compressed size. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 3495 + HTTPRequestContentLengthKey = attribute.Key("http.request_content_length") + // The size of the uncompressed request payload body after transport decoding. Not + // set if transport encoding not used. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 5493 + HTTPRequestContentLengthUncompressedKey = attribute.Key("http.request_content_length_uncompressed") + // The size of the response payload body in bytes. This is the number of bytes + // transferred excluding headers and is often, but not always, present as the + // [Content-Length](https://tools.ietf.org/html/rfc7230#section-3.3.2) header. For + // requests using transport encoding, this should be the compressed size. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 3495 + HTTPResponseContentLengthKey = attribute.Key("http.response_content_length") + // The size of the uncompressed response payload body after transport decoding. + // Not set if transport encoding not used. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 5493 + HTTPResponseContentLengthUncompressedKey = attribute.Key("http.response_content_length_uncompressed") + // The ordinal number of request re-sending attempt. + // + // Type: int + // Required: If and only if a request was retried. + // Stability: stable + // Examples: 3 + HTTPRetryCountKey = attribute.Key("http.retry_count") +) + +var ( + // HTTP/1.0 + HTTPFlavorHTTP10 = HTTPFlavorKey.String("1.0") + // HTTP/1.1 + HTTPFlavorHTTP11 = HTTPFlavorKey.String("1.1") + // HTTP/2 + HTTPFlavorHTTP20 = HTTPFlavorKey.String("2.0") + // HTTP/3 + HTTPFlavorHTTP30 = HTTPFlavorKey.String("3.0") + // SPDY protocol + HTTPFlavorSPDY = HTTPFlavorKey.String("SPDY") + // QUIC protocol + HTTPFlavorQUIC = HTTPFlavorKey.String("QUIC") +) + +// Semantic Convention for HTTP Server +const ( + // The primary server name of the matched virtual host. This should be obtained + // via configuration. If no such configuration can be obtained, this attribute + // MUST NOT be set ( `net.host.name` should be used instead). + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'example.com' + // Note: `http.url` is usually not readily available on the server side but would + // have to be assembled in a cumbersome and sometimes lossy process from other + // information (see e.g. open-telemetry/opentelemetry-python/pull/148). It is thus + // preferred to supply the raw data that is available. + HTTPServerNameKey = attribute.Key("http.server_name") + // The matched route (path template). + // + // Type: string + // Required: No + // Stability: stable + // Examples: '/users/:userID?' + HTTPRouteKey = attribute.Key("http.route") + // The IP address of the original client behind all proxies, if known (e.g. from + // [X-Forwarded-For](https://developer.mozilla.org/en- + // US/docs/Web/HTTP/Headers/X-Forwarded-For)). + // + // Type: string + // Required: No + // Stability: stable + // Examples: '83.164.160.102' + // Note: This is not necessarily the same as `net.peer.ip`, which would + // identify the network-level peer, which may be a proxy. + + // This attribute should be set when a source of information different + // from the one used for `net.peer.ip`, is available even if that other + // source just confirms the same value as `net.peer.ip`. + // Rationale: For `net.peer.ip`, one typically does not know if it + // comes from a proxy, reverse proxy, or the actual client. Setting + // `http.client_ip` when it's the same as `net.peer.ip` means that + // one is at least somewhat confident that the address is not that of + // the closest proxy. + HTTPClientIPKey = attribute.Key("http.client_ip") +) + +// Attributes that exist for multiple DynamoDB request types. +const ( + // The keys in the `RequestItems` object field. + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: 'Users', 'Cats' + AWSDynamoDBTableNamesKey = attribute.Key("aws.dynamodb.table_names") + // The JSON-serialized value of each item in the `ConsumedCapacity` response + // field. + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: '{ "CapacityUnits": number, "GlobalSecondaryIndexes": { "string" : { + // "CapacityUnits": number, "ReadCapacityUnits": number, "WriteCapacityUnits": + // number } }, "LocalSecondaryIndexes": { "string" : { "CapacityUnits": number, + // "ReadCapacityUnits": number, "WriteCapacityUnits": number } }, + // "ReadCapacityUnits": number, "Table": { "CapacityUnits": number, + // "ReadCapacityUnits": number, "WriteCapacityUnits": number }, "TableName": + // "string", "WriteCapacityUnits": number }' + AWSDynamoDBConsumedCapacityKey = attribute.Key("aws.dynamodb.consumed_capacity") + // The JSON-serialized value of the `ItemCollectionMetrics` response field. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '{ "string" : [ { "ItemCollectionKey": { "string" : { "B": blob, + // "BOOL": boolean, "BS": [ blob ], "L": [ "AttributeValue" ], "M": { "string" : + // "AttributeValue" }, "N": "string", "NS": [ "string" ], "NULL": boolean, "S": + // "string", "SS": [ "string" ] } }, "SizeEstimateRangeGB": [ number ] } ] }' + AWSDynamoDBItemCollectionMetricsKey = attribute.Key("aws.dynamodb.item_collection_metrics") + // The value of the `ProvisionedThroughput.ReadCapacityUnits` request parameter. + // + // Type: double + // Required: No + // Stability: stable + // Examples: 1.0, 2.0 + AWSDynamoDBProvisionedReadCapacityKey = attribute.Key("aws.dynamodb.provisioned_read_capacity") + // The value of the `ProvisionedThroughput.WriteCapacityUnits` request parameter. + // + // Type: double + // Required: No + // Stability: stable + // Examples: 1.0, 2.0 + AWSDynamoDBProvisionedWriteCapacityKey = attribute.Key("aws.dynamodb.provisioned_write_capacity") + // The value of the `ConsistentRead` request parameter. + // + // Type: boolean + // Required: No + // Stability: stable + AWSDynamoDBConsistentReadKey = attribute.Key("aws.dynamodb.consistent_read") + // The value of the `ProjectionExpression` request parameter. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Title', 'Title, Price, Color', 'Title, Description, RelatedItems, + // ProductReviews' + AWSDynamoDBProjectionKey = attribute.Key("aws.dynamodb.projection") + // The value of the `Limit` request parameter. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 10 + AWSDynamoDBLimitKey = attribute.Key("aws.dynamodb.limit") + // The value of the `AttributesToGet` request parameter. + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: 'lives', 'id' + AWSDynamoDBAttributesToGetKey = attribute.Key("aws.dynamodb.attributes_to_get") + // The value of the `IndexName` request parameter. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'name_to_group' + AWSDynamoDBIndexNameKey = attribute.Key("aws.dynamodb.index_name") + // The value of the `Select` request parameter. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'ALL_ATTRIBUTES', 'COUNT' + AWSDynamoDBSelectKey = attribute.Key("aws.dynamodb.select") +) + +// DynamoDB.CreateTable +const ( + // The JSON-serialized value of each item of the `GlobalSecondaryIndexes` request + // field + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: '{ "IndexName": "string", "KeySchema": [ { "AttributeName": "string", + // "KeyType": "string" } ], "Projection": { "NonKeyAttributes": [ "string" ], + // "ProjectionType": "string" }, "ProvisionedThroughput": { "ReadCapacityUnits": + // number, "WriteCapacityUnits": number } }' + AWSDynamoDBGlobalSecondaryIndexesKey = attribute.Key("aws.dynamodb.global_secondary_indexes") + // The JSON-serialized value of each item of the `LocalSecondaryIndexes` request + // field. + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: '{ "IndexARN": "string", "IndexName": "string", "IndexSizeBytes": + // number, "ItemCount": number, "KeySchema": [ { "AttributeName": "string", + // "KeyType": "string" } ], "Projection": { "NonKeyAttributes": [ "string" ], + // "ProjectionType": "string" } }' + AWSDynamoDBLocalSecondaryIndexesKey = attribute.Key("aws.dynamodb.local_secondary_indexes") +) + +// DynamoDB.ListTables +const ( + // The value of the `ExclusiveStartTableName` request parameter. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Users', 'CatsTable' + AWSDynamoDBExclusiveStartTableKey = attribute.Key("aws.dynamodb.exclusive_start_table") + // The the number of items in the `TableNames` response parameter. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 20 + AWSDynamoDBTableCountKey = attribute.Key("aws.dynamodb.table_count") +) + +// DynamoDB.Query +const ( + // The value of the `ScanIndexForward` request parameter. + // + // Type: boolean + // Required: No + // Stability: stable + AWSDynamoDBScanForwardKey = attribute.Key("aws.dynamodb.scan_forward") +) + +// DynamoDB.Scan +const ( + // The value of the `Segment` request parameter. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 10 + AWSDynamoDBSegmentKey = attribute.Key("aws.dynamodb.segment") + // The value of the `TotalSegments` request parameter. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 100 + AWSDynamoDBTotalSegmentsKey = attribute.Key("aws.dynamodb.total_segments") + // The value of the `Count` response parameter. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 10 + AWSDynamoDBCountKey = attribute.Key("aws.dynamodb.count") + // The value of the `ScannedCount` response parameter. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 50 + AWSDynamoDBScannedCountKey = attribute.Key("aws.dynamodb.scanned_count") +) + +// DynamoDB.UpdateTable +const ( + // The JSON-serialized value of each item in the `AttributeDefinitions` request + // field. + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: '{ "AttributeName": "string", "AttributeType": "string" }' + AWSDynamoDBAttributeDefinitionsKey = attribute.Key("aws.dynamodb.attribute_definitions") + // The JSON-serialized value of each item in the the `GlobalSecondaryIndexUpdates` + // request field. + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: '{ "Create": { "IndexName": "string", "KeySchema": [ { + // "AttributeName": "string", "KeyType": "string" } ], "Projection": { + // "NonKeyAttributes": [ "string" ], "ProjectionType": "string" }, + // "ProvisionedThroughput": { "ReadCapacityUnits": number, "WriteCapacityUnits": + // number } }' + AWSDynamoDBGlobalSecondaryIndexUpdatesKey = attribute.Key("aws.dynamodb.global_secondary_index_updates") +) + +// This document defines the attributes used in messaging systems. +const ( + // A string identifying the messaging system. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'kafka', 'rabbitmq', 'rocketmq', 'activemq', 'AmazonSQS' + MessagingSystemKey = attribute.Key("messaging.system") + // The message destination name. This might be equal to the span name but is + // required nevertheless. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'MyQueue', 'MyTopic' + MessagingDestinationKey = attribute.Key("messaging.destination") + // The kind of message destination + // + // Type: Enum + // Required: Required only if the message destination is either a `queue` or + // `topic`. + // Stability: stable + MessagingDestinationKindKey = attribute.Key("messaging.destination_kind") + // A boolean that is true if the message destination is temporary. + // + // Type: boolean + // Required: If missing, it is assumed to be false. + // Stability: stable + MessagingTempDestinationKey = attribute.Key("messaging.temp_destination") + // The name of the transport protocol. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'AMQP', 'MQTT' + MessagingProtocolKey = attribute.Key("messaging.protocol") + // The version of the transport protocol. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '0.9.1' + MessagingProtocolVersionKey = attribute.Key("messaging.protocol_version") + // Connection string. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'tibjmsnaming://localhost:7222', + // 'https://queue.amazonaws.com/80398EXAMPLE/MyQueue' + MessagingURLKey = attribute.Key("messaging.url") + // A value used by the messaging system as an identifier for the message, + // represented as a string. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '452a7c7c7c7048c2f887f61572b18fc2' + MessagingMessageIDKey = attribute.Key("messaging.message_id") + // The [conversation ID](#conversations) identifying the conversation to which the + // message belongs, represented as a string. Sometimes called "Correlation ID". + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'MyConversationID' + MessagingConversationIDKey = attribute.Key("messaging.conversation_id") + // The (uncompressed) size of the message payload in bytes. Also use this + // attribute if it is unknown whether the compressed or uncompressed payload size + // is reported. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 2738 + MessagingMessagePayloadSizeBytesKey = attribute.Key("messaging.message_payload_size_bytes") + // The compressed size of the message payload in bytes. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 2048 + MessagingMessagePayloadCompressedSizeBytesKey = attribute.Key("messaging.message_payload_compressed_size_bytes") +) + +var ( + // A message sent to a queue + MessagingDestinationKindQueue = MessagingDestinationKindKey.String("queue") + // A message sent to a topic + MessagingDestinationKindTopic = MessagingDestinationKindKey.String("topic") +) + +// Semantic convention for a consumer of messages received from a messaging system +const ( + // A string identifying the kind of message consumption as defined in the + // [Operation names](#operation-names) section above. If the operation is "send", + // this attribute MUST NOT be set, since the operation can be inferred from the + // span kind in that case. + // + // Type: Enum + // Required: No + // Stability: stable + MessagingOperationKey = attribute.Key("messaging.operation") + // The identifier for the consumer receiving a message. For Kafka, set it to + // `{messaging.kafka.consumer_group} - {messaging.kafka.client_id}`, if both are + // present, or only `messaging.kafka.consumer_group`. For brokers, such as + // RabbitMQ and Artemis, set it to the `client_id` of the client consuming the + // message. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'mygroup - client-6' + MessagingConsumerIDKey = attribute.Key("messaging.consumer_id") +) + +var ( + // receive + MessagingOperationReceive = MessagingOperationKey.String("receive") + // process + MessagingOperationProcess = MessagingOperationKey.String("process") +) + +// Attributes for RabbitMQ +const ( + // RabbitMQ message routing key. + // + // Type: string + // Required: Unless it is empty. + // Stability: stable + // Examples: 'myKey' + MessagingRabbitmqRoutingKeyKey = attribute.Key("messaging.rabbitmq.routing_key") +) + +// Attributes for Apache Kafka +const ( + // Message keys in Kafka are used for grouping alike messages to ensure they're + // processed on the same partition. They differ from `messaging.message_id` in + // that they're not unique. If the key is `null`, the attribute MUST NOT be set. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'myKey' + // Note: If the key type is not string, it's string representation has to be + // supplied for the attribute. If the key has no unambiguous, canonical string + // form, don't include its value. + MessagingKafkaMessageKeyKey = attribute.Key("messaging.kafka.message_key") + // Name of the Kafka Consumer Group that is handling the message. Only applies to + // consumers, not producers. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'my-group' + MessagingKafkaConsumerGroupKey = attribute.Key("messaging.kafka.consumer_group") + // Client ID for the Consumer or Producer that is handling the message. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'client-5' + MessagingKafkaClientIDKey = attribute.Key("messaging.kafka.client_id") + // Partition the message is sent to. + // + // Type: int + // Required: No + // Stability: stable + // Examples: 2 + MessagingKafkaPartitionKey = attribute.Key("messaging.kafka.partition") + // A boolean that is true if the message is a tombstone. + // + // Type: boolean + // Required: If missing, it is assumed to be false. + // Stability: stable + MessagingKafkaTombstoneKey = attribute.Key("messaging.kafka.tombstone") +) + +// Attributes for Apache RocketMQ +const ( + // Namespace of RocketMQ resources, resources in different namespaces are + // individual. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'myNamespace' + MessagingRocketmqNamespaceKey = attribute.Key("messaging.rocketmq.namespace") + // Name of the RocketMQ producer/consumer group that is handling the message. The + // client type is identified by the SpanKind. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'myConsumerGroup' + MessagingRocketmqClientGroupKey = attribute.Key("messaging.rocketmq.client_group") + // The unique identifier for each client. + // + // Type: string + // Required: Always + // Stability: stable + // Examples: 'myhost@8742@s8083jm' + MessagingRocketmqClientIDKey = attribute.Key("messaging.rocketmq.client_id") + // Type of message. + // + // Type: Enum + // Required: No + // Stability: stable + MessagingRocketmqMessageTypeKey = attribute.Key("messaging.rocketmq.message_type") + // The secondary classifier of message besides topic. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'tagA' + MessagingRocketmqMessageTagKey = attribute.Key("messaging.rocketmq.message_tag") + // Key(s) of message, another way to mark message besides message id. + // + // Type: string[] + // Required: No + // Stability: stable + // Examples: 'keyA', 'keyB' + MessagingRocketmqMessageKeysKey = attribute.Key("messaging.rocketmq.message_keys") + // Model of message consumption. This only applies to consumer spans. + // + // Type: Enum + // Required: No + // Stability: stable + MessagingRocketmqConsumptionModelKey = attribute.Key("messaging.rocketmq.consumption_model") +) + +var ( + // Normal message + MessagingRocketmqMessageTypeNormal = MessagingRocketmqMessageTypeKey.String("normal") + // FIFO message + MessagingRocketmqMessageTypeFifo = MessagingRocketmqMessageTypeKey.String("fifo") + // Delay message + MessagingRocketmqMessageTypeDelay = MessagingRocketmqMessageTypeKey.String("delay") + // Transaction message + MessagingRocketmqMessageTypeTransaction = MessagingRocketmqMessageTypeKey.String("transaction") +) + +var ( + // Clustering consumption model + MessagingRocketmqConsumptionModelClustering = MessagingRocketmqConsumptionModelKey.String("clustering") + // Broadcasting consumption model + MessagingRocketmqConsumptionModelBroadcasting = MessagingRocketmqConsumptionModelKey.String("broadcasting") +) + +// This document defines semantic conventions for remote procedure calls. +const ( + // A string identifying the remoting system. See below for a list of well-known + // identifiers. + // + // Type: Enum + // Required: Always + // Stability: stable + RPCSystemKey = attribute.Key("rpc.system") + // The full (logical) name of the service being called, including its package + // name, if applicable. + // + // Type: string + // Required: No, but recommended + // Stability: stable + // Examples: 'myservice.EchoService' + // Note: This is the logical name of the service from the RPC interface + // perspective, which can be different from the name of any implementing class. + // The `code.namespace` attribute may be used to store the latter (despite the + // attribute name, it may include a class name; e.g., class with method actually + // executing the call on the server side, RPC client stub class on the client + // side). + RPCServiceKey = attribute.Key("rpc.service") + // The name of the (logical) method being called, must be equal to the $method + // part in the span name. + // + // Type: string + // Required: No, but recommended + // Stability: stable + // Examples: 'exampleMethod' + // Note: This is the logical name of the method from the RPC interface + // perspective, which can be different from the name of any implementing + // method/function. The `code.function` attribute may be used to store the latter + // (e.g., method actually executing the call on the server side, RPC client stub + // method on the client side). + RPCMethodKey = attribute.Key("rpc.method") +) + +var ( + // gRPC + RPCSystemGRPC = RPCSystemKey.String("grpc") + // Java RMI + RPCSystemJavaRmi = RPCSystemKey.String("java_rmi") + // .NET WCF + RPCSystemDotnetWcf = RPCSystemKey.String("dotnet_wcf") + // Apache Dubbo + RPCSystemApacheDubbo = RPCSystemKey.String("apache_dubbo") +) + +// Tech-specific attributes for gRPC. +const ( + // The [numeric status + // code](https://github.com/grpc/grpc/blob/v1.33.2/doc/statuscodes.md) of the gRPC + // request. + // + // Type: Enum + // Required: Always + // Stability: stable + RPCGRPCStatusCodeKey = attribute.Key("rpc.grpc.status_code") +) + +var ( + // OK + RPCGRPCStatusCodeOk = RPCGRPCStatusCodeKey.Int(0) + // CANCELLED + RPCGRPCStatusCodeCancelled = RPCGRPCStatusCodeKey.Int(1) + // UNKNOWN + RPCGRPCStatusCodeUnknown = RPCGRPCStatusCodeKey.Int(2) + // INVALID_ARGUMENT + RPCGRPCStatusCodeInvalidArgument = RPCGRPCStatusCodeKey.Int(3) + // DEADLINE_EXCEEDED + RPCGRPCStatusCodeDeadlineExceeded = RPCGRPCStatusCodeKey.Int(4) + // NOT_FOUND + RPCGRPCStatusCodeNotFound = RPCGRPCStatusCodeKey.Int(5) + // ALREADY_EXISTS + RPCGRPCStatusCodeAlreadyExists = RPCGRPCStatusCodeKey.Int(6) + // PERMISSION_DENIED + RPCGRPCStatusCodePermissionDenied = RPCGRPCStatusCodeKey.Int(7) + // RESOURCE_EXHAUSTED + RPCGRPCStatusCodeResourceExhausted = RPCGRPCStatusCodeKey.Int(8) + // FAILED_PRECONDITION + RPCGRPCStatusCodeFailedPrecondition = RPCGRPCStatusCodeKey.Int(9) + // ABORTED + RPCGRPCStatusCodeAborted = RPCGRPCStatusCodeKey.Int(10) + // OUT_OF_RANGE + RPCGRPCStatusCodeOutOfRange = RPCGRPCStatusCodeKey.Int(11) + // UNIMPLEMENTED + RPCGRPCStatusCodeUnimplemented = RPCGRPCStatusCodeKey.Int(12) + // INTERNAL + RPCGRPCStatusCodeInternal = RPCGRPCStatusCodeKey.Int(13) + // UNAVAILABLE + RPCGRPCStatusCodeUnavailable = RPCGRPCStatusCodeKey.Int(14) + // DATA_LOSS + RPCGRPCStatusCodeDataLoss = RPCGRPCStatusCodeKey.Int(15) + // UNAUTHENTICATED + RPCGRPCStatusCodeUnauthenticated = RPCGRPCStatusCodeKey.Int(16) +) + +// Tech-specific attributes for [JSON RPC](https://www.jsonrpc.org/). +const ( + // Protocol version as in `jsonrpc` property of request/response. Since JSON-RPC + // 1.0 does not specify this, the value can be omitted. + // + // Type: string + // Required: If missing, it is assumed to be "1.0". + // Stability: stable + // Examples: '2.0', '1.0' + RPCJsonrpcVersionKey = attribute.Key("rpc.jsonrpc.version") + // `id` property of request or response. Since protocol allows id to be int, + // string, `null` or missing (for notifications), value is expected to be cast to + // string for simplicity. Use empty string in case of `null` value. Omit entirely + // if this is a notification. + // + // Type: string + // Required: No + // Stability: stable + // Examples: '10', 'request-7', '' + RPCJsonrpcRequestIDKey = attribute.Key("rpc.jsonrpc.request_id") + // `error.code` property of response if it is an error response. + // + // Type: int + // Required: If missing, response is assumed to be successful. + // Stability: stable + // Examples: -32700, 100 + RPCJsonrpcErrorCodeKey = attribute.Key("rpc.jsonrpc.error_code") + // `error.message` property of response if it is an error response. + // + // Type: string + // Required: No + // Stability: stable + // Examples: 'Parse error', 'User already exists' + RPCJsonrpcErrorMessageKey = attribute.Key("rpc.jsonrpc.error_message") +) + +// RPC received/sent message. +const ( + // Whether this is a received or sent message. + // + // Type: Enum + // Required: No + // Stability: stable + MessageTypeKey = attribute.Key("message.type") + // MUST be calculated as two different counters starting from `1` one for sent + // messages and one for received message. + // + // Type: int + // Required: No + // Stability: stable + // Note: This way we guarantee that the values will be consistent between + // different implementations. + MessageIDKey = attribute.Key("message.id") + // Compressed size of the message in bytes. + // + // Type: int + // Required: No + // Stability: stable + MessageCompressedSizeKey = attribute.Key("message.compressed_size") + // Uncompressed size of the message in bytes. + // + // Type: int + // Required: No + // Stability: stable + MessageUncompressedSizeKey = attribute.Key("message.uncompressed_size") +) + +var ( + // sent + MessageTypeSent = MessageTypeKey.String("SENT") + // received + MessageTypeReceived = MessageTypeKey.String("RECEIVED") +) diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/attribute_group.go b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/attribute_group.go new file mode 100644 index 000000000..67d1d4c44 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/attribute_group.go @@ -0,0 +1,1209 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated from semantic convention specification. DO NOT EDIT. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.20.0" + +import "go.opentelemetry.io/otel/attribute" + +// Describes HTTP attributes. +const ( + // HTTPMethodKey is the attribute Key conforming to the "http.method" + // semantic conventions. It represents the hTTP request method. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'GET', 'POST', 'HEAD' + HTTPMethodKey = attribute.Key("http.method") + + // HTTPStatusCodeKey is the attribute Key conforming to the + // "http.status_code" semantic conventions. It represents the [HTTP + // response status code](https://tools.ietf.org/html/rfc7231#section-6). + // + // Type: int + // RequirementLevel: ConditionallyRequired (If and only if one was + // received/sent.) + // Stability: stable + // Examples: 200 + HTTPStatusCodeKey = attribute.Key("http.status_code") +) + +// HTTPMethod returns an attribute KeyValue conforming to the "http.method" +// semantic conventions. It represents the hTTP request method. +func HTTPMethod(val string) attribute.KeyValue { + return HTTPMethodKey.String(val) +} + +// HTTPStatusCode returns an attribute KeyValue conforming to the +// "http.status_code" semantic conventions. It represents the [HTTP response +// status code](https://tools.ietf.org/html/rfc7231#section-6). +func HTTPStatusCode(val int) attribute.KeyValue { + return HTTPStatusCodeKey.Int(val) +} + +// HTTP Server spans attributes +const ( + // HTTPSchemeKey is the attribute Key conforming to the "http.scheme" + // semantic conventions. It represents the URI scheme identifying the used + // protocol. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'http', 'https' + HTTPSchemeKey = attribute.Key("http.scheme") + + // HTTPRouteKey is the attribute Key conforming to the "http.route" + // semantic conventions. It represents the matched route (path template in + // the format used by the respective server framework). See note below + // + // Type: string + // RequirementLevel: ConditionallyRequired (If and only if it's available) + // Stability: stable + // Examples: '/users/:userID?', '{controller}/{action}/{id?}' + // Note: MUST NOT be populated when this is not supported by the HTTP + // server framework as the route attribute should have low-cardinality and + // the URI path can NOT substitute it. + // SHOULD include the [application + // root](/specification/trace/semantic_conventions/http.md#http-server-definitions) + // if there is one. + HTTPRouteKey = attribute.Key("http.route") +) + +// HTTPScheme returns an attribute KeyValue conforming to the "http.scheme" +// semantic conventions. It represents the URI scheme identifying the used +// protocol. +func HTTPScheme(val string) attribute.KeyValue { + return HTTPSchemeKey.String(val) +} + +// HTTPRoute returns an attribute KeyValue conforming to the "http.route" +// semantic conventions. It represents the matched route (path template in the +// format used by the respective server framework). See note below +func HTTPRoute(val string) attribute.KeyValue { + return HTTPRouteKey.String(val) +} + +// Attributes for Events represented using Log Records. +const ( + // EventNameKey is the attribute Key conforming to the "event.name" + // semantic conventions. It represents the name identifies the event. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'click', 'exception' + EventNameKey = attribute.Key("event.name") + + // EventDomainKey is the attribute Key conforming to the "event.domain" + // semantic conventions. It represents the domain identifies the business + // context for the events. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + // Note: Events across different domains may have same `event.name`, yet be + // unrelated events. + EventDomainKey = attribute.Key("event.domain") +) + +var ( + // Events from browser apps + EventDomainBrowser = EventDomainKey.String("browser") + // Events from mobile apps + EventDomainDevice = EventDomainKey.String("device") + // Events from Kubernetes + EventDomainK8S = EventDomainKey.String("k8s") +) + +// EventName returns an attribute KeyValue conforming to the "event.name" +// semantic conventions. It represents the name identifies the event. +func EventName(val string) attribute.KeyValue { + return EventNameKey.String(val) +} + +// These attributes may be used for any network related operation. +const ( + // NetTransportKey is the attribute Key conforming to the "net.transport" + // semantic conventions. It represents the transport protocol used. See + // note below. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + NetTransportKey = attribute.Key("net.transport") + + // NetProtocolNameKey is the attribute Key conforming to the + // "net.protocol.name" semantic conventions. It represents the application + // layer protocol used. The value SHOULD be normalized to lowercase. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'amqp', 'http', 'mqtt' + NetProtocolNameKey = attribute.Key("net.protocol.name") + + // NetProtocolVersionKey is the attribute Key conforming to the + // "net.protocol.version" semantic conventions. It represents the version + // of the application layer protocol used. See note below. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '3.1.1' + // Note: `net.protocol.version` refers to the version of the protocol used + // and might be different from the protocol client's version. If the HTTP + // client used has a version of `0.27.2`, but sends HTTP version `1.1`, + // this attribute should be set to `1.1`. + NetProtocolVersionKey = attribute.Key("net.protocol.version") + + // NetSockPeerNameKey is the attribute Key conforming to the + // "net.sock.peer.name" semantic conventions. It represents the remote + // socket peer name. + // + // Type: string + // RequirementLevel: Recommended (If available and different from + // `net.peer.name` and if `net.sock.peer.addr` is set.) + // Stability: stable + // Examples: 'proxy.example.com' + NetSockPeerNameKey = attribute.Key("net.sock.peer.name") + + // NetSockPeerAddrKey is the attribute Key conforming to the + // "net.sock.peer.addr" semantic conventions. It represents the remote + // socket peer address: IPv4 or IPv6 for internet protocols, path for local + // communication, + // [etc](https://man7.org/linux/man-pages/man7/address_families.7.html). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '127.0.0.1', '/tmp/mysql.sock' + NetSockPeerAddrKey = attribute.Key("net.sock.peer.addr") + + // NetSockPeerPortKey is the attribute Key conforming to the + // "net.sock.peer.port" semantic conventions. It represents the remote + // socket peer port. + // + // Type: int + // RequirementLevel: Recommended (If defined for the address family and if + // different than `net.peer.port` and if `net.sock.peer.addr` is set.) + // Stability: stable + // Examples: 16456 + NetSockPeerPortKey = attribute.Key("net.sock.peer.port") + + // NetSockFamilyKey is the attribute Key conforming to the + // "net.sock.family" semantic conventions. It represents the protocol + // [address + // family](https://man7.org/linux/man-pages/man7/address_families.7.html) + // which is used for communication. + // + // Type: Enum + // RequirementLevel: ConditionallyRequired (If different than `inet` and if + // any of `net.sock.peer.addr` or `net.sock.host.addr` are set. Consumers + // of telemetry SHOULD accept both IPv4 and IPv6 formats for the address in + // `net.sock.peer.addr` if `net.sock.family` is not set. This is to support + // instrumentations that follow previous versions of this document.) + // Stability: stable + // Examples: 'inet6', 'bluetooth' + NetSockFamilyKey = attribute.Key("net.sock.family") + + // NetPeerNameKey is the attribute Key conforming to the "net.peer.name" + // semantic conventions. It represents the logical remote hostname, see + // note below. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'example.com' + // Note: `net.peer.name` SHOULD NOT be set if capturing it would require an + // extra DNS lookup. + NetPeerNameKey = attribute.Key("net.peer.name") + + // NetPeerPortKey is the attribute Key conforming to the "net.peer.port" + // semantic conventions. It represents the logical remote port number + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 80, 8080, 443 + NetPeerPortKey = attribute.Key("net.peer.port") + + // NetHostNameKey is the attribute Key conforming to the "net.host.name" + // semantic conventions. It represents the logical local hostname or + // similar, see note below. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'localhost' + NetHostNameKey = attribute.Key("net.host.name") + + // NetHostPortKey is the attribute Key conforming to the "net.host.port" + // semantic conventions. It represents the logical local port number, + // preferably the one that the peer used to connect + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 8080 + NetHostPortKey = attribute.Key("net.host.port") + + // NetSockHostAddrKey is the attribute Key conforming to the + // "net.sock.host.addr" semantic conventions. It represents the local + // socket address. Useful in case of a multi-IP host. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '192.168.0.1' + NetSockHostAddrKey = attribute.Key("net.sock.host.addr") + + // NetSockHostPortKey is the attribute Key conforming to the + // "net.sock.host.port" semantic conventions. It represents the local + // socket port number. + // + // Type: int + // RequirementLevel: ConditionallyRequired (If defined for the address + // family and if different than `net.host.port` and if `net.sock.host.addr` + // is set. In other cases, it is still recommended to set this.) + // Stability: stable + // Examples: 35555 + NetSockHostPortKey = attribute.Key("net.sock.host.port") +) + +var ( + // ip_tcp + NetTransportTCP = NetTransportKey.String("ip_tcp") + // ip_udp + NetTransportUDP = NetTransportKey.String("ip_udp") + // Named or anonymous pipe. See note below + NetTransportPipe = NetTransportKey.String("pipe") + // In-process communication + NetTransportInProc = NetTransportKey.String("inproc") + // Something else (non IP-based) + NetTransportOther = NetTransportKey.String("other") +) + +var ( + // IPv4 address + NetSockFamilyInet = NetSockFamilyKey.String("inet") + // IPv6 address + NetSockFamilyInet6 = NetSockFamilyKey.String("inet6") + // Unix domain socket path + NetSockFamilyUnix = NetSockFamilyKey.String("unix") +) + +// NetProtocolName returns an attribute KeyValue conforming to the +// "net.protocol.name" semantic conventions. It represents the application +// layer protocol used. The value SHOULD be normalized to lowercase. +func NetProtocolName(val string) attribute.KeyValue { + return NetProtocolNameKey.String(val) +} + +// NetProtocolVersion returns an attribute KeyValue conforming to the +// "net.protocol.version" semantic conventions. It represents the version of +// the application layer protocol used. See note below. +func NetProtocolVersion(val string) attribute.KeyValue { + return NetProtocolVersionKey.String(val) +} + +// NetSockPeerName returns an attribute KeyValue conforming to the +// "net.sock.peer.name" semantic conventions. It represents the remote socket +// peer name. +func NetSockPeerName(val string) attribute.KeyValue { + return NetSockPeerNameKey.String(val) +} + +// NetSockPeerAddr returns an attribute KeyValue conforming to the +// "net.sock.peer.addr" semantic conventions. It represents the remote socket +// peer address: IPv4 or IPv6 for internet protocols, path for local +// communication, +// [etc](https://man7.org/linux/man-pages/man7/address_families.7.html). +func NetSockPeerAddr(val string) attribute.KeyValue { + return NetSockPeerAddrKey.String(val) +} + +// NetSockPeerPort returns an attribute KeyValue conforming to the +// "net.sock.peer.port" semantic conventions. It represents the remote socket +// peer port. +func NetSockPeerPort(val int) attribute.KeyValue { + return NetSockPeerPortKey.Int(val) +} + +// NetPeerName returns an attribute KeyValue conforming to the +// "net.peer.name" semantic conventions. It represents the logical remote +// hostname, see note below. +func NetPeerName(val string) attribute.KeyValue { + return NetPeerNameKey.String(val) +} + +// NetPeerPort returns an attribute KeyValue conforming to the +// "net.peer.port" semantic conventions. It represents the logical remote port +// number +func NetPeerPort(val int) attribute.KeyValue { + return NetPeerPortKey.Int(val) +} + +// NetHostName returns an attribute KeyValue conforming to the +// "net.host.name" semantic conventions. It represents the logical local +// hostname or similar, see note below. +func NetHostName(val string) attribute.KeyValue { + return NetHostNameKey.String(val) +} + +// NetHostPort returns an attribute KeyValue conforming to the +// "net.host.port" semantic conventions. It represents the logical local port +// number, preferably the one that the peer used to connect +func NetHostPort(val int) attribute.KeyValue { + return NetHostPortKey.Int(val) +} + +// NetSockHostAddr returns an attribute KeyValue conforming to the +// "net.sock.host.addr" semantic conventions. It represents the local socket +// address. Useful in case of a multi-IP host. +func NetSockHostAddr(val string) attribute.KeyValue { + return NetSockHostAddrKey.String(val) +} + +// NetSockHostPort returns an attribute KeyValue conforming to the +// "net.sock.host.port" semantic conventions. It represents the local socket +// port number. +func NetSockHostPort(val int) attribute.KeyValue { + return NetSockHostPortKey.Int(val) +} + +// These attributes may be used for any network related operation. +const ( + // NetHostConnectionTypeKey is the attribute Key conforming to the + // "net.host.connection.type" semantic conventions. It represents the + // internet connection type currently being used by the host. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + // Examples: 'wifi' + NetHostConnectionTypeKey = attribute.Key("net.host.connection.type") + + // NetHostConnectionSubtypeKey is the attribute Key conforming to the + // "net.host.connection.subtype" semantic conventions. It represents the + // this describes more details regarding the connection.type. It may be the + // type of cell technology connection, but it could be used for describing + // details about a wifi connection. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + // Examples: 'LTE' + NetHostConnectionSubtypeKey = attribute.Key("net.host.connection.subtype") + + // NetHostCarrierNameKey is the attribute Key conforming to the + // "net.host.carrier.name" semantic conventions. It represents the name of + // the mobile carrier. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'sprint' + NetHostCarrierNameKey = attribute.Key("net.host.carrier.name") + + // NetHostCarrierMccKey is the attribute Key conforming to the + // "net.host.carrier.mcc" semantic conventions. It represents the mobile + // carrier country code. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '310' + NetHostCarrierMccKey = attribute.Key("net.host.carrier.mcc") + + // NetHostCarrierMncKey is the attribute Key conforming to the + // "net.host.carrier.mnc" semantic conventions. It represents the mobile + // carrier network code. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '001' + NetHostCarrierMncKey = attribute.Key("net.host.carrier.mnc") + + // NetHostCarrierIccKey is the attribute Key conforming to the + // "net.host.carrier.icc" semantic conventions. It represents the ISO + // 3166-1 alpha-2 2-character country code associated with the mobile + // carrier network. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'DE' + NetHostCarrierIccKey = attribute.Key("net.host.carrier.icc") +) + +var ( + // wifi + NetHostConnectionTypeWifi = NetHostConnectionTypeKey.String("wifi") + // wired + NetHostConnectionTypeWired = NetHostConnectionTypeKey.String("wired") + // cell + NetHostConnectionTypeCell = NetHostConnectionTypeKey.String("cell") + // unavailable + NetHostConnectionTypeUnavailable = NetHostConnectionTypeKey.String("unavailable") + // unknown + NetHostConnectionTypeUnknown = NetHostConnectionTypeKey.String("unknown") +) + +var ( + // GPRS + NetHostConnectionSubtypeGprs = NetHostConnectionSubtypeKey.String("gprs") + // EDGE + NetHostConnectionSubtypeEdge = NetHostConnectionSubtypeKey.String("edge") + // UMTS + NetHostConnectionSubtypeUmts = NetHostConnectionSubtypeKey.String("umts") + // CDMA + NetHostConnectionSubtypeCdma = NetHostConnectionSubtypeKey.String("cdma") + // EVDO Rel. 0 + NetHostConnectionSubtypeEvdo0 = NetHostConnectionSubtypeKey.String("evdo_0") + // EVDO Rev. A + NetHostConnectionSubtypeEvdoA = NetHostConnectionSubtypeKey.String("evdo_a") + // CDMA2000 1XRTT + NetHostConnectionSubtypeCdma20001xrtt = NetHostConnectionSubtypeKey.String("cdma2000_1xrtt") + // HSDPA + NetHostConnectionSubtypeHsdpa = NetHostConnectionSubtypeKey.String("hsdpa") + // HSUPA + NetHostConnectionSubtypeHsupa = NetHostConnectionSubtypeKey.String("hsupa") + // HSPA + NetHostConnectionSubtypeHspa = NetHostConnectionSubtypeKey.String("hspa") + // IDEN + NetHostConnectionSubtypeIden = NetHostConnectionSubtypeKey.String("iden") + // EVDO Rev. B + NetHostConnectionSubtypeEvdoB = NetHostConnectionSubtypeKey.String("evdo_b") + // LTE + NetHostConnectionSubtypeLte = NetHostConnectionSubtypeKey.String("lte") + // EHRPD + NetHostConnectionSubtypeEhrpd = NetHostConnectionSubtypeKey.String("ehrpd") + // HSPAP + NetHostConnectionSubtypeHspap = NetHostConnectionSubtypeKey.String("hspap") + // GSM + NetHostConnectionSubtypeGsm = NetHostConnectionSubtypeKey.String("gsm") + // TD-SCDMA + NetHostConnectionSubtypeTdScdma = NetHostConnectionSubtypeKey.String("td_scdma") + // IWLAN + NetHostConnectionSubtypeIwlan = NetHostConnectionSubtypeKey.String("iwlan") + // 5G NR (New Radio) + NetHostConnectionSubtypeNr = NetHostConnectionSubtypeKey.String("nr") + // 5G NRNSA (New Radio Non-Standalone) + NetHostConnectionSubtypeNrnsa = NetHostConnectionSubtypeKey.String("nrnsa") + // LTE CA + NetHostConnectionSubtypeLteCa = NetHostConnectionSubtypeKey.String("lte_ca") +) + +// NetHostCarrierName returns an attribute KeyValue conforming to the +// "net.host.carrier.name" semantic conventions. It represents the name of the +// mobile carrier. +func NetHostCarrierName(val string) attribute.KeyValue { + return NetHostCarrierNameKey.String(val) +} + +// NetHostCarrierMcc returns an attribute KeyValue conforming to the +// "net.host.carrier.mcc" semantic conventions. It represents the mobile +// carrier country code. +func NetHostCarrierMcc(val string) attribute.KeyValue { + return NetHostCarrierMccKey.String(val) +} + +// NetHostCarrierMnc returns an attribute KeyValue conforming to the +// "net.host.carrier.mnc" semantic conventions. It represents the mobile +// carrier network code. +func NetHostCarrierMnc(val string) attribute.KeyValue { + return NetHostCarrierMncKey.String(val) +} + +// NetHostCarrierIcc returns an attribute KeyValue conforming to the +// "net.host.carrier.icc" semantic conventions. It represents the ISO 3166-1 +// alpha-2 2-character country code associated with the mobile carrier network. +func NetHostCarrierIcc(val string) attribute.KeyValue { + return NetHostCarrierIccKey.String(val) +} + +// Semantic conventions for HTTP client and server Spans. +const ( + // HTTPRequestContentLengthKey is the attribute Key conforming to the + // "http.request_content_length" semantic conventions. It represents the + // size of the request payload body in bytes. This is the number of bytes + // transferred excluding headers and is often, but not always, present as + // the + // [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) + // header. For requests using transport encoding, this should be the + // compressed size. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 3495 + HTTPRequestContentLengthKey = attribute.Key("http.request_content_length") + + // HTTPResponseContentLengthKey is the attribute Key conforming to the + // "http.response_content_length" semantic conventions. It represents the + // size of the response payload body in bytes. This is the number of bytes + // transferred excluding headers and is often, but not always, present as + // the + // [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) + // header. For requests using transport encoding, this should be the + // compressed size. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 3495 + HTTPResponseContentLengthKey = attribute.Key("http.response_content_length") +) + +// HTTPRequestContentLength returns an attribute KeyValue conforming to the +// "http.request_content_length" semantic conventions. It represents the size +// of the request payload body in bytes. This is the number of bytes +// transferred excluding headers and is often, but not always, present as the +// [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) +// header. For requests using transport encoding, this should be the compressed +// size. +func HTTPRequestContentLength(val int) attribute.KeyValue { + return HTTPRequestContentLengthKey.Int(val) +} + +// HTTPResponseContentLength returns an attribute KeyValue conforming to the +// "http.response_content_length" semantic conventions. It represents the size +// of the response payload body in bytes. This is the number of bytes +// transferred excluding headers and is often, but not always, present as the +// [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) +// header. For requests using transport encoding, this should be the compressed +// size. +func HTTPResponseContentLength(val int) attribute.KeyValue { + return HTTPResponseContentLengthKey.Int(val) +} + +// Semantic convention describing per-message attributes populated on messaging +// spans or links. +const ( + // MessagingMessageIDKey is the attribute Key conforming to the + // "messaging.message.id" semantic conventions. It represents a value used + // by the messaging system as an identifier for the message, represented as + // a string. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '452a7c7c7c7048c2f887f61572b18fc2' + MessagingMessageIDKey = attribute.Key("messaging.message.id") + + // MessagingMessageConversationIDKey is the attribute Key conforming to the + // "messaging.message.conversation_id" semantic conventions. It represents + // the [conversation ID](#conversations) identifying the conversation to + // which the message belongs, represented as a string. Sometimes called + // "Correlation ID". + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'MyConversationID' + MessagingMessageConversationIDKey = attribute.Key("messaging.message.conversation_id") + + // MessagingMessagePayloadSizeBytesKey is the attribute Key conforming to + // the "messaging.message.payload_size_bytes" semantic conventions. It + // represents the (uncompressed) size of the message payload in bytes. Also + // use this attribute if it is unknown whether the compressed or + // uncompressed payload size is reported. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 2738 + MessagingMessagePayloadSizeBytesKey = attribute.Key("messaging.message.payload_size_bytes") + + // MessagingMessagePayloadCompressedSizeBytesKey is the attribute Key + // conforming to the "messaging.message.payload_compressed_size_bytes" + // semantic conventions. It represents the compressed size of the message + // payload in bytes. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 2048 + MessagingMessagePayloadCompressedSizeBytesKey = attribute.Key("messaging.message.payload_compressed_size_bytes") +) + +// MessagingMessageID returns an attribute KeyValue conforming to the +// "messaging.message.id" semantic conventions. It represents a value used by +// the messaging system as an identifier for the message, represented as a +// string. +func MessagingMessageID(val string) attribute.KeyValue { + return MessagingMessageIDKey.String(val) +} + +// MessagingMessageConversationID returns an attribute KeyValue conforming +// to the "messaging.message.conversation_id" semantic conventions. It +// represents the [conversation ID](#conversations) identifying the +// conversation to which the message belongs, represented as a string. +// Sometimes called "Correlation ID". +func MessagingMessageConversationID(val string) attribute.KeyValue { + return MessagingMessageConversationIDKey.String(val) +} + +// MessagingMessagePayloadSizeBytes returns an attribute KeyValue conforming +// to the "messaging.message.payload_size_bytes" semantic conventions. It +// represents the (uncompressed) size of the message payload in bytes. Also use +// this attribute if it is unknown whether the compressed or uncompressed +// payload size is reported. +func MessagingMessagePayloadSizeBytes(val int) attribute.KeyValue { + return MessagingMessagePayloadSizeBytesKey.Int(val) +} + +// MessagingMessagePayloadCompressedSizeBytes returns an attribute KeyValue +// conforming to the "messaging.message.payload_compressed_size_bytes" semantic +// conventions. It represents the compressed size of the message payload in +// bytes. +func MessagingMessagePayloadCompressedSizeBytes(val int) attribute.KeyValue { + return MessagingMessagePayloadCompressedSizeBytesKey.Int(val) +} + +// Semantic convention for attributes that describe messaging destination on +// broker +const ( + // MessagingDestinationNameKey is the attribute Key conforming to the + // "messaging.destination.name" semantic conventions. It represents the + // message destination name + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'MyQueue', 'MyTopic' + // Note: Destination name SHOULD uniquely identify a specific queue, topic + // or other entity within the broker. If + // the broker does not have such notion, the destination name SHOULD + // uniquely identify the broker. + MessagingDestinationNameKey = attribute.Key("messaging.destination.name") + + // MessagingDestinationTemplateKey is the attribute Key conforming to the + // "messaging.destination.template" semantic conventions. It represents the + // low cardinality representation of the messaging destination name + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '/customers/{customerID}' + // Note: Destination names could be constructed from templates. An example + // would be a destination name involving a user name or product id. + // Although the destination name in this case is of high cardinality, the + // underlying template is of low cardinality and can be effectively used + // for grouping and aggregation. + MessagingDestinationTemplateKey = attribute.Key("messaging.destination.template") + + // MessagingDestinationTemporaryKey is the attribute Key conforming to the + // "messaging.destination.temporary" semantic conventions. It represents a + // boolean that is true if the message destination is temporary and might + // not exist anymore after messages are processed. + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + MessagingDestinationTemporaryKey = attribute.Key("messaging.destination.temporary") + + // MessagingDestinationAnonymousKey is the attribute Key conforming to the + // "messaging.destination.anonymous" semantic conventions. It represents a + // boolean that is true if the message destination is anonymous (could be + // unnamed or have auto-generated name). + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + MessagingDestinationAnonymousKey = attribute.Key("messaging.destination.anonymous") +) + +// MessagingDestinationName returns an attribute KeyValue conforming to the +// "messaging.destination.name" semantic conventions. It represents the message +// destination name +func MessagingDestinationName(val string) attribute.KeyValue { + return MessagingDestinationNameKey.String(val) +} + +// MessagingDestinationTemplate returns an attribute KeyValue conforming to +// the "messaging.destination.template" semantic conventions. It represents the +// low cardinality representation of the messaging destination name +func MessagingDestinationTemplate(val string) attribute.KeyValue { + return MessagingDestinationTemplateKey.String(val) +} + +// MessagingDestinationTemporary returns an attribute KeyValue conforming to +// the "messaging.destination.temporary" semantic conventions. It represents a +// boolean that is true if the message destination is temporary and might not +// exist anymore after messages are processed. +func MessagingDestinationTemporary(val bool) attribute.KeyValue { + return MessagingDestinationTemporaryKey.Bool(val) +} + +// MessagingDestinationAnonymous returns an attribute KeyValue conforming to +// the "messaging.destination.anonymous" semantic conventions. It represents a +// boolean that is true if the message destination is anonymous (could be +// unnamed or have auto-generated name). +func MessagingDestinationAnonymous(val bool) attribute.KeyValue { + return MessagingDestinationAnonymousKey.Bool(val) +} + +// Semantic convention for attributes that describe messaging source on broker +const ( + // MessagingSourceNameKey is the attribute Key conforming to the + // "messaging.source.name" semantic conventions. It represents the message + // source name + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'MyQueue', 'MyTopic' + // Note: Source name SHOULD uniquely identify a specific queue, topic, or + // other entity within the broker. If + // the broker does not have such notion, the source name SHOULD uniquely + // identify the broker. + MessagingSourceNameKey = attribute.Key("messaging.source.name") + + // MessagingSourceTemplateKey is the attribute Key conforming to the + // "messaging.source.template" semantic conventions. It represents the low + // cardinality representation of the messaging source name + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '/customers/{customerID}' + // Note: Source names could be constructed from templates. An example would + // be a source name involving a user name or product id. Although the + // source name in this case is of high cardinality, the underlying template + // is of low cardinality and can be effectively used for grouping and + // aggregation. + MessagingSourceTemplateKey = attribute.Key("messaging.source.template") + + // MessagingSourceTemporaryKey is the attribute Key conforming to the + // "messaging.source.temporary" semantic conventions. It represents a + // boolean that is true if the message source is temporary and might not + // exist anymore after messages are processed. + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + MessagingSourceTemporaryKey = attribute.Key("messaging.source.temporary") + + // MessagingSourceAnonymousKey is the attribute Key conforming to the + // "messaging.source.anonymous" semantic conventions. It represents a + // boolean that is true if the message source is anonymous (could be + // unnamed or have auto-generated name). + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + MessagingSourceAnonymousKey = attribute.Key("messaging.source.anonymous") +) + +// MessagingSourceName returns an attribute KeyValue conforming to the +// "messaging.source.name" semantic conventions. It represents the message +// source name +func MessagingSourceName(val string) attribute.KeyValue { + return MessagingSourceNameKey.String(val) +} + +// MessagingSourceTemplate returns an attribute KeyValue conforming to the +// "messaging.source.template" semantic conventions. It represents the low +// cardinality representation of the messaging source name +func MessagingSourceTemplate(val string) attribute.KeyValue { + return MessagingSourceTemplateKey.String(val) +} + +// MessagingSourceTemporary returns an attribute KeyValue conforming to the +// "messaging.source.temporary" semantic conventions. It represents a boolean +// that is true if the message source is temporary and might not exist anymore +// after messages are processed. +func MessagingSourceTemporary(val bool) attribute.KeyValue { + return MessagingSourceTemporaryKey.Bool(val) +} + +// MessagingSourceAnonymous returns an attribute KeyValue conforming to the +// "messaging.source.anonymous" semantic conventions. It represents a boolean +// that is true if the message source is anonymous (could be unnamed or have +// auto-generated name). +func MessagingSourceAnonymous(val bool) attribute.KeyValue { + return MessagingSourceAnonymousKey.Bool(val) +} + +// Attributes for RabbitMQ +const ( + // MessagingRabbitmqDestinationRoutingKeyKey is the attribute Key + // conforming to the "messaging.rabbitmq.destination.routing_key" semantic + // conventions. It represents the rabbitMQ message routing key. + // + // Type: string + // RequirementLevel: ConditionallyRequired (If not empty.) + // Stability: stable + // Examples: 'myKey' + MessagingRabbitmqDestinationRoutingKeyKey = attribute.Key("messaging.rabbitmq.destination.routing_key") +) + +// MessagingRabbitmqDestinationRoutingKey returns an attribute KeyValue +// conforming to the "messaging.rabbitmq.destination.routing_key" semantic +// conventions. It represents the rabbitMQ message routing key. +func MessagingRabbitmqDestinationRoutingKey(val string) attribute.KeyValue { + return MessagingRabbitmqDestinationRoutingKeyKey.String(val) +} + +// Attributes for Apache Kafka +const ( + // MessagingKafkaMessageKeyKey is the attribute Key conforming to the + // "messaging.kafka.message.key" semantic conventions. It represents the + // message keys in Kafka are used for grouping alike messages to ensure + // they're processed on the same partition. They differ from + // `messaging.message.id` in that they're not unique. If the key is `null`, + // the attribute MUST NOT be set. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'myKey' + // Note: If the key type is not string, it's string representation has to + // be supplied for the attribute. If the key has no unambiguous, canonical + // string form, don't include its value. + MessagingKafkaMessageKeyKey = attribute.Key("messaging.kafka.message.key") + + // MessagingKafkaConsumerGroupKey is the attribute Key conforming to the + // "messaging.kafka.consumer.group" semantic conventions. It represents the + // name of the Kafka Consumer Group that is handling the message. Only + // applies to consumers, not producers. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'my-group' + MessagingKafkaConsumerGroupKey = attribute.Key("messaging.kafka.consumer.group") + + // MessagingKafkaClientIDKey is the attribute Key conforming to the + // "messaging.kafka.client_id" semantic conventions. It represents the + // client ID for the Consumer or Producer that is handling the message. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'client-5' + MessagingKafkaClientIDKey = attribute.Key("messaging.kafka.client_id") + + // MessagingKafkaDestinationPartitionKey is the attribute Key conforming to + // the "messaging.kafka.destination.partition" semantic conventions. It + // represents the partition the message is sent to. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 2 + MessagingKafkaDestinationPartitionKey = attribute.Key("messaging.kafka.destination.partition") + + // MessagingKafkaSourcePartitionKey is the attribute Key conforming to the + // "messaging.kafka.source.partition" semantic conventions. It represents + // the partition the message is received from. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 2 + MessagingKafkaSourcePartitionKey = attribute.Key("messaging.kafka.source.partition") + + // MessagingKafkaMessageOffsetKey is the attribute Key conforming to the + // "messaging.kafka.message.offset" semantic conventions. It represents the + // offset of a record in the corresponding Kafka partition. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 42 + MessagingKafkaMessageOffsetKey = attribute.Key("messaging.kafka.message.offset") + + // MessagingKafkaMessageTombstoneKey is the attribute Key conforming to the + // "messaging.kafka.message.tombstone" semantic conventions. It represents + // a boolean that is true if the message is a tombstone. + // + // Type: boolean + // RequirementLevel: ConditionallyRequired (If value is `true`. When + // missing, the value is assumed to be `false`.) + // Stability: stable + MessagingKafkaMessageTombstoneKey = attribute.Key("messaging.kafka.message.tombstone") +) + +// MessagingKafkaMessageKey returns an attribute KeyValue conforming to the +// "messaging.kafka.message.key" semantic conventions. It represents the +// message keys in Kafka are used for grouping alike messages to ensure they're +// processed on the same partition. They differ from `messaging.message.id` in +// that they're not unique. If the key is `null`, the attribute MUST NOT be +// set. +func MessagingKafkaMessageKey(val string) attribute.KeyValue { + return MessagingKafkaMessageKeyKey.String(val) +} + +// MessagingKafkaConsumerGroup returns an attribute KeyValue conforming to +// the "messaging.kafka.consumer.group" semantic conventions. It represents the +// name of the Kafka Consumer Group that is handling the message. Only applies +// to consumers, not producers. +func MessagingKafkaConsumerGroup(val string) attribute.KeyValue { + return MessagingKafkaConsumerGroupKey.String(val) +} + +// MessagingKafkaClientID returns an attribute KeyValue conforming to the +// "messaging.kafka.client_id" semantic conventions. It represents the client +// ID for the Consumer or Producer that is handling the message. +func MessagingKafkaClientID(val string) attribute.KeyValue { + return MessagingKafkaClientIDKey.String(val) +} + +// MessagingKafkaDestinationPartition returns an attribute KeyValue +// conforming to the "messaging.kafka.destination.partition" semantic +// conventions. It represents the partition the message is sent to. +func MessagingKafkaDestinationPartition(val int) attribute.KeyValue { + return MessagingKafkaDestinationPartitionKey.Int(val) +} + +// MessagingKafkaSourcePartition returns an attribute KeyValue conforming to +// the "messaging.kafka.source.partition" semantic conventions. It represents +// the partition the message is received from. +func MessagingKafkaSourcePartition(val int) attribute.KeyValue { + return MessagingKafkaSourcePartitionKey.Int(val) +} + +// MessagingKafkaMessageOffset returns an attribute KeyValue conforming to +// the "messaging.kafka.message.offset" semantic conventions. It represents the +// offset of a record in the corresponding Kafka partition. +func MessagingKafkaMessageOffset(val int) attribute.KeyValue { + return MessagingKafkaMessageOffsetKey.Int(val) +} + +// MessagingKafkaMessageTombstone returns an attribute KeyValue conforming +// to the "messaging.kafka.message.tombstone" semantic conventions. It +// represents a boolean that is true if the message is a tombstone. +func MessagingKafkaMessageTombstone(val bool) attribute.KeyValue { + return MessagingKafkaMessageTombstoneKey.Bool(val) +} + +// Attributes for Apache RocketMQ +const ( + // MessagingRocketmqNamespaceKey is the attribute Key conforming to the + // "messaging.rocketmq.namespace" semantic conventions. It represents the + // namespace of RocketMQ resources, resources in different namespaces are + // individual. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'myNamespace' + MessagingRocketmqNamespaceKey = attribute.Key("messaging.rocketmq.namespace") + + // MessagingRocketmqClientGroupKey is the attribute Key conforming to the + // "messaging.rocketmq.client_group" semantic conventions. It represents + // the name of the RocketMQ producer/consumer group that is handling the + // message. The client type is identified by the SpanKind. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'myConsumerGroup' + MessagingRocketmqClientGroupKey = attribute.Key("messaging.rocketmq.client_group") + + // MessagingRocketmqClientIDKey is the attribute Key conforming to the + // "messaging.rocketmq.client_id" semantic conventions. It represents the + // unique identifier for each client. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'myhost@8742@s8083jm' + MessagingRocketmqClientIDKey = attribute.Key("messaging.rocketmq.client_id") + + // MessagingRocketmqMessageDeliveryTimestampKey is the attribute Key + // conforming to the "messaging.rocketmq.message.delivery_timestamp" + // semantic conventions. It represents the timestamp in milliseconds that + // the delay message is expected to be delivered to consumer. + // + // Type: int + // RequirementLevel: ConditionallyRequired (If the message type is delay + // and delay time level is not specified.) + // Stability: stable + // Examples: 1665987217045 + MessagingRocketmqMessageDeliveryTimestampKey = attribute.Key("messaging.rocketmq.message.delivery_timestamp") + + // MessagingRocketmqMessageDelayTimeLevelKey is the attribute Key + // conforming to the "messaging.rocketmq.message.delay_time_level" semantic + // conventions. It represents the delay time level for delay message, which + // determines the message delay time. + // + // Type: int + // RequirementLevel: ConditionallyRequired (If the message type is delay + // and delivery timestamp is not specified.) + // Stability: stable + // Examples: 3 + MessagingRocketmqMessageDelayTimeLevelKey = attribute.Key("messaging.rocketmq.message.delay_time_level") + + // MessagingRocketmqMessageGroupKey is the attribute Key conforming to the + // "messaging.rocketmq.message.group" semantic conventions. It represents + // the it is essential for FIFO message. Messages that belong to the same + // message group are always processed one by one within the same consumer + // group. + // + // Type: string + // RequirementLevel: ConditionallyRequired (If the message type is FIFO.) + // Stability: stable + // Examples: 'myMessageGroup' + MessagingRocketmqMessageGroupKey = attribute.Key("messaging.rocketmq.message.group") + + // MessagingRocketmqMessageTypeKey is the attribute Key conforming to the + // "messaging.rocketmq.message.type" semantic conventions. It represents + // the type of message. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + MessagingRocketmqMessageTypeKey = attribute.Key("messaging.rocketmq.message.type") + + // MessagingRocketmqMessageTagKey is the attribute Key conforming to the + // "messaging.rocketmq.message.tag" semantic conventions. It represents the + // secondary classifier of message besides topic. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'tagA' + MessagingRocketmqMessageTagKey = attribute.Key("messaging.rocketmq.message.tag") + + // MessagingRocketmqMessageKeysKey is the attribute Key conforming to the + // "messaging.rocketmq.message.keys" semantic conventions. It represents + // the key(s) of message, another way to mark message besides message id. + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: 'keyA', 'keyB' + MessagingRocketmqMessageKeysKey = attribute.Key("messaging.rocketmq.message.keys") + + // MessagingRocketmqConsumptionModelKey is the attribute Key conforming to + // the "messaging.rocketmq.consumption_model" semantic conventions. It + // represents the model of message consumption. This only applies to + // consumer spans. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + MessagingRocketmqConsumptionModelKey = attribute.Key("messaging.rocketmq.consumption_model") +) + +var ( + // Normal message + MessagingRocketmqMessageTypeNormal = MessagingRocketmqMessageTypeKey.String("normal") + // FIFO message + MessagingRocketmqMessageTypeFifo = MessagingRocketmqMessageTypeKey.String("fifo") + // Delay message + MessagingRocketmqMessageTypeDelay = MessagingRocketmqMessageTypeKey.String("delay") + // Transaction message + MessagingRocketmqMessageTypeTransaction = MessagingRocketmqMessageTypeKey.String("transaction") +) + +var ( + // Clustering consumption model + MessagingRocketmqConsumptionModelClustering = MessagingRocketmqConsumptionModelKey.String("clustering") + // Broadcasting consumption model + MessagingRocketmqConsumptionModelBroadcasting = MessagingRocketmqConsumptionModelKey.String("broadcasting") +) + +// MessagingRocketmqNamespace returns an attribute KeyValue conforming to +// the "messaging.rocketmq.namespace" semantic conventions. It represents the +// namespace of RocketMQ resources, resources in different namespaces are +// individual. +func MessagingRocketmqNamespace(val string) attribute.KeyValue { + return MessagingRocketmqNamespaceKey.String(val) +} + +// MessagingRocketmqClientGroup returns an attribute KeyValue conforming to +// the "messaging.rocketmq.client_group" semantic conventions. It represents +// the name of the RocketMQ producer/consumer group that is handling the +// message. The client type is identified by the SpanKind. +func MessagingRocketmqClientGroup(val string) attribute.KeyValue { + return MessagingRocketmqClientGroupKey.String(val) +} + +// MessagingRocketmqClientID returns an attribute KeyValue conforming to the +// "messaging.rocketmq.client_id" semantic conventions. It represents the +// unique identifier for each client. +func MessagingRocketmqClientID(val string) attribute.KeyValue { + return MessagingRocketmqClientIDKey.String(val) +} + +// MessagingRocketmqMessageDeliveryTimestamp returns an attribute KeyValue +// conforming to the "messaging.rocketmq.message.delivery_timestamp" semantic +// conventions. It represents the timestamp in milliseconds that the delay +// message is expected to be delivered to consumer. +func MessagingRocketmqMessageDeliveryTimestamp(val int) attribute.KeyValue { + return MessagingRocketmqMessageDeliveryTimestampKey.Int(val) +} + +// MessagingRocketmqMessageDelayTimeLevel returns an attribute KeyValue +// conforming to the "messaging.rocketmq.message.delay_time_level" semantic +// conventions. It represents the delay time level for delay message, which +// determines the message delay time. +func MessagingRocketmqMessageDelayTimeLevel(val int) attribute.KeyValue { + return MessagingRocketmqMessageDelayTimeLevelKey.Int(val) +} + +// MessagingRocketmqMessageGroup returns an attribute KeyValue conforming to +// the "messaging.rocketmq.message.group" semantic conventions. It represents +// the it is essential for FIFO message. Messages that belong to the same +// message group are always processed one by one within the same consumer +// group. +func MessagingRocketmqMessageGroup(val string) attribute.KeyValue { + return MessagingRocketmqMessageGroupKey.String(val) +} + +// MessagingRocketmqMessageTag returns an attribute KeyValue conforming to +// the "messaging.rocketmq.message.tag" semantic conventions. It represents the +// secondary classifier of message besides topic. +func MessagingRocketmqMessageTag(val string) attribute.KeyValue { + return MessagingRocketmqMessageTagKey.String(val) +} + +// MessagingRocketmqMessageKeys returns an attribute KeyValue conforming to +// the "messaging.rocketmq.message.keys" semantic conventions. It represents +// the key(s) of message, another way to mark message besides message id. +func MessagingRocketmqMessageKeys(val ...string) attribute.KeyValue { + return MessagingRocketmqMessageKeysKey.StringSlice(val) +} + +// Describes user-agent attributes. +const ( + // UserAgentOriginalKey is the attribute Key conforming to the + // "user_agent.original" semantic conventions. It represents the value of + // the [HTTP + // User-Agent](https://www.rfc-editor.org/rfc/rfc9110.html#field.user-agent) + // header sent by the client. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'CERN-LineMode/2.15 libwww/2.17b3' + UserAgentOriginalKey = attribute.Key("user_agent.original") +) + +// UserAgentOriginal returns an attribute KeyValue conforming to the +// "user_agent.original" semantic conventions. It represents the value of the +// [HTTP +// User-Agent](https://www.rfc-editor.org/rfc/rfc9110.html#field.user-agent) +// header sent by the client. +func UserAgentOriginal(val string) attribute.KeyValue { + return UserAgentOriginalKey.String(val) +} diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/doc.go b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/doc.go new file mode 100644 index 000000000..359c5a696 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/doc.go @@ -0,0 +1,20 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package semconv implements OpenTelemetry semantic conventions. +// +// OpenTelemetry semantic conventions are agreed standardized naming +// patterns for OpenTelemetry things. This package represents the conventions +// as of the v1.20.0 version of the OpenTelemetry specification. +package semconv // import "go.opentelemetry.io/otel/semconv/v1.20.0" diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/event.go b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/event.go new file mode 100644 index 000000000..8ac9350d2 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/event.go @@ -0,0 +1,199 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated from semantic convention specification. DO NOT EDIT. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.20.0" + +import "go.opentelemetry.io/otel/attribute" + +// This semantic convention defines the attributes used to represent a feature +// flag evaluation as an event. +const ( + // FeatureFlagKeyKey is the attribute Key conforming to the + // "feature_flag.key" semantic conventions. It represents the unique + // identifier of the feature flag. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'logo-color' + FeatureFlagKeyKey = attribute.Key("feature_flag.key") + + // FeatureFlagProviderNameKey is the attribute Key conforming to the + // "feature_flag.provider_name" semantic conventions. It represents the + // name of the service provider that performs the flag evaluation. + // + // Type: string + // RequirementLevel: Recommended + // Stability: stable + // Examples: 'Flag Manager' + FeatureFlagProviderNameKey = attribute.Key("feature_flag.provider_name") + + // FeatureFlagVariantKey is the attribute Key conforming to the + // "feature_flag.variant" semantic conventions. It represents the sHOULD be + // a semantic identifier for a value. If one is unavailable, a stringified + // version of the value can be used. + // + // Type: string + // RequirementLevel: Recommended + // Stability: stable + // Examples: 'red', 'true', 'on' + // Note: A semantic identifier, commonly referred to as a variant, provides + // a means + // for referring to a value without including the value itself. This can + // provide additional context for understanding the meaning behind a value. + // For example, the variant `red` maybe be used for the value `#c05543`. + // + // A stringified version of the value can be used in situations where a + // semantic identifier is unavailable. String representation of the value + // should be determined by the implementer. + FeatureFlagVariantKey = attribute.Key("feature_flag.variant") +) + +// FeatureFlagKey returns an attribute KeyValue conforming to the +// "feature_flag.key" semantic conventions. It represents the unique identifier +// of the feature flag. +func FeatureFlagKey(val string) attribute.KeyValue { + return FeatureFlagKeyKey.String(val) +} + +// FeatureFlagProviderName returns an attribute KeyValue conforming to the +// "feature_flag.provider_name" semantic conventions. It represents the name of +// the service provider that performs the flag evaluation. +func FeatureFlagProviderName(val string) attribute.KeyValue { + return FeatureFlagProviderNameKey.String(val) +} + +// FeatureFlagVariant returns an attribute KeyValue conforming to the +// "feature_flag.variant" semantic conventions. It represents the sHOULD be a +// semantic identifier for a value. If one is unavailable, a stringified +// version of the value can be used. +func FeatureFlagVariant(val string) attribute.KeyValue { + return FeatureFlagVariantKey.String(val) +} + +// RPC received/sent message. +const ( + // MessageTypeKey is the attribute Key conforming to the "message.type" + // semantic conventions. It represents the whether this is a received or + // sent message. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + MessageTypeKey = attribute.Key("message.type") + + // MessageIDKey is the attribute Key conforming to the "message.id" + // semantic conventions. It represents the mUST be calculated as two + // different counters starting from `1` one for sent messages and one for + // received message. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Note: This way we guarantee that the values will be consistent between + // different implementations. + MessageIDKey = attribute.Key("message.id") + + // MessageCompressedSizeKey is the attribute Key conforming to the + // "message.compressed_size" semantic conventions. It represents the + // compressed size of the message in bytes. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + MessageCompressedSizeKey = attribute.Key("message.compressed_size") + + // MessageUncompressedSizeKey is the attribute Key conforming to the + // "message.uncompressed_size" semantic conventions. It represents the + // uncompressed size of the message in bytes. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + MessageUncompressedSizeKey = attribute.Key("message.uncompressed_size") +) + +var ( + // sent + MessageTypeSent = MessageTypeKey.String("SENT") + // received + MessageTypeReceived = MessageTypeKey.String("RECEIVED") +) + +// MessageID returns an attribute KeyValue conforming to the "message.id" +// semantic conventions. It represents the mUST be calculated as two different +// counters starting from `1` one for sent messages and one for received +// message. +func MessageID(val int) attribute.KeyValue { + return MessageIDKey.Int(val) +} + +// MessageCompressedSize returns an attribute KeyValue conforming to the +// "message.compressed_size" semantic conventions. It represents the compressed +// size of the message in bytes. +func MessageCompressedSize(val int) attribute.KeyValue { + return MessageCompressedSizeKey.Int(val) +} + +// MessageUncompressedSize returns an attribute KeyValue conforming to the +// "message.uncompressed_size" semantic conventions. It represents the +// uncompressed size of the message in bytes. +func MessageUncompressedSize(val int) attribute.KeyValue { + return MessageUncompressedSizeKey.Int(val) +} + +// The attributes used to report a single exception associated with a span. +const ( + // ExceptionEscapedKey is the attribute Key conforming to the + // "exception.escaped" semantic conventions. It represents the sHOULD be + // set to true if the exception event is recorded at a point where it is + // known that the exception is escaping the scope of the span. + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + // Note: An exception is considered to have escaped (or left) the scope of + // a span, + // if that span is ended while the exception is still logically "in + // flight". + // This may be actually "in flight" in some languages (e.g. if the + // exception + // is passed to a Context manager's `__exit__` method in Python) but will + // usually be caught at the point of recording the exception in most + // languages. + // + // It is usually not possible to determine at the point where an exception + // is thrown + // whether it will escape the scope of a span. + // However, it is trivial to know that an exception + // will escape, if one checks for an active exception just before ending + // the span, + // as done in the [example above](#recording-an-exception). + // + // It follows that an exception may still escape the scope of the span + // even if the `exception.escaped` attribute was not set or set to false, + // since the event might have been recorded at a time where it was not + // clear whether the exception will escape. + ExceptionEscapedKey = attribute.Key("exception.escaped") +) + +// ExceptionEscaped returns an attribute KeyValue conforming to the +// "exception.escaped" semantic conventions. It represents the sHOULD be set to +// true if the exception event is recorded at a point where it is known that +// the exception is escaping the scope of the span. +func ExceptionEscaped(val bool) attribute.KeyValue { + return ExceptionEscapedKey.Bool(val) +} diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/exception.go b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/exception.go new file mode 100644 index 000000000..09ff4dfdb --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/exception.go @@ -0,0 +1,20 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.20.0" + +const ( + // ExceptionEventName is the name of the Span event representing an exception. + ExceptionEventName = "exception" +) diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/http.go b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/http.go new file mode 100644 index 000000000..342aede95 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/http.go @@ -0,0 +1,21 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.20.0" + +// HTTP scheme attributes. +var ( + HTTPSchemeHTTP = HTTPSchemeKey.String("http") + HTTPSchemeHTTPS = HTTPSchemeKey.String("https") +) diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/resource.go b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/resource.go new file mode 100644 index 000000000..a2b906742 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/resource.go @@ -0,0 +1,2071 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated from semantic convention specification. DO NOT EDIT. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.20.0" + +import "go.opentelemetry.io/otel/attribute" + +// The web browser in which the application represented by the resource is +// running. The `browser.*` attributes MUST be used only for resources that +// represent applications running in a web browser (regardless of whether +// running on a mobile or desktop device). +const ( + // BrowserBrandsKey is the attribute Key conforming to the "browser.brands" + // semantic conventions. It represents the array of brand name and version + // separated by a space + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: ' Not A;Brand 99', 'Chromium 99', 'Chrome 99' + // Note: This value is intended to be taken from the [UA client hints + // API](https://wicg.github.io/ua-client-hints/#interface) + // (`navigator.userAgentData.brands`). + BrowserBrandsKey = attribute.Key("browser.brands") + + // BrowserPlatformKey is the attribute Key conforming to the + // "browser.platform" semantic conventions. It represents the platform on + // which the browser is running + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Windows', 'macOS', 'Android' + // Note: This value is intended to be taken from the [UA client hints + // API](https://wicg.github.io/ua-client-hints/#interface) + // (`navigator.userAgentData.platform`). If unavailable, the legacy + // `navigator.platform` API SHOULD NOT be used instead and this attribute + // SHOULD be left unset in order for the values to be consistent. + // The list of possible values is defined in the [W3C User-Agent Client + // Hints + // specification](https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform). + // Note that some (but not all) of these values can overlap with values in + // the [`os.type` and `os.name` attributes](./os.md). However, for + // consistency, the values in the `browser.platform` attribute should + // capture the exact value that the user agent provides. + BrowserPlatformKey = attribute.Key("browser.platform") + + // BrowserMobileKey is the attribute Key conforming to the "browser.mobile" + // semantic conventions. It represents a boolean that is true if the + // browser is running on a mobile device + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + // Note: This value is intended to be taken from the [UA client hints + // API](https://wicg.github.io/ua-client-hints/#interface) + // (`navigator.userAgentData.mobile`). If unavailable, this attribute + // SHOULD be left unset. + BrowserMobileKey = attribute.Key("browser.mobile") + + // BrowserLanguageKey is the attribute Key conforming to the + // "browser.language" semantic conventions. It represents the preferred + // language of the user using the browser + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'en', 'en-US', 'fr', 'fr-FR' + // Note: This value is intended to be taken from the Navigator API + // `navigator.language`. + BrowserLanguageKey = attribute.Key("browser.language") +) + +// BrowserBrands returns an attribute KeyValue conforming to the +// "browser.brands" semantic conventions. It represents the array of brand name +// and version separated by a space +func BrowserBrands(val ...string) attribute.KeyValue { + return BrowserBrandsKey.StringSlice(val) +} + +// BrowserPlatform returns an attribute KeyValue conforming to the +// "browser.platform" semantic conventions. It represents the platform on which +// the browser is running +func BrowserPlatform(val string) attribute.KeyValue { + return BrowserPlatformKey.String(val) +} + +// BrowserMobile returns an attribute KeyValue conforming to the +// "browser.mobile" semantic conventions. It represents a boolean that is true +// if the browser is running on a mobile device +func BrowserMobile(val bool) attribute.KeyValue { + return BrowserMobileKey.Bool(val) +} + +// BrowserLanguage returns an attribute KeyValue conforming to the +// "browser.language" semantic conventions. It represents the preferred +// language of the user using the browser +func BrowserLanguage(val string) attribute.KeyValue { + return BrowserLanguageKey.String(val) +} + +// A cloud environment (e.g. GCP, Azure, AWS) +const ( + // CloudProviderKey is the attribute Key conforming to the "cloud.provider" + // semantic conventions. It represents the name of the cloud provider. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + CloudProviderKey = attribute.Key("cloud.provider") + + // CloudAccountIDKey is the attribute Key conforming to the + // "cloud.account.id" semantic conventions. It represents the cloud account + // ID the resource is assigned to. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '111111111111', 'opentelemetry' + CloudAccountIDKey = attribute.Key("cloud.account.id") + + // CloudRegionKey is the attribute Key conforming to the "cloud.region" + // semantic conventions. It represents the geographical region the resource + // is running. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'us-central1', 'us-east-1' + // Note: Refer to your provider's docs to see the available regions, for + // example [Alibaba Cloud + // regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS + // regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), + // [Azure + // regions](https://azure.microsoft.com/en-us/global-infrastructure/geographies/), + // [Google Cloud regions](https://cloud.google.com/about/locations), or + // [Tencent Cloud + // regions](https://www.tencentcloud.com/document/product/213/6091). + CloudRegionKey = attribute.Key("cloud.region") + + // CloudResourceIDKey is the attribute Key conforming to the + // "cloud.resource_id" semantic conventions. It represents the cloud + // provider-specific native identifier of the monitored cloud resource + // (e.g. an + // [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) + // on AWS, a [fully qualified resource + // ID](https://learn.microsoft.com/en-us/rest/api/resources/resources/get-by-id) + // on Azure, a [full resource + // name](https://cloud.google.com/apis/design/resource_names#full_resource_name) + // on GCP) + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'arn:aws:lambda:REGION:ACCOUNT_ID:function:my-function', + // '//run.googleapis.com/projects/PROJECT_ID/locations/LOCATION_ID/services/SERVICE_ID', + // '/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions/' + // Note: On some cloud providers, it may not be possible to determine the + // full ID at startup, + // so it may be necessary to set `cloud.resource_id` as a span attribute + // instead. + // + // The exact value to use for `cloud.resource_id` depends on the cloud + // provider. + // The following well-known definitions MUST be used if you set this + // attribute and they apply: + // + // * **AWS Lambda:** The function + // [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html). + // Take care not to use the "invoked ARN" directly but replace any + // [alias + // suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html) + // with the resolved function version, as the same runtime instance may + // be invokable with + // multiple different aliases. + // * **GCP:** The [URI of the + // resource](https://cloud.google.com/iam/docs/full-resource-names) + // * **Azure:** The [Fully Qualified Resource + // ID](https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id) + // of the invoked function, + // *not* the function app, having the form + // `/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions/`. + // This means that a span attribute MUST be used, as an Azure function + // app can host multiple functions that would usually share + // a TracerProvider. + CloudResourceIDKey = attribute.Key("cloud.resource_id") + + // CloudAvailabilityZoneKey is the attribute Key conforming to the + // "cloud.availability_zone" semantic conventions. It represents the cloud + // regions often have multiple, isolated locations known as zones to + // increase availability. Availability zone represents the zone where the + // resource is running. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'us-east-1c' + // Note: Availability zones are called "zones" on Alibaba Cloud and Google + // Cloud. + CloudAvailabilityZoneKey = attribute.Key("cloud.availability_zone") + + // CloudPlatformKey is the attribute Key conforming to the "cloud.platform" + // semantic conventions. It represents the cloud platform in use. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + // Note: The prefix of the service SHOULD match the one specified in + // `cloud.provider`. + CloudPlatformKey = attribute.Key("cloud.platform") +) + +var ( + // Alibaba Cloud + CloudProviderAlibabaCloud = CloudProviderKey.String("alibaba_cloud") + // Amazon Web Services + CloudProviderAWS = CloudProviderKey.String("aws") + // Microsoft Azure + CloudProviderAzure = CloudProviderKey.String("azure") + // Google Cloud Platform + CloudProviderGCP = CloudProviderKey.String("gcp") + // Heroku Platform as a Service + CloudProviderHeroku = CloudProviderKey.String("heroku") + // IBM Cloud + CloudProviderIbmCloud = CloudProviderKey.String("ibm_cloud") + // Tencent Cloud + CloudProviderTencentCloud = CloudProviderKey.String("tencent_cloud") +) + +var ( + // Alibaba Cloud Elastic Compute Service + CloudPlatformAlibabaCloudECS = CloudPlatformKey.String("alibaba_cloud_ecs") + // Alibaba Cloud Function Compute + CloudPlatformAlibabaCloudFc = CloudPlatformKey.String("alibaba_cloud_fc") + // Red Hat OpenShift on Alibaba Cloud + CloudPlatformAlibabaCloudOpenshift = CloudPlatformKey.String("alibaba_cloud_openshift") + // AWS Elastic Compute Cloud + CloudPlatformAWSEC2 = CloudPlatformKey.String("aws_ec2") + // AWS Elastic Container Service + CloudPlatformAWSECS = CloudPlatformKey.String("aws_ecs") + // AWS Elastic Kubernetes Service + CloudPlatformAWSEKS = CloudPlatformKey.String("aws_eks") + // AWS Lambda + CloudPlatformAWSLambda = CloudPlatformKey.String("aws_lambda") + // AWS Elastic Beanstalk + CloudPlatformAWSElasticBeanstalk = CloudPlatformKey.String("aws_elastic_beanstalk") + // AWS App Runner + CloudPlatformAWSAppRunner = CloudPlatformKey.String("aws_app_runner") + // Red Hat OpenShift on AWS (ROSA) + CloudPlatformAWSOpenshift = CloudPlatformKey.String("aws_openshift") + // Azure Virtual Machines + CloudPlatformAzureVM = CloudPlatformKey.String("azure_vm") + // Azure Container Instances + CloudPlatformAzureContainerInstances = CloudPlatformKey.String("azure_container_instances") + // Azure Kubernetes Service + CloudPlatformAzureAKS = CloudPlatformKey.String("azure_aks") + // Azure Functions + CloudPlatformAzureFunctions = CloudPlatformKey.String("azure_functions") + // Azure App Service + CloudPlatformAzureAppService = CloudPlatformKey.String("azure_app_service") + // Azure Red Hat OpenShift + CloudPlatformAzureOpenshift = CloudPlatformKey.String("azure_openshift") + // Google Cloud Compute Engine (GCE) + CloudPlatformGCPComputeEngine = CloudPlatformKey.String("gcp_compute_engine") + // Google Cloud Run + CloudPlatformGCPCloudRun = CloudPlatformKey.String("gcp_cloud_run") + // Google Cloud Kubernetes Engine (GKE) + CloudPlatformGCPKubernetesEngine = CloudPlatformKey.String("gcp_kubernetes_engine") + // Google Cloud Functions (GCF) + CloudPlatformGCPCloudFunctions = CloudPlatformKey.String("gcp_cloud_functions") + // Google Cloud App Engine (GAE) + CloudPlatformGCPAppEngine = CloudPlatformKey.String("gcp_app_engine") + // Red Hat OpenShift on Google Cloud + CloudPlatformGCPOpenshift = CloudPlatformKey.String("gcp_openshift") + // Red Hat OpenShift on IBM Cloud + CloudPlatformIbmCloudOpenshift = CloudPlatformKey.String("ibm_cloud_openshift") + // Tencent Cloud Cloud Virtual Machine (CVM) + CloudPlatformTencentCloudCvm = CloudPlatformKey.String("tencent_cloud_cvm") + // Tencent Cloud Elastic Kubernetes Service (EKS) + CloudPlatformTencentCloudEKS = CloudPlatformKey.String("tencent_cloud_eks") + // Tencent Cloud Serverless Cloud Function (SCF) + CloudPlatformTencentCloudScf = CloudPlatformKey.String("tencent_cloud_scf") +) + +// CloudAccountID returns an attribute KeyValue conforming to the +// "cloud.account.id" semantic conventions. It represents the cloud account ID +// the resource is assigned to. +func CloudAccountID(val string) attribute.KeyValue { + return CloudAccountIDKey.String(val) +} + +// CloudRegion returns an attribute KeyValue conforming to the +// "cloud.region" semantic conventions. It represents the geographical region +// the resource is running. +func CloudRegion(val string) attribute.KeyValue { + return CloudRegionKey.String(val) +} + +// CloudResourceID returns an attribute KeyValue conforming to the +// "cloud.resource_id" semantic conventions. It represents the cloud +// provider-specific native identifier of the monitored cloud resource (e.g. an +// [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) +// on AWS, a [fully qualified resource +// ID](https://learn.microsoft.com/en-us/rest/api/resources/resources/get-by-id) +// on Azure, a [full resource +// name](https://cloud.google.com/apis/design/resource_names#full_resource_name) +// on GCP) +func CloudResourceID(val string) attribute.KeyValue { + return CloudResourceIDKey.String(val) +} + +// CloudAvailabilityZone returns an attribute KeyValue conforming to the +// "cloud.availability_zone" semantic conventions. It represents the cloud +// regions often have multiple, isolated locations known as zones to increase +// availability. Availability zone represents the zone where the resource is +// running. +func CloudAvailabilityZone(val string) attribute.KeyValue { + return CloudAvailabilityZoneKey.String(val) +} + +// Resources used by AWS Elastic Container Service (ECS). +const ( + // AWSECSContainerARNKey is the attribute Key conforming to the + // "aws.ecs.container.arn" semantic conventions. It represents the Amazon + // Resource Name (ARN) of an [ECS container + // instance](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_instances.html). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: + // 'arn:aws:ecs:us-west-1:123456789123:container/32624152-9086-4f0e-acae-1a75b14fe4d9' + AWSECSContainerARNKey = attribute.Key("aws.ecs.container.arn") + + // AWSECSClusterARNKey is the attribute Key conforming to the + // "aws.ecs.cluster.arn" semantic conventions. It represents the ARN of an + // [ECS + // cluster](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'arn:aws:ecs:us-west-2:123456789123:cluster/my-cluster' + AWSECSClusterARNKey = attribute.Key("aws.ecs.cluster.arn") + + // AWSECSLaunchtypeKey is the attribute Key conforming to the + // "aws.ecs.launchtype" semantic conventions. It represents the [launch + // type](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html) + // for an ECS task. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + AWSECSLaunchtypeKey = attribute.Key("aws.ecs.launchtype") + + // AWSECSTaskARNKey is the attribute Key conforming to the + // "aws.ecs.task.arn" semantic conventions. It represents the ARN of an + // [ECS task + // definition](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: + // 'arn:aws:ecs:us-west-1:123456789123:task/10838bed-421f-43ef-870a-f43feacbbb5b' + AWSECSTaskARNKey = attribute.Key("aws.ecs.task.arn") + + // AWSECSTaskFamilyKey is the attribute Key conforming to the + // "aws.ecs.task.family" semantic conventions. It represents the task + // definition family this task definition is a member of. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry-family' + AWSECSTaskFamilyKey = attribute.Key("aws.ecs.task.family") + + // AWSECSTaskRevisionKey is the attribute Key conforming to the + // "aws.ecs.task.revision" semantic conventions. It represents the revision + // for this task definition. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '8', '26' + AWSECSTaskRevisionKey = attribute.Key("aws.ecs.task.revision") +) + +var ( + // ec2 + AWSECSLaunchtypeEC2 = AWSECSLaunchtypeKey.String("ec2") + // fargate + AWSECSLaunchtypeFargate = AWSECSLaunchtypeKey.String("fargate") +) + +// AWSECSContainerARN returns an attribute KeyValue conforming to the +// "aws.ecs.container.arn" semantic conventions. It represents the Amazon +// Resource Name (ARN) of an [ECS container +// instance](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_instances.html). +func AWSECSContainerARN(val string) attribute.KeyValue { + return AWSECSContainerARNKey.String(val) +} + +// AWSECSClusterARN returns an attribute KeyValue conforming to the +// "aws.ecs.cluster.arn" semantic conventions. It represents the ARN of an [ECS +// cluster](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html). +func AWSECSClusterARN(val string) attribute.KeyValue { + return AWSECSClusterARNKey.String(val) +} + +// AWSECSTaskARN returns an attribute KeyValue conforming to the +// "aws.ecs.task.arn" semantic conventions. It represents the ARN of an [ECS +// task +// definition](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html). +func AWSECSTaskARN(val string) attribute.KeyValue { + return AWSECSTaskARNKey.String(val) +} + +// AWSECSTaskFamily returns an attribute KeyValue conforming to the +// "aws.ecs.task.family" semantic conventions. It represents the task +// definition family this task definition is a member of. +func AWSECSTaskFamily(val string) attribute.KeyValue { + return AWSECSTaskFamilyKey.String(val) +} + +// AWSECSTaskRevision returns an attribute KeyValue conforming to the +// "aws.ecs.task.revision" semantic conventions. It represents the revision for +// this task definition. +func AWSECSTaskRevision(val string) attribute.KeyValue { + return AWSECSTaskRevisionKey.String(val) +} + +// Resources used by AWS Elastic Kubernetes Service (EKS). +const ( + // AWSEKSClusterARNKey is the attribute Key conforming to the + // "aws.eks.cluster.arn" semantic conventions. It represents the ARN of an + // EKS cluster. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'arn:aws:ecs:us-west-2:123456789123:cluster/my-cluster' + AWSEKSClusterARNKey = attribute.Key("aws.eks.cluster.arn") +) + +// AWSEKSClusterARN returns an attribute KeyValue conforming to the +// "aws.eks.cluster.arn" semantic conventions. It represents the ARN of an EKS +// cluster. +func AWSEKSClusterARN(val string) attribute.KeyValue { + return AWSEKSClusterARNKey.String(val) +} + +// Resources specific to Amazon Web Services. +const ( + // AWSLogGroupNamesKey is the attribute Key conforming to the + // "aws.log.group.names" semantic conventions. It represents the name(s) of + // the AWS log group(s) an application is writing to. + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: '/aws/lambda/my-function', 'opentelemetry-service' + // Note: Multiple log groups must be supported for cases like + // multi-container applications, where a single application has sidecar + // containers, and each write to their own log group. + AWSLogGroupNamesKey = attribute.Key("aws.log.group.names") + + // AWSLogGroupARNsKey is the attribute Key conforming to the + // "aws.log.group.arns" semantic conventions. It represents the Amazon + // Resource Name(s) (ARN) of the AWS log group(s). + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: + // 'arn:aws:logs:us-west-1:123456789012:log-group:/aws/my/group:*' + // Note: See the [log group ARN format + // documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format). + AWSLogGroupARNsKey = attribute.Key("aws.log.group.arns") + + // AWSLogStreamNamesKey is the attribute Key conforming to the + // "aws.log.stream.names" semantic conventions. It represents the name(s) + // of the AWS log stream(s) an application is writing to. + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: 'logs/main/10838bed-421f-43ef-870a-f43feacbbb5b' + AWSLogStreamNamesKey = attribute.Key("aws.log.stream.names") + + // AWSLogStreamARNsKey is the attribute Key conforming to the + // "aws.log.stream.arns" semantic conventions. It represents the ARN(s) of + // the AWS log stream(s). + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: + // 'arn:aws:logs:us-west-1:123456789012:log-group:/aws/my/group:log-stream:logs/main/10838bed-421f-43ef-870a-f43feacbbb5b' + // Note: See the [log stream ARN format + // documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format). + // One log group can contain several log streams, so these ARNs necessarily + // identify both a log group and a log stream. + AWSLogStreamARNsKey = attribute.Key("aws.log.stream.arns") +) + +// AWSLogGroupNames returns an attribute KeyValue conforming to the +// "aws.log.group.names" semantic conventions. It represents the name(s) of the +// AWS log group(s) an application is writing to. +func AWSLogGroupNames(val ...string) attribute.KeyValue { + return AWSLogGroupNamesKey.StringSlice(val) +} + +// AWSLogGroupARNs returns an attribute KeyValue conforming to the +// "aws.log.group.arns" semantic conventions. It represents the Amazon Resource +// Name(s) (ARN) of the AWS log group(s). +func AWSLogGroupARNs(val ...string) attribute.KeyValue { + return AWSLogGroupARNsKey.StringSlice(val) +} + +// AWSLogStreamNames returns an attribute KeyValue conforming to the +// "aws.log.stream.names" semantic conventions. It represents the name(s) of +// the AWS log stream(s) an application is writing to. +func AWSLogStreamNames(val ...string) attribute.KeyValue { + return AWSLogStreamNamesKey.StringSlice(val) +} + +// AWSLogStreamARNs returns an attribute KeyValue conforming to the +// "aws.log.stream.arns" semantic conventions. It represents the ARN(s) of the +// AWS log stream(s). +func AWSLogStreamARNs(val ...string) attribute.KeyValue { + return AWSLogStreamARNsKey.StringSlice(val) +} + +// Heroku dyno metadata +const ( + // HerokuReleaseCreationTimestampKey is the attribute Key conforming to the + // "heroku.release.creation_timestamp" semantic conventions. It represents + // the time and date the release was created + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '2022-10-23T18:00:42Z' + HerokuReleaseCreationTimestampKey = attribute.Key("heroku.release.creation_timestamp") + + // HerokuReleaseCommitKey is the attribute Key conforming to the + // "heroku.release.commit" semantic conventions. It represents the commit + // hash for the current release + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'e6134959463efd8966b20e75b913cafe3f5ec' + HerokuReleaseCommitKey = attribute.Key("heroku.release.commit") + + // HerokuAppIDKey is the attribute Key conforming to the "heroku.app.id" + // semantic conventions. It represents the unique identifier for the + // application + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '2daa2797-e42b-4624-9322-ec3f968df4da' + HerokuAppIDKey = attribute.Key("heroku.app.id") +) + +// HerokuReleaseCreationTimestamp returns an attribute KeyValue conforming +// to the "heroku.release.creation_timestamp" semantic conventions. It +// represents the time and date the release was created +func HerokuReleaseCreationTimestamp(val string) attribute.KeyValue { + return HerokuReleaseCreationTimestampKey.String(val) +} + +// HerokuReleaseCommit returns an attribute KeyValue conforming to the +// "heroku.release.commit" semantic conventions. It represents the commit hash +// for the current release +func HerokuReleaseCommit(val string) attribute.KeyValue { + return HerokuReleaseCommitKey.String(val) +} + +// HerokuAppID returns an attribute KeyValue conforming to the +// "heroku.app.id" semantic conventions. It represents the unique identifier +// for the application +func HerokuAppID(val string) attribute.KeyValue { + return HerokuAppIDKey.String(val) +} + +// A container instance. +const ( + // ContainerNameKey is the attribute Key conforming to the "container.name" + // semantic conventions. It represents the container name used by container + // runtime. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry-autoconf' + ContainerNameKey = attribute.Key("container.name") + + // ContainerIDKey is the attribute Key conforming to the "container.id" + // semantic conventions. It represents the container ID. Usually a UUID, as + // for example used to [identify Docker + // containers](https://docs.docker.com/engine/reference/run/#container-identification). + // The UUID might be abbreviated. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'a3bf90e006b2' + ContainerIDKey = attribute.Key("container.id") + + // ContainerRuntimeKey is the attribute Key conforming to the + // "container.runtime" semantic conventions. It represents the container + // runtime managing this container. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'docker', 'containerd', 'rkt' + ContainerRuntimeKey = attribute.Key("container.runtime") + + // ContainerImageNameKey is the attribute Key conforming to the + // "container.image.name" semantic conventions. It represents the name of + // the image the container was built on. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'gcr.io/opentelemetry/operator' + ContainerImageNameKey = attribute.Key("container.image.name") + + // ContainerImageTagKey is the attribute Key conforming to the + // "container.image.tag" semantic conventions. It represents the container + // image tag. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '0.1' + ContainerImageTagKey = attribute.Key("container.image.tag") +) + +// ContainerName returns an attribute KeyValue conforming to the +// "container.name" semantic conventions. It represents the container name used +// by container runtime. +func ContainerName(val string) attribute.KeyValue { + return ContainerNameKey.String(val) +} + +// ContainerID returns an attribute KeyValue conforming to the +// "container.id" semantic conventions. It represents the container ID. Usually +// a UUID, as for example used to [identify Docker +// containers](https://docs.docker.com/engine/reference/run/#container-identification). +// The UUID might be abbreviated. +func ContainerID(val string) attribute.KeyValue { + return ContainerIDKey.String(val) +} + +// ContainerRuntime returns an attribute KeyValue conforming to the +// "container.runtime" semantic conventions. It represents the container +// runtime managing this container. +func ContainerRuntime(val string) attribute.KeyValue { + return ContainerRuntimeKey.String(val) +} + +// ContainerImageName returns an attribute KeyValue conforming to the +// "container.image.name" semantic conventions. It represents the name of the +// image the container was built on. +func ContainerImageName(val string) attribute.KeyValue { + return ContainerImageNameKey.String(val) +} + +// ContainerImageTag returns an attribute KeyValue conforming to the +// "container.image.tag" semantic conventions. It represents the container +// image tag. +func ContainerImageTag(val string) attribute.KeyValue { + return ContainerImageTagKey.String(val) +} + +// The software deployment. +const ( + // DeploymentEnvironmentKey is the attribute Key conforming to the + // "deployment.environment" semantic conventions. It represents the name of + // the [deployment + // environment](https://en.wikipedia.org/wiki/Deployment_environment) (aka + // deployment tier). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'staging', 'production' + DeploymentEnvironmentKey = attribute.Key("deployment.environment") +) + +// DeploymentEnvironment returns an attribute KeyValue conforming to the +// "deployment.environment" semantic conventions. It represents the name of the +// [deployment +// environment](https://en.wikipedia.org/wiki/Deployment_environment) (aka +// deployment tier). +func DeploymentEnvironment(val string) attribute.KeyValue { + return DeploymentEnvironmentKey.String(val) +} + +// The device on which the process represented by this resource is running. +const ( + // DeviceIDKey is the attribute Key conforming to the "device.id" semantic + // conventions. It represents a unique identifier representing the device + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '2ab2916d-a51f-4ac8-80ee-45ac31a28092' + // Note: The device identifier MUST only be defined using the values + // outlined below. This value is not an advertising identifier and MUST NOT + // be used as such. On iOS (Swift or Objective-C), this value MUST be equal + // to the [vendor + // identifier](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor). + // On Android (Java or Kotlin), this value MUST be equal to the Firebase + // Installation ID or a globally unique UUID which is persisted across + // sessions in your application. More information can be found + // [here](https://developer.android.com/training/articles/user-data-ids) on + // best practices and exact implementation details. Caution should be taken + // when storing personal data or anything which can identify a user. GDPR + // and data protection laws may apply, ensure you do your own due + // diligence. + DeviceIDKey = attribute.Key("device.id") + + // DeviceModelIdentifierKey is the attribute Key conforming to the + // "device.model.identifier" semantic conventions. It represents the model + // identifier for the device + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'iPhone3,4', 'SM-G920F' + // Note: It's recommended this value represents a machine readable version + // of the model identifier rather than the market or consumer-friendly name + // of the device. + DeviceModelIdentifierKey = attribute.Key("device.model.identifier") + + // DeviceModelNameKey is the attribute Key conforming to the + // "device.model.name" semantic conventions. It represents the marketing + // name for the device model + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'iPhone 6s Plus', 'Samsung Galaxy S6' + // Note: It's recommended this value represents a human readable version of + // the device model rather than a machine readable alternative. + DeviceModelNameKey = attribute.Key("device.model.name") + + // DeviceManufacturerKey is the attribute Key conforming to the + // "device.manufacturer" semantic conventions. It represents the name of + // the device manufacturer + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Apple', 'Samsung' + // Note: The Android OS provides this field via + // [Build](https://developer.android.com/reference/android/os/Build#MANUFACTURER). + // iOS apps SHOULD hardcode the value `Apple`. + DeviceManufacturerKey = attribute.Key("device.manufacturer") +) + +// DeviceID returns an attribute KeyValue conforming to the "device.id" +// semantic conventions. It represents a unique identifier representing the +// device +func DeviceID(val string) attribute.KeyValue { + return DeviceIDKey.String(val) +} + +// DeviceModelIdentifier returns an attribute KeyValue conforming to the +// "device.model.identifier" semantic conventions. It represents the model +// identifier for the device +func DeviceModelIdentifier(val string) attribute.KeyValue { + return DeviceModelIdentifierKey.String(val) +} + +// DeviceModelName returns an attribute KeyValue conforming to the +// "device.model.name" semantic conventions. It represents the marketing name +// for the device model +func DeviceModelName(val string) attribute.KeyValue { + return DeviceModelNameKey.String(val) +} + +// DeviceManufacturer returns an attribute KeyValue conforming to the +// "device.manufacturer" semantic conventions. It represents the name of the +// device manufacturer +func DeviceManufacturer(val string) attribute.KeyValue { + return DeviceManufacturerKey.String(val) +} + +// A serverless instance. +const ( + // FaaSNameKey is the attribute Key conforming to the "faas.name" semantic + // conventions. It represents the name of the single function that this + // runtime instance executes. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'my-function', 'myazurefunctionapp/some-function-name' + // Note: This is the name of the function as configured/deployed on the + // FaaS + // platform and is usually different from the name of the callback + // function (which may be stored in the + // [`code.namespace`/`code.function`](../../trace/semantic_conventions/span-general.md#source-code-attributes) + // span attributes). + // + // For some cloud providers, the above definition is ambiguous. The + // following + // definition of function name MUST be used for this attribute + // (and consequently the span name) for the listed cloud + // providers/products: + // + // * **Azure:** The full name `/`, i.e., function app name + // followed by a forward slash followed by the function name (this form + // can also be seen in the resource JSON for the function). + // This means that a span attribute MUST be used, as an Azure function + // app can host multiple functions that would usually share + // a TracerProvider (see also the `cloud.resource_id` attribute). + FaaSNameKey = attribute.Key("faas.name") + + // FaaSVersionKey is the attribute Key conforming to the "faas.version" + // semantic conventions. It represents the immutable version of the + // function being executed. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '26', 'pinkfroid-00002' + // Note: Depending on the cloud provider and platform, use: + // + // * **AWS Lambda:** The [function + // version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html) + // (an integer represented as a decimal string). + // * **Google Cloud Run:** The + // [revision](https://cloud.google.com/run/docs/managing/revisions) + // (i.e., the function name plus the revision suffix). + // * **Google Cloud Functions:** The value of the + // [`K_REVISION` environment + // variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically). + // * **Azure Functions:** Not applicable. Do not set this attribute. + FaaSVersionKey = attribute.Key("faas.version") + + // FaaSInstanceKey is the attribute Key conforming to the "faas.instance" + // semantic conventions. It represents the execution environment ID as a + // string, that will be potentially reused for other invocations to the + // same function/function version. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de' + // Note: * **AWS Lambda:** Use the (full) log stream name. + FaaSInstanceKey = attribute.Key("faas.instance") + + // FaaSMaxMemoryKey is the attribute Key conforming to the + // "faas.max_memory" semantic conventions. It represents the amount of + // memory available to the serverless function converted to Bytes. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 134217728 + // Note: It's recommended to set this attribute since e.g. too little + // memory can easily stop a Java AWS Lambda function from working + // correctly. On AWS Lambda, the environment variable + // `AWS_LAMBDA_FUNCTION_MEMORY_SIZE` provides this information (which must + // be multiplied by 1,048,576). + FaaSMaxMemoryKey = attribute.Key("faas.max_memory") +) + +// FaaSName returns an attribute KeyValue conforming to the "faas.name" +// semantic conventions. It represents the name of the single function that +// this runtime instance executes. +func FaaSName(val string) attribute.KeyValue { + return FaaSNameKey.String(val) +} + +// FaaSVersion returns an attribute KeyValue conforming to the +// "faas.version" semantic conventions. It represents the immutable version of +// the function being executed. +func FaaSVersion(val string) attribute.KeyValue { + return FaaSVersionKey.String(val) +} + +// FaaSInstance returns an attribute KeyValue conforming to the +// "faas.instance" semantic conventions. It represents the execution +// environment ID as a string, that will be potentially reused for other +// invocations to the same function/function version. +func FaaSInstance(val string) attribute.KeyValue { + return FaaSInstanceKey.String(val) +} + +// FaaSMaxMemory returns an attribute KeyValue conforming to the +// "faas.max_memory" semantic conventions. It represents the amount of memory +// available to the serverless function converted to Bytes. +func FaaSMaxMemory(val int) attribute.KeyValue { + return FaaSMaxMemoryKey.Int(val) +} + +// A host is defined as a general computing instance. +const ( + // HostIDKey is the attribute Key conforming to the "host.id" semantic + // conventions. It represents the unique host ID. For Cloud, this must be + // the instance_id assigned by the cloud provider. For non-containerized + // systems, this should be the `machine-id`. See the table below for the + // sources to use to determine the `machine-id` based on operating system. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'fdbf79e8af94cb7f9e8df36789187052' + HostIDKey = attribute.Key("host.id") + + // HostNameKey is the attribute Key conforming to the "host.name" semantic + // conventions. It represents the name of the host. On Unix systems, it may + // contain what the hostname command returns, or the fully qualified + // hostname, or another name specified by the user. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry-test' + HostNameKey = attribute.Key("host.name") + + // HostTypeKey is the attribute Key conforming to the "host.type" semantic + // conventions. It represents the type of host. For Cloud, this must be the + // machine type. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'n1-standard-1' + HostTypeKey = attribute.Key("host.type") + + // HostArchKey is the attribute Key conforming to the "host.arch" semantic + // conventions. It represents the CPU architecture the host system is + // running on. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + HostArchKey = attribute.Key("host.arch") + + // HostImageNameKey is the attribute Key conforming to the + // "host.image.name" semantic conventions. It represents the name of the VM + // image or OS install the host was instantiated from. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'infra-ami-eks-worker-node-7d4ec78312', 'CentOS-8-x86_64-1905' + HostImageNameKey = attribute.Key("host.image.name") + + // HostImageIDKey is the attribute Key conforming to the "host.image.id" + // semantic conventions. It represents the vM image ID. For Cloud, this + // value is from the provider. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'ami-07b06b442921831e5' + HostImageIDKey = attribute.Key("host.image.id") + + // HostImageVersionKey is the attribute Key conforming to the + // "host.image.version" semantic conventions. It represents the version + // string of the VM image as defined in [Version + // Attributes](README.md#version-attributes). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '0.1' + HostImageVersionKey = attribute.Key("host.image.version") +) + +var ( + // AMD64 + HostArchAMD64 = HostArchKey.String("amd64") + // ARM32 + HostArchARM32 = HostArchKey.String("arm32") + // ARM64 + HostArchARM64 = HostArchKey.String("arm64") + // Itanium + HostArchIA64 = HostArchKey.String("ia64") + // 32-bit PowerPC + HostArchPPC32 = HostArchKey.String("ppc32") + // 64-bit PowerPC + HostArchPPC64 = HostArchKey.String("ppc64") + // IBM z/Architecture + HostArchS390x = HostArchKey.String("s390x") + // 32-bit x86 + HostArchX86 = HostArchKey.String("x86") +) + +// HostID returns an attribute KeyValue conforming to the "host.id" semantic +// conventions. It represents the unique host ID. For Cloud, this must be the +// instance_id assigned by the cloud provider. For non-containerized systems, +// this should be the `machine-id`. See the table below for the sources to use +// to determine the `machine-id` based on operating system. +func HostID(val string) attribute.KeyValue { + return HostIDKey.String(val) +} + +// HostName returns an attribute KeyValue conforming to the "host.name" +// semantic conventions. It represents the name of the host. On Unix systems, +// it may contain what the hostname command returns, or the fully qualified +// hostname, or another name specified by the user. +func HostName(val string) attribute.KeyValue { + return HostNameKey.String(val) +} + +// HostType returns an attribute KeyValue conforming to the "host.type" +// semantic conventions. It represents the type of host. For Cloud, this must +// be the machine type. +func HostType(val string) attribute.KeyValue { + return HostTypeKey.String(val) +} + +// HostImageName returns an attribute KeyValue conforming to the +// "host.image.name" semantic conventions. It represents the name of the VM +// image or OS install the host was instantiated from. +func HostImageName(val string) attribute.KeyValue { + return HostImageNameKey.String(val) +} + +// HostImageID returns an attribute KeyValue conforming to the +// "host.image.id" semantic conventions. It represents the vM image ID. For +// Cloud, this value is from the provider. +func HostImageID(val string) attribute.KeyValue { + return HostImageIDKey.String(val) +} + +// HostImageVersion returns an attribute KeyValue conforming to the +// "host.image.version" semantic conventions. It represents the version string +// of the VM image as defined in [Version +// Attributes](README.md#version-attributes). +func HostImageVersion(val string) attribute.KeyValue { + return HostImageVersionKey.String(val) +} + +// A Kubernetes Cluster. +const ( + // K8SClusterNameKey is the attribute Key conforming to the + // "k8s.cluster.name" semantic conventions. It represents the name of the + // cluster. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry-cluster' + K8SClusterNameKey = attribute.Key("k8s.cluster.name") +) + +// K8SClusterName returns an attribute KeyValue conforming to the +// "k8s.cluster.name" semantic conventions. It represents the name of the +// cluster. +func K8SClusterName(val string) attribute.KeyValue { + return K8SClusterNameKey.String(val) +} + +// A Kubernetes Node object. +const ( + // K8SNodeNameKey is the attribute Key conforming to the "k8s.node.name" + // semantic conventions. It represents the name of the Node. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'node-1' + K8SNodeNameKey = attribute.Key("k8s.node.name") + + // K8SNodeUIDKey is the attribute Key conforming to the "k8s.node.uid" + // semantic conventions. It represents the UID of the Node. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '1eb3a0c6-0477-4080-a9cb-0cb7db65c6a2' + K8SNodeUIDKey = attribute.Key("k8s.node.uid") +) + +// K8SNodeName returns an attribute KeyValue conforming to the +// "k8s.node.name" semantic conventions. It represents the name of the Node. +func K8SNodeName(val string) attribute.KeyValue { + return K8SNodeNameKey.String(val) +} + +// K8SNodeUID returns an attribute KeyValue conforming to the "k8s.node.uid" +// semantic conventions. It represents the UID of the Node. +func K8SNodeUID(val string) attribute.KeyValue { + return K8SNodeUIDKey.String(val) +} + +// A Kubernetes Namespace. +const ( + // K8SNamespaceNameKey is the attribute Key conforming to the + // "k8s.namespace.name" semantic conventions. It represents the name of the + // namespace that the pod is running in. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'default' + K8SNamespaceNameKey = attribute.Key("k8s.namespace.name") +) + +// K8SNamespaceName returns an attribute KeyValue conforming to the +// "k8s.namespace.name" semantic conventions. It represents the name of the +// namespace that the pod is running in. +func K8SNamespaceName(val string) attribute.KeyValue { + return K8SNamespaceNameKey.String(val) +} + +// A Kubernetes Pod object. +const ( + // K8SPodUIDKey is the attribute Key conforming to the "k8s.pod.uid" + // semantic conventions. It represents the UID of the Pod. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SPodUIDKey = attribute.Key("k8s.pod.uid") + + // K8SPodNameKey is the attribute Key conforming to the "k8s.pod.name" + // semantic conventions. It represents the name of the Pod. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry-pod-autoconf' + K8SPodNameKey = attribute.Key("k8s.pod.name") +) + +// K8SPodUID returns an attribute KeyValue conforming to the "k8s.pod.uid" +// semantic conventions. It represents the UID of the Pod. +func K8SPodUID(val string) attribute.KeyValue { + return K8SPodUIDKey.String(val) +} + +// K8SPodName returns an attribute KeyValue conforming to the "k8s.pod.name" +// semantic conventions. It represents the name of the Pod. +func K8SPodName(val string) attribute.KeyValue { + return K8SPodNameKey.String(val) +} + +// A container in a +// [PodTemplate](https://kubernetes.io/docs/concepts/workloads/pods/#pod-templates). +const ( + // K8SContainerNameKey is the attribute Key conforming to the + // "k8s.container.name" semantic conventions. It represents the name of the + // Container from Pod specification, must be unique within a Pod. Container + // runtime usually uses different globally unique name (`container.name`). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'redis' + K8SContainerNameKey = attribute.Key("k8s.container.name") + + // K8SContainerRestartCountKey is the attribute Key conforming to the + // "k8s.container.restart_count" semantic conventions. It represents the + // number of times the container was restarted. This attribute can be used + // to identify a particular container (running or stopped) within a + // container spec. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 0, 2 + K8SContainerRestartCountKey = attribute.Key("k8s.container.restart_count") +) + +// K8SContainerName returns an attribute KeyValue conforming to the +// "k8s.container.name" semantic conventions. It represents the name of the +// Container from Pod specification, must be unique within a Pod. Container +// runtime usually uses different globally unique name (`container.name`). +func K8SContainerName(val string) attribute.KeyValue { + return K8SContainerNameKey.String(val) +} + +// K8SContainerRestartCount returns an attribute KeyValue conforming to the +// "k8s.container.restart_count" semantic conventions. It represents the number +// of times the container was restarted. This attribute can be used to identify +// a particular container (running or stopped) within a container spec. +func K8SContainerRestartCount(val int) attribute.KeyValue { + return K8SContainerRestartCountKey.Int(val) +} + +// A Kubernetes ReplicaSet object. +const ( + // K8SReplicaSetUIDKey is the attribute Key conforming to the + // "k8s.replicaset.uid" semantic conventions. It represents the UID of the + // ReplicaSet. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SReplicaSetUIDKey = attribute.Key("k8s.replicaset.uid") + + // K8SReplicaSetNameKey is the attribute Key conforming to the + // "k8s.replicaset.name" semantic conventions. It represents the name of + // the ReplicaSet. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry' + K8SReplicaSetNameKey = attribute.Key("k8s.replicaset.name") +) + +// K8SReplicaSetUID returns an attribute KeyValue conforming to the +// "k8s.replicaset.uid" semantic conventions. It represents the UID of the +// ReplicaSet. +func K8SReplicaSetUID(val string) attribute.KeyValue { + return K8SReplicaSetUIDKey.String(val) +} + +// K8SReplicaSetName returns an attribute KeyValue conforming to the +// "k8s.replicaset.name" semantic conventions. It represents the name of the +// ReplicaSet. +func K8SReplicaSetName(val string) attribute.KeyValue { + return K8SReplicaSetNameKey.String(val) +} + +// A Kubernetes Deployment object. +const ( + // K8SDeploymentUIDKey is the attribute Key conforming to the + // "k8s.deployment.uid" semantic conventions. It represents the UID of the + // Deployment. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SDeploymentUIDKey = attribute.Key("k8s.deployment.uid") + + // K8SDeploymentNameKey is the attribute Key conforming to the + // "k8s.deployment.name" semantic conventions. It represents the name of + // the Deployment. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry' + K8SDeploymentNameKey = attribute.Key("k8s.deployment.name") +) + +// K8SDeploymentUID returns an attribute KeyValue conforming to the +// "k8s.deployment.uid" semantic conventions. It represents the UID of the +// Deployment. +func K8SDeploymentUID(val string) attribute.KeyValue { + return K8SDeploymentUIDKey.String(val) +} + +// K8SDeploymentName returns an attribute KeyValue conforming to the +// "k8s.deployment.name" semantic conventions. It represents the name of the +// Deployment. +func K8SDeploymentName(val string) attribute.KeyValue { + return K8SDeploymentNameKey.String(val) +} + +// A Kubernetes StatefulSet object. +const ( + // K8SStatefulSetUIDKey is the attribute Key conforming to the + // "k8s.statefulset.uid" semantic conventions. It represents the UID of the + // StatefulSet. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SStatefulSetUIDKey = attribute.Key("k8s.statefulset.uid") + + // K8SStatefulSetNameKey is the attribute Key conforming to the + // "k8s.statefulset.name" semantic conventions. It represents the name of + // the StatefulSet. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry' + K8SStatefulSetNameKey = attribute.Key("k8s.statefulset.name") +) + +// K8SStatefulSetUID returns an attribute KeyValue conforming to the +// "k8s.statefulset.uid" semantic conventions. It represents the UID of the +// StatefulSet. +func K8SStatefulSetUID(val string) attribute.KeyValue { + return K8SStatefulSetUIDKey.String(val) +} + +// K8SStatefulSetName returns an attribute KeyValue conforming to the +// "k8s.statefulset.name" semantic conventions. It represents the name of the +// StatefulSet. +func K8SStatefulSetName(val string) attribute.KeyValue { + return K8SStatefulSetNameKey.String(val) +} + +// A Kubernetes DaemonSet object. +const ( + // K8SDaemonSetUIDKey is the attribute Key conforming to the + // "k8s.daemonset.uid" semantic conventions. It represents the UID of the + // DaemonSet. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SDaemonSetUIDKey = attribute.Key("k8s.daemonset.uid") + + // K8SDaemonSetNameKey is the attribute Key conforming to the + // "k8s.daemonset.name" semantic conventions. It represents the name of the + // DaemonSet. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry' + K8SDaemonSetNameKey = attribute.Key("k8s.daemonset.name") +) + +// K8SDaemonSetUID returns an attribute KeyValue conforming to the +// "k8s.daemonset.uid" semantic conventions. It represents the UID of the +// DaemonSet. +func K8SDaemonSetUID(val string) attribute.KeyValue { + return K8SDaemonSetUIDKey.String(val) +} + +// K8SDaemonSetName returns an attribute KeyValue conforming to the +// "k8s.daemonset.name" semantic conventions. It represents the name of the +// DaemonSet. +func K8SDaemonSetName(val string) attribute.KeyValue { + return K8SDaemonSetNameKey.String(val) +} + +// A Kubernetes Job object. +const ( + // K8SJobUIDKey is the attribute Key conforming to the "k8s.job.uid" + // semantic conventions. It represents the UID of the Job. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SJobUIDKey = attribute.Key("k8s.job.uid") + + // K8SJobNameKey is the attribute Key conforming to the "k8s.job.name" + // semantic conventions. It represents the name of the Job. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry' + K8SJobNameKey = attribute.Key("k8s.job.name") +) + +// K8SJobUID returns an attribute KeyValue conforming to the "k8s.job.uid" +// semantic conventions. It represents the UID of the Job. +func K8SJobUID(val string) attribute.KeyValue { + return K8SJobUIDKey.String(val) +} + +// K8SJobName returns an attribute KeyValue conforming to the "k8s.job.name" +// semantic conventions. It represents the name of the Job. +func K8SJobName(val string) attribute.KeyValue { + return K8SJobNameKey.String(val) +} + +// A Kubernetes CronJob object. +const ( + // K8SCronJobUIDKey is the attribute Key conforming to the + // "k8s.cronjob.uid" semantic conventions. It represents the UID of the + // CronJob. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' + K8SCronJobUIDKey = attribute.Key("k8s.cronjob.uid") + + // K8SCronJobNameKey is the attribute Key conforming to the + // "k8s.cronjob.name" semantic conventions. It represents the name of the + // CronJob. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'opentelemetry' + K8SCronJobNameKey = attribute.Key("k8s.cronjob.name") +) + +// K8SCronJobUID returns an attribute KeyValue conforming to the +// "k8s.cronjob.uid" semantic conventions. It represents the UID of the +// CronJob. +func K8SCronJobUID(val string) attribute.KeyValue { + return K8SCronJobUIDKey.String(val) +} + +// K8SCronJobName returns an attribute KeyValue conforming to the +// "k8s.cronjob.name" semantic conventions. It represents the name of the +// CronJob. +func K8SCronJobName(val string) attribute.KeyValue { + return K8SCronJobNameKey.String(val) +} + +// The operating system (OS) on which the process represented by this resource +// is running. +const ( + // OSTypeKey is the attribute Key conforming to the "os.type" semantic + // conventions. It represents the operating system type. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + OSTypeKey = attribute.Key("os.type") + + // OSDescriptionKey is the attribute Key conforming to the "os.description" + // semantic conventions. It represents the human readable (not intended to + // be parsed) OS version information, like e.g. reported by `ver` or + // `lsb_release -a` commands. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Microsoft Windows [Version 10.0.18363.778]', 'Ubuntu 18.04.1 + // LTS' + OSDescriptionKey = attribute.Key("os.description") + + // OSNameKey is the attribute Key conforming to the "os.name" semantic + // conventions. It represents the human readable operating system name. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'iOS', 'Android', 'Ubuntu' + OSNameKey = attribute.Key("os.name") + + // OSVersionKey is the attribute Key conforming to the "os.version" + // semantic conventions. It represents the version string of the operating + // system as defined in [Version + // Attributes](../../resource/semantic_conventions/README.md#version-attributes). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '14.2.1', '18.04.1' + OSVersionKey = attribute.Key("os.version") +) + +var ( + // Microsoft Windows + OSTypeWindows = OSTypeKey.String("windows") + // Linux + OSTypeLinux = OSTypeKey.String("linux") + // Apple Darwin + OSTypeDarwin = OSTypeKey.String("darwin") + // FreeBSD + OSTypeFreeBSD = OSTypeKey.String("freebsd") + // NetBSD + OSTypeNetBSD = OSTypeKey.String("netbsd") + // OpenBSD + OSTypeOpenBSD = OSTypeKey.String("openbsd") + // DragonFly BSD + OSTypeDragonflyBSD = OSTypeKey.String("dragonflybsd") + // HP-UX (Hewlett Packard Unix) + OSTypeHPUX = OSTypeKey.String("hpux") + // AIX (Advanced Interactive eXecutive) + OSTypeAIX = OSTypeKey.String("aix") + // SunOS, Oracle Solaris + OSTypeSolaris = OSTypeKey.String("solaris") + // IBM z/OS + OSTypeZOS = OSTypeKey.String("z_os") +) + +// OSDescription returns an attribute KeyValue conforming to the +// "os.description" semantic conventions. It represents the human readable (not +// intended to be parsed) OS version information, like e.g. reported by `ver` +// or `lsb_release -a` commands. +func OSDescription(val string) attribute.KeyValue { + return OSDescriptionKey.String(val) +} + +// OSName returns an attribute KeyValue conforming to the "os.name" semantic +// conventions. It represents the human readable operating system name. +func OSName(val string) attribute.KeyValue { + return OSNameKey.String(val) +} + +// OSVersion returns an attribute KeyValue conforming to the "os.version" +// semantic conventions. It represents the version string of the operating +// system as defined in [Version +// Attributes](../../resource/semantic_conventions/README.md#version-attributes). +func OSVersion(val string) attribute.KeyValue { + return OSVersionKey.String(val) +} + +// An operating system process. +const ( + // ProcessPIDKey is the attribute Key conforming to the "process.pid" + // semantic conventions. It represents the process identifier (PID). + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 1234 + ProcessPIDKey = attribute.Key("process.pid") + + // ProcessParentPIDKey is the attribute Key conforming to the + // "process.parent_pid" semantic conventions. It represents the parent + // Process identifier (PID). + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 111 + ProcessParentPIDKey = attribute.Key("process.parent_pid") + + // ProcessExecutableNameKey is the attribute Key conforming to the + // "process.executable.name" semantic conventions. It represents the name + // of the process executable. On Linux based systems, can be set to the + // `Name` in `proc/[pid]/status`. On Windows, can be set to the base name + // of `GetProcessImageFileNameW`. + // + // Type: string + // RequirementLevel: ConditionallyRequired (See alternative attributes + // below.) + // Stability: stable + // Examples: 'otelcol' + ProcessExecutableNameKey = attribute.Key("process.executable.name") + + // ProcessExecutablePathKey is the attribute Key conforming to the + // "process.executable.path" semantic conventions. It represents the full + // path to the process executable. On Linux based systems, can be set to + // the target of `proc/[pid]/exe`. On Windows, can be set to the result of + // `GetProcessImageFileNameW`. + // + // Type: string + // RequirementLevel: ConditionallyRequired (See alternative attributes + // below.) + // Stability: stable + // Examples: '/usr/bin/cmd/otelcol' + ProcessExecutablePathKey = attribute.Key("process.executable.path") + + // ProcessCommandKey is the attribute Key conforming to the + // "process.command" semantic conventions. It represents the command used + // to launch the process (i.e. the command name). On Linux based systems, + // can be set to the zeroth string in `proc/[pid]/cmdline`. On Windows, can + // be set to the first parameter extracted from `GetCommandLineW`. + // + // Type: string + // RequirementLevel: ConditionallyRequired (See alternative attributes + // below.) + // Stability: stable + // Examples: 'cmd/otelcol' + ProcessCommandKey = attribute.Key("process.command") + + // ProcessCommandLineKey is the attribute Key conforming to the + // "process.command_line" semantic conventions. It represents the full + // command used to launch the process as a single string representing the + // full command. On Windows, can be set to the result of `GetCommandLineW`. + // Do not set this if you have to assemble it just for monitoring; use + // `process.command_args` instead. + // + // Type: string + // RequirementLevel: ConditionallyRequired (See alternative attributes + // below.) + // Stability: stable + // Examples: 'C:\\cmd\\otecol --config="my directory\\config.yaml"' + ProcessCommandLineKey = attribute.Key("process.command_line") + + // ProcessCommandArgsKey is the attribute Key conforming to the + // "process.command_args" semantic conventions. It represents the all the + // command arguments (including the command/executable itself) as received + // by the process. On Linux-based systems (and some other Unixoid systems + // supporting procfs), can be set according to the list of null-delimited + // strings extracted from `proc/[pid]/cmdline`. For libc-based executables, + // this would be the full argv vector passed to `main`. + // + // Type: string[] + // RequirementLevel: ConditionallyRequired (See alternative attributes + // below.) + // Stability: stable + // Examples: 'cmd/otecol', '--config=config.yaml' + ProcessCommandArgsKey = attribute.Key("process.command_args") + + // ProcessOwnerKey is the attribute Key conforming to the "process.owner" + // semantic conventions. It represents the username of the user that owns + // the process. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'root' + ProcessOwnerKey = attribute.Key("process.owner") +) + +// ProcessPID returns an attribute KeyValue conforming to the "process.pid" +// semantic conventions. It represents the process identifier (PID). +func ProcessPID(val int) attribute.KeyValue { + return ProcessPIDKey.Int(val) +} + +// ProcessParentPID returns an attribute KeyValue conforming to the +// "process.parent_pid" semantic conventions. It represents the parent Process +// identifier (PID). +func ProcessParentPID(val int) attribute.KeyValue { + return ProcessParentPIDKey.Int(val) +} + +// ProcessExecutableName returns an attribute KeyValue conforming to the +// "process.executable.name" semantic conventions. It represents the name of +// the process executable. On Linux based systems, can be set to the `Name` in +// `proc/[pid]/status`. On Windows, can be set to the base name of +// `GetProcessImageFileNameW`. +func ProcessExecutableName(val string) attribute.KeyValue { + return ProcessExecutableNameKey.String(val) +} + +// ProcessExecutablePath returns an attribute KeyValue conforming to the +// "process.executable.path" semantic conventions. It represents the full path +// to the process executable. On Linux based systems, can be set to the target +// of `proc/[pid]/exe`. On Windows, can be set to the result of +// `GetProcessImageFileNameW`. +func ProcessExecutablePath(val string) attribute.KeyValue { + return ProcessExecutablePathKey.String(val) +} + +// ProcessCommand returns an attribute KeyValue conforming to the +// "process.command" semantic conventions. It represents the command used to +// launch the process (i.e. the command name). On Linux based systems, can be +// set to the zeroth string in `proc/[pid]/cmdline`. On Windows, can be set to +// the first parameter extracted from `GetCommandLineW`. +func ProcessCommand(val string) attribute.KeyValue { + return ProcessCommandKey.String(val) +} + +// ProcessCommandLine returns an attribute KeyValue conforming to the +// "process.command_line" semantic conventions. It represents the full command +// used to launch the process as a single string representing the full command. +// On Windows, can be set to the result of `GetCommandLineW`. Do not set this +// if you have to assemble it just for monitoring; use `process.command_args` +// instead. +func ProcessCommandLine(val string) attribute.KeyValue { + return ProcessCommandLineKey.String(val) +} + +// ProcessCommandArgs returns an attribute KeyValue conforming to the +// "process.command_args" semantic conventions. It represents the all the +// command arguments (including the command/executable itself) as received by +// the process. On Linux-based systems (and some other Unixoid systems +// supporting procfs), can be set according to the list of null-delimited +// strings extracted from `proc/[pid]/cmdline`. For libc-based executables, +// this would be the full argv vector passed to `main`. +func ProcessCommandArgs(val ...string) attribute.KeyValue { + return ProcessCommandArgsKey.StringSlice(val) +} + +// ProcessOwner returns an attribute KeyValue conforming to the +// "process.owner" semantic conventions. It represents the username of the user +// that owns the process. +func ProcessOwner(val string) attribute.KeyValue { + return ProcessOwnerKey.String(val) +} + +// The single (language) runtime instance which is monitored. +const ( + // ProcessRuntimeNameKey is the attribute Key conforming to the + // "process.runtime.name" semantic conventions. It represents the name of + // the runtime of this process. For compiled native binaries, this SHOULD + // be the name of the compiler. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'OpenJDK Runtime Environment' + ProcessRuntimeNameKey = attribute.Key("process.runtime.name") + + // ProcessRuntimeVersionKey is the attribute Key conforming to the + // "process.runtime.version" semantic conventions. It represents the + // version of the runtime of this process, as returned by the runtime + // without modification. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '14.0.2' + ProcessRuntimeVersionKey = attribute.Key("process.runtime.version") + + // ProcessRuntimeDescriptionKey is the attribute Key conforming to the + // "process.runtime.description" semantic conventions. It represents an + // additional description about the runtime of the process, for example a + // specific vendor customization of the runtime environment. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Eclipse OpenJ9 Eclipse OpenJ9 VM openj9-0.21.0' + ProcessRuntimeDescriptionKey = attribute.Key("process.runtime.description") +) + +// ProcessRuntimeName returns an attribute KeyValue conforming to the +// "process.runtime.name" semantic conventions. It represents the name of the +// runtime of this process. For compiled native binaries, this SHOULD be the +// name of the compiler. +func ProcessRuntimeName(val string) attribute.KeyValue { + return ProcessRuntimeNameKey.String(val) +} + +// ProcessRuntimeVersion returns an attribute KeyValue conforming to the +// "process.runtime.version" semantic conventions. It represents the version of +// the runtime of this process, as returned by the runtime without +// modification. +func ProcessRuntimeVersion(val string) attribute.KeyValue { + return ProcessRuntimeVersionKey.String(val) +} + +// ProcessRuntimeDescription returns an attribute KeyValue conforming to the +// "process.runtime.description" semantic conventions. It represents an +// additional description about the runtime of the process, for example a +// specific vendor customization of the runtime environment. +func ProcessRuntimeDescription(val string) attribute.KeyValue { + return ProcessRuntimeDescriptionKey.String(val) +} + +// A service instance. +const ( + // ServiceNameKey is the attribute Key conforming to the "service.name" + // semantic conventions. It represents the logical name of the service. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'shoppingcart' + // Note: MUST be the same for all instances of horizontally scaled + // services. If the value was not specified, SDKs MUST fallback to + // `unknown_service:` concatenated with + // [`process.executable.name`](process.md#process), e.g. + // `unknown_service:bash`. If `process.executable.name` is not available, + // the value MUST be set to `unknown_service`. + ServiceNameKey = attribute.Key("service.name") +) + +// ServiceName returns an attribute KeyValue conforming to the +// "service.name" semantic conventions. It represents the logical name of the +// service. +func ServiceName(val string) attribute.KeyValue { + return ServiceNameKey.String(val) +} + +// A service instance. +const ( + // ServiceNamespaceKey is the attribute Key conforming to the + // "service.namespace" semantic conventions. It represents a namespace for + // `service.name`. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Shop' + // Note: A string value having a meaning that helps to distinguish a group + // of services, for example the team name that owns a group of services. + // `service.name` is expected to be unique within the same namespace. If + // `service.namespace` is not specified in the Resource then `service.name` + // is expected to be unique for all services that have no explicit + // namespace defined (so the empty/unspecified namespace is simply one more + // valid namespace). Zero-length namespace string is assumed equal to + // unspecified namespace. + ServiceNamespaceKey = attribute.Key("service.namespace") + + // ServiceInstanceIDKey is the attribute Key conforming to the + // "service.instance.id" semantic conventions. It represents the string ID + // of the service instance. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'my-k8s-pod-deployment-1', + // '627cc493-f310-47de-96bd-71410b7dec09' + // Note: MUST be unique for each instance of the same + // `service.namespace,service.name` pair (in other words + // `service.namespace,service.name,service.instance.id` triplet MUST be + // globally unique). The ID helps to distinguish instances of the same + // service that exist at the same time (e.g. instances of a horizontally + // scaled service). It is preferable for the ID to be persistent and stay + // the same for the lifetime of the service instance, however it is + // acceptable that the ID is ephemeral and changes during important + // lifetime events for the service (e.g. service restarts). If the service + // has no inherent unique ID that can be used as the value of this + // attribute it is recommended to generate a random Version 1 or Version 4 + // RFC 4122 UUID (services aiming for reproducible UUIDs may also use + // Version 5, see RFC 4122 for more recommendations). + ServiceInstanceIDKey = attribute.Key("service.instance.id") + + // ServiceVersionKey is the attribute Key conforming to the + // "service.version" semantic conventions. It represents the version string + // of the service API or implementation. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '2.0.0' + ServiceVersionKey = attribute.Key("service.version") +) + +// ServiceNamespace returns an attribute KeyValue conforming to the +// "service.namespace" semantic conventions. It represents a namespace for +// `service.name`. +func ServiceNamespace(val string) attribute.KeyValue { + return ServiceNamespaceKey.String(val) +} + +// ServiceInstanceID returns an attribute KeyValue conforming to the +// "service.instance.id" semantic conventions. It represents the string ID of +// the service instance. +func ServiceInstanceID(val string) attribute.KeyValue { + return ServiceInstanceIDKey.String(val) +} + +// ServiceVersion returns an attribute KeyValue conforming to the +// "service.version" semantic conventions. It represents the version string of +// the service API or implementation. +func ServiceVersion(val string) attribute.KeyValue { + return ServiceVersionKey.String(val) +} + +// The telemetry SDK used to capture data recorded by the instrumentation +// libraries. +const ( + // TelemetrySDKNameKey is the attribute Key conforming to the + // "telemetry.sdk.name" semantic conventions. It represents the name of the + // telemetry SDK as defined above. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'opentelemetry' + TelemetrySDKNameKey = attribute.Key("telemetry.sdk.name") + + // TelemetrySDKLanguageKey is the attribute Key conforming to the + // "telemetry.sdk.language" semantic conventions. It represents the + // language of the telemetry SDK. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + TelemetrySDKLanguageKey = attribute.Key("telemetry.sdk.language") + + // TelemetrySDKVersionKey is the attribute Key conforming to the + // "telemetry.sdk.version" semantic conventions. It represents the version + // string of the telemetry SDK. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: '1.2.3' + TelemetrySDKVersionKey = attribute.Key("telemetry.sdk.version") +) + +var ( + // cpp + TelemetrySDKLanguageCPP = TelemetrySDKLanguageKey.String("cpp") + // dotnet + TelemetrySDKLanguageDotnet = TelemetrySDKLanguageKey.String("dotnet") + // erlang + TelemetrySDKLanguageErlang = TelemetrySDKLanguageKey.String("erlang") + // go + TelemetrySDKLanguageGo = TelemetrySDKLanguageKey.String("go") + // java + TelemetrySDKLanguageJava = TelemetrySDKLanguageKey.String("java") + // nodejs + TelemetrySDKLanguageNodejs = TelemetrySDKLanguageKey.String("nodejs") + // php + TelemetrySDKLanguagePHP = TelemetrySDKLanguageKey.String("php") + // python + TelemetrySDKLanguagePython = TelemetrySDKLanguageKey.String("python") + // ruby + TelemetrySDKLanguageRuby = TelemetrySDKLanguageKey.String("ruby") + // webjs + TelemetrySDKLanguageWebjs = TelemetrySDKLanguageKey.String("webjs") + // swift + TelemetrySDKLanguageSwift = TelemetrySDKLanguageKey.String("swift") +) + +// TelemetrySDKName returns an attribute KeyValue conforming to the +// "telemetry.sdk.name" semantic conventions. It represents the name of the +// telemetry SDK as defined above. +func TelemetrySDKName(val string) attribute.KeyValue { + return TelemetrySDKNameKey.String(val) +} + +// TelemetrySDKVersion returns an attribute KeyValue conforming to the +// "telemetry.sdk.version" semantic conventions. It represents the version +// string of the telemetry SDK. +func TelemetrySDKVersion(val string) attribute.KeyValue { + return TelemetrySDKVersionKey.String(val) +} + +// The telemetry SDK used to capture data recorded by the instrumentation +// libraries. +const ( + // TelemetryAutoVersionKey is the attribute Key conforming to the + // "telemetry.auto.version" semantic conventions. It represents the version + // string of the auto instrumentation agent, if used. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '1.2.3' + TelemetryAutoVersionKey = attribute.Key("telemetry.auto.version") +) + +// TelemetryAutoVersion returns an attribute KeyValue conforming to the +// "telemetry.auto.version" semantic conventions. It represents the version +// string of the auto instrumentation agent, if used. +func TelemetryAutoVersion(val string) attribute.KeyValue { + return TelemetryAutoVersionKey.String(val) +} + +// Resource describing the packaged software running the application code. Web +// engines are typically executed using process.runtime. +const ( + // WebEngineNameKey is the attribute Key conforming to the "webengine.name" + // semantic conventions. It represents the name of the web engine. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'WildFly' + WebEngineNameKey = attribute.Key("webengine.name") + + // WebEngineVersionKey is the attribute Key conforming to the + // "webengine.version" semantic conventions. It represents the version of + // the web engine. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '21.0.0' + WebEngineVersionKey = attribute.Key("webengine.version") + + // WebEngineDescriptionKey is the attribute Key conforming to the + // "webengine.description" semantic conventions. It represents the + // additional description of the web engine (e.g. detailed version and + // edition information). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'WildFly Full 21.0.0.Final (WildFly Core 13.0.1.Final) - + // 2.2.2.Final' + WebEngineDescriptionKey = attribute.Key("webengine.description") +) + +// WebEngineName returns an attribute KeyValue conforming to the +// "webengine.name" semantic conventions. It represents the name of the web +// engine. +func WebEngineName(val string) attribute.KeyValue { + return WebEngineNameKey.String(val) +} + +// WebEngineVersion returns an attribute KeyValue conforming to the +// "webengine.version" semantic conventions. It represents the version of the +// web engine. +func WebEngineVersion(val string) attribute.KeyValue { + return WebEngineVersionKey.String(val) +} + +// WebEngineDescription returns an attribute KeyValue conforming to the +// "webengine.description" semantic conventions. It represents the additional +// description of the web engine (e.g. detailed version and edition +// information). +func WebEngineDescription(val string) attribute.KeyValue { + return WebEngineDescriptionKey.String(val) +} + +// Attributes used by non-OTLP exporters to represent OpenTelemetry Scope's +// concepts. +const ( + // OTelScopeNameKey is the attribute Key conforming to the + // "otel.scope.name" semantic conventions. It represents the name of the + // instrumentation scope - (`InstrumentationScope.Name` in OTLP). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'io.opentelemetry.contrib.mongodb' + OTelScopeNameKey = attribute.Key("otel.scope.name") + + // OTelScopeVersionKey is the attribute Key conforming to the + // "otel.scope.version" semantic conventions. It represents the version of + // the instrumentation scope - (`InstrumentationScope.Version` in OTLP). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '1.0.0' + OTelScopeVersionKey = attribute.Key("otel.scope.version") +) + +// OTelScopeName returns an attribute KeyValue conforming to the +// "otel.scope.name" semantic conventions. It represents the name of the +// instrumentation scope - (`InstrumentationScope.Name` in OTLP). +func OTelScopeName(val string) attribute.KeyValue { + return OTelScopeNameKey.String(val) +} + +// OTelScopeVersion returns an attribute KeyValue conforming to the +// "otel.scope.version" semantic conventions. It represents the version of the +// instrumentation scope - (`InstrumentationScope.Version` in OTLP). +func OTelScopeVersion(val string) attribute.KeyValue { + return OTelScopeVersionKey.String(val) +} + +// Span attributes used by non-OTLP exporters to represent OpenTelemetry +// Scope's concepts. +const ( + // OTelLibraryNameKey is the attribute Key conforming to the + // "otel.library.name" semantic conventions. It represents the deprecated, + // use the `otel.scope.name` attribute. + // + // Type: string + // RequirementLevel: Optional + // Stability: deprecated + // Examples: 'io.opentelemetry.contrib.mongodb' + OTelLibraryNameKey = attribute.Key("otel.library.name") + + // OTelLibraryVersionKey is the attribute Key conforming to the + // "otel.library.version" semantic conventions. It represents the + // deprecated, use the `otel.scope.version` attribute. + // + // Type: string + // RequirementLevel: Optional + // Stability: deprecated + // Examples: '1.0.0' + OTelLibraryVersionKey = attribute.Key("otel.library.version") +) + +// OTelLibraryName returns an attribute KeyValue conforming to the +// "otel.library.name" semantic conventions. It represents the deprecated, use +// the `otel.scope.name` attribute. +func OTelLibraryName(val string) attribute.KeyValue { + return OTelLibraryNameKey.String(val) +} + +// OTelLibraryVersion returns an attribute KeyValue conforming to the +// "otel.library.version" semantic conventions. It represents the deprecated, +// use the `otel.scope.version` attribute. +func OTelLibraryVersion(val string) attribute.KeyValue { + return OTelLibraryVersionKey.String(val) +} diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/schema.go b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/schema.go new file mode 100644 index 000000000..e449e5c3b --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/schema.go @@ -0,0 +1,20 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.20.0" + +// SchemaURL is the schema URL that matches the version of the semantic conventions +// that this package defines. Semconv packages starting from v1.4.0 must declare +// non-empty schema URL in the form https://opentelemetry.io/schemas/ +const SchemaURL = "https://opentelemetry.io/schemas/1.20.0" diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/trace.go b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/trace.go new file mode 100644 index 000000000..851774148 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/trace.go @@ -0,0 +1,2610 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated from semantic convention specification. DO NOT EDIT. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.20.0" + +import "go.opentelemetry.io/otel/attribute" + +// The shared attributes used to report a single exception associated with a +// span or log. +const ( + // ExceptionTypeKey is the attribute Key conforming to the "exception.type" + // semantic conventions. It represents the type of the exception (its + // fully-qualified class name, if applicable). The dynamic type of the + // exception should be preferred over the static type in languages that + // support it. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'java.net.ConnectException', 'OSError' + ExceptionTypeKey = attribute.Key("exception.type") + + // ExceptionMessageKey is the attribute Key conforming to the + // "exception.message" semantic conventions. It represents the exception + // message. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Division by zero', "Can't convert 'int' object to str + // implicitly" + ExceptionMessageKey = attribute.Key("exception.message") + + // ExceptionStacktraceKey is the attribute Key conforming to the + // "exception.stacktrace" semantic conventions. It represents a stacktrace + // as a string in the natural representation for the language runtime. The + // representation is to be determined and documented by each language SIG. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Exception in thread "main" java.lang.RuntimeException: Test + // exception\\n at ' + // 'com.example.GenerateTrace.methodB(GenerateTrace.java:13)\\n at ' + // 'com.example.GenerateTrace.methodA(GenerateTrace.java:9)\\n at ' + // 'com.example.GenerateTrace.main(GenerateTrace.java:5)' + ExceptionStacktraceKey = attribute.Key("exception.stacktrace") +) + +// ExceptionType returns an attribute KeyValue conforming to the +// "exception.type" semantic conventions. It represents the type of the +// exception (its fully-qualified class name, if applicable). The dynamic type +// of the exception should be preferred over the static type in languages that +// support it. +func ExceptionType(val string) attribute.KeyValue { + return ExceptionTypeKey.String(val) +} + +// ExceptionMessage returns an attribute KeyValue conforming to the +// "exception.message" semantic conventions. It represents the exception +// message. +func ExceptionMessage(val string) attribute.KeyValue { + return ExceptionMessageKey.String(val) +} + +// ExceptionStacktrace returns an attribute KeyValue conforming to the +// "exception.stacktrace" semantic conventions. It represents a stacktrace as a +// string in the natural representation for the language runtime. The +// representation is to be determined and documented by each language SIG. +func ExceptionStacktrace(val string) attribute.KeyValue { + return ExceptionStacktraceKey.String(val) +} + +// The attributes described in this section are rather generic. They may be +// used in any Log Record they apply to. +const ( + // LogRecordUIDKey is the attribute Key conforming to the "log.record.uid" + // semantic conventions. It represents a unique identifier for the Log + // Record. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '01ARZ3NDEKTSV4RRFFQ69G5FAV' + // Note: If an id is provided, other log records with the same id will be + // considered duplicates and can be removed safely. This means, that two + // distinguishable log records MUST have different values. + // The id MAY be an [Universally Unique Lexicographically Sortable + // Identifier (ULID)](https://github.com/ulid/spec), but other identifiers + // (e.g. UUID) may be used as needed. + LogRecordUIDKey = attribute.Key("log.record.uid") +) + +// LogRecordUID returns an attribute KeyValue conforming to the +// "log.record.uid" semantic conventions. It represents a unique identifier for +// the Log Record. +func LogRecordUID(val string) attribute.KeyValue { + return LogRecordUIDKey.String(val) +} + +// Span attributes used by AWS Lambda (in addition to general `faas` +// attributes). +const ( + // AWSLambdaInvokedARNKey is the attribute Key conforming to the + // "aws.lambda.invoked_arn" semantic conventions. It represents the full + // invoked ARN as provided on the `Context` passed to the function + // (`Lambda-Runtime-Invoked-Function-ARN` header on the + // `/runtime/invocation/next` applicable). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'arn:aws:lambda:us-east-1:123456:function:myfunction:myalias' + // Note: This may be different from `cloud.resource_id` if an alias is + // involved. + AWSLambdaInvokedARNKey = attribute.Key("aws.lambda.invoked_arn") +) + +// AWSLambdaInvokedARN returns an attribute KeyValue conforming to the +// "aws.lambda.invoked_arn" semantic conventions. It represents the full +// invoked ARN as provided on the `Context` passed to the function +// (`Lambda-Runtime-Invoked-Function-ARN` header on the +// `/runtime/invocation/next` applicable). +func AWSLambdaInvokedARN(val string) attribute.KeyValue { + return AWSLambdaInvokedARNKey.String(val) +} + +// Attributes for CloudEvents. CloudEvents is a specification on how to define +// event data in a standard way. These attributes can be attached to spans when +// performing operations with CloudEvents, regardless of the protocol being +// used. +const ( + // CloudeventsEventIDKey is the attribute Key conforming to the + // "cloudevents.event_id" semantic conventions. It represents the + // [event_id](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#id) + // uniquely identifies the event. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: '123e4567-e89b-12d3-a456-426614174000', '0001' + CloudeventsEventIDKey = attribute.Key("cloudevents.event_id") + + // CloudeventsEventSourceKey is the attribute Key conforming to the + // "cloudevents.event_source" semantic conventions. It represents the + // [source](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#source-1) + // identifies the context in which an event happened. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'https://github.com/cloudevents', + // '/cloudevents/spec/pull/123', 'my-service' + CloudeventsEventSourceKey = attribute.Key("cloudevents.event_source") + + // CloudeventsEventSpecVersionKey is the attribute Key conforming to the + // "cloudevents.event_spec_version" semantic conventions. It represents the + // [version of the CloudEvents + // specification](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#specversion) + // which the event uses. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '1.0' + CloudeventsEventSpecVersionKey = attribute.Key("cloudevents.event_spec_version") + + // CloudeventsEventTypeKey is the attribute Key conforming to the + // "cloudevents.event_type" semantic conventions. It represents the + // [event_type](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#type) + // contains a value describing the type of event related to the originating + // occurrence. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'com.github.pull_request.opened', + // 'com.example.object.deleted.v2' + CloudeventsEventTypeKey = attribute.Key("cloudevents.event_type") + + // CloudeventsEventSubjectKey is the attribute Key conforming to the + // "cloudevents.event_subject" semantic conventions. It represents the + // [subject](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#subject) + // of the event in the context of the event producer (identified by + // source). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'mynewfile.jpg' + CloudeventsEventSubjectKey = attribute.Key("cloudevents.event_subject") +) + +// CloudeventsEventID returns an attribute KeyValue conforming to the +// "cloudevents.event_id" semantic conventions. It represents the +// [event_id](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#id) +// uniquely identifies the event. +func CloudeventsEventID(val string) attribute.KeyValue { + return CloudeventsEventIDKey.String(val) +} + +// CloudeventsEventSource returns an attribute KeyValue conforming to the +// "cloudevents.event_source" semantic conventions. It represents the +// [source](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#source-1) +// identifies the context in which an event happened. +func CloudeventsEventSource(val string) attribute.KeyValue { + return CloudeventsEventSourceKey.String(val) +} + +// CloudeventsEventSpecVersion returns an attribute KeyValue conforming to +// the "cloudevents.event_spec_version" semantic conventions. It represents the +// [version of the CloudEvents +// specification](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#specversion) +// which the event uses. +func CloudeventsEventSpecVersion(val string) attribute.KeyValue { + return CloudeventsEventSpecVersionKey.String(val) +} + +// CloudeventsEventType returns an attribute KeyValue conforming to the +// "cloudevents.event_type" semantic conventions. It represents the +// [event_type](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#type) +// contains a value describing the type of event related to the originating +// occurrence. +func CloudeventsEventType(val string) attribute.KeyValue { + return CloudeventsEventTypeKey.String(val) +} + +// CloudeventsEventSubject returns an attribute KeyValue conforming to the +// "cloudevents.event_subject" semantic conventions. It represents the +// [subject](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#subject) +// of the event in the context of the event producer (identified by source). +func CloudeventsEventSubject(val string) attribute.KeyValue { + return CloudeventsEventSubjectKey.String(val) +} + +// Semantic conventions for the OpenTracing Shim +const ( + // OpentracingRefTypeKey is the attribute Key conforming to the + // "opentracing.ref_type" semantic conventions. It represents the + // parent-child Reference type + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + // Note: The causal relationship between a child Span and a parent Span. + OpentracingRefTypeKey = attribute.Key("opentracing.ref_type") +) + +var ( + // The parent Span depends on the child Span in some capacity + OpentracingRefTypeChildOf = OpentracingRefTypeKey.String("child_of") + // The parent Span does not depend in any way on the result of the child Span + OpentracingRefTypeFollowsFrom = OpentracingRefTypeKey.String("follows_from") +) + +// The attributes used to perform database client calls. +const ( + // DBSystemKey is the attribute Key conforming to the "db.system" semantic + // conventions. It represents an identifier for the database management + // system (DBMS) product being used. See below for a list of well-known + // identifiers. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + DBSystemKey = attribute.Key("db.system") + + // DBConnectionStringKey is the attribute Key conforming to the + // "db.connection_string" semantic conventions. It represents the + // connection string used to connect to the database. It is recommended to + // remove embedded credentials. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Server=(localdb)\\v11.0;Integrated Security=true;' + DBConnectionStringKey = attribute.Key("db.connection_string") + + // DBUserKey is the attribute Key conforming to the "db.user" semantic + // conventions. It represents the username for accessing the database. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'readonly_user', 'reporting_user' + DBUserKey = attribute.Key("db.user") + + // DBJDBCDriverClassnameKey is the attribute Key conforming to the + // "db.jdbc.driver_classname" semantic conventions. It represents the + // fully-qualified class name of the [Java Database Connectivity + // (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) + // driver used to connect. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'org.postgresql.Driver', + // 'com.microsoft.sqlserver.jdbc.SQLServerDriver' + DBJDBCDriverClassnameKey = attribute.Key("db.jdbc.driver_classname") + + // DBNameKey is the attribute Key conforming to the "db.name" semantic + // conventions. It represents the this attribute is used to report the name + // of the database being accessed. For commands that switch the database, + // this should be set to the target database (even if the command fails). + // + // Type: string + // RequirementLevel: ConditionallyRequired (If applicable.) + // Stability: stable + // Examples: 'customers', 'main' + // Note: In some SQL databases, the database name to be used is called + // "schema name". In case there are multiple layers that could be + // considered for database name (e.g. Oracle instance name and schema + // name), the database name to be used is the more specific layer (e.g. + // Oracle schema name). + DBNameKey = attribute.Key("db.name") + + // DBStatementKey is the attribute Key conforming to the "db.statement" + // semantic conventions. It represents the database statement being + // executed. + // + // Type: string + // RequirementLevel: Recommended (Should be collected by default only if + // there is sanitization that excludes sensitive information.) + // Stability: stable + // Examples: 'SELECT * FROM wuser_table', 'SET mykey "WuValue"' + DBStatementKey = attribute.Key("db.statement") + + // DBOperationKey is the attribute Key conforming to the "db.operation" + // semantic conventions. It represents the name of the operation being + // executed, e.g. the [MongoDB command + // name](https://docs.mongodb.com/manual/reference/command/#database-operations) + // such as `findAndModify`, or the SQL keyword. + // + // Type: string + // RequirementLevel: ConditionallyRequired (If `db.statement` is not + // applicable.) + // Stability: stable + // Examples: 'findAndModify', 'HMSET', 'SELECT' + // Note: When setting this to an SQL keyword, it is not recommended to + // attempt any client-side parsing of `db.statement` just to get this + // property, but it should be set if the operation name is provided by the + // library being instrumented. If the SQL statement has an ambiguous + // operation, or performs more than one operation, this value may be + // omitted. + DBOperationKey = attribute.Key("db.operation") +) + +var ( + // Some other SQL database. Fallback only. See notes + DBSystemOtherSQL = DBSystemKey.String("other_sql") + // Microsoft SQL Server + DBSystemMSSQL = DBSystemKey.String("mssql") + // Microsoft SQL Server Compact + DBSystemMssqlcompact = DBSystemKey.String("mssqlcompact") + // MySQL + DBSystemMySQL = DBSystemKey.String("mysql") + // Oracle Database + DBSystemOracle = DBSystemKey.String("oracle") + // IBM DB2 + DBSystemDB2 = DBSystemKey.String("db2") + // PostgreSQL + DBSystemPostgreSQL = DBSystemKey.String("postgresql") + // Amazon Redshift + DBSystemRedshift = DBSystemKey.String("redshift") + // Apache Hive + DBSystemHive = DBSystemKey.String("hive") + // Cloudscape + DBSystemCloudscape = DBSystemKey.String("cloudscape") + // HyperSQL DataBase + DBSystemHSQLDB = DBSystemKey.String("hsqldb") + // Progress Database + DBSystemProgress = DBSystemKey.String("progress") + // SAP MaxDB + DBSystemMaxDB = DBSystemKey.String("maxdb") + // SAP HANA + DBSystemHanaDB = DBSystemKey.String("hanadb") + // Ingres + DBSystemIngres = DBSystemKey.String("ingres") + // FirstSQL + DBSystemFirstSQL = DBSystemKey.String("firstsql") + // EnterpriseDB + DBSystemEDB = DBSystemKey.String("edb") + // InterSystems Caché + DBSystemCache = DBSystemKey.String("cache") + // Adabas (Adaptable Database System) + DBSystemAdabas = DBSystemKey.String("adabas") + // Firebird + DBSystemFirebird = DBSystemKey.String("firebird") + // Apache Derby + DBSystemDerby = DBSystemKey.String("derby") + // FileMaker + DBSystemFilemaker = DBSystemKey.String("filemaker") + // Informix + DBSystemInformix = DBSystemKey.String("informix") + // InstantDB + DBSystemInstantDB = DBSystemKey.String("instantdb") + // InterBase + DBSystemInterbase = DBSystemKey.String("interbase") + // MariaDB + DBSystemMariaDB = DBSystemKey.String("mariadb") + // Netezza + DBSystemNetezza = DBSystemKey.String("netezza") + // Pervasive PSQL + DBSystemPervasive = DBSystemKey.String("pervasive") + // PointBase + DBSystemPointbase = DBSystemKey.String("pointbase") + // SQLite + DBSystemSqlite = DBSystemKey.String("sqlite") + // Sybase + DBSystemSybase = DBSystemKey.String("sybase") + // Teradata + DBSystemTeradata = DBSystemKey.String("teradata") + // Vertica + DBSystemVertica = DBSystemKey.String("vertica") + // H2 + DBSystemH2 = DBSystemKey.String("h2") + // ColdFusion IMQ + DBSystemColdfusion = DBSystemKey.String("coldfusion") + // Apache Cassandra + DBSystemCassandra = DBSystemKey.String("cassandra") + // Apache HBase + DBSystemHBase = DBSystemKey.String("hbase") + // MongoDB + DBSystemMongoDB = DBSystemKey.String("mongodb") + // Redis + DBSystemRedis = DBSystemKey.String("redis") + // Couchbase + DBSystemCouchbase = DBSystemKey.String("couchbase") + // CouchDB + DBSystemCouchDB = DBSystemKey.String("couchdb") + // Microsoft Azure Cosmos DB + DBSystemCosmosDB = DBSystemKey.String("cosmosdb") + // Amazon DynamoDB + DBSystemDynamoDB = DBSystemKey.String("dynamodb") + // Neo4j + DBSystemNeo4j = DBSystemKey.String("neo4j") + // Apache Geode + DBSystemGeode = DBSystemKey.String("geode") + // Elasticsearch + DBSystemElasticsearch = DBSystemKey.String("elasticsearch") + // Memcached + DBSystemMemcached = DBSystemKey.String("memcached") + // CockroachDB + DBSystemCockroachdb = DBSystemKey.String("cockroachdb") + // OpenSearch + DBSystemOpensearch = DBSystemKey.String("opensearch") + // ClickHouse + DBSystemClickhouse = DBSystemKey.String("clickhouse") + // Cloud Spanner + DBSystemSpanner = DBSystemKey.String("spanner") + // Trino + DBSystemTrino = DBSystemKey.String("trino") +) + +// DBConnectionString returns an attribute KeyValue conforming to the +// "db.connection_string" semantic conventions. It represents the connection +// string used to connect to the database. It is recommended to remove embedded +// credentials. +func DBConnectionString(val string) attribute.KeyValue { + return DBConnectionStringKey.String(val) +} + +// DBUser returns an attribute KeyValue conforming to the "db.user" semantic +// conventions. It represents the username for accessing the database. +func DBUser(val string) attribute.KeyValue { + return DBUserKey.String(val) +} + +// DBJDBCDriverClassname returns an attribute KeyValue conforming to the +// "db.jdbc.driver_classname" semantic conventions. It represents the +// fully-qualified class name of the [Java Database Connectivity +// (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver +// used to connect. +func DBJDBCDriverClassname(val string) attribute.KeyValue { + return DBJDBCDriverClassnameKey.String(val) +} + +// DBName returns an attribute KeyValue conforming to the "db.name" semantic +// conventions. It represents the this attribute is used to report the name of +// the database being accessed. For commands that switch the database, this +// should be set to the target database (even if the command fails). +func DBName(val string) attribute.KeyValue { + return DBNameKey.String(val) +} + +// DBStatement returns an attribute KeyValue conforming to the +// "db.statement" semantic conventions. It represents the database statement +// being executed. +func DBStatement(val string) attribute.KeyValue { + return DBStatementKey.String(val) +} + +// DBOperation returns an attribute KeyValue conforming to the +// "db.operation" semantic conventions. It represents the name of the operation +// being executed, e.g. the [MongoDB command +// name](https://docs.mongodb.com/manual/reference/command/#database-operations) +// such as `findAndModify`, or the SQL keyword. +func DBOperation(val string) attribute.KeyValue { + return DBOperationKey.String(val) +} + +// Connection-level attributes for Microsoft SQL Server +const ( + // DBMSSQLInstanceNameKey is the attribute Key conforming to the + // "db.mssql.instance_name" semantic conventions. It represents the + // Microsoft SQL Server [instance + // name](https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15) + // connecting to. This name is used to determine the port of a named + // instance. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'MSSQLSERVER' + // Note: If setting a `db.mssql.instance_name`, `net.peer.port` is no + // longer required (but still recommended if non-standard). + DBMSSQLInstanceNameKey = attribute.Key("db.mssql.instance_name") +) + +// DBMSSQLInstanceName returns an attribute KeyValue conforming to the +// "db.mssql.instance_name" semantic conventions. It represents the Microsoft +// SQL Server [instance +// name](https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15) +// connecting to. This name is used to determine the port of a named instance. +func DBMSSQLInstanceName(val string) attribute.KeyValue { + return DBMSSQLInstanceNameKey.String(val) +} + +// Call-level attributes for Cassandra +const ( + // DBCassandraPageSizeKey is the attribute Key conforming to the + // "db.cassandra.page_size" semantic conventions. It represents the fetch + // size used for paging, i.e. how many rows will be returned at once. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 5000 + DBCassandraPageSizeKey = attribute.Key("db.cassandra.page_size") + + // DBCassandraConsistencyLevelKey is the attribute Key conforming to the + // "db.cassandra.consistency_level" semantic conventions. It represents the + // consistency level of the query. Based on consistency values from + // [CQL](https://docs.datastax.com/en/cassandra-oss/3.0/cassandra/dml/dmlConfigConsistency.html). + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + DBCassandraConsistencyLevelKey = attribute.Key("db.cassandra.consistency_level") + + // DBCassandraTableKey is the attribute Key conforming to the + // "db.cassandra.table" semantic conventions. It represents the name of the + // primary table that the operation is acting upon, including the keyspace + // name (if applicable). + // + // Type: string + // RequirementLevel: Recommended + // Stability: stable + // Examples: 'mytable' + // Note: This mirrors the db.sql.table attribute but references cassandra + // rather than sql. It is not recommended to attempt any client-side + // parsing of `db.statement` just to get this property, but it should be + // set if it is provided by the library being instrumented. If the + // operation is acting upon an anonymous table, or more than one table, + // this value MUST NOT be set. + DBCassandraTableKey = attribute.Key("db.cassandra.table") + + // DBCassandraIdempotenceKey is the attribute Key conforming to the + // "db.cassandra.idempotence" semantic conventions. It represents the + // whether or not the query is idempotent. + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + DBCassandraIdempotenceKey = attribute.Key("db.cassandra.idempotence") + + // DBCassandraSpeculativeExecutionCountKey is the attribute Key conforming + // to the "db.cassandra.speculative_execution_count" semantic conventions. + // It represents the number of times a query was speculatively executed. + // Not set or `0` if the query was not executed speculatively. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 0, 2 + DBCassandraSpeculativeExecutionCountKey = attribute.Key("db.cassandra.speculative_execution_count") + + // DBCassandraCoordinatorIDKey is the attribute Key conforming to the + // "db.cassandra.coordinator.id" semantic conventions. It represents the ID + // of the coordinating node for a query. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'be13faa2-8574-4d71-926d-27f16cf8a7af' + DBCassandraCoordinatorIDKey = attribute.Key("db.cassandra.coordinator.id") + + // DBCassandraCoordinatorDCKey is the attribute Key conforming to the + // "db.cassandra.coordinator.dc" semantic conventions. It represents the + // data center of the coordinating node for a query. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'us-west-2' + DBCassandraCoordinatorDCKey = attribute.Key("db.cassandra.coordinator.dc") +) + +var ( + // all + DBCassandraConsistencyLevelAll = DBCassandraConsistencyLevelKey.String("all") + // each_quorum + DBCassandraConsistencyLevelEachQuorum = DBCassandraConsistencyLevelKey.String("each_quorum") + // quorum + DBCassandraConsistencyLevelQuorum = DBCassandraConsistencyLevelKey.String("quorum") + // local_quorum + DBCassandraConsistencyLevelLocalQuorum = DBCassandraConsistencyLevelKey.String("local_quorum") + // one + DBCassandraConsistencyLevelOne = DBCassandraConsistencyLevelKey.String("one") + // two + DBCassandraConsistencyLevelTwo = DBCassandraConsistencyLevelKey.String("two") + // three + DBCassandraConsistencyLevelThree = DBCassandraConsistencyLevelKey.String("three") + // local_one + DBCassandraConsistencyLevelLocalOne = DBCassandraConsistencyLevelKey.String("local_one") + // any + DBCassandraConsistencyLevelAny = DBCassandraConsistencyLevelKey.String("any") + // serial + DBCassandraConsistencyLevelSerial = DBCassandraConsistencyLevelKey.String("serial") + // local_serial + DBCassandraConsistencyLevelLocalSerial = DBCassandraConsistencyLevelKey.String("local_serial") +) + +// DBCassandraPageSize returns an attribute KeyValue conforming to the +// "db.cassandra.page_size" semantic conventions. It represents the fetch size +// used for paging, i.e. how many rows will be returned at once. +func DBCassandraPageSize(val int) attribute.KeyValue { + return DBCassandraPageSizeKey.Int(val) +} + +// DBCassandraTable returns an attribute KeyValue conforming to the +// "db.cassandra.table" semantic conventions. It represents the name of the +// primary table that the operation is acting upon, including the keyspace name +// (if applicable). +func DBCassandraTable(val string) attribute.KeyValue { + return DBCassandraTableKey.String(val) +} + +// DBCassandraIdempotence returns an attribute KeyValue conforming to the +// "db.cassandra.idempotence" semantic conventions. It represents the whether +// or not the query is idempotent. +func DBCassandraIdempotence(val bool) attribute.KeyValue { + return DBCassandraIdempotenceKey.Bool(val) +} + +// DBCassandraSpeculativeExecutionCount returns an attribute KeyValue +// conforming to the "db.cassandra.speculative_execution_count" semantic +// conventions. It represents the number of times a query was speculatively +// executed. Not set or `0` if the query was not executed speculatively. +func DBCassandraSpeculativeExecutionCount(val int) attribute.KeyValue { + return DBCassandraSpeculativeExecutionCountKey.Int(val) +} + +// DBCassandraCoordinatorID returns an attribute KeyValue conforming to the +// "db.cassandra.coordinator.id" semantic conventions. It represents the ID of +// the coordinating node for a query. +func DBCassandraCoordinatorID(val string) attribute.KeyValue { + return DBCassandraCoordinatorIDKey.String(val) +} + +// DBCassandraCoordinatorDC returns an attribute KeyValue conforming to the +// "db.cassandra.coordinator.dc" semantic conventions. It represents the data +// center of the coordinating node for a query. +func DBCassandraCoordinatorDC(val string) attribute.KeyValue { + return DBCassandraCoordinatorDCKey.String(val) +} + +// Call-level attributes for Redis +const ( + // DBRedisDBIndexKey is the attribute Key conforming to the + // "db.redis.database_index" semantic conventions. It represents the index + // of the database being accessed as used in the [`SELECT` + // command](https://redis.io/commands/select), provided as an integer. To + // be used instead of the generic `db.name` attribute. + // + // Type: int + // RequirementLevel: ConditionallyRequired (If other than the default + // database (`0`).) + // Stability: stable + // Examples: 0, 1, 15 + DBRedisDBIndexKey = attribute.Key("db.redis.database_index") +) + +// DBRedisDBIndex returns an attribute KeyValue conforming to the +// "db.redis.database_index" semantic conventions. It represents the index of +// the database being accessed as used in the [`SELECT` +// command](https://redis.io/commands/select), provided as an integer. To be +// used instead of the generic `db.name` attribute. +func DBRedisDBIndex(val int) attribute.KeyValue { + return DBRedisDBIndexKey.Int(val) +} + +// Call-level attributes for MongoDB +const ( + // DBMongoDBCollectionKey is the attribute Key conforming to the + // "db.mongodb.collection" semantic conventions. It represents the + // collection being accessed within the database stated in `db.name`. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'customers', 'products' + DBMongoDBCollectionKey = attribute.Key("db.mongodb.collection") +) + +// DBMongoDBCollection returns an attribute KeyValue conforming to the +// "db.mongodb.collection" semantic conventions. It represents the collection +// being accessed within the database stated in `db.name`. +func DBMongoDBCollection(val string) attribute.KeyValue { + return DBMongoDBCollectionKey.String(val) +} + +// Call-level attributes for SQL databases +const ( + // DBSQLTableKey is the attribute Key conforming to the "db.sql.table" + // semantic conventions. It represents the name of the primary table that + // the operation is acting upon, including the database name (if + // applicable). + // + // Type: string + // RequirementLevel: Recommended + // Stability: stable + // Examples: 'public.users', 'customers' + // Note: It is not recommended to attempt any client-side parsing of + // `db.statement` just to get this property, but it should be set if it is + // provided by the library being instrumented. If the operation is acting + // upon an anonymous table, or more than one table, this value MUST NOT be + // set. + DBSQLTableKey = attribute.Key("db.sql.table") +) + +// DBSQLTable returns an attribute KeyValue conforming to the "db.sql.table" +// semantic conventions. It represents the name of the primary table that the +// operation is acting upon, including the database name (if applicable). +func DBSQLTable(val string) attribute.KeyValue { + return DBSQLTableKey.String(val) +} + +// Call-level attributes for Cosmos DB. +const ( + // DBCosmosDBClientIDKey is the attribute Key conforming to the + // "db.cosmosdb.client_id" semantic conventions. It represents the unique + // Cosmos client instance id. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '3ba4827d-4422-483f-b59f-85b74211c11d' + DBCosmosDBClientIDKey = attribute.Key("db.cosmosdb.client_id") + + // DBCosmosDBOperationTypeKey is the attribute Key conforming to the + // "db.cosmosdb.operation_type" semantic conventions. It represents the + // cosmosDB Operation Type. + // + // Type: Enum + // RequirementLevel: ConditionallyRequired (when performing one of the + // operations in this list) + // Stability: stable + DBCosmosDBOperationTypeKey = attribute.Key("db.cosmosdb.operation_type") + + // DBCosmosDBConnectionModeKey is the attribute Key conforming to the + // "db.cosmosdb.connection_mode" semantic conventions. It represents the + // cosmos client connection mode. + // + // Type: Enum + // RequirementLevel: ConditionallyRequired (if not `direct` (or pick gw as + // default)) + // Stability: stable + DBCosmosDBConnectionModeKey = attribute.Key("db.cosmosdb.connection_mode") + + // DBCosmosDBContainerKey is the attribute Key conforming to the + // "db.cosmosdb.container" semantic conventions. It represents the cosmos + // DB container name. + // + // Type: string + // RequirementLevel: ConditionallyRequired (if available) + // Stability: stable + // Examples: 'anystring' + DBCosmosDBContainerKey = attribute.Key("db.cosmosdb.container") + + // DBCosmosDBRequestContentLengthKey is the attribute Key conforming to the + // "db.cosmosdb.request_content_length" semantic conventions. It represents + // the request payload size in bytes + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + DBCosmosDBRequestContentLengthKey = attribute.Key("db.cosmosdb.request_content_length") + + // DBCosmosDBStatusCodeKey is the attribute Key conforming to the + // "db.cosmosdb.status_code" semantic conventions. It represents the cosmos + // DB status code. + // + // Type: int + // RequirementLevel: ConditionallyRequired (if response was received) + // Stability: stable + // Examples: 200, 201 + DBCosmosDBStatusCodeKey = attribute.Key("db.cosmosdb.status_code") + + // DBCosmosDBSubStatusCodeKey is the attribute Key conforming to the + // "db.cosmosdb.sub_status_code" semantic conventions. It represents the + // cosmos DB sub status code. + // + // Type: int + // RequirementLevel: ConditionallyRequired (when response was received and + // contained sub-code.) + // Stability: stable + // Examples: 1000, 1002 + DBCosmosDBSubStatusCodeKey = attribute.Key("db.cosmosdb.sub_status_code") + + // DBCosmosDBRequestChargeKey is the attribute Key conforming to the + // "db.cosmosdb.request_charge" semantic conventions. It represents the rU + // consumed for that operation + // + // Type: double + // RequirementLevel: ConditionallyRequired (when available) + // Stability: stable + // Examples: 46.18, 1.0 + DBCosmosDBRequestChargeKey = attribute.Key("db.cosmosdb.request_charge") +) + +var ( + // invalid + DBCosmosDBOperationTypeInvalid = DBCosmosDBOperationTypeKey.String("Invalid") + // create + DBCosmosDBOperationTypeCreate = DBCosmosDBOperationTypeKey.String("Create") + // patch + DBCosmosDBOperationTypePatch = DBCosmosDBOperationTypeKey.String("Patch") + // read + DBCosmosDBOperationTypeRead = DBCosmosDBOperationTypeKey.String("Read") + // read_feed + DBCosmosDBOperationTypeReadFeed = DBCosmosDBOperationTypeKey.String("ReadFeed") + // delete + DBCosmosDBOperationTypeDelete = DBCosmosDBOperationTypeKey.String("Delete") + // replace + DBCosmosDBOperationTypeReplace = DBCosmosDBOperationTypeKey.String("Replace") + // execute + DBCosmosDBOperationTypeExecute = DBCosmosDBOperationTypeKey.String("Execute") + // query + DBCosmosDBOperationTypeQuery = DBCosmosDBOperationTypeKey.String("Query") + // head + DBCosmosDBOperationTypeHead = DBCosmosDBOperationTypeKey.String("Head") + // head_feed + DBCosmosDBOperationTypeHeadFeed = DBCosmosDBOperationTypeKey.String("HeadFeed") + // upsert + DBCosmosDBOperationTypeUpsert = DBCosmosDBOperationTypeKey.String("Upsert") + // batch + DBCosmosDBOperationTypeBatch = DBCosmosDBOperationTypeKey.String("Batch") + // query_plan + DBCosmosDBOperationTypeQueryPlan = DBCosmosDBOperationTypeKey.String("QueryPlan") + // execute_javascript + DBCosmosDBOperationTypeExecuteJavascript = DBCosmosDBOperationTypeKey.String("ExecuteJavaScript") +) + +var ( + // Gateway (HTTP) connections mode + DBCosmosDBConnectionModeGateway = DBCosmosDBConnectionModeKey.String("gateway") + // Direct connection + DBCosmosDBConnectionModeDirect = DBCosmosDBConnectionModeKey.String("direct") +) + +// DBCosmosDBClientID returns an attribute KeyValue conforming to the +// "db.cosmosdb.client_id" semantic conventions. It represents the unique +// Cosmos client instance id. +func DBCosmosDBClientID(val string) attribute.KeyValue { + return DBCosmosDBClientIDKey.String(val) +} + +// DBCosmosDBContainer returns an attribute KeyValue conforming to the +// "db.cosmosdb.container" semantic conventions. It represents the cosmos DB +// container name. +func DBCosmosDBContainer(val string) attribute.KeyValue { + return DBCosmosDBContainerKey.String(val) +} + +// DBCosmosDBRequestContentLength returns an attribute KeyValue conforming +// to the "db.cosmosdb.request_content_length" semantic conventions. It +// represents the request payload size in bytes +func DBCosmosDBRequestContentLength(val int) attribute.KeyValue { + return DBCosmosDBRequestContentLengthKey.Int(val) +} + +// DBCosmosDBStatusCode returns an attribute KeyValue conforming to the +// "db.cosmosdb.status_code" semantic conventions. It represents the cosmos DB +// status code. +func DBCosmosDBStatusCode(val int) attribute.KeyValue { + return DBCosmosDBStatusCodeKey.Int(val) +} + +// DBCosmosDBSubStatusCode returns an attribute KeyValue conforming to the +// "db.cosmosdb.sub_status_code" semantic conventions. It represents the cosmos +// DB sub status code. +func DBCosmosDBSubStatusCode(val int) attribute.KeyValue { + return DBCosmosDBSubStatusCodeKey.Int(val) +} + +// DBCosmosDBRequestCharge returns an attribute KeyValue conforming to the +// "db.cosmosdb.request_charge" semantic conventions. It represents the rU +// consumed for that operation +func DBCosmosDBRequestCharge(val float64) attribute.KeyValue { + return DBCosmosDBRequestChargeKey.Float64(val) +} + +// Span attributes used by non-OTLP exporters to represent OpenTelemetry Span's +// concepts. +const ( + // OTelStatusCodeKey is the attribute Key conforming to the + // "otel.status_code" semantic conventions. It represents the name of the + // code, either "OK" or "ERROR". MUST NOT be set if the status code is + // UNSET. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + OTelStatusCodeKey = attribute.Key("otel.status_code") + + // OTelStatusDescriptionKey is the attribute Key conforming to the + // "otel.status_description" semantic conventions. It represents the + // description of the Status if it has a value, otherwise not set. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'resource not found' + OTelStatusDescriptionKey = attribute.Key("otel.status_description") +) + +var ( + // The operation has been validated by an Application developer or Operator to have completed successfully + OTelStatusCodeOk = OTelStatusCodeKey.String("OK") + // The operation contains an error + OTelStatusCodeError = OTelStatusCodeKey.String("ERROR") +) + +// OTelStatusDescription returns an attribute KeyValue conforming to the +// "otel.status_description" semantic conventions. It represents the +// description of the Status if it has a value, otherwise not set. +func OTelStatusDescription(val string) attribute.KeyValue { + return OTelStatusDescriptionKey.String(val) +} + +// This semantic convention describes an instance of a function that runs +// without provisioning or managing of servers (also known as serverless +// functions or Function as a Service (FaaS)) with spans. +const ( + // FaaSTriggerKey is the attribute Key conforming to the "faas.trigger" + // semantic conventions. It represents the type of the trigger which caused + // this function invocation. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + // Note: For the server/consumer span on the incoming side, + // `faas.trigger` MUST be set. + // + // Clients invoking FaaS instances usually cannot set `faas.trigger`, + // since they would typically need to look in the payload to determine + // the event type. If clients set it, it should be the same as the + // trigger that corresponding incoming would have (i.e., this has + // nothing to do with the underlying transport used to make the API + // call to invoke the lambda, which is often HTTP). + FaaSTriggerKey = attribute.Key("faas.trigger") + + // FaaSInvocationIDKey is the attribute Key conforming to the + // "faas.invocation_id" semantic conventions. It represents the invocation + // ID of the current function invocation. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'af9d5aa4-a685-4c5f-a22b-444f80b3cc28' + FaaSInvocationIDKey = attribute.Key("faas.invocation_id") +) + +var ( + // A response to some data source operation such as a database or filesystem read/write + FaaSTriggerDatasource = FaaSTriggerKey.String("datasource") + // To provide an answer to an inbound HTTP request + FaaSTriggerHTTP = FaaSTriggerKey.String("http") + // A function is set to be executed when messages are sent to a messaging system + FaaSTriggerPubsub = FaaSTriggerKey.String("pubsub") + // A function is scheduled to be executed regularly + FaaSTriggerTimer = FaaSTriggerKey.String("timer") + // If none of the others apply + FaaSTriggerOther = FaaSTriggerKey.String("other") +) + +// FaaSInvocationID returns an attribute KeyValue conforming to the +// "faas.invocation_id" semantic conventions. It represents the invocation ID +// of the current function invocation. +func FaaSInvocationID(val string) attribute.KeyValue { + return FaaSInvocationIDKey.String(val) +} + +// Semantic Convention for FaaS triggered as a response to some data source +// operation such as a database or filesystem read/write. +const ( + // FaaSDocumentCollectionKey is the attribute Key conforming to the + // "faas.document.collection" semantic conventions. It represents the name + // of the source on which the triggering operation was performed. For + // example, in Cloud Storage or S3 corresponds to the bucket name, and in + // Cosmos DB to the database name. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'myBucketName', 'myDBName' + FaaSDocumentCollectionKey = attribute.Key("faas.document.collection") + + // FaaSDocumentOperationKey is the attribute Key conforming to the + // "faas.document.operation" semantic conventions. It represents the + // describes the type of the operation that was performed on the data. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + FaaSDocumentOperationKey = attribute.Key("faas.document.operation") + + // FaaSDocumentTimeKey is the attribute Key conforming to the + // "faas.document.time" semantic conventions. It represents a string + // containing the time when the data was accessed in the [ISO + // 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format + // expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '2020-01-23T13:47:06Z' + FaaSDocumentTimeKey = attribute.Key("faas.document.time") + + // FaaSDocumentNameKey is the attribute Key conforming to the + // "faas.document.name" semantic conventions. It represents the document + // name/table subjected to the operation. For example, in Cloud Storage or + // S3 is the name of the file, and in Cosmos DB the table name. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'myFile.txt', 'myTableName' + FaaSDocumentNameKey = attribute.Key("faas.document.name") +) + +var ( + // When a new object is created + FaaSDocumentOperationInsert = FaaSDocumentOperationKey.String("insert") + // When an object is modified + FaaSDocumentOperationEdit = FaaSDocumentOperationKey.String("edit") + // When an object is deleted + FaaSDocumentOperationDelete = FaaSDocumentOperationKey.String("delete") +) + +// FaaSDocumentCollection returns an attribute KeyValue conforming to the +// "faas.document.collection" semantic conventions. It represents the name of +// the source on which the triggering operation was performed. For example, in +// Cloud Storage or S3 corresponds to the bucket name, and in Cosmos DB to the +// database name. +func FaaSDocumentCollection(val string) attribute.KeyValue { + return FaaSDocumentCollectionKey.String(val) +} + +// FaaSDocumentTime returns an attribute KeyValue conforming to the +// "faas.document.time" semantic conventions. It represents a string containing +// the time when the data was accessed in the [ISO +// 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format +// expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). +func FaaSDocumentTime(val string) attribute.KeyValue { + return FaaSDocumentTimeKey.String(val) +} + +// FaaSDocumentName returns an attribute KeyValue conforming to the +// "faas.document.name" semantic conventions. It represents the document +// name/table subjected to the operation. For example, in Cloud Storage or S3 +// is the name of the file, and in Cosmos DB the table name. +func FaaSDocumentName(val string) attribute.KeyValue { + return FaaSDocumentNameKey.String(val) +} + +// Semantic Convention for FaaS scheduled to be executed regularly. +const ( + // FaaSTimeKey is the attribute Key conforming to the "faas.time" semantic + // conventions. It represents a string containing the function invocation + // time in the [ISO + // 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format + // expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '2020-01-23T13:47:06Z' + FaaSTimeKey = attribute.Key("faas.time") + + // FaaSCronKey is the attribute Key conforming to the "faas.cron" semantic + // conventions. It represents a string containing the schedule period as + // [Cron + // Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '0/5 * * * ? *' + FaaSCronKey = attribute.Key("faas.cron") +) + +// FaaSTime returns an attribute KeyValue conforming to the "faas.time" +// semantic conventions. It represents a string containing the function +// invocation time in the [ISO +// 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format +// expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). +func FaaSTime(val string) attribute.KeyValue { + return FaaSTimeKey.String(val) +} + +// FaaSCron returns an attribute KeyValue conforming to the "faas.cron" +// semantic conventions. It represents a string containing the schedule period +// as [Cron +// Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm). +func FaaSCron(val string) attribute.KeyValue { + return FaaSCronKey.String(val) +} + +// Contains additional attributes for incoming FaaS spans. +const ( + // FaaSColdstartKey is the attribute Key conforming to the "faas.coldstart" + // semantic conventions. It represents a boolean that is true if the + // serverless function is executed for the first time (aka cold-start). + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + FaaSColdstartKey = attribute.Key("faas.coldstart") +) + +// FaaSColdstart returns an attribute KeyValue conforming to the +// "faas.coldstart" semantic conventions. It represents a boolean that is true +// if the serverless function is executed for the first time (aka cold-start). +func FaaSColdstart(val bool) attribute.KeyValue { + return FaaSColdstartKey.Bool(val) +} + +// Contains additional attributes for outgoing FaaS spans. +const ( + // FaaSInvokedNameKey is the attribute Key conforming to the + // "faas.invoked_name" semantic conventions. It represents the name of the + // invoked function. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'my-function' + // Note: SHOULD be equal to the `faas.name` resource attribute of the + // invoked function. + FaaSInvokedNameKey = attribute.Key("faas.invoked_name") + + // FaaSInvokedProviderKey is the attribute Key conforming to the + // "faas.invoked_provider" semantic conventions. It represents the cloud + // provider of the invoked function. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + // Note: SHOULD be equal to the `cloud.provider` resource attribute of the + // invoked function. + FaaSInvokedProviderKey = attribute.Key("faas.invoked_provider") + + // FaaSInvokedRegionKey is the attribute Key conforming to the + // "faas.invoked_region" semantic conventions. It represents the cloud + // region of the invoked function. + // + // Type: string + // RequirementLevel: ConditionallyRequired (For some cloud providers, like + // AWS or GCP, the region in which a function is hosted is essential to + // uniquely identify the function and also part of its endpoint. Since it's + // part of the endpoint being called, the region is always known to + // clients. In these cases, `faas.invoked_region` MUST be set accordingly. + // If the region is unknown to the client or not required for identifying + // the invoked function, setting `faas.invoked_region` is optional.) + // Stability: stable + // Examples: 'eu-central-1' + // Note: SHOULD be equal to the `cloud.region` resource attribute of the + // invoked function. + FaaSInvokedRegionKey = attribute.Key("faas.invoked_region") +) + +var ( + // Alibaba Cloud + FaaSInvokedProviderAlibabaCloud = FaaSInvokedProviderKey.String("alibaba_cloud") + // Amazon Web Services + FaaSInvokedProviderAWS = FaaSInvokedProviderKey.String("aws") + // Microsoft Azure + FaaSInvokedProviderAzure = FaaSInvokedProviderKey.String("azure") + // Google Cloud Platform + FaaSInvokedProviderGCP = FaaSInvokedProviderKey.String("gcp") + // Tencent Cloud + FaaSInvokedProviderTencentCloud = FaaSInvokedProviderKey.String("tencent_cloud") +) + +// FaaSInvokedName returns an attribute KeyValue conforming to the +// "faas.invoked_name" semantic conventions. It represents the name of the +// invoked function. +func FaaSInvokedName(val string) attribute.KeyValue { + return FaaSInvokedNameKey.String(val) +} + +// FaaSInvokedRegion returns an attribute KeyValue conforming to the +// "faas.invoked_region" semantic conventions. It represents the cloud region +// of the invoked function. +func FaaSInvokedRegion(val string) attribute.KeyValue { + return FaaSInvokedRegionKey.String(val) +} + +// Operations that access some remote service. +const ( + // PeerServiceKey is the attribute Key conforming to the "peer.service" + // semantic conventions. It represents the + // [`service.name`](../../resource/semantic_conventions/README.md#service) + // of the remote service. SHOULD be equal to the actual `service.name` + // resource attribute of the remote service if any. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'AuthTokenCache' + PeerServiceKey = attribute.Key("peer.service") +) + +// PeerService returns an attribute KeyValue conforming to the +// "peer.service" semantic conventions. It represents the +// [`service.name`](../../resource/semantic_conventions/README.md#service) of +// the remote service. SHOULD be equal to the actual `service.name` resource +// attribute of the remote service if any. +func PeerService(val string) attribute.KeyValue { + return PeerServiceKey.String(val) +} + +// These attributes may be used for any operation with an authenticated and/or +// authorized enduser. +const ( + // EnduserIDKey is the attribute Key conforming to the "enduser.id" + // semantic conventions. It represents the username or client_id extracted + // from the access token or + // [Authorization](https://tools.ietf.org/html/rfc7235#section-4.2) header + // in the inbound request from outside the system. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'username' + EnduserIDKey = attribute.Key("enduser.id") + + // EnduserRoleKey is the attribute Key conforming to the "enduser.role" + // semantic conventions. It represents the actual/assumed role the client + // is making the request under extracted from token or application security + // context. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'admin' + EnduserRoleKey = attribute.Key("enduser.role") + + // EnduserScopeKey is the attribute Key conforming to the "enduser.scope" + // semantic conventions. It represents the scopes or granted authorities + // the client currently possesses extracted from token or application + // security context. The value would come from the scope associated with an + // [OAuth 2.0 Access + // Token](https://tools.ietf.org/html/rfc6749#section-3.3) or an attribute + // value in a [SAML 2.0 + // Assertion](http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'read:message, write:files' + EnduserScopeKey = attribute.Key("enduser.scope") +) + +// EnduserID returns an attribute KeyValue conforming to the "enduser.id" +// semantic conventions. It represents the username or client_id extracted from +// the access token or +// [Authorization](https://tools.ietf.org/html/rfc7235#section-4.2) header in +// the inbound request from outside the system. +func EnduserID(val string) attribute.KeyValue { + return EnduserIDKey.String(val) +} + +// EnduserRole returns an attribute KeyValue conforming to the +// "enduser.role" semantic conventions. It represents the actual/assumed role +// the client is making the request under extracted from token or application +// security context. +func EnduserRole(val string) attribute.KeyValue { + return EnduserRoleKey.String(val) +} + +// EnduserScope returns an attribute KeyValue conforming to the +// "enduser.scope" semantic conventions. It represents the scopes or granted +// authorities the client currently possesses extracted from token or +// application security context. The value would come from the scope associated +// with an [OAuth 2.0 Access +// Token](https://tools.ietf.org/html/rfc6749#section-3.3) or an attribute +// value in a [SAML 2.0 +// Assertion](http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html). +func EnduserScope(val string) attribute.KeyValue { + return EnduserScopeKey.String(val) +} + +// These attributes may be used for any operation to store information about a +// thread that started a span. +const ( + // ThreadIDKey is the attribute Key conforming to the "thread.id" semantic + // conventions. It represents the current "managed" thread ID (as opposed + // to OS thread ID). + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 42 + ThreadIDKey = attribute.Key("thread.id") + + // ThreadNameKey is the attribute Key conforming to the "thread.name" + // semantic conventions. It represents the current thread name. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'main' + ThreadNameKey = attribute.Key("thread.name") +) + +// ThreadID returns an attribute KeyValue conforming to the "thread.id" +// semantic conventions. It represents the current "managed" thread ID (as +// opposed to OS thread ID). +func ThreadID(val int) attribute.KeyValue { + return ThreadIDKey.Int(val) +} + +// ThreadName returns an attribute KeyValue conforming to the "thread.name" +// semantic conventions. It represents the current thread name. +func ThreadName(val string) attribute.KeyValue { + return ThreadNameKey.String(val) +} + +// These attributes allow to report this unit of code and therefore to provide +// more context about the span. +const ( + // CodeFunctionKey is the attribute Key conforming to the "code.function" + // semantic conventions. It represents the method or function name, or + // equivalent (usually rightmost part of the code unit's name). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'serveRequest' + CodeFunctionKey = attribute.Key("code.function") + + // CodeNamespaceKey is the attribute Key conforming to the "code.namespace" + // semantic conventions. It represents the "namespace" within which + // `code.function` is defined. Usually the qualified class or module name, + // such that `code.namespace` + some separator + `code.function` form a + // unique identifier for the code unit. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'com.example.MyHTTPService' + CodeNamespaceKey = attribute.Key("code.namespace") + + // CodeFilepathKey is the attribute Key conforming to the "code.filepath" + // semantic conventions. It represents the source code file name that + // identifies the code unit as uniquely as possible (preferably an absolute + // file path). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '/usr/local/MyApplication/content_root/app/index.php' + CodeFilepathKey = attribute.Key("code.filepath") + + // CodeLineNumberKey is the attribute Key conforming to the "code.lineno" + // semantic conventions. It represents the line number in `code.filepath` + // best representing the operation. It SHOULD point within the code unit + // named in `code.function`. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 42 + CodeLineNumberKey = attribute.Key("code.lineno") + + // CodeColumnKey is the attribute Key conforming to the "code.column" + // semantic conventions. It represents the column number in `code.filepath` + // best representing the operation. It SHOULD point within the code unit + // named in `code.function`. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 16 + CodeColumnKey = attribute.Key("code.column") +) + +// CodeFunction returns an attribute KeyValue conforming to the +// "code.function" semantic conventions. It represents the method or function +// name, or equivalent (usually rightmost part of the code unit's name). +func CodeFunction(val string) attribute.KeyValue { + return CodeFunctionKey.String(val) +} + +// CodeNamespace returns an attribute KeyValue conforming to the +// "code.namespace" semantic conventions. It represents the "namespace" within +// which `code.function` is defined. Usually the qualified class or module +// name, such that `code.namespace` + some separator + `code.function` form a +// unique identifier for the code unit. +func CodeNamespace(val string) attribute.KeyValue { + return CodeNamespaceKey.String(val) +} + +// CodeFilepath returns an attribute KeyValue conforming to the +// "code.filepath" semantic conventions. It represents the source code file +// name that identifies the code unit as uniquely as possible (preferably an +// absolute file path). +func CodeFilepath(val string) attribute.KeyValue { + return CodeFilepathKey.String(val) +} + +// CodeLineNumber returns an attribute KeyValue conforming to the "code.lineno" +// semantic conventions. It represents the line number in `code.filepath` best +// representing the operation. It SHOULD point within the code unit named in +// `code.function`. +func CodeLineNumber(val int) attribute.KeyValue { + return CodeLineNumberKey.Int(val) +} + +// CodeColumn returns an attribute KeyValue conforming to the "code.column" +// semantic conventions. It represents the column number in `code.filepath` +// best representing the operation. It SHOULD point within the code unit named +// in `code.function`. +func CodeColumn(val int) attribute.KeyValue { + return CodeColumnKey.Int(val) +} + +// Semantic Convention for HTTP Client +const ( + // HTTPURLKey is the attribute Key conforming to the "http.url" semantic + // conventions. It represents the full HTTP request URL in the form + // `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is + // not transmitted over HTTP, but if it is known, it should be included + // nevertheless. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'https://www.foo.bar/search?q=OpenTelemetry#SemConv' + // Note: `http.url` MUST NOT contain credentials passed via URL in form of + // `https://username:password@www.example.com/`. In such case the + // attribute's value should be `https://www.example.com/`. + HTTPURLKey = attribute.Key("http.url") + + // HTTPResendCountKey is the attribute Key conforming to the + // "http.resend_count" semantic conventions. It represents the ordinal + // number of request resending attempt (for any reason, including + // redirects). + // + // Type: int + // RequirementLevel: Recommended (if and only if request was retried.) + // Stability: stable + // Examples: 3 + // Note: The resend count SHOULD be updated each time an HTTP request gets + // resent by the client, regardless of what was the cause of the resending + // (e.g. redirection, authorization failure, 503 Server Unavailable, + // network issues, or any other). + HTTPResendCountKey = attribute.Key("http.resend_count") +) + +// HTTPURL returns an attribute KeyValue conforming to the "http.url" +// semantic conventions. It represents the full HTTP request URL in the form +// `scheme://host[:port]/path?query[#fragment]`. Usually the fragment is not +// transmitted over HTTP, but if it is known, it should be included +// nevertheless. +func HTTPURL(val string) attribute.KeyValue { + return HTTPURLKey.String(val) +} + +// HTTPResendCount returns an attribute KeyValue conforming to the +// "http.resend_count" semantic conventions. It represents the ordinal number +// of request resending attempt (for any reason, including redirects). +func HTTPResendCount(val int) attribute.KeyValue { + return HTTPResendCountKey.Int(val) +} + +// Semantic Convention for HTTP Server +const ( + // HTTPTargetKey is the attribute Key conforming to the "http.target" + // semantic conventions. It represents the full request target as passed in + // a HTTP request line or equivalent. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: '/users/12314/?q=ddds' + HTTPTargetKey = attribute.Key("http.target") + + // HTTPClientIPKey is the attribute Key conforming to the "http.client_ip" + // semantic conventions. It represents the IP address of the original + // client behind all proxies, if known (e.g. from + // [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '83.164.160.102' + // Note: This is not necessarily the same as `net.sock.peer.addr`, which + // would + // identify the network-level peer, which may be a proxy. + // + // This attribute should be set when a source of information different + // from the one used for `net.sock.peer.addr`, is available even if that + // other + // source just confirms the same value as `net.sock.peer.addr`. + // Rationale: For `net.sock.peer.addr`, one typically does not know if it + // comes from a proxy, reverse proxy, or the actual client. Setting + // `http.client_ip` when it's the same as `net.sock.peer.addr` means that + // one is at least somewhat confident that the address is not that of + // the closest proxy. + HTTPClientIPKey = attribute.Key("http.client_ip") +) + +// HTTPTarget returns an attribute KeyValue conforming to the "http.target" +// semantic conventions. It represents the full request target as passed in a +// HTTP request line or equivalent. +func HTTPTarget(val string) attribute.KeyValue { + return HTTPTargetKey.String(val) +} + +// HTTPClientIP returns an attribute KeyValue conforming to the +// "http.client_ip" semantic conventions. It represents the IP address of the +// original client behind all proxies, if known (e.g. from +// [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)). +func HTTPClientIP(val string) attribute.KeyValue { + return HTTPClientIPKey.String(val) +} + +// The `aws` conventions apply to operations using the AWS SDK. They map +// request or response parameters in AWS SDK API calls to attributes on a Span. +// The conventions have been collected over time based on feedback from AWS +// users of tracing and will continue to evolve as new interesting conventions +// are found. +// Some descriptions are also provided for populating general OpenTelemetry +// semantic conventions based on these APIs. +const ( + // AWSRequestIDKey is the attribute Key conforming to the "aws.request_id" + // semantic conventions. It represents the AWS request ID as returned in + // the response headers `x-amz-request-id` or `x-amz-requestid`. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '79b9da39-b7ae-508a-a6bc-864b2829c622', 'C9ER4AJX75574TDJ' + AWSRequestIDKey = attribute.Key("aws.request_id") +) + +// AWSRequestID returns an attribute KeyValue conforming to the +// "aws.request_id" semantic conventions. It represents the AWS request ID as +// returned in the response headers `x-amz-request-id` or `x-amz-requestid`. +func AWSRequestID(val string) attribute.KeyValue { + return AWSRequestIDKey.String(val) +} + +// Attributes that exist for multiple DynamoDB request types. +const ( + // AWSDynamoDBTableNamesKey is the attribute Key conforming to the + // "aws.dynamodb.table_names" semantic conventions. It represents the keys + // in the `RequestItems` object field. + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Users', 'Cats' + AWSDynamoDBTableNamesKey = attribute.Key("aws.dynamodb.table_names") + + // AWSDynamoDBConsumedCapacityKey is the attribute Key conforming to the + // "aws.dynamodb.consumed_capacity" semantic conventions. It represents the + // JSON-serialized value of each item in the `ConsumedCapacity` response + // field. + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: '{ "CapacityUnits": number, "GlobalSecondaryIndexes": { + // "string" : { "CapacityUnits": number, "ReadCapacityUnits": number, + // "WriteCapacityUnits": number } }, "LocalSecondaryIndexes": { "string" : + // { "CapacityUnits": number, "ReadCapacityUnits": number, + // "WriteCapacityUnits": number } }, "ReadCapacityUnits": number, "Table": + // { "CapacityUnits": number, "ReadCapacityUnits": number, + // "WriteCapacityUnits": number }, "TableName": "string", + // "WriteCapacityUnits": number }' + AWSDynamoDBConsumedCapacityKey = attribute.Key("aws.dynamodb.consumed_capacity") + + // AWSDynamoDBItemCollectionMetricsKey is the attribute Key conforming to + // the "aws.dynamodb.item_collection_metrics" semantic conventions. It + // represents the JSON-serialized value of the `ItemCollectionMetrics` + // response field. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '{ "string" : [ { "ItemCollectionKey": { "string" : { "B": + // blob, "BOOL": boolean, "BS": [ blob ], "L": [ "AttributeValue" ], "M": { + // "string" : "AttributeValue" }, "N": "string", "NS": [ "string" ], + // "NULL": boolean, "S": "string", "SS": [ "string" ] } }, + // "SizeEstimateRangeGB": [ number ] } ] }' + AWSDynamoDBItemCollectionMetricsKey = attribute.Key("aws.dynamodb.item_collection_metrics") + + // AWSDynamoDBProvisionedReadCapacityKey is the attribute Key conforming to + // the "aws.dynamodb.provisioned_read_capacity" semantic conventions. It + // represents the value of the `ProvisionedThroughput.ReadCapacityUnits` + // request parameter. + // + // Type: double + // RequirementLevel: Optional + // Stability: stable + // Examples: 1.0, 2.0 + AWSDynamoDBProvisionedReadCapacityKey = attribute.Key("aws.dynamodb.provisioned_read_capacity") + + // AWSDynamoDBProvisionedWriteCapacityKey is the attribute Key conforming + // to the "aws.dynamodb.provisioned_write_capacity" semantic conventions. + // It represents the value of the + // `ProvisionedThroughput.WriteCapacityUnits` request parameter. + // + // Type: double + // RequirementLevel: Optional + // Stability: stable + // Examples: 1.0, 2.0 + AWSDynamoDBProvisionedWriteCapacityKey = attribute.Key("aws.dynamodb.provisioned_write_capacity") + + // AWSDynamoDBConsistentReadKey is the attribute Key conforming to the + // "aws.dynamodb.consistent_read" semantic conventions. It represents the + // value of the `ConsistentRead` request parameter. + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + AWSDynamoDBConsistentReadKey = attribute.Key("aws.dynamodb.consistent_read") + + // AWSDynamoDBProjectionKey is the attribute Key conforming to the + // "aws.dynamodb.projection" semantic conventions. It represents the value + // of the `ProjectionExpression` request parameter. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Title', 'Title, Price, Color', 'Title, Description, + // RelatedItems, ProductReviews' + AWSDynamoDBProjectionKey = attribute.Key("aws.dynamodb.projection") + + // AWSDynamoDBLimitKey is the attribute Key conforming to the + // "aws.dynamodb.limit" semantic conventions. It represents the value of + // the `Limit` request parameter. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 10 + AWSDynamoDBLimitKey = attribute.Key("aws.dynamodb.limit") + + // AWSDynamoDBAttributesToGetKey is the attribute Key conforming to the + // "aws.dynamodb.attributes_to_get" semantic conventions. It represents the + // value of the `AttributesToGet` request parameter. + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: 'lives', 'id' + AWSDynamoDBAttributesToGetKey = attribute.Key("aws.dynamodb.attributes_to_get") + + // AWSDynamoDBIndexNameKey is the attribute Key conforming to the + // "aws.dynamodb.index_name" semantic conventions. It represents the value + // of the `IndexName` request parameter. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'name_to_group' + AWSDynamoDBIndexNameKey = attribute.Key("aws.dynamodb.index_name") + + // AWSDynamoDBSelectKey is the attribute Key conforming to the + // "aws.dynamodb.select" semantic conventions. It represents the value of + // the `Select` request parameter. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'ALL_ATTRIBUTES', 'COUNT' + AWSDynamoDBSelectKey = attribute.Key("aws.dynamodb.select") +) + +// AWSDynamoDBTableNames returns an attribute KeyValue conforming to the +// "aws.dynamodb.table_names" semantic conventions. It represents the keys in +// the `RequestItems` object field. +func AWSDynamoDBTableNames(val ...string) attribute.KeyValue { + return AWSDynamoDBTableNamesKey.StringSlice(val) +} + +// AWSDynamoDBConsumedCapacity returns an attribute KeyValue conforming to +// the "aws.dynamodb.consumed_capacity" semantic conventions. It represents the +// JSON-serialized value of each item in the `ConsumedCapacity` response field. +func AWSDynamoDBConsumedCapacity(val ...string) attribute.KeyValue { + return AWSDynamoDBConsumedCapacityKey.StringSlice(val) +} + +// AWSDynamoDBItemCollectionMetrics returns an attribute KeyValue conforming +// to the "aws.dynamodb.item_collection_metrics" semantic conventions. It +// represents the JSON-serialized value of the `ItemCollectionMetrics` response +// field. +func AWSDynamoDBItemCollectionMetrics(val string) attribute.KeyValue { + return AWSDynamoDBItemCollectionMetricsKey.String(val) +} + +// AWSDynamoDBProvisionedReadCapacity returns an attribute KeyValue +// conforming to the "aws.dynamodb.provisioned_read_capacity" semantic +// conventions. It represents the value of the +// `ProvisionedThroughput.ReadCapacityUnits` request parameter. +func AWSDynamoDBProvisionedReadCapacity(val float64) attribute.KeyValue { + return AWSDynamoDBProvisionedReadCapacityKey.Float64(val) +} + +// AWSDynamoDBProvisionedWriteCapacity returns an attribute KeyValue +// conforming to the "aws.dynamodb.provisioned_write_capacity" semantic +// conventions. It represents the value of the +// `ProvisionedThroughput.WriteCapacityUnits` request parameter. +func AWSDynamoDBProvisionedWriteCapacity(val float64) attribute.KeyValue { + return AWSDynamoDBProvisionedWriteCapacityKey.Float64(val) +} + +// AWSDynamoDBConsistentRead returns an attribute KeyValue conforming to the +// "aws.dynamodb.consistent_read" semantic conventions. It represents the value +// of the `ConsistentRead` request parameter. +func AWSDynamoDBConsistentRead(val bool) attribute.KeyValue { + return AWSDynamoDBConsistentReadKey.Bool(val) +} + +// AWSDynamoDBProjection returns an attribute KeyValue conforming to the +// "aws.dynamodb.projection" semantic conventions. It represents the value of +// the `ProjectionExpression` request parameter. +func AWSDynamoDBProjection(val string) attribute.KeyValue { + return AWSDynamoDBProjectionKey.String(val) +} + +// AWSDynamoDBLimit returns an attribute KeyValue conforming to the +// "aws.dynamodb.limit" semantic conventions. It represents the value of the +// `Limit` request parameter. +func AWSDynamoDBLimit(val int) attribute.KeyValue { + return AWSDynamoDBLimitKey.Int(val) +} + +// AWSDynamoDBAttributesToGet returns an attribute KeyValue conforming to +// the "aws.dynamodb.attributes_to_get" semantic conventions. It represents the +// value of the `AttributesToGet` request parameter. +func AWSDynamoDBAttributesToGet(val ...string) attribute.KeyValue { + return AWSDynamoDBAttributesToGetKey.StringSlice(val) +} + +// AWSDynamoDBIndexName returns an attribute KeyValue conforming to the +// "aws.dynamodb.index_name" semantic conventions. It represents the value of +// the `IndexName` request parameter. +func AWSDynamoDBIndexName(val string) attribute.KeyValue { + return AWSDynamoDBIndexNameKey.String(val) +} + +// AWSDynamoDBSelect returns an attribute KeyValue conforming to the +// "aws.dynamodb.select" semantic conventions. It represents the value of the +// `Select` request parameter. +func AWSDynamoDBSelect(val string) attribute.KeyValue { + return AWSDynamoDBSelectKey.String(val) +} + +// DynamoDB.CreateTable +const ( + // AWSDynamoDBGlobalSecondaryIndexesKey is the attribute Key conforming to + // the "aws.dynamodb.global_secondary_indexes" semantic conventions. It + // represents the JSON-serialized value of each item of the + // `GlobalSecondaryIndexes` request field + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: '{ "IndexName": "string", "KeySchema": [ { "AttributeName": + // "string", "KeyType": "string" } ], "Projection": { "NonKeyAttributes": [ + // "string" ], "ProjectionType": "string" }, "ProvisionedThroughput": { + // "ReadCapacityUnits": number, "WriteCapacityUnits": number } }' + AWSDynamoDBGlobalSecondaryIndexesKey = attribute.Key("aws.dynamodb.global_secondary_indexes") + + // AWSDynamoDBLocalSecondaryIndexesKey is the attribute Key conforming to + // the "aws.dynamodb.local_secondary_indexes" semantic conventions. It + // represents the JSON-serialized value of each item of the + // `LocalSecondaryIndexes` request field. + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: '{ "IndexARN": "string", "IndexName": "string", + // "IndexSizeBytes": number, "ItemCount": number, "KeySchema": [ { + // "AttributeName": "string", "KeyType": "string" } ], "Projection": { + // "NonKeyAttributes": [ "string" ], "ProjectionType": "string" } }' + AWSDynamoDBLocalSecondaryIndexesKey = attribute.Key("aws.dynamodb.local_secondary_indexes") +) + +// AWSDynamoDBGlobalSecondaryIndexes returns an attribute KeyValue +// conforming to the "aws.dynamodb.global_secondary_indexes" semantic +// conventions. It represents the JSON-serialized value of each item of the +// `GlobalSecondaryIndexes` request field +func AWSDynamoDBGlobalSecondaryIndexes(val ...string) attribute.KeyValue { + return AWSDynamoDBGlobalSecondaryIndexesKey.StringSlice(val) +} + +// AWSDynamoDBLocalSecondaryIndexes returns an attribute KeyValue conforming +// to the "aws.dynamodb.local_secondary_indexes" semantic conventions. It +// represents the JSON-serialized value of each item of the +// `LocalSecondaryIndexes` request field. +func AWSDynamoDBLocalSecondaryIndexes(val ...string) attribute.KeyValue { + return AWSDynamoDBLocalSecondaryIndexesKey.StringSlice(val) +} + +// DynamoDB.ListTables +const ( + // AWSDynamoDBExclusiveStartTableKey is the attribute Key conforming to the + // "aws.dynamodb.exclusive_start_table" semantic conventions. It represents + // the value of the `ExclusiveStartTableName` request parameter. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Users', 'CatsTable' + AWSDynamoDBExclusiveStartTableKey = attribute.Key("aws.dynamodb.exclusive_start_table") + + // AWSDynamoDBTableCountKey is the attribute Key conforming to the + // "aws.dynamodb.table_count" semantic conventions. It represents the the + // number of items in the `TableNames` response parameter. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 20 + AWSDynamoDBTableCountKey = attribute.Key("aws.dynamodb.table_count") +) + +// AWSDynamoDBExclusiveStartTable returns an attribute KeyValue conforming +// to the "aws.dynamodb.exclusive_start_table" semantic conventions. It +// represents the value of the `ExclusiveStartTableName` request parameter. +func AWSDynamoDBExclusiveStartTable(val string) attribute.KeyValue { + return AWSDynamoDBExclusiveStartTableKey.String(val) +} + +// AWSDynamoDBTableCount returns an attribute KeyValue conforming to the +// "aws.dynamodb.table_count" semantic conventions. It represents the the +// number of items in the `TableNames` response parameter. +func AWSDynamoDBTableCount(val int) attribute.KeyValue { + return AWSDynamoDBTableCountKey.Int(val) +} + +// DynamoDB.Query +const ( + // AWSDynamoDBScanForwardKey is the attribute Key conforming to the + // "aws.dynamodb.scan_forward" semantic conventions. It represents the + // value of the `ScanIndexForward` request parameter. + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + AWSDynamoDBScanForwardKey = attribute.Key("aws.dynamodb.scan_forward") +) + +// AWSDynamoDBScanForward returns an attribute KeyValue conforming to the +// "aws.dynamodb.scan_forward" semantic conventions. It represents the value of +// the `ScanIndexForward` request parameter. +func AWSDynamoDBScanForward(val bool) attribute.KeyValue { + return AWSDynamoDBScanForwardKey.Bool(val) +} + +// DynamoDB.Scan +const ( + // AWSDynamoDBSegmentKey is the attribute Key conforming to the + // "aws.dynamodb.segment" semantic conventions. It represents the value of + // the `Segment` request parameter. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 10 + AWSDynamoDBSegmentKey = attribute.Key("aws.dynamodb.segment") + + // AWSDynamoDBTotalSegmentsKey is the attribute Key conforming to the + // "aws.dynamodb.total_segments" semantic conventions. It represents the + // value of the `TotalSegments` request parameter. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 100 + AWSDynamoDBTotalSegmentsKey = attribute.Key("aws.dynamodb.total_segments") + + // AWSDynamoDBCountKey is the attribute Key conforming to the + // "aws.dynamodb.count" semantic conventions. It represents the value of + // the `Count` response parameter. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 10 + AWSDynamoDBCountKey = attribute.Key("aws.dynamodb.count") + + // AWSDynamoDBScannedCountKey is the attribute Key conforming to the + // "aws.dynamodb.scanned_count" semantic conventions. It represents the + // value of the `ScannedCount` response parameter. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 50 + AWSDynamoDBScannedCountKey = attribute.Key("aws.dynamodb.scanned_count") +) + +// AWSDynamoDBSegment returns an attribute KeyValue conforming to the +// "aws.dynamodb.segment" semantic conventions. It represents the value of the +// `Segment` request parameter. +func AWSDynamoDBSegment(val int) attribute.KeyValue { + return AWSDynamoDBSegmentKey.Int(val) +} + +// AWSDynamoDBTotalSegments returns an attribute KeyValue conforming to the +// "aws.dynamodb.total_segments" semantic conventions. It represents the value +// of the `TotalSegments` request parameter. +func AWSDynamoDBTotalSegments(val int) attribute.KeyValue { + return AWSDynamoDBTotalSegmentsKey.Int(val) +} + +// AWSDynamoDBCount returns an attribute KeyValue conforming to the +// "aws.dynamodb.count" semantic conventions. It represents the value of the +// `Count` response parameter. +func AWSDynamoDBCount(val int) attribute.KeyValue { + return AWSDynamoDBCountKey.Int(val) +} + +// AWSDynamoDBScannedCount returns an attribute KeyValue conforming to the +// "aws.dynamodb.scanned_count" semantic conventions. It represents the value +// of the `ScannedCount` response parameter. +func AWSDynamoDBScannedCount(val int) attribute.KeyValue { + return AWSDynamoDBScannedCountKey.Int(val) +} + +// DynamoDB.UpdateTable +const ( + // AWSDynamoDBAttributeDefinitionsKey is the attribute Key conforming to + // the "aws.dynamodb.attribute_definitions" semantic conventions. It + // represents the JSON-serialized value of each item in the + // `AttributeDefinitions` request field. + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: '{ "AttributeName": "string", "AttributeType": "string" }' + AWSDynamoDBAttributeDefinitionsKey = attribute.Key("aws.dynamodb.attribute_definitions") + + // AWSDynamoDBGlobalSecondaryIndexUpdatesKey is the attribute Key + // conforming to the "aws.dynamodb.global_secondary_index_updates" semantic + // conventions. It represents the JSON-serialized value of each item in the + // the `GlobalSecondaryIndexUpdates` request field. + // + // Type: string[] + // RequirementLevel: Optional + // Stability: stable + // Examples: '{ "Create": { "IndexName": "string", "KeySchema": [ { + // "AttributeName": "string", "KeyType": "string" } ], "Projection": { + // "NonKeyAttributes": [ "string" ], "ProjectionType": "string" }, + // "ProvisionedThroughput": { "ReadCapacityUnits": number, + // "WriteCapacityUnits": number } }' + AWSDynamoDBGlobalSecondaryIndexUpdatesKey = attribute.Key("aws.dynamodb.global_secondary_index_updates") +) + +// AWSDynamoDBAttributeDefinitions returns an attribute KeyValue conforming +// to the "aws.dynamodb.attribute_definitions" semantic conventions. It +// represents the JSON-serialized value of each item in the +// `AttributeDefinitions` request field. +func AWSDynamoDBAttributeDefinitions(val ...string) attribute.KeyValue { + return AWSDynamoDBAttributeDefinitionsKey.StringSlice(val) +} + +// AWSDynamoDBGlobalSecondaryIndexUpdates returns an attribute KeyValue +// conforming to the "aws.dynamodb.global_secondary_index_updates" semantic +// conventions. It represents the JSON-serialized value of each item in the the +// `GlobalSecondaryIndexUpdates` request field. +func AWSDynamoDBGlobalSecondaryIndexUpdates(val ...string) attribute.KeyValue { + return AWSDynamoDBGlobalSecondaryIndexUpdatesKey.StringSlice(val) +} + +// Attributes that exist for S3 request types. +const ( + // AWSS3BucketKey is the attribute Key conforming to the "aws.s3.bucket" + // semantic conventions. It represents the S3 bucket name the request + // refers to. Corresponds to the `--bucket` parameter of the [S3 + // API](https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html) + // operations. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'some-bucket-name' + // Note: The `bucket` attribute is applicable to all S3 operations that + // reference a bucket, i.e. that require the bucket name as a mandatory + // parameter. + // This applies to almost all S3 operations except `list-buckets`. + AWSS3BucketKey = attribute.Key("aws.s3.bucket") + + // AWSS3KeyKey is the attribute Key conforming to the "aws.s3.key" semantic + // conventions. It represents the S3 object key the request refers to. + // Corresponds to the `--key` parameter of the [S3 + // API](https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html) + // operations. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'someFile.yml' + // Note: The `key` attribute is applicable to all object-related S3 + // operations, i.e. that require the object key as a mandatory parameter. + // This applies in particular to the following operations: + // + // - + // [copy-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html) + // - + // [delete-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html) + // - + // [get-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/get-object.html) + // - + // [head-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/head-object.html) + // - + // [put-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/put-object.html) + // - + // [restore-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/restore-object.html) + // - + // [select-object-content](https://docs.aws.amazon.com/cli/latest/reference/s3api/select-object-content.html) + // - + // [abort-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html) + // - + // [complete-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html) + // - + // [create-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/create-multipart-upload.html) + // - + // [list-parts](https://docs.aws.amazon.com/cli/latest/reference/s3api/list-parts.html) + // - + // [upload-part](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html) + // - + // [upload-part-copy](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html) + AWSS3KeyKey = attribute.Key("aws.s3.key") + + // AWSS3CopySourceKey is the attribute Key conforming to the + // "aws.s3.copy_source" semantic conventions. It represents the source + // object (in the form `bucket`/`key`) for the copy operation. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'someFile.yml' + // Note: The `copy_source` attribute applies to S3 copy operations and + // corresponds to the `--copy-source` parameter + // of the [copy-object operation within the S3 + // API](https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html). + // This applies in particular to the following operations: + // + // - + // [copy-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html) + // - + // [upload-part-copy](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html) + AWSS3CopySourceKey = attribute.Key("aws.s3.copy_source") + + // AWSS3UploadIDKey is the attribute Key conforming to the + // "aws.s3.upload_id" semantic conventions. It represents the upload ID + // that identifies the multipart upload. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'dfRtDYWFbkRONycy.Yxwh66Yjlx.cph0gtNBtJ' + // Note: The `upload_id` attribute applies to S3 multipart-upload + // operations and corresponds to the `--upload-id` parameter + // of the [S3 + // API](https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html) + // multipart operations. + // This applies in particular to the following operations: + // + // - + // [abort-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html) + // - + // [complete-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html) + // - + // [list-parts](https://docs.aws.amazon.com/cli/latest/reference/s3api/list-parts.html) + // - + // [upload-part](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html) + // - + // [upload-part-copy](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html) + AWSS3UploadIDKey = attribute.Key("aws.s3.upload_id") + + // AWSS3DeleteKey is the attribute Key conforming to the "aws.s3.delete" + // semantic conventions. It represents the delete request container that + // specifies the objects to be deleted. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: + // 'Objects=[{Key=string,VersionID=string},{Key=string,VersionID=string}],Quiet=boolean' + // Note: The `delete` attribute is only applicable to the + // [delete-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html) + // operation. + // The `delete` attribute corresponds to the `--delete` parameter of the + // [delete-objects operation within the S3 + // API](https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-objects.html). + AWSS3DeleteKey = attribute.Key("aws.s3.delete") + + // AWSS3PartNumberKey is the attribute Key conforming to the + // "aws.s3.part_number" semantic conventions. It represents the part number + // of the part being uploaded in a multipart-upload operation. This is a + // positive integer between 1 and 10,000. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 3456 + // Note: The `part_number` attribute is only applicable to the + // [upload-part](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html) + // and + // [upload-part-copy](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html) + // operations. + // The `part_number` attribute corresponds to the `--part-number` parameter + // of the + // [upload-part operation within the S3 + // API](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html). + AWSS3PartNumberKey = attribute.Key("aws.s3.part_number") +) + +// AWSS3Bucket returns an attribute KeyValue conforming to the +// "aws.s3.bucket" semantic conventions. It represents the S3 bucket name the +// request refers to. Corresponds to the `--bucket` parameter of the [S3 +// API](https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html) +// operations. +func AWSS3Bucket(val string) attribute.KeyValue { + return AWSS3BucketKey.String(val) +} + +// AWSS3Key returns an attribute KeyValue conforming to the "aws.s3.key" +// semantic conventions. It represents the S3 object key the request refers to. +// Corresponds to the `--key` parameter of the [S3 +// API](https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html) +// operations. +func AWSS3Key(val string) attribute.KeyValue { + return AWSS3KeyKey.String(val) +} + +// AWSS3CopySource returns an attribute KeyValue conforming to the +// "aws.s3.copy_source" semantic conventions. It represents the source object +// (in the form `bucket`/`key`) for the copy operation. +func AWSS3CopySource(val string) attribute.KeyValue { + return AWSS3CopySourceKey.String(val) +} + +// AWSS3UploadID returns an attribute KeyValue conforming to the +// "aws.s3.upload_id" semantic conventions. It represents the upload ID that +// identifies the multipart upload. +func AWSS3UploadID(val string) attribute.KeyValue { + return AWSS3UploadIDKey.String(val) +} + +// AWSS3Delete returns an attribute KeyValue conforming to the +// "aws.s3.delete" semantic conventions. It represents the delete request +// container that specifies the objects to be deleted. +func AWSS3Delete(val string) attribute.KeyValue { + return AWSS3DeleteKey.String(val) +} + +// AWSS3PartNumber returns an attribute KeyValue conforming to the +// "aws.s3.part_number" semantic conventions. It represents the part number of +// the part being uploaded in a multipart-upload operation. This is a positive +// integer between 1 and 10,000. +func AWSS3PartNumber(val int) attribute.KeyValue { + return AWSS3PartNumberKey.Int(val) +} + +// Semantic conventions to apply when instrumenting the GraphQL implementation. +// They map GraphQL operations to attributes on a Span. +const ( + // GraphqlOperationNameKey is the attribute Key conforming to the + // "graphql.operation.name" semantic conventions. It represents the name of + // the operation being executed. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'findBookByID' + GraphqlOperationNameKey = attribute.Key("graphql.operation.name") + + // GraphqlOperationTypeKey is the attribute Key conforming to the + // "graphql.operation.type" semantic conventions. It represents the type of + // the operation being executed. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + // Examples: 'query', 'mutation', 'subscription' + GraphqlOperationTypeKey = attribute.Key("graphql.operation.type") + + // GraphqlDocumentKey is the attribute Key conforming to the + // "graphql.document" semantic conventions. It represents the GraphQL + // document being executed. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'query findBookByID { bookByID(id: ?) { name } }' + // Note: The value may be sanitized to exclude sensitive information. + GraphqlDocumentKey = attribute.Key("graphql.document") +) + +var ( + // GraphQL query + GraphqlOperationTypeQuery = GraphqlOperationTypeKey.String("query") + // GraphQL mutation + GraphqlOperationTypeMutation = GraphqlOperationTypeKey.String("mutation") + // GraphQL subscription + GraphqlOperationTypeSubscription = GraphqlOperationTypeKey.String("subscription") +) + +// GraphqlOperationName returns an attribute KeyValue conforming to the +// "graphql.operation.name" semantic conventions. It represents the name of the +// operation being executed. +func GraphqlOperationName(val string) attribute.KeyValue { + return GraphqlOperationNameKey.String(val) +} + +// GraphqlDocument returns an attribute KeyValue conforming to the +// "graphql.document" semantic conventions. It represents the GraphQL document +// being executed. +func GraphqlDocument(val string) attribute.KeyValue { + return GraphqlDocumentKey.String(val) +} + +// General attributes used in messaging systems. +const ( + // MessagingSystemKey is the attribute Key conforming to the + // "messaging.system" semantic conventions. It represents a string + // identifying the messaging system. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'kafka', 'rabbitmq', 'rocketmq', 'activemq', 'AmazonSQS' + MessagingSystemKey = attribute.Key("messaging.system") + + // MessagingOperationKey is the attribute Key conforming to the + // "messaging.operation" semantic conventions. It represents a string + // identifying the kind of messaging operation as defined in the [Operation + // names](#operation-names) section above. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + // Note: If a custom value is used, it MUST be of low cardinality. + MessagingOperationKey = attribute.Key("messaging.operation") + + // MessagingBatchMessageCountKey is the attribute Key conforming to the + // "messaging.batch.message_count" semantic conventions. It represents the + // number of messages sent, received, or processed in the scope of the + // batching operation. + // + // Type: int + // RequirementLevel: ConditionallyRequired (If the span describes an + // operation on a batch of messages.) + // Stability: stable + // Examples: 0, 1, 2 + // Note: Instrumentations SHOULD NOT set `messaging.batch.message_count` on + // spans that operate with a single message. When a messaging client + // library supports both batch and single-message API for the same + // operation, instrumentations SHOULD use `messaging.batch.message_count` + // for batching APIs and SHOULD NOT use it for single-message APIs. + MessagingBatchMessageCountKey = attribute.Key("messaging.batch.message_count") +) + +var ( + // publish + MessagingOperationPublish = MessagingOperationKey.String("publish") + // receive + MessagingOperationReceive = MessagingOperationKey.String("receive") + // process + MessagingOperationProcess = MessagingOperationKey.String("process") +) + +// MessagingSystem returns an attribute KeyValue conforming to the +// "messaging.system" semantic conventions. It represents a string identifying +// the messaging system. +func MessagingSystem(val string) attribute.KeyValue { + return MessagingSystemKey.String(val) +} + +// MessagingBatchMessageCount returns an attribute KeyValue conforming to +// the "messaging.batch.message_count" semantic conventions. It represents the +// number of messages sent, received, or processed in the scope of the batching +// operation. +func MessagingBatchMessageCount(val int) attribute.KeyValue { + return MessagingBatchMessageCountKey.Int(val) +} + +// Semantic convention for a consumer of messages received from a messaging +// system +const ( + // MessagingConsumerIDKey is the attribute Key conforming to the + // "messaging.consumer.id" semantic conventions. It represents the + // identifier for the consumer receiving a message. For Kafka, set it to + // `{messaging.kafka.consumer.group} - {messaging.kafka.client_id}`, if + // both are present, or only `messaging.kafka.consumer.group`. For brokers, + // such as RabbitMQ and Artemis, set it to the `client_id` of the client + // consuming the message. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'mygroup - client-6' + MessagingConsumerIDKey = attribute.Key("messaging.consumer.id") +) + +// MessagingConsumerID returns an attribute KeyValue conforming to the +// "messaging.consumer.id" semantic conventions. It represents the identifier +// for the consumer receiving a message. For Kafka, set it to +// `{messaging.kafka.consumer.group} - {messaging.kafka.client_id}`, if both +// are present, or only `messaging.kafka.consumer.group`. For brokers, such as +// RabbitMQ and Artemis, set it to the `client_id` of the client consuming the +// message. +func MessagingConsumerID(val string) attribute.KeyValue { + return MessagingConsumerIDKey.String(val) +} + +// Semantic conventions for remote procedure calls. +const ( + // RPCSystemKey is the attribute Key conforming to the "rpc.system" + // semantic conventions. It represents a string identifying the remoting + // system. See below for a list of well-known identifiers. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + RPCSystemKey = attribute.Key("rpc.system") + + // RPCServiceKey is the attribute Key conforming to the "rpc.service" + // semantic conventions. It represents the full (logical) name of the + // service being called, including its package name, if applicable. + // + // Type: string + // RequirementLevel: Recommended + // Stability: stable + // Examples: 'myservice.EchoService' + // Note: This is the logical name of the service from the RPC interface + // perspective, which can be different from the name of any implementing + // class. The `code.namespace` attribute may be used to store the latter + // (despite the attribute name, it may include a class name; e.g., class + // with method actually executing the call on the server side, RPC client + // stub class on the client side). + RPCServiceKey = attribute.Key("rpc.service") + + // RPCMethodKey is the attribute Key conforming to the "rpc.method" + // semantic conventions. It represents the name of the (logical) method + // being called, must be equal to the $method part in the span name. + // + // Type: string + // RequirementLevel: Recommended + // Stability: stable + // Examples: 'exampleMethod' + // Note: This is the logical name of the method from the RPC interface + // perspective, which can be different from the name of any implementing + // method/function. The `code.function` attribute may be used to store the + // latter (e.g., method actually executing the call on the server side, RPC + // client stub method on the client side). + RPCMethodKey = attribute.Key("rpc.method") +) + +var ( + // gRPC + RPCSystemGRPC = RPCSystemKey.String("grpc") + // Java RMI + RPCSystemJavaRmi = RPCSystemKey.String("java_rmi") + // .NET WCF + RPCSystemDotnetWcf = RPCSystemKey.String("dotnet_wcf") + // Apache Dubbo + RPCSystemApacheDubbo = RPCSystemKey.String("apache_dubbo") + // Connect RPC + RPCSystemConnectRPC = RPCSystemKey.String("connect_rpc") +) + +// RPCService returns an attribute KeyValue conforming to the "rpc.service" +// semantic conventions. It represents the full (logical) name of the service +// being called, including its package name, if applicable. +func RPCService(val string) attribute.KeyValue { + return RPCServiceKey.String(val) +} + +// RPCMethod returns an attribute KeyValue conforming to the "rpc.method" +// semantic conventions. It represents the name of the (logical) method being +// called, must be equal to the $method part in the span name. +func RPCMethod(val string) attribute.KeyValue { + return RPCMethodKey.String(val) +} + +// Tech-specific attributes for gRPC. +const ( + // RPCGRPCStatusCodeKey is the attribute Key conforming to the + // "rpc.grpc.status_code" semantic conventions. It represents the [numeric + // status + // code](https://github.com/grpc/grpc/blob/v1.33.2/doc/statuscodes.md) of + // the gRPC request. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + RPCGRPCStatusCodeKey = attribute.Key("rpc.grpc.status_code") +) + +var ( + // OK + RPCGRPCStatusCodeOk = RPCGRPCStatusCodeKey.Int(0) + // CANCELLED + RPCGRPCStatusCodeCancelled = RPCGRPCStatusCodeKey.Int(1) + // UNKNOWN + RPCGRPCStatusCodeUnknown = RPCGRPCStatusCodeKey.Int(2) + // INVALID_ARGUMENT + RPCGRPCStatusCodeInvalidArgument = RPCGRPCStatusCodeKey.Int(3) + // DEADLINE_EXCEEDED + RPCGRPCStatusCodeDeadlineExceeded = RPCGRPCStatusCodeKey.Int(4) + // NOT_FOUND + RPCGRPCStatusCodeNotFound = RPCGRPCStatusCodeKey.Int(5) + // ALREADY_EXISTS + RPCGRPCStatusCodeAlreadyExists = RPCGRPCStatusCodeKey.Int(6) + // PERMISSION_DENIED + RPCGRPCStatusCodePermissionDenied = RPCGRPCStatusCodeKey.Int(7) + // RESOURCE_EXHAUSTED + RPCGRPCStatusCodeResourceExhausted = RPCGRPCStatusCodeKey.Int(8) + // FAILED_PRECONDITION + RPCGRPCStatusCodeFailedPrecondition = RPCGRPCStatusCodeKey.Int(9) + // ABORTED + RPCGRPCStatusCodeAborted = RPCGRPCStatusCodeKey.Int(10) + // OUT_OF_RANGE + RPCGRPCStatusCodeOutOfRange = RPCGRPCStatusCodeKey.Int(11) + // UNIMPLEMENTED + RPCGRPCStatusCodeUnimplemented = RPCGRPCStatusCodeKey.Int(12) + // INTERNAL + RPCGRPCStatusCodeInternal = RPCGRPCStatusCodeKey.Int(13) + // UNAVAILABLE + RPCGRPCStatusCodeUnavailable = RPCGRPCStatusCodeKey.Int(14) + // DATA_LOSS + RPCGRPCStatusCodeDataLoss = RPCGRPCStatusCodeKey.Int(15) + // UNAUTHENTICATED + RPCGRPCStatusCodeUnauthenticated = RPCGRPCStatusCodeKey.Int(16) +) + +// Tech-specific attributes for [JSON RPC](https://www.jsonrpc.org/). +const ( + // RPCJsonrpcVersionKey is the attribute Key conforming to the + // "rpc.jsonrpc.version" semantic conventions. It represents the protocol + // version as in `jsonrpc` property of request/response. Since JSON-RPC 1.0 + // does not specify this, the value can be omitted. + // + // Type: string + // RequirementLevel: ConditionallyRequired (If other than the default + // version (`1.0`)) + // Stability: stable + // Examples: '2.0', '1.0' + RPCJsonrpcVersionKey = attribute.Key("rpc.jsonrpc.version") + + // RPCJsonrpcRequestIDKey is the attribute Key conforming to the + // "rpc.jsonrpc.request_id" semantic conventions. It represents the `id` + // property of request or response. Since protocol allows id to be int, + // string, `null` or missing (for notifications), value is expected to be + // cast to string for simplicity. Use empty string in case of `null` value. + // Omit entirely if this is a notification. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '10', 'request-7', '' + RPCJsonrpcRequestIDKey = attribute.Key("rpc.jsonrpc.request_id") + + // RPCJsonrpcErrorCodeKey is the attribute Key conforming to the + // "rpc.jsonrpc.error_code" semantic conventions. It represents the + // `error.code` property of response if it is an error response. + // + // Type: int + // RequirementLevel: ConditionallyRequired (If response is not successful.) + // Stability: stable + // Examples: -32700, 100 + RPCJsonrpcErrorCodeKey = attribute.Key("rpc.jsonrpc.error_code") + + // RPCJsonrpcErrorMessageKey is the attribute Key conforming to the + // "rpc.jsonrpc.error_message" semantic conventions. It represents the + // `error.message` property of response if it is an error response. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Parse error', 'User already exists' + RPCJsonrpcErrorMessageKey = attribute.Key("rpc.jsonrpc.error_message") +) + +// RPCJsonrpcVersion returns an attribute KeyValue conforming to the +// "rpc.jsonrpc.version" semantic conventions. It represents the protocol +// version as in `jsonrpc` property of request/response. Since JSON-RPC 1.0 +// does not specify this, the value can be omitted. +func RPCJsonrpcVersion(val string) attribute.KeyValue { + return RPCJsonrpcVersionKey.String(val) +} + +// RPCJsonrpcRequestID returns an attribute KeyValue conforming to the +// "rpc.jsonrpc.request_id" semantic conventions. It represents the `id` +// property of request or response. Since protocol allows id to be int, string, +// `null` or missing (for notifications), value is expected to be cast to +// string for simplicity. Use empty string in case of `null` value. Omit +// entirely if this is a notification. +func RPCJsonrpcRequestID(val string) attribute.KeyValue { + return RPCJsonrpcRequestIDKey.String(val) +} + +// RPCJsonrpcErrorCode returns an attribute KeyValue conforming to the +// "rpc.jsonrpc.error_code" semantic conventions. It represents the +// `error.code` property of response if it is an error response. +func RPCJsonrpcErrorCode(val int) attribute.KeyValue { + return RPCJsonrpcErrorCodeKey.Int(val) +} + +// RPCJsonrpcErrorMessage returns an attribute KeyValue conforming to the +// "rpc.jsonrpc.error_message" semantic conventions. It represents the +// `error.message` property of response if it is an error response. +func RPCJsonrpcErrorMessage(val string) attribute.KeyValue { + return RPCJsonrpcErrorMessageKey.String(val) +} + +// Tech-specific attributes for Connect RPC. +const ( + // RPCConnectRPCErrorCodeKey is the attribute Key conforming to the + // "rpc.connect_rpc.error_code" semantic conventions. It represents the + // [error codes](https://connect.build/docs/protocol/#error-codes) of the + // Connect request. Error codes are always string values. + // + // Type: Enum + // RequirementLevel: ConditionallyRequired (If response is not successful + // and if error code available.) + // Stability: stable + RPCConnectRPCErrorCodeKey = attribute.Key("rpc.connect_rpc.error_code") +) + +var ( + // cancelled + RPCConnectRPCErrorCodeCancelled = RPCConnectRPCErrorCodeKey.String("cancelled") + // unknown + RPCConnectRPCErrorCodeUnknown = RPCConnectRPCErrorCodeKey.String("unknown") + // invalid_argument + RPCConnectRPCErrorCodeInvalidArgument = RPCConnectRPCErrorCodeKey.String("invalid_argument") + // deadline_exceeded + RPCConnectRPCErrorCodeDeadlineExceeded = RPCConnectRPCErrorCodeKey.String("deadline_exceeded") + // not_found + RPCConnectRPCErrorCodeNotFound = RPCConnectRPCErrorCodeKey.String("not_found") + // already_exists + RPCConnectRPCErrorCodeAlreadyExists = RPCConnectRPCErrorCodeKey.String("already_exists") + // permission_denied + RPCConnectRPCErrorCodePermissionDenied = RPCConnectRPCErrorCodeKey.String("permission_denied") + // resource_exhausted + RPCConnectRPCErrorCodeResourceExhausted = RPCConnectRPCErrorCodeKey.String("resource_exhausted") + // failed_precondition + RPCConnectRPCErrorCodeFailedPrecondition = RPCConnectRPCErrorCodeKey.String("failed_precondition") + // aborted + RPCConnectRPCErrorCodeAborted = RPCConnectRPCErrorCodeKey.String("aborted") + // out_of_range + RPCConnectRPCErrorCodeOutOfRange = RPCConnectRPCErrorCodeKey.String("out_of_range") + // unimplemented + RPCConnectRPCErrorCodeUnimplemented = RPCConnectRPCErrorCodeKey.String("unimplemented") + // internal + RPCConnectRPCErrorCodeInternal = RPCConnectRPCErrorCodeKey.String("internal") + // unavailable + RPCConnectRPCErrorCodeUnavailable = RPCConnectRPCErrorCodeKey.String("unavailable") + // data_loss + RPCConnectRPCErrorCodeDataLoss = RPCConnectRPCErrorCodeKey.String("data_loss") + // unauthenticated + RPCConnectRPCErrorCodeUnauthenticated = RPCConnectRPCErrorCodeKey.String("unauthenticated") +) diff --git a/vendor/modules.txt b/vendor/modules.txt index cd764883c..964e32a12 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -124,7 +124,7 @@ github.com/breml/errchkjson # github.com/briandowns/spinner v1.23.0 ## explicit; go 1.17 github.com/briandowns/spinner -# github.com/bufbuild/buf v1.18.0 +# github.com/bufbuild/buf v1.23.1 ## explicit; go 1.19 github.com/bufbuild/buf/cmd/buf github.com/bufbuild/buf/private/buf/bufapp @@ -138,16 +138,21 @@ github.com/bufbuild/buf/private/buf/bufgen github.com/bufbuild/buf/private/buf/bufmigrate github.com/bufbuild/buf/private/buf/bufprint github.com/bufbuild/buf/private/buf/bufref +github.com/bufbuild/buf/private/buf/bufsync github.com/bufbuild/buf/private/buf/bufwire github.com/bufbuild/buf/private/buf/bufwork github.com/bufbuild/buf/private/buf/cmd/buf -github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/plugindelete -github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/pluginpush +github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/goversion +github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/mavenversion +github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/npmversion +github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/package/swiftversion github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/protoc github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokendelete github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokenget github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokenlist +github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/repo/reposync github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/workspace/workspacepush +github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/graph github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/migratev1beta1 github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/price github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/commit/commitget @@ -157,10 +162,8 @@ github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/draft/draftlis github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/organization/organizationcreate github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/organization/organizationdelete github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/organization/organizationget -github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugincreate github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/plugindelete -github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginlist -github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginversion/pluginversionlist +github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/repository/repositorycreate github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/repository/repositorydelete github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/repository/repositorydeprecate @@ -170,11 +173,6 @@ github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/repository/rep github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/repository/repositoryupdate github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/tag/tagcreate github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/tag/taglist -github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatecreate -github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatedelete -github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templatelist -github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversioncreate -github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/template/templateversion/templateversionlist github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/webhook/webhookcreate github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/webhook/webhookdelete github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/webhook/webhooklist @@ -218,6 +216,7 @@ github.com/bufbuild/buf/private/bufpkg/bufcheck/buflint/internal/buflintv1beta1 github.com/bufbuild/buf/private/bufpkg/bufcheck/internal github.com/bufbuild/buf/private/bufpkg/bufconfig github.com/bufbuild/buf/private/bufpkg/bufconnect +github.com/bufbuild/buf/private/bufpkg/bufgraph github.com/bufbuild/buf/private/bufpkg/bufimage github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagebuild github.com/bufbuild/buf/private/bufpkg/bufimage/bufimagemodify @@ -264,9 +263,9 @@ github.com/bufbuild/buf/private/pkg/app/appverbose github.com/bufbuild/buf/private/pkg/cert/certclient github.com/bufbuild/buf/private/pkg/command github.com/bufbuild/buf/private/pkg/connectclient +github.com/bufbuild/buf/private/pkg/dag github.com/bufbuild/buf/private/pkg/diff github.com/bufbuild/buf/private/pkg/encoding -github.com/bufbuild/buf/private/pkg/filelock github.com/bufbuild/buf/private/pkg/filepathextended github.com/bufbuild/buf/private/pkg/git github.com/bufbuild/buf/private/pkg/httpauth @@ -286,6 +285,7 @@ github.com/bufbuild/buf/private/pkg/prototime github.com/bufbuild/buf/private/pkg/protoversion github.com/bufbuild/buf/private/pkg/storage github.com/bufbuild/buf/private/pkg/storage/storagearchive +github.com/bufbuild/buf/private/pkg/storage/storagegit github.com/bufbuild/buf/private/pkg/storage/storagemem github.com/bufbuild/buf/private/pkg/storage/storagemem/internal github.com/bufbuild/buf/private/pkg/storage/storageos @@ -299,10 +299,13 @@ github.com/bufbuild/buf/private/pkg/uuidutil github.com/bufbuild/buf/private/pkg/verbose github.com/bufbuild/buf/private/pkg/zaputil github.com/bufbuild/buf/private/usage -# github.com/bufbuild/connect-go v1.7.0 +# github.com/bufbuild/connect-go v1.8.0 ## explicit; go 1.19 github.com/bufbuild/connect-go github.com/bufbuild/connect-go/internal/gen/connectext/grpc/status/v1 +# github.com/bufbuild/connect-opentelemetry-go v0.3.0 +## explicit; go 1.19 +github.com/bufbuild/connect-opentelemetry-go # github.com/bufbuild/protocompile v0.5.1 ## explicit; go 1.18 github.com/bufbuild/protocompile @@ -352,6 +355,10 @@ github.com/cloudflare/circl/math/mlsbset github.com/cloudflare/circl/sign github.com/cloudflare/circl/sign/ed25519 github.com/cloudflare/circl/sign/ed448 +# github.com/containerd/stargz-snapshotter/estargz v0.14.3 +## explicit; go 1.19 +github.com/containerd/stargz-snapshotter/estargz +github.com/containerd/stargz-snapshotter/estargz/errorutil # github.com/cpuguy83/go-md2man/v2 v2.0.2 ## explicit; go 1.11 github.com/cpuguy83/go-md2man/v2/md2man @@ -379,18 +386,18 @@ github.com/davecgh/go-spew/spew # github.com/denis-tingaikin/go-header v0.4.3 ## explicit; go 1.17 github.com/denis-tingaikin/go-header -# github.com/docker/cli v23.0.5+incompatible +# github.com/docker/cli v24.0.2+incompatible ## explicit github.com/docker/cli/cli/config github.com/docker/cli/cli/config/configfile github.com/docker/cli/cli/config/credentials github.com/docker/cli/cli/config/types -# github.com/docker/distribution v2.8.2-beta.1+incompatible +# github.com/docker/distribution v2.8.2+incompatible ## explicit github.com/docker/distribution/digestset github.com/docker/distribution/reference github.com/docker/distribution/registry/client/auth/challenge -# github.com/docker/docker v23.0.5+incompatible +# github.com/docker/docker v24.0.2+incompatible ## explicit github.com/docker/docker/api github.com/docker/docker/api/types @@ -442,8 +449,8 @@ github.com/esimonov/ifshort/pkg/analyzer # github.com/ettle/strcase v0.1.1 ## explicit; go 1.12 github.com/ettle/strcase -# github.com/evilmartians/lefthook v1.3.13 -## explicit; go 1.19 +# github.com/evilmartians/lefthook v1.4.4 +## explicit; go 1.20 github.com/evilmartians/lefthook github.com/evilmartians/lefthook/cmd github.com/evilmartians/lefthook/internal/config @@ -777,10 +784,11 @@ github.com/google/go-cmp/cmp/internal/diff github.com/google/go-cmp/cmp/internal/flags github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value -# github.com/google/go-containerregistry v0.14.0 +# github.com/google/go-containerregistry v0.15.2 ## explicit; go 1.18 github.com/google/go-containerregistry/internal/and github.com/google/go-containerregistry/internal/compression +github.com/google/go-containerregistry/internal/estargz github.com/google/go-containerregistry/internal/gzip github.com/google/go-containerregistry/internal/redact github.com/google/go-containerregistry/internal/retry @@ -792,13 +800,16 @@ github.com/google/go-containerregistry/pkg/compression github.com/google/go-containerregistry/pkg/logs github.com/google/go-containerregistry/pkg/name github.com/google/go-containerregistry/pkg/v1 +github.com/google/go-containerregistry/pkg/v1/empty github.com/google/go-containerregistry/pkg/v1/match +github.com/google/go-containerregistry/pkg/v1/mutate github.com/google/go-containerregistry/pkg/v1/partial github.com/google/go-containerregistry/pkg/v1/remote github.com/google/go-containerregistry/pkg/v1/remote/transport github.com/google/go-containerregistry/pkg/v1/stream +github.com/google/go-containerregistry/pkg/v1/tarball github.com/google/go-containerregistry/pkg/v1/types -# github.com/google/pprof v0.0.0-20230502171905-255e3b9b56de +# github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 ## explicit; go 1.19 github.com/google/pprof/profile # github.com/google/uuid v1.3.0 @@ -1010,7 +1021,7 @@ github.com/matoous/godox # github.com/mattn/go-colorable v0.1.13 ## explicit; go 1.15 github.com/mattn/go-colorable -# github.com/mattn/go-isatty v0.0.18 +# github.com/mattn/go-isatty v0.0.19 ## explicit; go 1.15 github.com/mattn/go-isatty # github.com/mattn/go-runewidth v0.0.14 @@ -1119,8 +1130,8 @@ github.com/nginxinc/nginx-go-crossplane # github.com/nginxinc/nginx-plus-go-client v0.10.0 ## explicit; go 1.18 github.com/nginxinc/nginx-plus-go-client/client -# github.com/nginxinc/nginx-prometheus-exporter v0.10.0 -## explicit; go 1.17 +# github.com/nginxinc/nginx-prometheus-exporter v0.11.0 +## explicit; go 1.19 github.com/nginxinc/nginx-prometheus-exporter/client # github.com/nishanths/exhaustive v0.9.5 ## explicit; go 1.14 @@ -1187,22 +1198,22 @@ github.com/polyfloyd/go-errorlint/errorlint # github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c ## explicit; go 1.14 github.com/power-devops/perfstat -# github.com/prometheus/client_golang v1.13.0 +# github.com/prometheus/client_golang v1.16.0 ## explicit; go 1.17 github.com/prometheus/client_golang/prometheus github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/promhttp github.com/prometheus/client_golang/prometheus/testutil/promlint -# github.com/prometheus/client_model v0.3.0 -## explicit; go 1.9 +# github.com/prometheus/client_model v0.4.0 +## explicit; go 1.18 github.com/prometheus/client_model/go -# github.com/prometheus/common v0.37.0 -## explicit; go 1.16 +# github.com/prometheus/common v0.44.0 +## explicit; go 1.18 github.com/prometheus/common/expfmt github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg github.com/prometheus/common/model -# github.com/prometheus/procfs v0.8.0 -## explicit; go 1.17 +# github.com/prometheus/procfs v0.11.0 +## explicit; go 1.19 github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util @@ -1249,8 +1260,8 @@ github.com/quasilyte/stdinfo # github.com/rivo/uniseg v0.2.0 ## explicit; go 1.12 github.com/rivo/uniseg -# github.com/rogpeppe/go-internal v1.9.0 -## explicit; go 1.17 +# github.com/rogpeppe/go-internal v1.11.0 +## explicit; go 1.19 github.com/rogpeppe/go-internal/fmtsort # github.com/rs/cors v1.9.0 ## explicit; go 1.13 @@ -1293,8 +1304,9 @@ github.com/shirou/gopsutil/internal/common github.com/shirou/gopsutil/mem github.com/shirou/gopsutil/net github.com/shirou/gopsutil/process -# github.com/shirou/gopsutil/v3 v3.23.2 +# github.com/shirou/gopsutil/v3 v3.23.6 ## explicit; go 1.15 +github.com/shirou/gopsutil/v3/common github.com/shirou/gopsutil/v3/cpu github.com/shirou/gopsutil/v3/disk github.com/shirou/gopsutil/v3/host @@ -1303,6 +1315,9 @@ github.com/shirou/gopsutil/v3/load github.com/shirou/gopsutil/v3/mem github.com/shirou/gopsutil/v3/net github.com/shirou/gopsutil/v3/process +# github.com/shoenig/go-m1cpu v0.1.6 +## explicit; go 1.20 +github.com/shoenig/go-m1cpu # github.com/shopspring/decimal v1.3.1 ## explicit; go 1.13 github.com/shopspring/decimal @@ -1384,7 +1399,7 @@ github.com/tdakkota/asciicheck # github.com/tetafro/godot v1.4.11 ## explicit; go 1.16 github.com/tetafro/godot -# github.com/tetratelabs/wazero v1.1.0 +# github.com/tetratelabs/wazero v1.2.1 ## explicit; go 1.18 github.com/tetratelabs/wazero github.com/tetratelabs/wazero/api @@ -1394,10 +1409,12 @@ github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1 github.com/tetratelabs/wazero/internal/asm github.com/tetratelabs/wazero/internal/asm/amd64 github.com/tetratelabs/wazero/internal/asm/arm64 +github.com/tetratelabs/wazero/internal/bitpack github.com/tetratelabs/wazero/internal/descriptor github.com/tetratelabs/wazero/internal/engine/compiler github.com/tetratelabs/wazero/internal/engine/interpreter github.com/tetratelabs/wazero/internal/filecache +github.com/tetratelabs/wazero/internal/fsapi github.com/tetratelabs/wazero/internal/gojs github.com/tetratelabs/wazero/internal/gojs/config github.com/tetratelabs/wazero/internal/gojs/custom @@ -1411,6 +1428,7 @@ github.com/tetratelabs/wazero/internal/internalapi github.com/tetratelabs/wazero/internal/leb128 github.com/tetratelabs/wazero/internal/moremath github.com/tetratelabs/wazero/internal/platform +github.com/tetratelabs/wazero/internal/sock github.com/tetratelabs/wazero/internal/sys github.com/tetratelabs/wazero/internal/sysfs github.com/tetratelabs/wazero/internal/u32 @@ -1475,6 +1493,9 @@ github.com/uudashr/gocognit # github.com/vardius/message-bus v1.1.5 ## explicit; go 1.12 github.com/vardius/message-bus +# github.com/vbatts/tar-split v0.11.3 +## explicit; go 1.15 +github.com/vbatts/tar-split/archive/tar # github.com/xanzy/ssh-agent v0.3.3 ## explicit; go 1.16 github.com/xanzy/ssh-agent @@ -1486,7 +1507,7 @@ github.com/yagipy/maintidx/pkg/halstvol # github.com/yeya24/promlinter v0.2.0 ## explicit; go 1.16 github.com/yeya24/promlinter -# github.com/yusufpapurcu/wmi v1.2.2 +# github.com/yusufpapurcu/wmi v1.2.3 ## explicit; go 1.16 github.com/yusufpapurcu/wmi # gitlab.com/bosi/decorder v0.2.3 @@ -1515,11 +1536,15 @@ go.opentelemetry.io/otel/internal/attribute go.opentelemetry.io/otel/internal/baggage go.opentelemetry.io/otel/internal/global go.opentelemetry.io/otel/propagation +go.opentelemetry.io/otel/semconv/internal +go.opentelemetry.io/otel/semconv/v1.12.0 go.opentelemetry.io/otel/semconv/v1.17.0 +go.opentelemetry.io/otel/semconv/v1.20.0 # go.opentelemetry.io/otel/metric v1.16.0 ## explicit; go 1.19 go.opentelemetry.io/otel/metric go.opentelemetry.io/otel/metric/embedded +go.opentelemetry.io/otel/metric/noop # go.opentelemetry.io/otel/sdk v1.16.0 ## explicit; go 1.19 go.opentelemetry.io/otel/sdk @@ -1569,7 +1594,7 @@ golang.org/x/crypto/ssh golang.org/x/crypto/ssh/agent golang.org/x/crypto/ssh/internal/bcrypt_pbkdf golang.org/x/crypto/ssh/knownhosts -# golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 +# golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 ## explicit; go 1.20 golang.org/x/exp/constraints golang.org/x/exp/slices @@ -1867,11 +1892,14 @@ honnef.co/go/tools/staticcheck/fakereflect honnef.co/go/tools/staticcheck/fakexml honnef.co/go/tools/stylecheck honnef.co/go/tools/unused -# mvdan.cc/gofumpt v0.4.0 -## explicit; go 1.18 +# mvdan.cc/gofumpt v0.5.0 +## explicit; go 1.19 mvdan.cc/gofumpt mvdan.cc/gofumpt/format -mvdan.cc/gofumpt/internal/diff +mvdan.cc/gofumpt/internal/govendor/diff +mvdan.cc/gofumpt/internal/govendor/go/doc/comment +mvdan.cc/gofumpt/internal/govendor/go/format +mvdan.cc/gofumpt/internal/govendor/go/printer mvdan.cc/gofumpt/internal/version # mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed ## explicit diff --git a/vendor/mvdan.cc/gofumpt/CHANGELOG.md b/vendor/mvdan.cc/gofumpt/CHANGELOG.md index 8c7b8247c..b47adb29e 100644 --- a/vendor/mvdan.cc/gofumpt/CHANGELOG.md +++ b/vendor/mvdan.cc/gofumpt/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## [v0.5.0] - 2023-04-09 + +This release is based on Go 1.20's gofmt, and requires Go 1.19 or later. + +The biggest change in this release is that we now vendor copies of the packages +`go/format`, `go/printer`, and `go/doc/comment` on top of `cmd/gofmt` itself. +This allows for each gofumpt release to format code in exactly the same way +no matter what Go version is used to build it, as Go versions can change those +three packages in ways that alter formatting behavior. + +This vendoring adds a small amount of duplication when using the +`mvdan.cc/gofumpt/format` library, but it's the only way to make gofumpt +versions consistent in their behavior and formatting, just like gofmt. + +The jump to Go 1.20's `go/printer` should also bring a small performance +improvement, as we contributed patches to make printing about 25% faster: + +* https://go.dev/cl/412555 +* https://go.dev/cl/412557 +* https://go.dev/cl/424924 + +The following changes are included as well: + +* Skip `testdata` dirs by default like we already do for `vendor` - [#260] +* Avoid inserting newlines incorrectly in some func signatures - [#235] +* Avoid joining some comments with the previous line - [#256] +* Fix `gofumpt -version` for release archives - [#253] + ## [v0.4.0] - 2022-09-27 This release is based on Go 1.19's gofmt, and requires Go 1.18 or later. @@ -111,6 +139,9 @@ those building programs with gofumpt. Finally, this release adds the `-version` flag, to print the tool's own version. The flag will work for "master" builds too. +[v0.5.0]: https://github.com/mvdan/gofumpt/releases/tag/v0.5.0 +[#212]: https://github.com/mvdan/gofumpt/issues/212 + [v0.4.0]: https://github.com/mvdan/gofumpt/releases/tag/v0.4.0 [#212]: https://github.com/mvdan/gofumpt/issues/212 [#217]: https://github.com/mvdan/gofumpt/issues/217 diff --git a/vendor/mvdan.cc/gofumpt/README.md b/vendor/mvdan.cc/gofumpt/README.md index 8d14123ed..a0206ef17 100644 --- a/vendor/mvdan.cc/gofumpt/README.md +++ b/vendor/mvdan.cc/gofumpt/README.md @@ -7,7 +7,7 @@ Enforce a stricter format than `gofmt`, while being backwards compatible. That is, `gofumpt` is happy with a subset of the formats that `gofmt` is happy with. -The tool is a fork of `gofmt` as of Go 1.19, and requires Go 1.18 or later. +The tool is a fork of `gofmt` as of Go 1.20, and requires Go 1.19 or later. It can be used as a drop-in replacement to format your Go code, and running `gofmt` after `gofumpt` should produce no changes. For example: @@ -15,9 +15,11 @@ For example: gofumpt -l -w . Some of the Go source files in this repository belong to the Go project. +The project includes copies of `go/printer` and `go/doc/comment` as of Go 1.20 +to ensure consistent formatting independent of what Go version is being used. The [added formatting rules](#Added-rules) are implemented in the `format` package. -Note that vendor directories are skipped unless given as explicit arguments. +`vendor` and `testdata` directories are skipped unless given as explicit arguments. Similarly, the added rules do not apply to generated Go files unless they are given as explicit arguments. @@ -26,18 +28,18 @@ and the `-s` flag is hidden as it is always enabled. ### Added rules -No empty lines following an assignment operator +**No empty lines following an assignment operator** -
example +
Example -``` +```go func foo() { foo := "bar" } ``` -``` +```go func foo() { foo := "bar" } @@ -45,11 +47,11 @@ func foo() {
-No empty lines around function bodies +**No empty lines around function bodies** -
example +
Example -``` +```go func foo() { println("bar") @@ -57,7 +59,7 @@ func foo() { } ``` -``` +```go func foo() { println("bar") } @@ -65,11 +67,11 @@ func foo() {
-Functions should separate `) {` where the indentation helps readability +**Functions should separate `) {` where the indentation helps readability** -
example +
Example -``` +```go func foo(s string, i int) { println("bar") @@ -83,7 +85,7 @@ func bar(s string, } ``` -``` +```go func foo(s string, i int, ) { @@ -100,18 +102,18 @@ func bar(s string,
-No empty lines around a lone statement (or comment) in a block +**No empty lines around a lone statement (or comment) in a block** -
example +
Example -``` +```go if err != nil { return err } ``` -``` +```go if err != nil { return err } @@ -119,11 +121,11 @@ if err != nil {
-No empty lines before a simple error check +**No empty lines before a simple error check** -
example +
Example -``` +```go foo, err := processFoo() if err != nil { @@ -131,7 +133,7 @@ if err != nil { } ``` -``` +```go foo, err := processFoo() if err != nil { return err @@ -140,11 +142,11 @@ if err != nil {
-Composite literals should use newlines consistently +**Composite literals should use newlines consistently** -
example +
Example -``` +```go // A newline before or after an element requires newlines for the opening and // closing braces. var ints = []int{1, 2, @@ -160,7 +162,7 @@ var matrix = [][]int{ } ``` -``` +```go var ints = []int{ 1, 2, 3, 4, @@ -177,11 +179,11 @@ var matrix = [][]int{
-Empty field lists should use a single line +**Empty field lists should use a single line** -
example +
Example -``` +```go var V interface { } = 3 @@ -192,7 +194,7 @@ func F( ) ``` -``` +```go var V interface{} = 3 type T struct{} @@ -202,11 +204,11 @@ func F()
-`std` imports must be in a separate group at the top +**`std` imports must be in a separate group at the top** -
example +
Example -``` +```go import ( "foo.com/bar" @@ -216,7 +218,7 @@ import ( ) ``` -``` +```go import ( "io" "io/ioutil" @@ -227,18 +229,18 @@ import (
-Short case clauses should take a single line +**Short case clauses should take a single line** -
example +
Example -``` +```go switch c { case 'a', 'b', 'c', 'd': } ``` -``` +```go switch c { case 'a', 'b', 'c', 'd': } @@ -246,11 +248,11 @@ case 'a', 'b', 'c', 'd':
-Multiline top-level declarations must be separated by empty lines +**Multiline top-level declarations must be separated by empty lines** -
example +
Example -``` +```go func foo() { println("multiline foo") } @@ -259,7 +261,7 @@ func bar() { } ``` -``` +```go func foo() { println("multiline foo") } @@ -271,33 +273,33 @@ func bar() {
-Single var declarations should not be grouped with parentheses +**Single var declarations should not be grouped with parentheses** -
example +
Example -``` +```go var ( foo = "bar" ) ``` -``` +```go var foo = "bar" ```
-Contiguous top-level declarations should be grouped together +**Contiguous top-level declarations should be grouped together** -
example +
Example -``` +```go var nicer = "x" var with = "y" var alignment = "z" ``` -``` +```go var ( nicer = "x" with = "y" @@ -307,63 +309,60 @@ var (
+**Simple var-declaration statements should use short assignments** -Simple var-declaration statements should use short assignments +
Example -
example - -``` +```go var s = "somestring" ``` -``` +```go s := "somestring" ```
+**The `-s` code simplification flag is enabled by default** -The `-s` code simplification flag is enabled by default +
Example -
example - -``` +```go var _ = [][]int{[]int{1}} ``` -``` +```go var _ = [][]int{{1}} ```
+**Octal integer literals should use the `0o` prefix on modules using Go 1.13 and later** -Octal integer literals should use the `0o` prefix on modules using Go 1.13 and later +
Example -
example - -``` +```go const perm = 0755 ``` -``` +```go const perm = 0o755 ```
-Comments which aren't Go directives should start with a whitespace +**Comments which aren't Go directives should start with a whitespace** -
example +
Example -``` +```go //go:noinline //Foo is awesome. func Foo() {} ``` -``` +```go //go:noinline // Foo is awesome. @@ -372,11 +371,11 @@ func Foo() {}
-Composite literals should not have leading or trailing empty lines +**Composite literals should not have leading or trailing empty lines** -
example +
Example -``` +```go var _ = []string{ "foo", @@ -390,7 +389,7 @@ var _ = map[string]string{ } ``` -``` +```go var _ = []string{ "foo", } @@ -402,11 +401,11 @@ var _ = map[string]string{
-Field lists should not have leading or trailing empty lines +**Field lists should not have leading or trailing empty lines** -
example +
Example -``` +```go type Person interface { Name() string @@ -422,7 +421,7 @@ type ZeroFields struct { } ``` -``` +```go type Person interface { Name() string @@ -438,15 +437,15 @@ type ZeroFields struct { #### Extra rules behind `-extra` -Adjacent parameters with the same type should be grouped together +**Adjacent parameters with the same type should be grouped together** -
example +
Example -``` +```go func Foo(bar string, baz string) {} ``` -``` +```go func Foo(bar, baz string) {} ``` @@ -499,7 +498,12 @@ When a window asks for settings, you can enter the following: To avoid unnecessary runs, you should disable all checkboxes in the *Advanced* section. -#### Vim-go +#### Vim + +The configuration depends on the plugin you are using: [vim-go](https://github.com/fatih/vim-go) +or [govim](https://github.com/govim/govim). + +##### vim-go To configure `gopls` to use `gofumpt`: @@ -508,7 +512,7 @@ let g:go_fmt_command="gopls" let g:go_gopls_gofumpt=1 ``` -#### Govim +##### govim To configure `gopls` to use `gofumpt`: @@ -552,6 +556,16 @@ For [eglot](https://github.com/joaotavora/eglot) users: '((:gopls . ((gofumpt . t))))) ``` +#### Helix + +When using the `gopls` language server, modify the Go settings in `~/.config/helix/languages.toml`: + +```toml +[[language]] +name = "go" +config = { "formatting.gofumpt" = true } +``` + #### Sublime Text With ST4, install the Sublime Text LSP extension according to [the documentation](https://github.com/sublimelsp/LSP), diff --git a/vendor/mvdan.cc/gofumpt/format/format.go b/vendor/mvdan.cc/gofumpt/format/format.go index fa4f2fcb6..787561781 100644 --- a/vendor/mvdan.cc/gofumpt/format/format.go +++ b/vendor/mvdan.cc/gofumpt/format/format.go @@ -10,7 +10,6 @@ import ( "bytes" "fmt" "go/ast" - "go/format" "go/parser" "go/token" "os" @@ -26,6 +25,7 @@ import ( "golang.org/x/mod/semver" "golang.org/x/tools/go/ast/astutil" + "mvdan.cc/gofumpt/internal/govendor/go/format" "mvdan.cc/gofumpt/internal/version" ) @@ -395,7 +395,7 @@ func (f *fumpter) applyPre(c *astutil.Cursor) { slc := []string{ "//gofumpt:diagnose", "version:", - version.String(), + version.String(""), "flags:", "-lang=" + f.LangVersion, "-modpath=" + f.ModulePath, @@ -467,13 +467,19 @@ func (f *fumpter) applyPre(c *astutil.Cursor) { specEnd := node.Specs[0].End() if len(f.commentsBetween(node.TokPos, specPos)) > 0 { - // If the single spec has any comment, it must - // go before the entire declaration now. + // If the single spec has a comment on the line above, + // the comment must go before the entire declaration now. node.TokPos = specPos } else { f.removeLines(f.Line(node.TokPos), f.Line(specPos)) } - f.removeLines(f.Line(specEnd), f.Line(node.Rparen)) + if len(f.commentsBetween(specEnd, node.Rparen)) > 0 { + // Leave one newline to not force a comment on the next line to + // become an inline comment. + f.removeLines(f.Line(specEnd)+1, f.Line(node.Rparen)) + } else { + f.removeLines(f.Line(specEnd), f.Line(node.Rparen)) + } // Remove the parentheses. go/printer will automatically // get rid of the newlines. @@ -546,12 +552,19 @@ func (f *fumpter) applyPre(c *astutil.Cursor) { if f.Line(sign.Pos()) != endLine { handleMultiLine := func(fl *ast.FieldList) { + // Refuse to insert a newline before the closing token + // if the list is empty or all in one line. if fl == nil || len(fl.List) == 0 { return } + fieldOpeningLine := f.Line(fl.Opening) + fieldClosingLine := f.Line(fl.Closing) + if fieldOpeningLine == fieldClosingLine { + return + } + lastFieldEnd := fl.List[len(fl.List)-1].End() lastFieldLine := f.Line(lastFieldEnd) - fieldClosingLine := f.Line(fl.Closing) isLastFieldOnFieldClosingLine := lastFieldLine == fieldClosingLine isLastFieldOnSigClosingLine := lastFieldLine == endLine diff --git a/vendor/mvdan.cc/gofumpt/gofmt.go b/vendor/mvdan.cc/gofumpt/gofmt.go index d2a6290fe..384795a99 100644 --- a/vendor/mvdan.cc/gofumpt/gofmt.go +++ b/vendor/mvdan.cc/gofumpt/gofmt.go @@ -12,12 +12,12 @@ import ( "fmt" "go/ast" "go/parser" - "go/printer" "go/scanner" "go/token" "io" "io/fs" "os" + "os/exec" "path/filepath" "regexp" "runtime" @@ -25,16 +25,17 @@ import ( "strings" "sync" - // TODO: we can soon use os/exec thanks to - // https://go.dev/issue/43724 "golang.org/x/sync/semaphore" - exec "golang.org/x/sys/execabs" gformat "mvdan.cc/gofumpt/format" - "mvdan.cc/gofumpt/internal/diff" - "mvdan.cc/gofumpt/internal/version" + "mvdan.cc/gofumpt/internal/govendor/diff" + "mvdan.cc/gofumpt/internal/govendor/go/printer" + gversion "mvdan.cc/gofumpt/internal/version" ) +//go:generate go run gen_govendor.go +//go:generate go run . -w internal/govendor + var ( // main operation modes list = flag.Bool("l", false, "") @@ -56,6 +57,8 @@ var ( simplifyAST = flag.Bool("s", false, "") ) +var version = "" + // Keep these in sync with go/format/format.go. const ( tabWidth = 8 @@ -81,9 +84,6 @@ var fdSem = make(chan bool, 200) var ( fileSet = token.NewFileSet() // per process FileSet parserMode parser.Mode - - // walkingVendorDir is true if we are explicitly walking a vendor directory. - walkingVendorDir bool ) func usage() { @@ -238,7 +238,7 @@ func (r *reporter) getState() *reporterState { // Warnf emits a warning message to the reporter's error stream, // without changing its exit code. -func (r *reporter) Warnf(format string, args ...interface{}) { +func (r *reporter) Warnf(format string, args ...any) { fmt.Fprintf(r.getState().err, format, args...) } @@ -463,7 +463,7 @@ func gofmtMain(s *sequencer) { // Print the gofumpt version if the user asks for it. if *showVersion { - fmt.Println(version.String()) + fmt.Println(gversion.String(version)) return } @@ -509,11 +509,14 @@ func gofmtMain(s *sequencer) { }) default: // Directories are walked, ignoring non-Go files. - walkingVendorDir = filepath.Base(arg) == "vendor" err := filepath.WalkDir(arg, func(path string, f fs.DirEntry, err error) error { - if !walkingVendorDir && filepath.Base(path) == "vendor" { + // vendor and testdata directories are skipped, + // unless they are explicitly passed as an argument. + base := filepath.Base(path) + if path != arg && (base == "vendor" || base == "testdata") { return filepath.SkipDir } + if err != nil || !isGoFile(f) { return err } @@ -541,7 +544,7 @@ type module struct { } } -func loadModuleInfo(dir string) interface{} { +func loadModuleInfo(dir string) any { cmd := exec.Command("go", "mod", "edit", "-json") cmd.Dir = dir diff --git a/vendor/mvdan.cc/gofumpt/internal.go b/vendor/mvdan.cc/gofumpt/internal.go index 058158ad4..55c652c34 100644 --- a/vendor/mvdan.cc/gofumpt/internal.go +++ b/vendor/mvdan.cc/gofumpt/internal.go @@ -13,9 +13,10 @@ import ( "bytes" "go/ast" "go/parser" - "go/printer" "go/token" "strings" + + "mvdan.cc/gofumpt/internal/govendor/go/printer" ) // parse parses src, which was read from the named file, diff --git a/vendor/mvdan.cc/gofumpt/internal/diff/diff.go b/vendor/mvdan.cc/gofumpt/internal/govendor/diff/diff.go similarity index 100% rename from vendor/mvdan.cc/gofumpt/internal/diff/diff.go rename to vendor/mvdan.cc/gofumpt/internal/govendor/diff/diff.go diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/doc.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/doc.go new file mode 100644 index 000000000..45a476aa9 --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/doc.go @@ -0,0 +1,36 @@ +// Copyright 2022 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 comment implements parsing and reformatting of Go doc comments, +(documentation comments), which are comments that immediately precede +a top-level declaration of a package, const, func, type, or var. + +Go doc comment syntax is a simplified subset of Markdown that supports +links, headings, paragraphs, lists (without nesting), and preformatted text blocks. +The details of the syntax are documented at https://go.dev/doc/comment. + +To parse the text associated with a doc comment (after removing comment markers), +use a [Parser]: + + var p comment.Parser + doc := p.Parse(text) + +The result is a [*Doc]. +To reformat it as a doc comment, HTML, Markdown, or plain text, +use a [Printer]: + + var pr comment.Printer + os.Stdout.Write(pr.Text(doc)) + +The [Parser] and [Printer] types are structs whose fields can be +modified to customize the operations. +For details, see the documentation for those types. + +Use cases that need additional control over reformatting can +implement their own logic by inspecting the parsed syntax itself. +See the documentation for [Doc], [Block], [Text] for an overview +and links to additional types. +*/ +package comment diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/html.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/html.go new file mode 100644 index 000000000..bc076f6a5 --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/html.go @@ -0,0 +1,169 @@ +// Copyright 2022 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 comment + +import ( + "bytes" + "fmt" + "strconv" +) + +// An htmlPrinter holds the state needed for printing a Doc as HTML. +type htmlPrinter struct { + *Printer + tight bool +} + +// HTML returns an HTML formatting of the Doc. +// See the [Printer] documentation for ways to customize the HTML output. +func (p *Printer) HTML(d *Doc) []byte { + hp := &htmlPrinter{Printer: p} + var out bytes.Buffer + for _, x := range d.Content { + hp.block(&out, x) + } + return out.Bytes() +} + +// block prints the block x to out. +func (p *htmlPrinter) block(out *bytes.Buffer, x Block) { + switch x := x.(type) { + default: + fmt.Fprintf(out, "?%T", x) + + case *Paragraph: + if !p.tight { + out.WriteString("

") + } + p.text(out, x.Text) + out.WriteString("\n") + + case *Heading: + out.WriteString("") + p.text(out, x.Text) + out.WriteString("\n") + + case *Code: + out.WriteString("

")
+		p.escape(out, x.Text)
+		out.WriteString("
\n") + + case *List: + kind := "ol>\n" + if x.Items[0].Number == "" { + kind = "ul>\n" + } + out.WriteString("<") + out.WriteString(kind) + next := "1" + for _, item := range x.Items { + out.WriteString("") + p.tight = !x.BlankBetween() + for _, blk := range item.Content { + p.block(out, blk) + } + p.tight = false + } + out.WriteString("= 0; i-- { + if b[i] < '9' { + b[i]++ + return string(b) + } + b[i] = '0' + } + return "1" + string(b) +} + +// text prints the text sequence x to out. +func (p *htmlPrinter) text(out *bytes.Buffer, x []Text) { + for _, t := range x { + switch t := t.(type) { + case Plain: + p.escape(out, string(t)) + case Italic: + out.WriteString("") + p.escape(out, string(t)) + out.WriteString("") + case *Link: + out.WriteString(``) + p.text(out, t.Text) + out.WriteString("") + case *DocLink: + url := p.docLinkURL(t) + if url != "" { + out.WriteString(``) + } + p.text(out, t.Text) + if url != "" { + out.WriteString("") + } + } + } +} + +// escape prints s to out as plain text, +// escaping < & " ' and > to avoid being misinterpreted +// in larger HTML constructs. +func (p *htmlPrinter) escape(out *bytes.Buffer, s string) { + start := 0 + for i := 0; i < len(s); i++ { + switch s[i] { + case '<': + out.WriteString(s[start:i]) + out.WriteString("<") + start = i + 1 + case '&': + out.WriteString(s[start:i]) + out.WriteString("&") + start = i + 1 + case '"': + out.WriteString(s[start:i]) + out.WriteString(""") + start = i + 1 + case '\'': + out.WriteString(s[start:i]) + out.WriteString("'") + start = i + 1 + case '>': + out.WriteString(s[start:i]) + out.WriteString(">") + start = i + 1 + } + } + out.WriteString(s[start:]) +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/markdown.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/markdown.go new file mode 100644 index 000000000..d8550f2e3 --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/markdown.go @@ -0,0 +1,188 @@ +// Copyright 2022 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 comment + +import ( + "bytes" + "fmt" + "strings" +) + +// An mdPrinter holds the state needed for printing a Doc as Markdown. +type mdPrinter struct { + *Printer + headingPrefix string + raw bytes.Buffer +} + +// Markdown returns a Markdown formatting of the Doc. +// See the [Printer] documentation for ways to customize the Markdown output. +func (p *Printer) Markdown(d *Doc) []byte { + mp := &mdPrinter{ + Printer: p, + headingPrefix: strings.Repeat("#", p.headingLevel()) + " ", + } + + var out bytes.Buffer + for i, x := range d.Content { + if i > 0 { + out.WriteByte('\n') + } + mp.block(&out, x) + } + return out.Bytes() +} + +// block prints the block x to out. +func (p *mdPrinter) block(out *bytes.Buffer, x Block) { + switch x := x.(type) { + default: + fmt.Fprintf(out, "?%T", x) + + case *Paragraph: + p.text(out, x.Text) + out.WriteString("\n") + + case *Heading: + out.WriteString(p.headingPrefix) + p.text(out, x.Text) + if id := p.headingID(x); id != "" { + out.WriteString(" {#") + out.WriteString(id) + out.WriteString("}") + } + out.WriteString("\n") + + case *Code: + md := x.Text + for md != "" { + var line string + line, md, _ = strings.Cut(md, "\n") + if line != "" { + out.WriteString("\t") + out.WriteString(line) + } + out.WriteString("\n") + } + + case *List: + loose := x.BlankBetween() + for i, item := range x.Items { + if i > 0 && loose { + out.WriteString("\n") + } + if n := item.Number; n != "" { + out.WriteString(" ") + out.WriteString(n) + out.WriteString(". ") + } else { + out.WriteString(" - ") // SP SP - SP + } + for i, blk := range item.Content { + const fourSpace = " " + if i > 0 { + out.WriteString("\n" + fourSpace) + } + p.text(out, blk.(*Paragraph).Text) + out.WriteString("\n") + } + } + } +} + +// text prints the text sequence x to out. +func (p *mdPrinter) text(out *bytes.Buffer, x []Text) { + p.raw.Reset() + p.rawText(&p.raw, x) + line := bytes.TrimSpace(p.raw.Bytes()) + if len(line) == 0 { + return + } + switch line[0] { + case '+', '-', '*', '#': + // Escape what would be the start of an unordered list or heading. + out.WriteByte('\\') + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + i := 1 + for i < len(line) && '0' <= line[i] && line[i] <= '9' { + i++ + } + if i < len(line) && (line[i] == '.' || line[i] == ')') { + // Escape what would be the start of an ordered list. + out.Write(line[:i]) + out.WriteByte('\\') + line = line[i:] + } + } + out.Write(line) +} + +// rawText prints the text sequence x to out, +// without worrying about escaping characters +// that have special meaning at the start of a Markdown line. +func (p *mdPrinter) rawText(out *bytes.Buffer, x []Text) { + for _, t := range x { + switch t := t.(type) { + case Plain: + p.escape(out, string(t)) + case Italic: + out.WriteString("*") + p.escape(out, string(t)) + out.WriteString("*") + case *Link: + out.WriteString("[") + p.rawText(out, t.Text) + out.WriteString("](") + out.WriteString(t.URL) + out.WriteString(")") + case *DocLink: + url := p.docLinkURL(t) + if url != "" { + out.WriteString("[") + } + p.rawText(out, t.Text) + if url != "" { + out.WriteString("](") + url = strings.ReplaceAll(url, "(", "%28") + url = strings.ReplaceAll(url, ")", "%29") + out.WriteString(url) + out.WriteString(")") + } + } + } +} + +// escape prints s to out as plain text, +// escaping special characters to avoid being misinterpreted +// as Markdown markup sequences. +func (p *mdPrinter) escape(out *bytes.Buffer, s string) { + start := 0 + for i := 0; i < len(s); i++ { + switch s[i] { + case '\n': + // Turn all \n into spaces, for a few reasons: + // - Avoid introducing paragraph breaks accidentally. + // - Avoid the need to reindent after the newline. + // - Avoid problems with Markdown renderers treating + // every mid-paragraph newline as a
. + out.WriteString(s[start:i]) + out.WriteByte(' ') + start = i + 1 + continue + case '`', '_', '*', '[', '<', '\\': + // Not all of these need to be escaped all the time, + // but is valid and easy to do so. + // We assume the Markdown is being passed to a + // Markdown renderer, not edited by a person, + // so it's fine to have escapes that are not strictly + // necessary in some cases. + out.WriteString(s[start:i]) + out.WriteByte('\\') + out.WriteByte(s[i]) + start = i + 1 + } + } + out.WriteString(s[start:]) +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/parse.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/parse.go new file mode 100644 index 000000000..372577b2b --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/parse.go @@ -0,0 +1,1262 @@ +// Copyright 2022 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 comment + +import ( + "sort" + "strings" + "unicode" + "unicode/utf8" +) + +// A Doc is a parsed Go doc comment. +type Doc struct { + // Content is the sequence of content blocks in the comment. + Content []Block + + // Links is the link definitions in the comment. + Links []*LinkDef +} + +// A LinkDef is a single link definition. +type LinkDef struct { + Text string // the link text + URL string // the link URL + Used bool // whether the comment uses the definition +} + +// A Block is block-level content in a doc comment, +// one of [*Code], [*Heading], [*List], or [*Paragraph]. +type Block interface { + block() +} + +// A Heading is a doc comment heading. +type Heading struct { + Text []Text // the heading text +} + +func (*Heading) block() {} + +// A List is a numbered or bullet list. +// Lists are always non-empty: len(Items) > 0. +// In a numbered list, every Items[i].Number is a non-empty string. +// In a bullet list, every Items[i].Number is an empty string. +type List struct { + // Items is the list items. + Items []*ListItem + + // ForceBlankBefore indicates that the list must be + // preceded by a blank line when reformatting the comment, + // overriding the usual conditions. See the BlankBefore method. + // + // The comment parser sets ForceBlankBefore for any list + // that is preceded by a blank line, to make sure + // the blank line is preserved when printing. + ForceBlankBefore bool + + // ForceBlankBetween indicates that list items must be + // separated by blank lines when reformatting the comment, + // overriding the usual conditions. See the BlankBetween method. + // + // The comment parser sets ForceBlankBetween for any list + // that has a blank line between any two of its items, to make sure + // the blank lines are preserved when printing. + ForceBlankBetween bool +} + +func (*List) block() {} + +// BlankBefore reports whether a reformatting of the comment +// should include a blank line before the list. +// The default rule is the same as for [BlankBetween]: +// if the list item content contains any blank lines +// (meaning at least one item has multiple paragraphs) +// then the list itself must be preceded by a blank line. +// A preceding blank line can be forced by setting [List].ForceBlankBefore. +func (l *List) BlankBefore() bool { + return l.ForceBlankBefore || l.BlankBetween() +} + +// BlankBetween reports whether a reformatting of the comment +// should include a blank line between each pair of list items. +// The default rule is that if the list item content contains any blank lines +// (meaning at least one item has multiple paragraphs) +// then list items must themselves be separated by blank lines. +// Blank line separators can be forced by setting [List].ForceBlankBetween. +func (l *List) BlankBetween() bool { + if l.ForceBlankBetween { + return true + } + for _, item := range l.Items { + if len(item.Content) != 1 { + // Unreachable for parsed comments today, + // since the only way to get multiple item.Content + // is multiple paragraphs, which must have been + // separated by a blank line. + return true + } + } + return false +} + +// A ListItem is a single item in a numbered or bullet list. +type ListItem struct { + // Number is a decimal string in a numbered list + // or an empty string in a bullet list. + Number string // "1", "2", ...; "" for bullet list + + // Content is the list content. + // Currently, restrictions in the parser and printer + // require every element of Content to be a *Paragraph. + Content []Block // Content of this item. +} + +// A Paragraph is a paragraph of text. +type Paragraph struct { + Text []Text +} + +func (*Paragraph) block() {} + +// A Code is a preformatted code block. +type Code struct { + // Text is the preformatted text, ending with a newline character. + // It may be multiple lines, each of which ends with a newline character. + // It is never empty, nor does it start or end with a blank line. + Text string +} + +func (*Code) block() {} + +// A Text is text-level content in a doc comment, +// one of [Plain], [Italic], [*Link], or [*DocLink]. +type Text interface { + text() +} + +// A Plain is a string rendered as plain text (not italicized). +type Plain string + +func (Plain) text() {} + +// An Italic is a string rendered as italicized text. +type Italic string + +func (Italic) text() {} + +// A Link is a link to a specific URL. +type Link struct { + Auto bool // is this an automatic (implicit) link of a literal URL? + Text []Text // text of link + URL string // target URL of link +} + +func (*Link) text() {} + +// A DocLink is a link to documentation for a Go package or symbol. +type DocLink struct { + Text []Text // text of link + + // ImportPath, Recv, and Name identify the Go package or symbol + // that is the link target. The potential combinations of + // non-empty fields are: + // - ImportPath: a link to another package + // - ImportPath, Name: a link to a const, func, type, or var in another package + // - ImportPath, Recv, Name: a link to a method in another package + // - Name: a link to a const, func, type, or var in this package + // - Recv, Name: a link to a method in this package + ImportPath string // import path + Recv string // receiver type, without any pointer star, for methods + Name string // const, func, type, var, or method name +} + +func (*DocLink) text() {} + +// A Parser is a doc comment parser. +// The fields in the struct can be filled in before calling Parse +// in order to customize the details of the parsing process. +type Parser struct { + // Words is a map of Go identifier words that + // should be italicized and potentially linked. + // If Words[w] is the empty string, then the word w + // is only italicized. Otherwise it is linked, using + // Words[w] as the link target. + // Words corresponds to the [go/doc.ToHTML] words parameter. + Words map[string]string + + // LookupPackage resolves a package name to an import path. + // + // If LookupPackage(name) returns ok == true, then [name] + // (or [name.Sym] or [name.Sym.Method]) + // is considered a documentation link to importPath's package docs. + // It is valid to return "", true, in which case name is considered + // to refer to the current package. + // + // If LookupPackage(name) returns ok == false, + // then [name] (or [name.Sym] or [name.Sym.Method]) + // will not be considered a documentation link, + // except in the case where name is the full (but single-element) import path + // of a package in the standard library, such as in [math] or [io.Reader]. + // LookupPackage is still called for such names, + // in order to permit references to imports of other packages + // with the same package names. + // + // Setting LookupPackage to nil is equivalent to setting it to + // a function that always returns "", false. + LookupPackage func(name string) (importPath string, ok bool) + + // LookupSym reports whether a symbol name or method name + // exists in the current package. + // + // If LookupSym("", "Name") returns true, then [Name] + // is considered a documentation link for a const, func, type, or var. + // + // Similarly, if LookupSym("Recv", "Name") returns true, + // then [Recv.Name] is considered a documentation link for + // type Recv's method Name. + // + // Setting LookupSym to nil is equivalent to setting it to a function + // that always returns false. + LookupSym func(recv, name string) (ok bool) +} + +// parseDoc is parsing state for a single doc comment. +type parseDoc struct { + *Parser + *Doc + links map[string]*LinkDef + lines []string + lookupSym func(recv, name string) bool +} + +// lookupPkg is called to look up the pkg in [pkg], [pkg.Name], and [pkg.Name.Recv]. +// If pkg has a slash, it is assumed to be the full import path and is returned with ok = true. +// +// Otherwise, pkg is probably a simple package name like "rand" (not "crypto/rand" or "math/rand"). +// d.LookupPackage provides a way for the caller to allow resolving such names with reference +// to the imports in the surrounding package. +// +// There is one collision between these two cases: single-element standard library names +// like "math" are full import paths but don't contain slashes. We let d.LookupPackage have +// the first chance to resolve it, in case there's a different package imported as math, +// and otherwise we refer to a built-in list of single-element standard library package names. +func (d *parseDoc) lookupPkg(pkg string) (importPath string, ok bool) { + if strings.Contains(pkg, "/") { // assume a full import path + if validImportPath(pkg) { + return pkg, true + } + return "", false + } + if d.LookupPackage != nil { + // Give LookupPackage a chance. + if path, ok := d.LookupPackage(pkg); ok { + return path, true + } + } + return DefaultLookupPackage(pkg) +} + +func isStdPkg(path string) bool { + // TODO(rsc): Use sort.Find once we don't have to worry about + // copying this code into older Go environments. + i := sort.Search(len(stdPkgs), func(i int) bool { return stdPkgs[i] >= path }) + return i < len(stdPkgs) && stdPkgs[i] == path +} + +// DefaultLookupPackage is the default package lookup +// function, used when [Parser].LookupPackage is nil. +// It recognizes names of the packages from the standard +// library with single-element import paths, such as math, +// which would otherwise be impossible to name. +// +// Note that the go/doc package provides a more sophisticated +// lookup based on the imports used in the current package. +func DefaultLookupPackage(name string) (importPath string, ok bool) { + if isStdPkg(name) { + return name, true + } + return "", false +} + +// Parse parses the doc comment text and returns the *Doc form. +// Comment markers (/* // and */) in the text must have already been removed. +func (p *Parser) Parse(text string) *Doc { + lines := unindent(strings.Split(text, "\n")) + d := &parseDoc{ + Parser: p, + Doc: new(Doc), + links: make(map[string]*LinkDef), + lines: lines, + lookupSym: func(recv, name string) bool { return false }, + } + if p.LookupSym != nil { + d.lookupSym = p.LookupSym + } + + // First pass: break into block structure and collect known links. + // The text is all recorded as Plain for now. + var prev span + for _, s := range parseSpans(lines) { + var b Block + switch s.kind { + default: + panic("mvdan.cc/gofumpt/internal/govendor/go/doc/comment: internal error: unknown span kind") + case spanList: + b = d.list(lines[s.start:s.end], prev.end < s.start) + case spanCode: + b = d.code(lines[s.start:s.end]) + case spanOldHeading: + b = d.oldHeading(lines[s.start]) + case spanHeading: + b = d.heading(lines[s.start]) + case spanPara: + b = d.paragraph(lines[s.start:s.end]) + } + if b != nil { + d.Content = append(d.Content, b) + } + prev = s + } + + // Second pass: interpret all the Plain text now that we know the links. + for _, b := range d.Content { + switch b := b.(type) { + case *Paragraph: + b.Text = d.parseLinkedText(string(b.Text[0].(Plain))) + case *List: + for _, i := range b.Items { + for _, c := range i.Content { + p := c.(*Paragraph) + p.Text = d.parseLinkedText(string(p.Text[0].(Plain))) + } + } + } + } + + return d.Doc +} + +// A span represents a single span of comment lines (lines[start:end]) +// of an identified kind (code, heading, paragraph, and so on). +type span struct { + start int + end int + kind spanKind +} + +// A spanKind describes the kind of span. +type spanKind int + +const ( + _ spanKind = iota + spanCode + spanHeading + spanList + spanOldHeading + spanPara +) + +func parseSpans(lines []string) []span { + var spans []span + + // The loop may process a line twice: once as unindented + // and again forced indented. So the maximum expected + // number of iterations is 2*len(lines). The repeating logic + // can be subtle, though, and to protect against introduction + // of infinite loops in future changes, we watch to see that + // we are not looping too much. A panic is better than a + // quiet infinite loop. + watchdog := 2 * len(lines) + + i := 0 + forceIndent := 0 +Spans: + for { + // Skip blank lines. + for i < len(lines) && lines[i] == "" { + i++ + } + if i >= len(lines) { + break + } + if watchdog--; watchdog < 0 { + panic("mvdan.cc/gofumpt/internal/govendor/go/doc/comment: internal error: not making progress") + } + + var kind spanKind + start := i + end := i + if i < forceIndent || indented(lines[i]) { + // Indented (or force indented). + // Ends before next unindented. (Blank lines are OK.) + // If this is an unindented list that we are heuristically treating as indented, + // then accept unindented list item lines up to the first blank lines. + // The heuristic is disabled at blank lines to contain its effect + // to non-gofmt'ed sections of the comment. + unindentedListOK := isList(lines[i]) && i < forceIndent + i++ + for i < len(lines) && (lines[i] == "" || i < forceIndent || indented(lines[i]) || (unindentedListOK && isList(lines[i]))) { + if lines[i] == "" { + unindentedListOK = false + } + i++ + } + + // Drop trailing blank lines. + end = i + for end > start && lines[end-1] == "" { + end-- + } + + // If indented lines are followed (without a blank line) + // by an unindented line ending in a brace, + // take that one line too. This fixes the common mistake + // of pasting in something like + // + // func main() { + // fmt.Println("hello, world") + // } + // + // and forgetting to indent it. + // The heuristic will never trigger on a gofmt'ed comment, + // because any gofmt'ed code block or list would be + // followed by a blank line or end of comment. + if end < len(lines) && strings.HasPrefix(lines[end], "}") { + end++ + } + + if isList(lines[start]) { + kind = spanList + } else { + kind = spanCode + } + } else { + // Unindented. Ends at next blank or indented line. + i++ + for i < len(lines) && lines[i] != "" && !indented(lines[i]) { + i++ + } + end = i + + // If unindented lines are followed (without a blank line) + // by an indented line that would start a code block, + // check whether the final unindented lines + // should be left for the indented section. + // This can happen for the common mistakes of + // unindented code or unindented lists. + // The heuristic will never trigger on a gofmt'ed comment, + // because any gofmt'ed code block would have a blank line + // preceding it after the unindented lines. + if i < len(lines) && lines[i] != "" && !isList(lines[i]) { + switch { + case isList(lines[i-1]): + // If the final unindented line looks like a list item, + // this may be the first indented line wrap of + // a mistakenly unindented list. + // Leave all the unindented list items. + forceIndent = end + end-- + for end > start && isList(lines[end-1]) { + end-- + } + + case strings.HasSuffix(lines[i-1], "{") || strings.HasSuffix(lines[i-1], `\`): + // If the final unindented line ended in { or \ + // it is probably the start of a misindented code block. + // Give the user a single line fix. + // Often that's enough; if not, the user can fix the others themselves. + forceIndent = end + end-- + } + + if start == end && forceIndent > start { + i = start + continue Spans + } + } + + // Span is either paragraph or heading. + if end-start == 1 && isHeading(lines[start]) { + kind = spanHeading + } else if end-start == 1 && isOldHeading(lines[start], lines, start) { + kind = spanOldHeading + } else { + kind = spanPara + } + } + + spans = append(spans, span{start, end, kind}) + i = end + } + + return spans +} + +// indented reports whether line is indented +// (starts with a leading space or tab). +func indented(line string) bool { + return line != "" && (line[0] == ' ' || line[0] == '\t') +} + +// unindent removes any common space/tab prefix +// from each line in lines, returning a copy of lines in which +// those prefixes have been trimmed from each line. +// It also replaces any lines containing only spaces with blank lines (empty strings). +func unindent(lines []string) []string { + // Trim leading and trailing blank lines. + for len(lines) > 0 && isBlank(lines[0]) { + lines = lines[1:] + } + for len(lines) > 0 && isBlank(lines[len(lines)-1]) { + lines = lines[:len(lines)-1] + } + if len(lines) == 0 { + return nil + } + + // Compute and remove common indentation. + prefix := leadingSpace(lines[0]) + for _, line := range lines[1:] { + if !isBlank(line) { + prefix = commonPrefix(prefix, leadingSpace(line)) + } + } + + out := make([]string, len(lines)) + for i, line := range lines { + line = strings.TrimPrefix(line, prefix) + if strings.TrimSpace(line) == "" { + line = "" + } + out[i] = line + } + for len(out) > 0 && out[0] == "" { + out = out[1:] + } + for len(out) > 0 && out[len(out)-1] == "" { + out = out[:len(out)-1] + } + return out +} + +// isBlank reports whether s is a blank line. +func isBlank(s string) bool { + return len(s) == 0 || (len(s) == 1 && s[0] == '\n') +} + +// commonPrefix returns the longest common prefix of a and b. +func commonPrefix(a, b string) string { + i := 0 + for i < len(a) && i < len(b) && a[i] == b[i] { + i++ + } + return a[0:i] +} + +// leadingSpace returns the longest prefix of s consisting of spaces and tabs. +func leadingSpace(s string) string { + i := 0 + for i < len(s) && (s[i] == ' ' || s[i] == '\t') { + i++ + } + return s[:i] +} + +// isOldHeading reports whether line is an old-style section heading. +// line is all[off]. +func isOldHeading(line string, all []string, off int) bool { + if off <= 0 || all[off-1] != "" || off+2 >= len(all) || all[off+1] != "" || leadingSpace(all[off+2]) != "" { + return false + } + + line = strings.TrimSpace(line) + + // a heading must start with an uppercase letter + r, _ := utf8.DecodeRuneInString(line) + if !unicode.IsLetter(r) || !unicode.IsUpper(r) { + return false + } + + // it must end in a letter or digit: + r, _ = utf8.DecodeLastRuneInString(line) + if !unicode.IsLetter(r) && !unicode.IsDigit(r) { + return false + } + + // exclude lines with illegal characters. we allow "()," + if strings.ContainsAny(line, ";:!?+*/=[]{}_^°&§~%#@<\">\\") { + return false + } + + // allow "'" for possessive "'s" only + for b := line; ; { + var ok bool + if _, b, ok = strings.Cut(b, "'"); !ok { + break + } + if b != "s" && !strings.HasPrefix(b, "s ") { + return false // ' not followed by s and then end-of-word + } + } + + // allow "." when followed by non-space + for b := line; ; { + var ok bool + if _, b, ok = strings.Cut(b, "."); !ok { + break + } + if b == "" || strings.HasPrefix(b, " ") { + return false // not followed by non-space + } + } + + return true +} + +// oldHeading returns the *Heading for the given old-style section heading line. +func (d *parseDoc) oldHeading(line string) Block { + return &Heading{Text: []Text{Plain(strings.TrimSpace(line))}} +} + +// isHeading reports whether line is a new-style section heading. +func isHeading(line string) bool { + return len(line) >= 2 && + line[0] == '#' && + (line[1] == ' ' || line[1] == '\t') && + strings.TrimSpace(line) != "#" +} + +// heading returns the *Heading for the given new-style section heading line. +func (d *parseDoc) heading(line string) Block { + return &Heading{Text: []Text{Plain(strings.TrimSpace(line[1:]))}} +} + +// code returns a code block built from the lines. +func (d *parseDoc) code(lines []string) *Code { + body := unindent(lines) + body = append(body, "") // to get final \n from Join + return &Code{Text: strings.Join(body, "\n")} +} + +// paragraph returns a paragraph block built from the lines. +// If the lines are link definitions, paragraph adds them to d and returns nil. +func (d *parseDoc) paragraph(lines []string) Block { + // Is this a block of known links? Handle. + var defs []*LinkDef + for _, line := range lines { + def, ok := parseLink(line) + if !ok { + goto NoDefs + } + defs = append(defs, def) + } + for _, def := range defs { + d.Links = append(d.Links, def) + if d.links[def.Text] == nil { + d.links[def.Text] = def + } + } + return nil +NoDefs: + + return &Paragraph{Text: []Text{Plain(strings.Join(lines, "\n"))}} +} + +// parseLink parses a single link definition line: +// +// [text]: url +// +// It returns the link definition and whether the line was well formed. +func parseLink(line string) (*LinkDef, bool) { + if line == "" || line[0] != '[' { + return nil, false + } + i := strings.Index(line, "]:") + if i < 0 || i+3 >= len(line) || (line[i+2] != ' ' && line[i+2] != '\t') { + return nil, false + } + + text := line[1:i] + url := strings.TrimSpace(line[i+3:]) + j := strings.Index(url, "://") + if j < 0 || !isScheme(url[:j]) { + return nil, false + } + + // Line has right form and has valid scheme://. + // That's good enough for us - we are not as picky + // about the characters beyond the :// as we are + // when extracting inline URLs from text. + return &LinkDef{Text: text, URL: url}, true +} + +// list returns a list built from the indented lines, +// using forceBlankBefore as the value of the List's ForceBlankBefore field. +func (d *parseDoc) list(lines []string, forceBlankBefore bool) *List { + num, _, _ := listMarker(lines[0]) + var ( + list *List = &List{ForceBlankBefore: forceBlankBefore} + item *ListItem + text []string + ) + flush := func() { + if item != nil { + if para := d.paragraph(text); para != nil { + item.Content = append(item.Content, para) + } + } + text = nil + } + + for _, line := range lines { + if n, after, ok := listMarker(line); ok && (n != "") == (num != "") { + // start new list item + flush() + + item = &ListItem{Number: n} + list.Items = append(list.Items, item) + line = after + } + line = strings.TrimSpace(line) + if line == "" { + list.ForceBlankBetween = true + flush() + continue + } + text = append(text, strings.TrimSpace(line)) + } + flush() + return list +} + +// listMarker parses the line as beginning with a list marker. +// If it can do that, it returns the numeric marker ("" for a bullet list), +// the rest of the line, and ok == true. +// Otherwise, it returns "", "", false. +func listMarker(line string) (num, rest string, ok bool) { + line = strings.TrimSpace(line) + if line == "" { + return "", "", false + } + + // Can we find a marker? + if r, n := utf8.DecodeRuneInString(line); r == '•' || r == '*' || r == '+' || r == '-' { + num, rest = "", line[n:] + } else if '0' <= line[0] && line[0] <= '9' { + n := 1 + for n < len(line) && '0' <= line[n] && line[n] <= '9' { + n++ + } + if n >= len(line) || (line[n] != '.' && line[n] != ')') { + return "", "", false + } + num, rest = line[:n], line[n+1:] + } else { + return "", "", false + } + + if !indented(rest) || strings.TrimSpace(rest) == "" { + return "", "", false + } + + return num, rest, true +} + +// isList reports whether the line is the first line of a list, +// meaning starts with a list marker after any indentation. +// (The caller is responsible for checking the line is indented, as appropriate.) +func isList(line string) bool { + _, _, ok := listMarker(line) + return ok +} + +// parseLinkedText parses text that is allowed to contain explicit links, +// such as [math.Sin] or [Go home page], into a slice of Text items. +// +// A “pkg” is only assumed to be a full import path if it starts with +// a domain name (a path element with a dot) or is one of the packages +// from the standard library (“[os]”, “[encoding/json]”, and so on). +// To avoid problems with maps, generics, and array types, doc links +// must be both preceded and followed by punctuation, spaces, tabs, +// or the start or end of a line. An example problem would be treating +// map[ast.Expr]TypeAndValue as containing a link. +func (d *parseDoc) parseLinkedText(text string) []Text { + var out []Text + wrote := 0 + flush := func(i int) { + if wrote < i { + out = d.parseText(out, text[wrote:i], true) + wrote = i + } + } + + start := -1 + var buf []byte + for i := 0; i < len(text); i++ { + c := text[i] + if c == '\n' || c == '\t' { + c = ' ' + } + switch c { + case '[': + start = i + case ']': + if start >= 0 { + if def, ok := d.links[string(buf)]; ok { + def.Used = true + flush(start) + out = append(out, &Link{ + Text: d.parseText(nil, text[start+1:i], false), + URL: def.URL, + }) + wrote = i + 1 + } else if link, ok := d.docLink(text[start+1:i], text[:start], text[i+1:]); ok { + flush(start) + link.Text = d.parseText(nil, text[start+1:i], false) + out = append(out, link) + wrote = i + 1 + } + } + start = -1 + buf = buf[:0] + } + if start >= 0 && i != start { + buf = append(buf, c) + } + } + + flush(len(text)) + return out +} + +// docLink parses text, which was found inside [ ] brackets, +// as a doc link if possible, returning the DocLink and ok == true +// or else nil, false. +// The before and after strings are the text before the [ and after the ] +// on the same line. Doc links must be preceded and followed by +// punctuation, spaces, tabs, or the start or end of a line. +func (d *parseDoc) docLink(text, before, after string) (link *DocLink, ok bool) { + if before != "" { + r, _ := utf8.DecodeLastRuneInString(before) + if !unicode.IsPunct(r) && r != ' ' && r != '\t' && r != '\n' { + return nil, false + } + } + if after != "" { + r, _ := utf8.DecodeRuneInString(after) + if !unicode.IsPunct(r) && r != ' ' && r != '\t' && r != '\n' { + return nil, false + } + } + text = strings.TrimPrefix(text, "*") + pkg, name, ok := splitDocName(text) + var recv string + if ok { + pkg, recv, _ = splitDocName(pkg) + } + if pkg != "" { + if pkg, ok = d.lookupPkg(pkg); !ok { + return nil, false + } + } else { + if ok = d.lookupSym(recv, name); !ok { + return nil, false + } + } + link = &DocLink{ + ImportPath: pkg, + Recv: recv, + Name: name, + } + return link, true +} + +// If text is of the form before.Name, where Name is a capitalized Go identifier, +// then splitDocName returns before, name, true. +// Otherwise it returns text, "", false. +func splitDocName(text string) (before, name string, foundDot bool) { + i := strings.LastIndex(text, ".") + name = text[i+1:] + if !isName(name) { + return text, "", false + } + if i >= 0 { + before = text[:i] + } + return before, name, true +} + +// parseText parses s as text and returns the result of appending +// those parsed Text elements to out. +// parseText does not handle explicit links like [math.Sin] or [Go home page]: +// those are handled by parseLinkedText. +// If autoLink is true, then parseText recognizes URLs and words from d.Words +// and converts those to links as appropriate. +func (d *parseDoc) parseText(out []Text, s string, autoLink bool) []Text { + var w strings.Builder + wrote := 0 + writeUntil := func(i int) { + w.WriteString(s[wrote:i]) + wrote = i + } + flush := func(i int) { + writeUntil(i) + if w.Len() > 0 { + out = append(out, Plain(w.String())) + w.Reset() + } + } + for i := 0; i < len(s); { + t := s[i:] + if autoLink { + if url, ok := autoURL(t); ok { + flush(i) + // Note: The old comment parser would look up the URL in words + // and replace the target with words[URL] if it was non-empty. + // That would allow creating links that display as one URL but + // when clicked go to a different URL. Not sure what the point + // of that is, so we're not doing that lookup here. + out = append(out, &Link{Auto: true, Text: []Text{Plain(url)}, URL: url}) + i += len(url) + wrote = i + continue + } + if id, ok := ident(t); ok { + url, italics := d.Words[id] + if !italics { + i += len(id) + continue + } + flush(i) + if url == "" { + out = append(out, Italic(id)) + } else { + out = append(out, &Link{Auto: true, Text: []Text{Italic(id)}, URL: url}) + } + i += len(id) + wrote = i + continue + } + } + switch { + case strings.HasPrefix(t, "``"): + if len(t) >= 3 && t[2] == '`' { + // Do not convert `` inside ```, in case people are mistakenly writing Markdown. + i += 3 + for i < len(t) && t[i] == '`' { + i++ + } + break + } + writeUntil(i) + w.WriteRune('“') + i += 2 + wrote = i + case strings.HasPrefix(t, "''"): + writeUntil(i) + w.WriteRune('”') + i += 2 + wrote = i + default: + i++ + } + } + flush(len(s)) + return out +} + +// autoURL checks whether s begins with a URL that should be hyperlinked. +// If so, it returns the URL, which is a prefix of s, and ok == true. +// Otherwise it returns "", false. +// The caller should skip over the first len(url) bytes of s +// before further processing. +func autoURL(s string) (url string, ok bool) { + // Find the ://. Fast path to pick off non-URL, + // since we call this at every position in the string. + // The shortest possible URL is ftp://x, 7 bytes. + var i int + switch { + case len(s) < 7: + return "", false + case s[3] == ':': + i = 3 + case s[4] == ':': + i = 4 + case s[5] == ':': + i = 5 + case s[6] == ':': + i = 6 + default: + return "", false + } + if i+3 > len(s) || s[i:i+3] != "://" { + return "", false + } + + // Check valid scheme. + if !isScheme(s[:i]) { + return "", false + } + + // Scan host part. Must have at least one byte, + // and must start and end in non-punctuation. + i += 3 + if i >= len(s) || !isHost(s[i]) || isPunct(s[i]) { + return "", false + } + i++ + end := i + for i < len(s) && isHost(s[i]) { + if !isPunct(s[i]) { + end = i + 1 + } + i++ + } + i = end + + // At this point we are definitely returning a URL (scheme://host). + // We just have to find the longest path we can add to it. + // Heuristics abound. + // We allow parens, braces, and brackets, + // but only if they match (#5043, #22285). + // We allow .,:;?! in the path but not at the end, + // to avoid end-of-sentence punctuation (#18139, #16565). + stk := []byte{} + end = i +Path: + for ; i < len(s); i++ { + if isPunct(s[i]) { + continue + } + if !isPath(s[i]) { + break + } + switch s[i] { + case '(': + stk = append(stk, ')') + case '{': + stk = append(stk, '}') + case '[': + stk = append(stk, ']') + case ')', '}', ']': + if len(stk) == 0 || stk[len(stk)-1] != s[i] { + break Path + } + stk = stk[:len(stk)-1] + } + if len(stk) == 0 { + end = i + 1 + } + } + + return s[:end], true +} + +// isScheme reports whether s is a recognized URL scheme. +// Note that if strings of new length (beyond 3-7) +// are added here, the fast path at the top of autoURL will need updating. +func isScheme(s string) bool { + switch s { + case "file", + "ftp", + "gopher", + "http", + "https", + "mailto", + "nntp": + return true + } + return false +} + +// isHost reports whether c is a byte that can appear in a URL host, +// like www.example.com or user@[::1]:8080 +func isHost(c byte) bool { + // mask is a 128-bit bitmap with 1s for allowed bytes, + // so that the byte c can be tested with a shift and an and. + // If c > 128, then 1<>64)) != 0 +} + +// isPunct reports whether c is a punctuation byte that can appear +// inside a path but not at the end. +func isPunct(c byte) bool { + // mask is a 128-bit bitmap with 1s for allowed bytes, + // so that the byte c can be tested with a shift and an and. + // If c > 128, then 1<>64)) != 0 +} + +// isPath reports whether c is a (non-punctuation) path byte. +func isPath(c byte) bool { + // mask is a 128-bit bitmap with 1s for allowed bytes, + // so that the byte c can be tested with a shift and an and. + // If c > 128, then 1<>64)) != 0 +} + +// isName reports whether s is a capitalized Go identifier (like Name). +func isName(s string) bool { + t, ok := ident(s) + if !ok || t != s { + return false + } + r, _ := utf8.DecodeRuneInString(s) + return unicode.IsUpper(r) +} + +// ident checks whether s begins with a Go identifier. +// If so, it returns the identifier, which is a prefix of s, and ok == true. +// Otherwise it returns "", false. +// The caller should skip over the first len(id) bytes of s +// before further processing. +func ident(s string) (id string, ok bool) { + // Scan [\pL_][\pL_0-9]* + n := 0 + for n < len(s) { + if c := s[n]; c < utf8.RuneSelf { + if isIdentASCII(c) && (n > 0 || c < '0' || c > '9') { + n++ + continue + } + break + } + r, nr := utf8.DecodeRuneInString(s[n:]) + if unicode.IsLetter(r) { + n += nr + continue + } + break + } + return s[:n], n > 0 +} + +// isIdentASCII reports whether c is an ASCII identifier byte. +func isIdentASCII(c byte) bool { + // mask is a 128-bit bitmap with 1s for allowed bytes, + // so that the byte c can be tested with a shift and an and. + // If c > 128, then 1<>64)) != 0 +} + +// validImportPath reports whether path is a valid import path. +// It is a lightly edited copy of golang.org/x/mod/module.CheckImportPath. +func validImportPath(path string) bool { + if !utf8.ValidString(path) { + return false + } + if path == "" { + return false + } + if path[0] == '-' { + return false + } + if strings.Contains(path, "//") { + return false + } + if path[len(path)-1] == '/' { + return false + } + elemStart := 0 + for i, r := range path { + if r == '/' { + if !validImportPathElem(path[elemStart:i]) { + return false + } + elemStart = i + 1 + } + } + return validImportPathElem(path[elemStart:]) +} + +func validImportPathElem(elem string) bool { + if elem == "" || elem[0] == '.' || elem[len(elem)-1] == '.' { + return false + } + for i := 0; i < len(elem); i++ { + if !importPathOK(elem[i]) { + return false + } + } + return true +} + +func importPathOK(c byte) bool { + // mask is a 128-bit bitmap with 1s for allowed bytes, + // so that the byte c can be tested with a shift and an and. + // If c > 128, then 1<>64)) != 0 +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/print.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/print.go new file mode 100644 index 000000000..4e9da3d1e --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/print.go @@ -0,0 +1,290 @@ +// Copyright 2022 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 comment + +import ( + "bytes" + "fmt" + "strings" +) + +// A Printer is a doc comment printer. +// The fields in the struct can be filled in before calling +// any of the printing methods +// in order to customize the details of the printing process. +type Printer struct { + // HeadingLevel is the nesting level used for + // HTML and Markdown headings. + // If HeadingLevel is zero, it defaults to level 3, + // meaning to use

and ###. + HeadingLevel int + + // HeadingID is a function that computes the heading ID + // (anchor tag) to use for the heading h when generating + // HTML and Markdown. If HeadingID returns an empty string, + // then the heading ID is omitted. + // If HeadingID is nil, h.DefaultID is used. + HeadingID func(h *Heading) string + + // DocLinkURL is a function that computes the URL for the given DocLink. + // If DocLinkURL is nil, then link.DefaultURL(p.DocLinkBaseURL) is used. + DocLinkURL func(link *DocLink) string + + // DocLinkBaseURL is used when DocLinkURL is nil, + // passed to [DocLink.DefaultURL] to construct a DocLink's URL. + // See that method's documentation for details. + DocLinkBaseURL string + + // TextPrefix is a prefix to print at the start of every line + // when generating text output using the Text method. + TextPrefix string + + // TextCodePrefix is the prefix to print at the start of each + // preformatted (code block) line when generating text output, + // instead of (not in addition to) TextPrefix. + // If TextCodePrefix is the empty string, it defaults to TextPrefix+"\t". + TextCodePrefix string + + // TextWidth is the maximum width text line to generate, + // measured in Unicode code points, + // excluding TextPrefix and the newline character. + // If TextWidth is zero, it defaults to 80 minus the number of code points in TextPrefix. + // If TextWidth is negative, there is no limit. + TextWidth int +} + +func (p *Printer) headingLevel() int { + if p.HeadingLevel <= 0 { + return 3 + } + return p.HeadingLevel +} + +func (p *Printer) headingID(h *Heading) string { + if p.HeadingID == nil { + return h.DefaultID() + } + return p.HeadingID(h) +} + +func (p *Printer) docLinkURL(link *DocLink) string { + if p.DocLinkURL != nil { + return p.DocLinkURL(link) + } + return link.DefaultURL(p.DocLinkBaseURL) +} + +// DefaultURL constructs and returns the documentation URL for l, +// using baseURL as a prefix for links to other packages. +// +// The possible forms returned by DefaultURL are: +// - baseURL/ImportPath, for a link to another package +// - baseURL/ImportPath#Name, for a link to a const, func, type, or var in another package +// - baseURL/ImportPath#Recv.Name, for a link to a method in another package +// - #Name, for a link to a const, func, type, or var in this package +// - #Recv.Name, for a link to a method in this package +// +// If baseURL ends in a trailing slash, then DefaultURL inserts +// a slash between ImportPath and # in the anchored forms. +// For example, here are some baseURL values and URLs they can generate: +// +// "/pkg/" → "/pkg/math/#Sqrt" +// "/pkg" → "/pkg/math#Sqrt" +// "/" → "/math/#Sqrt" +// "" → "/math#Sqrt" +func (l *DocLink) DefaultURL(baseURL string) string { + if l.ImportPath != "" { + slash := "" + if strings.HasSuffix(baseURL, "/") { + slash = "/" + } else { + baseURL += "/" + } + switch { + case l.Name == "": + return baseURL + l.ImportPath + slash + case l.Recv != "": + return baseURL + l.ImportPath + slash + "#" + l.Recv + "." + l.Name + default: + return baseURL + l.ImportPath + slash + "#" + l.Name + } + } + if l.Recv != "" { + return "#" + l.Recv + "." + l.Name + } + return "#" + l.Name +} + +// DefaultID returns the default anchor ID for the heading h. +// +// The default anchor ID is constructed by converting every +// rune that is not alphanumeric ASCII to an underscore +// and then adding the prefix “hdr-”. +// For example, if the heading text is “Go Doc Comments”, +// the default ID is “hdr-Go_Doc_Comments”. +func (h *Heading) DefaultID() string { + // Note: The “hdr-” prefix is important to avoid DOM clobbering attacks. + // See https://pkg.go.dev/github.com/google/safehtml#Identifier. + var out strings.Builder + var p textPrinter + p.oneLongLine(&out, h.Text) + s := strings.TrimSpace(out.String()) + if s == "" { + return "" + } + out.Reset() + out.WriteString("hdr-") + for _, r := range s { + if r < 0x80 && isIdentASCII(byte(r)) { + out.WriteByte(byte(r)) + } else { + out.WriteByte('_') + } + } + return out.String() +} + +type commentPrinter struct { + *Printer + headingPrefix string + needDoc map[string]bool +} + +// Comment returns the standard Go formatting of the Doc, +// without any comment markers. +func (p *Printer) Comment(d *Doc) []byte { + cp := &commentPrinter{Printer: p} + var out bytes.Buffer + for i, x := range d.Content { + if i > 0 && blankBefore(x) { + out.WriteString("\n") + } + cp.block(&out, x) + } + + // Print one block containing all the link definitions that were used, + // and then a second block containing all the unused ones. + // This makes it easy to clean up the unused ones: gofmt and + // delete the final block. And it's a nice visual signal without + // affecting the way the comment formats for users. + for i := 0; i < 2; i++ { + used := i == 0 + first := true + for _, def := range d.Links { + if def.Used == used { + if first { + out.WriteString("\n") + first = false + } + out.WriteString("[") + out.WriteString(def.Text) + out.WriteString("]: ") + out.WriteString(def.URL) + out.WriteString("\n") + } + } + } + + return out.Bytes() +} + +// blankBefore reports whether the block x requires a blank line before it. +// All blocks do, except for Lists that return false from x.BlankBefore(). +func blankBefore(x Block) bool { + if x, ok := x.(*List); ok { + return x.BlankBefore() + } + return true +} + +// block prints the block x to out. +func (p *commentPrinter) block(out *bytes.Buffer, x Block) { + switch x := x.(type) { + default: + fmt.Fprintf(out, "?%T", x) + + case *Paragraph: + p.text(out, "", x.Text) + out.WriteString("\n") + + case *Heading: + out.WriteString("# ") + p.text(out, "", x.Text) + out.WriteString("\n") + + case *Code: + md := x.Text + for md != "" { + var line string + line, md, _ = strings.Cut(md, "\n") + if line != "" { + out.WriteString("\t") + out.WriteString(line) + } + out.WriteString("\n") + } + + case *List: + loose := x.BlankBetween() + for i, item := range x.Items { + if i > 0 && loose { + out.WriteString("\n") + } + out.WriteString(" ") + if item.Number == "" { + out.WriteString(" - ") + } else { + out.WriteString(item.Number) + out.WriteString(". ") + } + for i, blk := range item.Content { + const fourSpace = " " + if i > 0 { + out.WriteString("\n" + fourSpace) + } + p.text(out, fourSpace, blk.(*Paragraph).Text) + out.WriteString("\n") + } + } + } +} + +// text prints the text sequence x to out. +func (p *commentPrinter) text(out *bytes.Buffer, indent string, x []Text) { + for _, t := range x { + switch t := t.(type) { + case Plain: + p.indent(out, indent, string(t)) + case Italic: + p.indent(out, indent, string(t)) + case *Link: + if t.Auto { + p.text(out, indent, t.Text) + } else { + out.WriteString("[") + p.text(out, indent, t.Text) + out.WriteString("]") + } + case *DocLink: + out.WriteString("[") + p.text(out, indent, t.Text) + out.WriteString("]") + } + } +} + +// indent prints s to out, indenting with the indent string +// after each newline in s. +func (p *commentPrinter) indent(out *bytes.Buffer, indent, s string) { + for s != "" { + line, rest, ok := strings.Cut(s, "\n") + out.WriteString(line) + if ok { + out.WriteString("\n") + out.WriteString(indent) + } + s = rest + } +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/std.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/std.go new file mode 100644 index 000000000..6786e4d7a --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/std.go @@ -0,0 +1,44 @@ +// Copyright 2022 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. + +// Code generated by 'go generate' DO NOT EDIT. +//disabled go:generate ./mkstd.sh + +package comment + +var stdPkgs = []string{ + "bufio", + "bytes", + "context", + "crypto", + "embed", + "encoding", + "errors", + "expvar", + "flag", + "fmt", + "hash", + "html", + "image", + "io", + "log", + "math", + "mime", + "net", + "os", + "path", + "plugin", + "reflect", + "regexp", + "runtime", + "sort", + "strconv", + "strings", + "sync", + "syscall", + "testing", + "time", + "unicode", + "unsafe", +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/text.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/text.go new file mode 100644 index 000000000..6f9c2e201 --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/doc/comment/text.go @@ -0,0 +1,337 @@ +// Copyright 2022 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 comment + +import ( + "bytes" + "fmt" + "sort" + "strings" + "unicode/utf8" +) + +// A textPrinter holds the state needed for printing a Doc as plain text. +type textPrinter struct { + *Printer + long strings.Builder + prefix string + codePrefix string + width int +} + +// Text returns a textual formatting of the Doc. +// See the [Printer] documentation for ways to customize the text output. +func (p *Printer) Text(d *Doc) []byte { + tp := &textPrinter{ + Printer: p, + prefix: p.TextPrefix, + codePrefix: p.TextCodePrefix, + width: p.TextWidth, + } + if tp.codePrefix == "" { + tp.codePrefix = p.TextPrefix + "\t" + } + if tp.width == 0 { + tp.width = 80 - utf8.RuneCountInString(tp.prefix) + } + + var out bytes.Buffer + for i, x := range d.Content { + if i > 0 && blankBefore(x) { + out.WriteString(tp.prefix) + writeNL(&out) + } + tp.block(&out, x) + } + anyUsed := false + for _, def := range d.Links { + if def.Used { + anyUsed = true + break + } + } + if anyUsed { + writeNL(&out) + for _, def := range d.Links { + if def.Used { + fmt.Fprintf(&out, "[%s]: %s\n", def.Text, def.URL) + } + } + } + return out.Bytes() +} + +// writeNL calls out.WriteByte('\n') +// but first trims trailing spaces on the previous line. +func writeNL(out *bytes.Buffer) { + // Trim trailing spaces. + data := out.Bytes() + n := 0 + for n < len(data) && (data[len(data)-n-1] == ' ' || data[len(data)-n-1] == '\t') { + n++ + } + if n > 0 { + out.Truncate(len(data) - n) + } + out.WriteByte('\n') +} + +// block prints the block x to out. +func (p *textPrinter) block(out *bytes.Buffer, x Block) { + switch x := x.(type) { + default: + fmt.Fprintf(out, "?%T\n", x) + + case *Paragraph: + out.WriteString(p.prefix) + p.text(out, "", x.Text) + + case *Heading: + out.WriteString(p.prefix) + out.WriteString("# ") + p.text(out, "", x.Text) + + case *Code: + text := x.Text + for text != "" { + var line string + line, text, _ = strings.Cut(text, "\n") + if line != "" { + out.WriteString(p.codePrefix) + out.WriteString(line) + } + writeNL(out) + } + + case *List: + loose := x.BlankBetween() + for i, item := range x.Items { + if i > 0 && loose { + out.WriteString(p.prefix) + writeNL(out) + } + out.WriteString(p.prefix) + out.WriteString(" ") + if item.Number == "" { + out.WriteString(" - ") + } else { + out.WriteString(item.Number) + out.WriteString(". ") + } + for i, blk := range item.Content { + const fourSpace = " " + if i > 0 { + writeNL(out) + out.WriteString(p.prefix) + out.WriteString(fourSpace) + } + p.text(out, fourSpace, blk.(*Paragraph).Text) + } + } + } +} + +// text prints the text sequence x to out. +func (p *textPrinter) text(out *bytes.Buffer, indent string, x []Text) { + p.oneLongLine(&p.long, x) + words := strings.Fields(p.long.String()) + p.long.Reset() + + var seq []int + if p.width < 0 || len(words) == 0 { + seq = []int{0, len(words)} // one long line + } else { + seq = wrap(words, p.width-utf8.RuneCountInString(indent)) + } + for i := 0; i+1 < len(seq); i++ { + if i > 0 { + out.WriteString(p.prefix) + out.WriteString(indent) + } + for j, w := range words[seq[i]:seq[i+1]] { + if j > 0 { + out.WriteString(" ") + } + out.WriteString(w) + } + writeNL(out) + } +} + +// oneLongLine prints the text sequence x to out as one long line, +// without worrying about line wrapping. +// Explicit links have the [ ] dropped to improve readability. +func (p *textPrinter) oneLongLine(out *strings.Builder, x []Text) { + for _, t := range x { + switch t := t.(type) { + case Plain: + out.WriteString(string(t)) + case Italic: + out.WriteString(string(t)) + case *Link: + p.oneLongLine(out, t.Text) + case *DocLink: + p.oneLongLine(out, t.Text) + } + } +} + +// wrap wraps words into lines of at most max runes, +// minimizing the sum of the squares of the leftover lengths +// at the end of each line (except the last, of course), +// with a preference for ending lines at punctuation (.,:;). +// +// The returned slice gives the indexes of the first words +// on each line in the wrapped text with a final entry of len(words). +// Thus the lines are words[seq[0]:seq[1]], words[seq[1]:seq[2]], +// ..., words[seq[len(seq)-2]:seq[len(seq)-1]]. +// +// The implementation runs in O(n log n) time, where n = len(words), +// using the algorithm described in D. S. Hirschberg and L. L. Larmore, +// “[The least weight subsequence problem],” FOCS 1985, pp. 137-143. +// +// [The least weight subsequence problem]: https://doi.org/10.1109/SFCS.1985.60 +func wrap(words []string, max int) (seq []int) { + // The algorithm requires that our scoring function be concave, + // meaning that for all i₀ ≤ i₁ < j₀ ≤ j₁, + // weight(i₀, j₀) + weight(i₁, j₁) ≤ weight(i₀, j₁) + weight(i₁, j₀). + // + // Our weights are two-element pairs [hi, lo] + // ordered by elementwise comparison. + // The hi entry counts the weight for lines that are longer than max, + // and the lo entry counts the weight for lines that are not. + // This forces the algorithm to first minimize the number of lines + // that are longer than max, which correspond to lines with + // single very long words. Having done that, it can move on to + // minimizing the lo score, which is more interesting. + // + // The lo score is the sum for each line of the square of the + // number of spaces remaining at the end of the line and a + // penalty of 64 given out for not ending the line in a + // punctuation character (.,:;). + // The penalty is somewhat arbitrarily chosen by trying + // different amounts and judging how nice the wrapped text looks. + // Roughly speaking, using 64 means that we are willing to + // end a line with eight blank spaces in order to end at a + // punctuation character, even if the next word would fit in + // those spaces. + // + // We care about ending in punctuation characters because + // it makes the text easier to skim if not too many sentences + // or phrases begin with a single word on the previous line. + + // A score is the score (also called weight) for a given line. + // add and cmp add and compare scores. + type score struct { + hi int64 + lo int64 + } + add := func(s, t score) score { return score{s.hi + t.hi, s.lo + t.lo} } + cmp := func(s, t score) int { + switch { + case s.hi < t.hi: + return -1 + case s.hi > t.hi: + return +1 + case s.lo < t.lo: + return -1 + case s.lo > t.lo: + return +1 + } + return 0 + } + + // total[j] is the total number of runes + // (including separating spaces) in words[:j]. + total := make([]int, len(words)+1) + total[0] = 0 + for i, s := range words { + total[1+i] = total[i] + utf8.RuneCountInString(s) + 1 + } + + // weight returns weight(i, j). + weight := func(i, j int) score { + // On the last line, there is zero weight for being too short. + n := total[j] - 1 - total[i] + if j == len(words) && n <= max { + return score{0, 0} + } + + // Otherwise the weight is the penalty plus the square of the number of + // characters remaining on the line or by which the line goes over. + // In the latter case, that value goes in the hi part of the score. + // (See note above.) + p := wrapPenalty(words[j-1]) + v := int64(max-n) * int64(max-n) + if n > max { + return score{v, p} + } + return score{0, v + p} + } + + // The rest of this function is “The Basic Algorithm” from + // Hirschberg and Larmore's conference paper, + // using the same names as in the paper. + f := []score{{0, 0}} + g := func(i, j int) score { return add(f[i], weight(i, j)) } + + bridge := func(a, b, c int) bool { + k := c + sort.Search(len(words)+1-c, func(k int) bool { + k += c + return cmp(g(a, k), g(b, k)) > 0 + }) + if k > len(words) { + return true + } + return cmp(g(c, k), g(b, k)) <= 0 + } + + // d is a one-ended deque implemented as a slice. + d := make([]int, 1, len(words)) + d[0] = 0 + bestleft := make([]int, 1, len(words)) + bestleft[0] = -1 + for m := 1; m < len(words); m++ { + f = append(f, g(d[0], m)) + bestleft = append(bestleft, d[0]) + for len(d) > 1 && cmp(g(d[1], m+1), g(d[0], m+1)) <= 0 { + d = d[1:] // “Retire” + } + for len(d) > 1 && bridge(d[len(d)-2], d[len(d)-1], m) { + d = d[:len(d)-1] // “Fire” + } + if cmp(g(m, len(words)), g(d[len(d)-1], len(words))) < 0 { + d = append(d, m) // “Hire” + // The next few lines are not in the paper but are necessary + // to handle two-word inputs correctly. It appears to be + // just a bug in the paper's pseudocode. + if len(d) == 2 && cmp(g(d[1], m+1), g(d[0], m+1)) <= 0 { + d = d[1:] + } + } + } + bestleft = append(bestleft, d[0]) + + // Recover least weight sequence from bestleft. + n := 1 + for m := len(words); m > 0; m = bestleft[m] { + n++ + } + seq = make([]int, n) + for m := len(words); m > 0; m = bestleft[m] { + n-- + seq[n] = m + } + return seq +} + +// wrapPenalty is the penalty for inserting a line break after word s. +func wrapPenalty(s string) int64 { + switch s[len(s)-1] { + case '.', ',', ':', ';': + return 0 + } + return 64 +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/format/format.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/format/format.go new file mode 100644 index 000000000..5540686ed --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/format/format.go @@ -0,0 +1,134 @@ +// 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 format implements standard formatting of Go source. +// +// Note that formatting of Go source code changes over time, so tools relying on +// consistent formatting should execute a specific version of the gofmt binary +// instead of using this package. That way, the formatting will be stable, and +// the tools won't need to be recompiled each time gofmt changes. +// +// For example, pre-submit checks that use this package directly would behave +// differently depending on what Go version each developer uses, causing the +// check to be inherently fragile. +package format + +import ( + "bytes" + "fmt" + "go/ast" + "go/parser" + "go/token" + "io" + + "mvdan.cc/gofumpt/internal/govendor/go/printer" +) + +// Keep these in sync with cmd/gofmt/gofmt.go. +const ( + tabWidth = 8 + printerMode = printer.UseSpaces | printer.TabIndent | printerNormalizeNumbers + + // printerNormalizeNumbers means to canonicalize number literal prefixes + // and exponents while printing. See https://golang.org/doc/go1.13#gofmt. + // + // This value is defined in mvdan.cc/gofumpt/internal/govendor/go/printer specifically for mvdan.cc/gofumpt/internal/govendor/go/format and cmd/gofmt. + printerNormalizeNumbers = 1 << 30 +) + +var config = printer.Config{Mode: printerMode, Tabwidth: tabWidth} + +const parserMode = parser.ParseComments | parser.SkipObjectResolution + +// Node formats node in canonical gofmt style and writes the result to dst. +// +// The node type must be *ast.File, *printer.CommentedNode, []ast.Decl, +// []ast.Stmt, or assignment-compatible to ast.Expr, ast.Decl, ast.Spec, +// or ast.Stmt. Node does not modify node. Imports are not sorted for +// nodes representing partial source files (for instance, if the node is +// not an *ast.File or a *printer.CommentedNode not wrapping an *ast.File). +// +// The function may return early (before the entire result is written) +// and return a formatting error, for instance due to an incorrect AST. +func Node(dst io.Writer, fset *token.FileSet, node any) error { + // Determine if we have a complete source file (file != nil). + var file *ast.File + var cnode *printer.CommentedNode + switch n := node.(type) { + case *ast.File: + file = n + case *printer.CommentedNode: + if f, ok := n.Node.(*ast.File); ok { + file = f + cnode = n + } + } + + // Sort imports if necessary. + if file != nil && hasUnsortedImports(file) { + // Make a copy of the AST because ast.SortImports is destructive. + // TODO(gri) Do this more efficiently. + var buf bytes.Buffer + err := config.Fprint(&buf, fset, file) + if err != nil { + return err + } + file, err = parser.ParseFile(fset, "", buf.Bytes(), parserMode) + if err != nil { + // We should never get here. If we do, provide good diagnostic. + return fmt.Errorf("format.Node internal error (%s)", err) + } + ast.SortImports(fset, file) + + // Use new file with sorted imports. + node = file + if cnode != nil { + node = &printer.CommentedNode{Node: file, Comments: cnode.Comments} + } + } + + return config.Fprint(dst, fset, node) +} + +// Source formats src in canonical gofmt style and returns the result +// or an (I/O or syntax) error. src is expected to be a syntactically +// correct Go source file, or a list of Go declarations or statements. +// +// If src is a partial source file, the leading and trailing space of src +// is applied to the result (such that it has the same leading and trailing +// space as src), and the result is indented by the same amount as the first +// line of src containing code. Imports are not sorted for partial source files. +func Source(src []byte) ([]byte, error) { + fset := token.NewFileSet() + file, sourceAdj, indentAdj, err := parse(fset, "", src, true) + if err != nil { + return nil, err + } + + if sourceAdj == nil { + // Complete source file. + // TODO(gri) consider doing this always. + ast.SortImports(fset, file) + } + + return format(fset, file, sourceAdj, indentAdj, src, config) +} + +func hasUnsortedImports(file *ast.File) bool { + for _, d := range file.Decls { + d, ok := d.(*ast.GenDecl) + if !ok || d.Tok != token.IMPORT { + // Not an import declaration, so we're done. + // Imports are always first. + return false + } + if d.Lparen.IsValid() { + // For now assume all grouped imports are unsorted. + // TODO(gri) Should check if they are sorted already. + return true + } + // Ungrouped imports are sorted by default. + } + return false +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/format/internal.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/format/internal.go new file mode 100644 index 000000000..df0358714 --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/format/internal.go @@ -0,0 +1,177 @@ +// Copyright 2015 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. + +// TODO(gri): This file and the file src/cmd/gofmt/internal.go are +// the same (but for this comment and the package name). Do not modify +// one without the other. Determine if we can factor out functionality +// in a public API. See also #11844 for context. + +package format + +import ( + "bytes" + "go/ast" + "go/parser" + "go/token" + "strings" + + "mvdan.cc/gofumpt/internal/govendor/go/printer" +) + +// parse parses src, which was read from the named file, +// as a Go source file, declaration, or statement list. +func parse(fset *token.FileSet, filename string, src []byte, fragmentOk bool) ( + file *ast.File, + sourceAdj func(src []byte, indent int) []byte, + indentAdj int, + err error, +) { + // Try as whole source file. + file, err = parser.ParseFile(fset, filename, src, parserMode) + // If there's no error, return. If the error is that the source file didn't begin with a + // package line and source fragments are ok, fall through to + // try as a source fragment. Stop and return on any other error. + if err == nil || !fragmentOk || !strings.Contains(err.Error(), "expected 'package'") { + return + } + + // If this is a declaration list, make it a source file + // by inserting a package clause. + // Insert using a ';', not a newline, so that the line numbers + // in psrc match the ones in src. + psrc := append([]byte("package p;"), src...) + file, err = parser.ParseFile(fset, filename, psrc, parserMode) + if err == nil { + sourceAdj = func(src []byte, indent int) []byte { + // Remove the package clause. + // Gofmt has turned the ';' into a '\n'. + src = src[indent+len("package p\n"):] + return bytes.TrimSpace(src) + } + return + } + // If the error is that the source file didn't begin with a + // declaration, fall through to try as a statement list. + // Stop and return on any other error. + if !strings.Contains(err.Error(), "expected declaration") { + return + } + + // If this is a statement list, make it a source file + // by inserting a package clause and turning the list + // into a function body. This handles expressions too. + // Insert using a ';', not a newline, so that the line numbers + // in fsrc match the ones in src. Add an extra '\n' before the '}' + // to make sure comments are flushed before the '}'. + fsrc := append(append([]byte("package p; func _() {"), src...), '\n', '\n', '}') + file, err = parser.ParseFile(fset, filename, fsrc, parserMode) + if err == nil { + sourceAdj = func(src []byte, indent int) []byte { + // Cap adjusted indent to zero. + if indent < 0 { + indent = 0 + } + // Remove the wrapping. + // Gofmt has turned the "; " into a "\n\n". + // There will be two non-blank lines with indent, hence 2*indent. + src = src[2*indent+len("package p\n\nfunc _() {"):] + // Remove only the "}\n" suffix: remaining whitespaces will be trimmed anyway + src = src[:len(src)-len("}\n")] + return bytes.TrimSpace(src) + } + // Gofmt has also indented the function body one level. + // Adjust that with indentAdj. + indentAdj = -1 + } + + // Succeeded, or out of options. + return +} + +// format formats the given package file originally obtained from src +// and adjusts the result based on the original source via sourceAdj +// and indentAdj. +func format( + fset *token.FileSet, + file *ast.File, + sourceAdj func(src []byte, indent int) []byte, + indentAdj int, + src []byte, + cfg printer.Config, +) ([]byte, error) { + if sourceAdj == nil { + // Complete source file. + var buf bytes.Buffer + err := cfg.Fprint(&buf, fset, file) + if err != nil { + return nil, err + } + return buf.Bytes(), nil + } + + // Partial source file. + // Determine and prepend leading space. + i, j := 0, 0 + for j < len(src) && isSpace(src[j]) { + if src[j] == '\n' { + i = j + 1 // byte offset of last line in leading space + } + j++ + } + var res []byte + res = append(res, src[:i]...) + + // Determine and prepend indentation of first code line. + // Spaces are ignored unless there are no tabs, + // in which case spaces count as one tab. + indent := 0 + hasSpace := false + for _, b := range src[i:j] { + switch b { + case ' ': + hasSpace = true + case '\t': + indent++ + } + } + if indent == 0 && hasSpace { + indent = 1 + } + for i := 0; i < indent; i++ { + res = append(res, '\t') + } + + // Format the source. + // Write it without any leading and trailing space. + cfg.Indent = indent + indentAdj + var buf bytes.Buffer + err := cfg.Fprint(&buf, fset, file) + if err != nil { + return nil, err + } + out := sourceAdj(buf.Bytes(), cfg.Indent) + + // If the adjusted output is empty, the source + // was empty but (possibly) for white space. + // The result is the incoming source. + if len(out) == 0 { + return src, nil + } + + // Otherwise, append output to leading space. + res = append(res, out...) + + // Determine and append trailing space. + i = len(src) + for i > 0 && isSpace(src[i-1]) { + i-- + } + return append(res, src[i:]...), nil +} + +// isSpace reports whether the byte is a space character. +// isSpace defines a space as being among the following bytes: ' ', '\t', '\n' and '\r'. +func isSpace(b byte) bool { + return b == ' ' || b == '\t' || b == '\n' || b == '\r' +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/comment.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/comment.go new file mode 100644 index 000000000..5b9775dc8 --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/comment.go @@ -0,0 +1,155 @@ +// Copyright 2022 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 printer + +import ( + "go/ast" + "strings" + + "mvdan.cc/gofumpt/internal/govendor/go/doc/comment" +) + +// formatDocComment reformats the doc comment list, +// returning the canonical formatting. +func formatDocComment(list []*ast.Comment) []*ast.Comment { + // Extract comment text (removing comment markers). + var kind, text string + var directives []*ast.Comment + if len(list) == 1 && strings.HasPrefix(list[0].Text, "/*") { + kind = "/*" + text = list[0].Text + if !strings.Contains(text, "\n") || allStars(text) { + // Single-line /* .. */ comment in doc comment position, + // or multiline old-style comment like + // /* + // * Comment + // * text here. + // */ + // Should not happen, since it will not work well as a + // doc comment, but if it does, just ignore: + // reformatting it will only make the situation worse. + return list + } + text = text[2 : len(text)-2] // cut /* and */ + } else if strings.HasPrefix(list[0].Text, "//") { + kind = "//" + var b strings.Builder + for _, c := range list { + if !strings.HasPrefix(c.Text, "//") { + return list + } + // Accumulate //go:build etc lines separately. + if isDirective(c.Text[2:]) { + directives = append(directives, c) + continue + } + b.WriteString(strings.TrimPrefix(c.Text[2:], " ")) + b.WriteString("\n") + } + text = b.String() + } else { + // Not sure what this is, so leave alone. + return list + } + + if text == "" { + return list + } + + // Parse comment and reformat as text. + var p comment.Parser + d := p.Parse(text) + + var pr comment.Printer + text = string(pr.Comment(d)) + + // For /* */ comment, return one big comment with text inside. + slash := list[0].Slash + if kind == "/*" { + c := &ast.Comment{ + Slash: slash, + Text: "/*\n" + text + "*/", + } + return []*ast.Comment{c} + } + + // For // comment, return sequence of // lines. + var out []*ast.Comment + for text != "" { + var line string + line, text, _ = strings.Cut(text, "\n") + if line == "" { + line = "//" + } else if strings.HasPrefix(line, "\t") { + line = "//" + line + } else { + line = "// " + line + } + out = append(out, &ast.Comment{ + Slash: slash, + Text: line, + }) + } + if len(directives) > 0 { + out = append(out, &ast.Comment{ + Slash: slash, + Text: "//", + }) + for _, c := range directives { + out = append(out, &ast.Comment{ + Slash: slash, + Text: c.Text, + }) + } + } + return out +} + +// isDirective reports whether c is a comment directive. +// See go.dev/issue/37974. +// This code is also in go/ast. +func isDirective(c string) bool { + // "//line " is a line directive. + // "//extern " is for gccgo. + // "//export " is for cgo. + // (The // has been removed.) + if strings.HasPrefix(c, "line ") || strings.HasPrefix(c, "extern ") || strings.HasPrefix(c, "export ") { + return true + } + + // "//[a-z0-9]+:[a-z0-9]" + // (The // has been removed.) + colon := strings.Index(c, ":") + if colon <= 0 || colon+1 >= len(c) { + return false + } + for i := 0; i <= colon+1; i++ { + if i == colon { + continue + } + b := c[i] + if !('a' <= b && b <= 'z' || '0' <= b && b <= '9') { + return false + } + } + return true +} + +// allStars reports whether text is the interior of an +// old-style /* */ comment with a star at the start of each line. +func allStars(text string) bool { + for i := 0; i < len(text); i++ { + if text[i] == '\n' { + j := i + 1 + for j < len(text) && (text[j] == ' ' || text[j] == '\t') { + j++ + } + if j < len(text) && text[j] != '*' { + return false + } + } + } + return true +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/gobuild.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/gobuild.go new file mode 100644 index 000000000..f00492d07 --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/gobuild.go @@ -0,0 +1,170 @@ +// Copyright 2020 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 printer + +import ( + "go/build/constraint" + "sort" + "text/tabwriter" +) + +func (p *printer) fixGoBuildLines() { + if len(p.goBuild)+len(p.plusBuild) == 0 { + return + } + + // Find latest possible placement of //go:build and // +build comments. + // That's just after the last blank line before we find a non-comment. + // (We'll add another blank line after our comment block.) + // When we start dropping // +build comments, we can skip over /* */ comments too. + // Note that we are processing tabwriter input, so every comment + // begins and ends with a tabwriter.Escape byte. + // And some newlines have turned into \f bytes. + insert := 0 + for pos := 0; ; { + // Skip leading space at beginning of line. + blank := true + for pos < len(p.output) && (p.output[pos] == ' ' || p.output[pos] == '\t') { + pos++ + } + // Skip over // comment if any. + if pos+3 < len(p.output) && p.output[pos] == tabwriter.Escape && p.output[pos+1] == '/' && p.output[pos+2] == '/' { + blank = false + for pos < len(p.output) && !isNL(p.output[pos]) { + pos++ + } + } + // Skip over \n at end of line. + if pos >= len(p.output) || !isNL(p.output[pos]) { + break + } + pos++ + + if blank { + insert = pos + } + } + + // If there is a //go:build comment before the place we identified, + // use that point instead. (Earlier in the file is always fine.) + if len(p.goBuild) > 0 && p.goBuild[0] < insert { + insert = p.goBuild[0] + } else if len(p.plusBuild) > 0 && p.plusBuild[0] < insert { + insert = p.plusBuild[0] + } + + var x constraint.Expr + switch len(p.goBuild) { + case 0: + // Synthesize //go:build expression from // +build lines. + for _, pos := range p.plusBuild { + y, err := constraint.Parse(p.commentTextAt(pos)) + if err != nil { + x = nil + break + } + if x == nil { + x = y + } else { + x = &constraint.AndExpr{X: x, Y: y} + } + } + case 1: + // Parse //go:build expression. + x, _ = constraint.Parse(p.commentTextAt(p.goBuild[0])) + } + + var block []byte + if x == nil { + // Don't have a valid //go:build expression to treat as truth. + // Bring all the lines together but leave them alone. + // Note that these are already tabwriter-escaped. + for _, pos := range p.goBuild { + block = append(block, p.lineAt(pos)...) + } + for _, pos := range p.plusBuild { + block = append(block, p.lineAt(pos)...) + } + } else { + block = append(block, tabwriter.Escape) + block = append(block, "//go:build "...) + block = append(block, x.String()...) + block = append(block, tabwriter.Escape, '\n') + if len(p.plusBuild) > 0 { + lines, err := constraint.PlusBuildLines(x) + if err != nil { + lines = []string{"// +build error: " + err.Error()} + } + for _, line := range lines { + block = append(block, tabwriter.Escape) + block = append(block, line...) + block = append(block, tabwriter.Escape, '\n') + } + } + } + block = append(block, '\n') + + // Build sorted list of lines to delete from remainder of output. + toDelete := append(p.goBuild, p.plusBuild...) + sort.Ints(toDelete) + + // Collect output after insertion point, with lines deleted, into after. + var after []byte + start := insert + for _, end := range toDelete { + if end < start { + continue + } + after = appendLines(after, p.output[start:end]) + start = end + len(p.lineAt(end)) + } + after = appendLines(after, p.output[start:]) + if n := len(after); n >= 2 && isNL(after[n-1]) && isNL(after[n-2]) { + after = after[:n-1] + } + + p.output = p.output[:insert] + p.output = append(p.output, block...) + p.output = append(p.output, after...) +} + +// appendLines is like append(x, y...) +// but it avoids creating doubled blank lines, +// which would not be gofmt-standard output. +// It assumes that only whole blocks of lines are being appended, +// not line fragments. +func appendLines(x, y []byte) []byte { + if len(y) > 0 && isNL(y[0]) && // y starts in blank line + (len(x) == 0 || len(x) >= 2 && isNL(x[len(x)-1]) && isNL(x[len(x)-2])) { // x is empty or ends in blank line + y = y[1:] // delete y's leading blank line + } + return append(x, y...) +} + +func (p *printer) lineAt(start int) []byte { + pos := start + for pos < len(p.output) && !isNL(p.output[pos]) { + pos++ + } + if pos < len(p.output) { + pos++ + } + return p.output[start:pos] +} + +func (p *printer) commentTextAt(start int) string { + if start < len(p.output) && p.output[start] == tabwriter.Escape { + start++ + } + pos := start + for pos < len(p.output) && p.output[pos] != tabwriter.Escape && !isNL(p.output[pos]) { + pos++ + } + return string(p.output[start:pos]) +} + +func isNL(b byte) bool { + return b == '\n' || b == '\f' +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/nodes.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/nodes.go new file mode 100644 index 000000000..a58525b85 --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/nodes.go @@ -0,0 +1,2001 @@ +// Copyright 2009 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 file implements printing of AST nodes; specifically +// expressions, statements, declarations, and files. It uses +// the print functionality implemented in printer.go. + +package printer + +import ( + "go/ast" + "go/token" + "math" + "strconv" + "strings" + "unicode" + "unicode/utf8" +) + +// Formatting issues: +// - better comment formatting for /*-style comments at the end of a line (e.g. a declaration) +// when the comment spans multiple lines; if such a comment is just two lines, formatting is +// not idempotent +// - formatting of expression lists +// - should use blank instead of tab to separate one-line function bodies from +// the function header unless there is a group of consecutive one-liners + +// ---------------------------------------------------------------------------- +// Common AST nodes. + +// Print as many newlines as necessary (but at least min newlines) to get to +// the current line. ws is printed before the first line break. If newSection +// is set, the first line break is printed as formfeed. Returns 0 if no line +// breaks were printed, returns 1 if there was exactly one newline printed, +// and returns a value > 1 if there was a formfeed or more than one newline +// printed. +// +// TODO(gri): linebreak may add too many lines if the next statement at "line" +// is preceded by comments because the computation of n assumes +// the current position before the comment and the target position +// after the comment. Thus, after interspersing such comments, the +// space taken up by them is not considered to reduce the number of +// linebreaks. At the moment there is no easy way to know about +// future (not yet interspersed) comments in this function. +func (p *printer) linebreak(line, min int, ws whiteSpace, newSection bool) (nbreaks int) { + n := nlimit(line - p.pos.Line) + if n < min { + n = min + } + if n > 0 { + p.print(ws) + if newSection { + p.print(formfeed) + n-- + nbreaks = 2 + } + nbreaks += n + for ; n > 0; n-- { + p.print(newline) + } + } + return +} + +// setComment sets g as the next comment if g != nil and if node comments +// are enabled - this mode is used when printing source code fragments such +// as exports only. It assumes that there is no pending comment in p.comments +// and at most one pending comment in the p.comment cache. +func (p *printer) setComment(g *ast.CommentGroup) { + if g == nil || !p.useNodeComments { + return + } + if p.comments == nil { + // initialize p.comments lazily + p.comments = make([]*ast.CommentGroup, 1) + } else if p.cindex < len(p.comments) { + // for some reason there are pending comments; this + // should never happen - handle gracefully and flush + // all comments up to g, ignore anything after that + p.flush(p.posFor(g.List[0].Pos()), token.ILLEGAL) + p.comments = p.comments[0:1] + // in debug mode, report error + p.internalError("setComment found pending comments") + } + p.comments[0] = g + p.cindex = 0 + // don't overwrite any pending comment in the p.comment cache + // (there may be a pending comment when a line comment is + // immediately followed by a lead comment with no other + // tokens between) + if p.commentOffset == infinity { + p.nextComment() // get comment ready for use + } +} + +type exprListMode uint + +const ( + commaTerm exprListMode = 1 << iota // list is optionally terminated by a comma + noIndent // no extra indentation in multi-line lists +) + +// If indent is set, a multi-line identifier list is indented after the +// first linebreak encountered. +func (p *printer) identList(list []*ast.Ident, indent bool) { + // convert into an expression list so we can re-use exprList formatting + xlist := make([]ast.Expr, len(list)) + for i, x := range list { + xlist[i] = x + } + var mode exprListMode + if !indent { + mode = noIndent + } + p.exprList(token.NoPos, xlist, 1, mode, token.NoPos, false) +} + +const filteredMsg = "contains filtered or unexported fields" + +// Print a list of expressions. If the list spans multiple +// source lines, the original line breaks are respected between +// expressions. +// +// TODO(gri) Consider rewriting this to be independent of []ast.Expr +// so that we can use the algorithm for any kind of list +// +// (e.g., pass list via a channel over which to range). +func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exprListMode, next0 token.Pos, isIncomplete bool) { + if len(list) == 0 { + if isIncomplete { + prev := p.posFor(prev0) + next := p.posFor(next0) + if prev.IsValid() && prev.Line == next.Line { + p.print("/* " + filteredMsg + " */") + } else { + p.print(newline) + p.print(indent, "// "+filteredMsg, unindent, newline) + } + } + return + } + + prev := p.posFor(prev0) + next := p.posFor(next0) + line := p.lineFor(list[0].Pos()) + endLine := p.lineFor(list[len(list)-1].End()) + + if prev.IsValid() && prev.Line == line && line == endLine { + // all list entries on a single line + for i, x := range list { + if i > 0 { + // use position of expression following the comma as + // comma position for correct comment placement + p.setPos(x.Pos()) + p.print(token.COMMA, blank) + } + p.expr0(x, depth) + } + if isIncomplete { + p.print(token.COMMA, blank, "/* "+filteredMsg+" */") + } + return + } + + // list entries span multiple lines; + // use source code positions to guide line breaks + + // Don't add extra indentation if noIndent is set; + // i.e., pretend that the first line is already indented. + ws := ignore + if mode&noIndent == 0 { + ws = indent + } + + // The first linebreak is always a formfeed since this section must not + // depend on any previous formatting. + prevBreak := -1 // index of last expression that was followed by a linebreak + if prev.IsValid() && prev.Line < line && p.linebreak(line, 0, ws, true) > 0 { + ws = ignore + prevBreak = 0 + } + + // initialize expression/key size: a zero value indicates expr/key doesn't fit on a single line + size := 0 + + // We use the ratio between the geometric mean of the previous key sizes and + // the current size to determine if there should be a break in the alignment. + // To compute the geometric mean we accumulate the ln(size) values (lnsum) + // and the number of sizes included (count). + lnsum := 0.0 + count := 0 + + // print all list elements + prevLine := prev.Line + for i, x := range list { + line = p.lineFor(x.Pos()) + + // Determine if the next linebreak, if any, needs to use formfeed: + // in general, use the entire node size to make the decision; for + // key:value expressions, use the key size. + // TODO(gri) for a better result, should probably incorporate both + // the key and the node size into the decision process + useFF := true + + // Determine element size: All bets are off if we don't have + // position information for the previous and next token (likely + // generated code - simply ignore the size in this case by setting + // it to 0). + prevSize := size + const infinity = 1e6 // larger than any source line + size = p.nodeSize(x, infinity) + pair, isPair := x.(*ast.KeyValueExpr) + if size <= infinity && prev.IsValid() && next.IsValid() { + // x fits on a single line + if isPair { + size = p.nodeSize(pair.Key, infinity) // size <= infinity + } + } else { + // size too large or we don't have good layout information + size = 0 + } + + // If the previous line and the current line had single- + // line-expressions and the key sizes are small or the + // ratio between the current key and the geometric mean + // if the previous key sizes does not exceed a threshold, + // align columns and do not use formfeed. + if prevSize > 0 && size > 0 { + const smallSize = 40 + if count == 0 || prevSize <= smallSize && size <= smallSize { + useFF = false + } else { + const r = 2.5 // threshold + geomean := math.Exp(lnsum / float64(count)) // count > 0 + ratio := float64(size) / geomean + useFF = r*ratio <= 1 || r <= ratio + } + } + + needsLinebreak := 0 < prevLine && prevLine < line + if i > 0 { + // Use position of expression following the comma as + // comma position for correct comment placement, but + // only if the expression is on the same line. + if !needsLinebreak { + p.setPos(x.Pos()) + } + p.print(token.COMMA) + needsBlank := true + if needsLinebreak { + // Lines are broken using newlines so comments remain aligned + // unless useFF is set or there are multiple expressions on + // the same line in which case formfeed is used. + nbreaks := p.linebreak(line, 0, ws, useFF || prevBreak+1 < i) + if nbreaks > 0 { + ws = ignore + prevBreak = i + needsBlank = false // we got a line break instead + } + // If there was a new section or more than one new line + // (which means that the tabwriter will implicitly break + // the section), reset the geomean variables since we are + // starting a new group of elements with the next element. + if nbreaks > 1 { + lnsum = 0 + count = 0 + } + } + if needsBlank { + p.print(blank) + } + } + + if len(list) > 1 && isPair && size > 0 && needsLinebreak { + // We have a key:value expression that fits onto one line + // and it's not on the same line as the prior expression: + // Use a column for the key such that consecutive entries + // can align if possible. + // (needsLinebreak is set if we started a new line before) + p.expr(pair.Key) + p.setPos(pair.Colon) + p.print(token.COLON, vtab) + p.expr(pair.Value) + } else { + p.expr0(x, depth) + } + + if size > 0 { + lnsum += math.Log(float64(size)) + count++ + } + + prevLine = line + } + + if mode&commaTerm != 0 && next.IsValid() && p.pos.Line < next.Line { + // Print a terminating comma if the next token is on a new line. + p.print(token.COMMA) + if isIncomplete { + p.print(newline) + p.print("// " + filteredMsg) + } + if ws == ignore && mode&noIndent == 0 { + // unindent if we indented + p.print(unindent) + } + p.print(formfeed) // terminating comma needs a line break to look good + return + } + + if isIncomplete { + p.print(token.COMMA, newline) + p.print("// "+filteredMsg, newline) + } + + if ws == ignore && mode&noIndent == 0 { + // unindent if we indented + p.print(unindent) + } +} + +type paramMode int + +const ( + funcParam paramMode = iota + funcTParam + typeTParam +) + +func (p *printer) parameters(fields *ast.FieldList, mode paramMode) { + openTok, closeTok := token.LPAREN, token.RPAREN + if mode != funcParam { + openTok, closeTok = token.LBRACK, token.RBRACK + } + p.setPos(fields.Opening) + p.print(openTok) + if len(fields.List) > 0 { + prevLine := p.lineFor(fields.Opening) + ws := indent + for i, par := range fields.List { + // determine par begin and end line (may be different + // if there are multiple parameter names for this par + // or the type is on a separate line) + parLineBeg := p.lineFor(par.Pos()) + parLineEnd := p.lineFor(par.End()) + // separating "," if needed + needsLinebreak := 0 < prevLine && prevLine < parLineBeg + if i > 0 { + // use position of parameter following the comma as + // comma position for correct comma placement, but + // only if the next parameter is on the same line + if !needsLinebreak { + p.setPos(par.Pos()) + } + p.print(token.COMMA) + } + // separator if needed (linebreak or blank) + if needsLinebreak && p.linebreak(parLineBeg, 0, ws, true) > 0 { + // break line if the opening "(" or previous parameter ended on a different line + ws = ignore + } else if i > 0 { + p.print(blank) + } + // parameter names + if len(par.Names) > 0 { + // Very subtle: If we indented before (ws == ignore), identList + // won't indent again. If we didn't (ws == indent), identList will + // indent if the identList spans multiple lines, and it will outdent + // again at the end (and still ws == indent). Thus, a subsequent indent + // by a linebreak call after a type, or in the next multi-line identList + // will do the right thing. + p.identList(par.Names, ws == indent) + p.print(blank) + } + // parameter type + p.expr(stripParensAlways(par.Type)) + prevLine = parLineEnd + } + + // if the closing ")" is on a separate line from the last parameter, + // print an additional "," and line break + if closing := p.lineFor(fields.Closing); 0 < prevLine && prevLine < closing { + p.print(token.COMMA) + p.linebreak(closing, 0, ignore, true) + } else if mode == typeTParam && fields.NumFields() == 1 && combinesWithName(fields.List[0].Type) { + // A type parameter list [P T] where the name P and the type expression T syntactically + // combine to another valid (value) expression requires a trailing comma, as in [P *T,] + // (or an enclosing interface as in [P interface(*T)]), so that the type parameter list + // is not parsed as an array length [P*T]. + p.print(token.COMMA) + } + + // unindent if we indented + if ws == ignore { + p.print(unindent) + } + } + + p.setPos(fields.Closing) + p.print(closeTok) +} + +// combinesWithName reports whether a name followed by the expression x +// syntactically combines to another valid (value) expression. For instance +// using *T for x, "name *T" syntactically appears as the expression x*T. +// On the other hand, using P|Q or *P|~Q for x, "name P|Q" or name *P|~Q" +// cannot be combined into a valid (value) expression. +func combinesWithName(x ast.Expr) bool { + switch x := x.(type) { + case *ast.StarExpr: + // name *x.X combines to name*x.X if x.X is not a type element + return !isTypeElem(x.X) + case *ast.BinaryExpr: + return combinesWithName(x.X) && !isTypeElem(x.Y) + case *ast.ParenExpr: + // name(x) combines but we are making sure at + // the call site that x is never parenthesized. + panic("unexpected parenthesized expression") + } + return false +} + +// isTypeElem reports whether x is a (possibly parenthesized) type element expression. +// The result is false if x could be a type element OR an ordinary (value) expression. +func isTypeElem(x ast.Expr) bool { + switch x := x.(type) { + case *ast.ArrayType, *ast.StructType, *ast.FuncType, *ast.InterfaceType, *ast.MapType, *ast.ChanType: + return true + case *ast.UnaryExpr: + return x.Op == token.TILDE + case *ast.BinaryExpr: + return isTypeElem(x.X) || isTypeElem(x.Y) + case *ast.ParenExpr: + return isTypeElem(x.X) + } + return false +} + +func (p *printer) signature(sig *ast.FuncType) { + if sig.TypeParams != nil { + p.parameters(sig.TypeParams, funcTParam) + } + if sig.Params != nil { + p.parameters(sig.Params, funcParam) + } else { + p.print(token.LPAREN, token.RPAREN) + } + res := sig.Results + n := res.NumFields() + if n > 0 { + // res != nil + p.print(blank) + if n == 1 && res.List[0].Names == nil { + // single anonymous res; no ()'s + p.expr(stripParensAlways(res.List[0].Type)) + return + } + p.parameters(res, funcParam) + } +} + +func identListSize(list []*ast.Ident, maxSize int) (size int) { + for i, x := range list { + if i > 0 { + size += len(", ") + } + size += utf8.RuneCountInString(x.Name) + if size >= maxSize { + break + } + } + return +} + +func (p *printer) isOneLineFieldList(list []*ast.Field) bool { + if len(list) != 1 { + return false // allow only one field + } + f := list[0] + if f.Tag != nil || f.Comment != nil { + return false // don't allow tags or comments + } + // only name(s) and type + const maxSize = 30 // adjust as appropriate, this is an approximate value + namesSize := identListSize(f.Names, maxSize) + if namesSize > 0 { + namesSize = 1 // blank between names and types + } + typeSize := p.nodeSize(f.Type, maxSize) + return namesSize+typeSize <= maxSize +} + +func (p *printer) setLineComment(text string) { + p.setComment(&ast.CommentGroup{List: []*ast.Comment{{Slash: token.NoPos, Text: text}}}) +} + +func (p *printer) fieldList(fields *ast.FieldList, isStruct, isIncomplete bool) { + lbrace := fields.Opening + list := fields.List + rbrace := fields.Closing + hasComments := isIncomplete || p.commentBefore(p.posFor(rbrace)) + srcIsOneLine := lbrace.IsValid() && rbrace.IsValid() && p.lineFor(lbrace) == p.lineFor(rbrace) + + if !hasComments && srcIsOneLine { + // possibly a one-line struct/interface + if len(list) == 0 { + // no blank between keyword and {} in this case + p.setPos(lbrace) + p.print(token.LBRACE) + p.setPos(rbrace) + p.print(token.RBRACE) + return + } else if p.isOneLineFieldList(list) { + // small enough - print on one line + // (don't use identList and ignore source line breaks) + p.setPos(lbrace) + p.print(token.LBRACE, blank) + f := list[0] + if isStruct { + for i, x := range f.Names { + if i > 0 { + // no comments so no need for comma position + p.print(token.COMMA, blank) + } + p.expr(x) + } + if len(f.Names) > 0 { + p.print(blank) + } + p.expr(f.Type) + } else { // interface + if len(f.Names) > 0 { + name := f.Names[0] // method name + p.expr(name) + p.signature(f.Type.(*ast.FuncType)) // don't print "func" + } else { + // embedded interface + p.expr(f.Type) + } + } + p.print(blank) + p.setPos(rbrace) + p.print(token.RBRACE) + return + } + } + // hasComments || !srcIsOneLine + + p.print(blank) + p.setPos(lbrace) + p.print(token.LBRACE, indent) + if hasComments || len(list) > 0 { + p.print(formfeed) + } + + if isStruct { + + sep := vtab + if len(list) == 1 { + sep = blank + } + var line int + for i, f := range list { + if i > 0 { + p.linebreak(p.lineFor(f.Pos()), 1, ignore, p.linesFrom(line) > 0) + } + extraTabs := 0 + p.setComment(f.Doc) + p.recordLine(&line) + if len(f.Names) > 0 { + // named fields + p.identList(f.Names, false) + p.print(sep) + p.expr(f.Type) + extraTabs = 1 + } else { + // anonymous field + p.expr(f.Type) + extraTabs = 2 + } + if f.Tag != nil { + if len(f.Names) > 0 && sep == vtab { + p.print(sep) + } + p.print(sep) + p.expr(f.Tag) + extraTabs = 0 + } + if f.Comment != nil { + for ; extraTabs > 0; extraTabs-- { + p.print(sep) + } + p.setComment(f.Comment) + } + } + if isIncomplete { + if len(list) > 0 { + p.print(formfeed) + } + p.flush(p.posFor(rbrace), token.RBRACE) // make sure we don't lose the last line comment + p.setLineComment("// " + filteredMsg) + } + + } else { // interface + + var line int + var prev *ast.Ident // previous "type" identifier + for i, f := range list { + var name *ast.Ident // first name, or nil + if len(f.Names) > 0 { + name = f.Names[0] + } + if i > 0 { + // don't do a line break (min == 0) if we are printing a list of types + // TODO(gri) this doesn't work quite right if the list of types is + // spread across multiple lines + min := 1 + if prev != nil && name == prev { + min = 0 + } + p.linebreak(p.lineFor(f.Pos()), min, ignore, p.linesFrom(line) > 0) + } + p.setComment(f.Doc) + p.recordLine(&line) + if name != nil { + // method + p.expr(name) + p.signature(f.Type.(*ast.FuncType)) // don't print "func" + prev = nil + } else { + // embedded interface + p.expr(f.Type) + prev = nil + } + p.setComment(f.Comment) + } + if isIncomplete { + if len(list) > 0 { + p.print(formfeed) + } + p.flush(p.posFor(rbrace), token.RBRACE) // make sure we don't lose the last line comment + p.setLineComment("// contains filtered or unexported methods") + } + + } + p.print(unindent, formfeed) + p.setPos(rbrace) + p.print(token.RBRACE) +} + +// ---------------------------------------------------------------------------- +// Expressions + +func walkBinary(e *ast.BinaryExpr) (has4, has5 bool, maxProblem int) { + switch e.Op.Precedence() { + case 4: + has4 = true + case 5: + has5 = true + } + + switch l := e.X.(type) { + case *ast.BinaryExpr: + if l.Op.Precedence() < e.Op.Precedence() { + // parens will be inserted. + // pretend this is an *ast.ParenExpr and do nothing. + break + } + h4, h5, mp := walkBinary(l) + has4 = has4 || h4 + has5 = has5 || h5 + if maxProblem < mp { + maxProblem = mp + } + } + + switch r := e.Y.(type) { + case *ast.BinaryExpr: + if r.Op.Precedence() <= e.Op.Precedence() { + // parens will be inserted. + // pretend this is an *ast.ParenExpr and do nothing. + break + } + h4, h5, mp := walkBinary(r) + has4 = has4 || h4 + has5 = has5 || h5 + if maxProblem < mp { + maxProblem = mp + } + + case *ast.StarExpr: + if e.Op == token.QUO { // `*/` + maxProblem = 5 + } + + case *ast.UnaryExpr: + switch e.Op.String() + r.Op.String() { + case "/*", "&&", "&^": + maxProblem = 5 + case "++", "--": + if maxProblem < 4 { + maxProblem = 4 + } + } + } + return +} + +func cutoff(e *ast.BinaryExpr, depth int) int { + has4, has5, maxProblem := walkBinary(e) + if maxProblem > 0 { + return maxProblem + 1 + } + if has4 && has5 { + if depth == 1 { + return 5 + } + return 4 + } + if depth == 1 { + return 6 + } + return 4 +} + +func diffPrec(expr ast.Expr, prec int) int { + x, ok := expr.(*ast.BinaryExpr) + if !ok || prec != x.Op.Precedence() { + return 1 + } + return 0 +} + +func reduceDepth(depth int) int { + depth-- + if depth < 1 { + depth = 1 + } + return depth +} + +// Format the binary expression: decide the cutoff and then format. +// Let's call depth == 1 Normal mode, and depth > 1 Compact mode. +// (Algorithm suggestion by Russ Cox.) +// +// The precedences are: +// +// 5 * / % << >> & &^ +// 4 + - | ^ +// 3 == != < <= > >= +// 2 && +// 1 || +// +// The only decision is whether there will be spaces around levels 4 and 5. +// There are never spaces at level 6 (unary), and always spaces at levels 3 and below. +// +// To choose the cutoff, look at the whole expression but excluding primary +// expressions (function calls, parenthesized exprs), and apply these rules: +// +// 1. If there is a binary operator with a right side unary operand +// that would clash without a space, the cutoff must be (in order): +// +// /* 6 +// && 6 +// &^ 6 +// ++ 5 +// -- 5 +// +// (Comparison operators always have spaces around them.) +// +// 2. If there is a mix of level 5 and level 4 operators, then the cutoff +// is 5 (use spaces to distinguish precedence) in Normal mode +// and 4 (never use spaces) in Compact mode. +// +// 3. If there are no level 4 operators or no level 5 operators, then the +// cutoff is 6 (always use spaces) in Normal mode +// and 4 (never use spaces) in Compact mode. +func (p *printer) binaryExpr(x *ast.BinaryExpr, prec1, cutoff, depth int) { + prec := x.Op.Precedence() + if prec < prec1 { + // parenthesis needed + // Note: The parser inserts an ast.ParenExpr node; thus this case + // can only occur if the AST is created in a different way. + p.print(token.LPAREN) + p.expr0(x, reduceDepth(depth)) // parentheses undo one level of depth + p.print(token.RPAREN) + return + } + + printBlank := prec < cutoff + + ws := indent + p.expr1(x.X, prec, depth+diffPrec(x.X, prec)) + if printBlank { + p.print(blank) + } + xline := p.pos.Line // before the operator (it may be on the next line!) + yline := p.lineFor(x.Y.Pos()) + p.setPos(x.OpPos) + p.print(x.Op) + if xline != yline && xline > 0 && yline > 0 { + // at least one line break, but respect an extra empty line + // in the source + if p.linebreak(yline, 1, ws, true) > 0 { + ws = ignore + printBlank = false // no blank after line break + } + } + if printBlank { + p.print(blank) + } + p.expr1(x.Y, prec+1, depth+1) + if ws == ignore { + p.print(unindent) + } +} + +func isBinary(expr ast.Expr) bool { + _, ok := expr.(*ast.BinaryExpr) + return ok +} + +func (p *printer) expr1(expr ast.Expr, prec1, depth int) { + p.setPos(expr.Pos()) + + switch x := expr.(type) { + case *ast.BadExpr: + p.print("BadExpr") + + case *ast.Ident: + p.print(x) + + case *ast.BinaryExpr: + if depth < 1 { + p.internalError("depth < 1:", depth) + depth = 1 + } + p.binaryExpr(x, prec1, cutoff(x, depth), depth) + + case *ast.KeyValueExpr: + p.expr(x.Key) + p.setPos(x.Colon) + p.print(token.COLON, blank) + p.expr(x.Value) + + case *ast.StarExpr: + const prec = token.UnaryPrec + if prec < prec1 { + // parenthesis needed + p.print(token.LPAREN) + p.print(token.MUL) + p.expr(x.X) + p.print(token.RPAREN) + } else { + // no parenthesis needed + p.print(token.MUL) + p.expr(x.X) + } + + case *ast.UnaryExpr: + const prec = token.UnaryPrec + if prec < prec1 { + // parenthesis needed + p.print(token.LPAREN) + p.expr(x) + p.print(token.RPAREN) + } else { + // no parenthesis needed + p.print(x.Op) + if x.Op == token.RANGE { + // TODO(gri) Remove this code if it cannot be reached. + p.print(blank) + } + p.expr1(x.X, prec, depth) + } + + case *ast.BasicLit: + if p.Config.Mode&normalizeNumbers != 0 { + x = normalizedNumber(x) + } + p.print(x) + + case *ast.FuncLit: + p.setPos(x.Type.Pos()) + p.print(token.FUNC) + // See the comment in funcDecl about how the header size is computed. + startCol := p.out.Column - len("func") + p.signature(x.Type) + p.funcBody(p.distanceFrom(x.Type.Pos(), startCol), blank, x.Body) + + case *ast.ParenExpr: + if _, hasParens := x.X.(*ast.ParenExpr); hasParens { + // don't print parentheses around an already parenthesized expression + // TODO(gri) consider making this more general and incorporate precedence levels + p.expr0(x.X, depth) + } else { + p.print(token.LPAREN) + p.expr0(x.X, reduceDepth(depth)) // parentheses undo one level of depth + p.setPos(x.Rparen) + p.print(token.RPAREN) + } + + case *ast.SelectorExpr: + p.selectorExpr(x, depth, false) + + case *ast.TypeAssertExpr: + p.expr1(x.X, token.HighestPrec, depth) + p.print(token.PERIOD) + p.setPos(x.Lparen) + p.print(token.LPAREN) + if x.Type != nil { + p.expr(x.Type) + } else { + p.print(token.TYPE) + } + p.setPos(x.Rparen) + p.print(token.RPAREN) + + case *ast.IndexExpr: + // TODO(gri): should treat[] like parentheses and undo one level of depth + p.expr1(x.X, token.HighestPrec, 1) + p.setPos(x.Lbrack) + p.print(token.LBRACK) + p.expr0(x.Index, depth+1) + p.setPos(x.Rbrack) + p.print(token.RBRACK) + + case *ast.IndexListExpr: + // TODO(gri): as for IndexExpr, should treat [] like parentheses and undo + // one level of depth + p.expr1(x.X, token.HighestPrec, 1) + p.setPos(x.Lbrack) + p.print(token.LBRACK) + p.exprList(x.Lbrack, x.Indices, depth+1, commaTerm, x.Rbrack, false) + p.setPos(x.Rbrack) + p.print(token.RBRACK) + + case *ast.SliceExpr: + // TODO(gri): should treat[] like parentheses and undo one level of depth + p.expr1(x.X, token.HighestPrec, 1) + p.setPos(x.Lbrack) + p.print(token.LBRACK) + indices := []ast.Expr{x.Low, x.High} + if x.Max != nil { + indices = append(indices, x.Max) + } + // determine if we need extra blanks around ':' + var needsBlanks bool + if depth <= 1 { + var indexCount int + var hasBinaries bool + for _, x := range indices { + if x != nil { + indexCount++ + if isBinary(x) { + hasBinaries = true + } + } + } + if indexCount > 1 && hasBinaries { + needsBlanks = true + } + } + for i, x := range indices { + if i > 0 { + if indices[i-1] != nil && needsBlanks { + p.print(blank) + } + p.print(token.COLON) + if x != nil && needsBlanks { + p.print(blank) + } + } + if x != nil { + p.expr0(x, depth+1) + } + } + p.setPos(x.Rbrack) + p.print(token.RBRACK) + + case *ast.CallExpr: + if len(x.Args) > 1 { + depth++ + } + var wasIndented bool + if _, ok := x.Fun.(*ast.FuncType); ok { + // conversions to literal function types require parentheses around the type + p.print(token.LPAREN) + wasIndented = p.possibleSelectorExpr(x.Fun, token.HighestPrec, depth) + p.print(token.RPAREN) + } else { + wasIndented = p.possibleSelectorExpr(x.Fun, token.HighestPrec, depth) + } + p.setPos(x.Lparen) + p.print(token.LPAREN) + if x.Ellipsis.IsValid() { + p.exprList(x.Lparen, x.Args, depth, 0, x.Ellipsis, false) + p.setPos(x.Ellipsis) + p.print(token.ELLIPSIS) + if x.Rparen.IsValid() && p.lineFor(x.Ellipsis) < p.lineFor(x.Rparen) { + p.print(token.COMMA, formfeed) + } + } else { + p.exprList(x.Lparen, x.Args, depth, commaTerm, x.Rparen, false) + } + p.setPos(x.Rparen) + p.print(token.RPAREN) + if wasIndented { + p.print(unindent) + } + + case *ast.CompositeLit: + // composite literal elements that are composite literals themselves may have the type omitted + if x.Type != nil { + p.expr1(x.Type, token.HighestPrec, depth) + } + p.level++ + p.setPos(x.Lbrace) + p.print(token.LBRACE) + p.exprList(x.Lbrace, x.Elts, 1, commaTerm, x.Rbrace, x.Incomplete) + // do not insert extra line break following a /*-style comment + // before the closing '}' as it might break the code if there + // is no trailing ',' + mode := noExtraLinebreak + // do not insert extra blank following a /*-style comment + // before the closing '}' unless the literal is empty + if len(x.Elts) > 0 { + mode |= noExtraBlank + } + // need the initial indent to print lone comments with + // the proper level of indentation + p.print(indent, unindent, mode) + p.setPos(x.Rbrace) + p.print(token.RBRACE, mode) + p.level-- + + case *ast.Ellipsis: + p.print(token.ELLIPSIS) + if x.Elt != nil { + p.expr(x.Elt) + } + + case *ast.ArrayType: + p.print(token.LBRACK) + if x.Len != nil { + p.expr(x.Len) + } + p.print(token.RBRACK) + p.expr(x.Elt) + + case *ast.StructType: + p.print(token.STRUCT) + p.fieldList(x.Fields, true, x.Incomplete) + + case *ast.FuncType: + p.print(token.FUNC) + p.signature(x) + + case *ast.InterfaceType: + p.print(token.INTERFACE) + p.fieldList(x.Methods, false, x.Incomplete) + + case *ast.MapType: + p.print(token.MAP, token.LBRACK) + p.expr(x.Key) + p.print(token.RBRACK) + p.expr(x.Value) + + case *ast.ChanType: + switch x.Dir { + case ast.SEND | ast.RECV: + p.print(token.CHAN) + case ast.RECV: + p.print(token.ARROW, token.CHAN) // x.Arrow and x.Pos() are the same + case ast.SEND: + p.print(token.CHAN) + p.setPos(x.Arrow) + p.print(token.ARROW) + } + p.print(blank) + p.expr(x.Value) + + default: + panic("unreachable") + } +} + +// normalizedNumber rewrites base prefixes and exponents +// of numbers to use lower-case letters (0X123 to 0x123 and 1.2E3 to 1.2e3), +// and removes leading 0's from integer imaginary literals (0765i to 765i). +// It leaves hexadecimal digits alone. +// +// normalizedNumber doesn't modify the ast.BasicLit value lit points to. +// If lit is not a number or a number in canonical format already, +// lit is returned as is. Otherwise a new ast.BasicLit is created. +func normalizedNumber(lit *ast.BasicLit) *ast.BasicLit { + if lit.Kind != token.INT && lit.Kind != token.FLOAT && lit.Kind != token.IMAG { + return lit // not a number - nothing to do + } + if len(lit.Value) < 2 { + return lit // only one digit (common case) - nothing to do + } + // len(lit.Value) >= 2 + + // We ignore lit.Kind because for lit.Kind == token.IMAG the literal may be an integer + // or floating-point value, decimal or not. Instead, just consider the literal pattern. + x := lit.Value + switch x[:2] { + default: + // 0-prefix octal, decimal int, or float (possibly with 'i' suffix) + if i := strings.LastIndexByte(x, 'E'); i >= 0 { + x = x[:i] + "e" + x[i+1:] + break + } + // remove leading 0's from integer (but not floating-point) imaginary literals + if x[len(x)-1] == 'i' && !strings.ContainsAny(x, ".e") { + x = strings.TrimLeft(x, "0_") + if x == "i" { + x = "0i" + } + } + case "0X": + x = "0x" + x[2:] + // possibly a hexadecimal float + if i := strings.LastIndexByte(x, 'P'); i >= 0 { + x = x[:i] + "p" + x[i+1:] + } + case "0x": + // possibly a hexadecimal float + i := strings.LastIndexByte(x, 'P') + if i == -1 { + return lit // nothing to do + } + x = x[:i] + "p" + x[i+1:] + case "0O": + x = "0o" + x[2:] + case "0o": + return lit // nothing to do + case "0B": + x = "0b" + x[2:] + case "0b": + return lit // nothing to do + } + + return &ast.BasicLit{ValuePos: lit.ValuePos, Kind: lit.Kind, Value: x} +} + +func (p *printer) possibleSelectorExpr(expr ast.Expr, prec1, depth int) bool { + if x, ok := expr.(*ast.SelectorExpr); ok { + return p.selectorExpr(x, depth, true) + } + p.expr1(expr, prec1, depth) + return false +} + +// selectorExpr handles an *ast.SelectorExpr node and reports whether x spans +// multiple lines. +func (p *printer) selectorExpr(x *ast.SelectorExpr, depth int, isMethod bool) bool { + p.expr1(x.X, token.HighestPrec, depth) + p.print(token.PERIOD) + if line := p.lineFor(x.Sel.Pos()); p.pos.IsValid() && p.pos.Line < line { + p.print(indent, newline) + p.setPos(x.Sel.Pos()) + p.print(x.Sel) + if !isMethod { + p.print(unindent) + } + return true + } + p.setPos(x.Sel.Pos()) + p.print(x.Sel) + return false +} + +func (p *printer) expr0(x ast.Expr, depth int) { + p.expr1(x, token.LowestPrec, depth) +} + +func (p *printer) expr(x ast.Expr) { + const depth = 1 + p.expr1(x, token.LowestPrec, depth) +} + +// ---------------------------------------------------------------------------- +// Statements + +// Print the statement list indented, but without a newline after the last statement. +// Extra line breaks between statements in the source are respected but at most one +// empty line is printed between statements. +func (p *printer) stmtList(list []ast.Stmt, nindent int, nextIsRBrace bool) { + if nindent > 0 { + p.print(indent) + } + var line int + i := 0 + for _, s := range list { + // ignore empty statements (was issue 3466) + if _, isEmpty := s.(*ast.EmptyStmt); !isEmpty { + // nindent == 0 only for lists of switch/select case clauses; + // in those cases each clause is a new section + if len(p.output) > 0 { + // only print line break if we are not at the beginning of the output + // (i.e., we are not printing only a partial program) + p.linebreak(p.lineFor(s.Pos()), 1, ignore, i == 0 || nindent == 0 || p.linesFrom(line) > 0) + } + p.recordLine(&line) + p.stmt(s, nextIsRBrace && i == len(list)-1) + // labeled statements put labels on a separate line, but here + // we only care about the start line of the actual statement + // without label - correct line for each label + for t := s; ; { + lt, _ := t.(*ast.LabeledStmt) + if lt == nil { + break + } + line++ + t = lt.Stmt + } + i++ + } + } + if nindent > 0 { + p.print(unindent) + } +} + +// block prints an *ast.BlockStmt; it always spans at least two lines. +func (p *printer) block(b *ast.BlockStmt, nindent int) { + p.setPos(b.Lbrace) + p.print(token.LBRACE) + p.stmtList(b.List, nindent, true) + p.linebreak(p.lineFor(b.Rbrace), 1, ignore, true) + p.setPos(b.Rbrace) + p.print(token.RBRACE) +} + +func isTypeName(x ast.Expr) bool { + switch t := x.(type) { + case *ast.Ident: + return true + case *ast.SelectorExpr: + return isTypeName(t.X) + } + return false +} + +func stripParens(x ast.Expr) ast.Expr { + if px, strip := x.(*ast.ParenExpr); strip { + // parentheses must not be stripped if there are any + // unparenthesized composite literals starting with + // a type name + ast.Inspect(px.X, func(node ast.Node) bool { + switch x := node.(type) { + case *ast.ParenExpr: + // parentheses protect enclosed composite literals + return false + case *ast.CompositeLit: + if isTypeName(x.Type) { + strip = false // do not strip parentheses + } + return false + } + // in all other cases, keep inspecting + return true + }) + if strip { + return stripParens(px.X) + } + } + return x +} + +func stripParensAlways(x ast.Expr) ast.Expr { + if x, ok := x.(*ast.ParenExpr); ok { + return stripParensAlways(x.X) + } + return x +} + +func (p *printer) controlClause(isForStmt bool, init ast.Stmt, expr ast.Expr, post ast.Stmt) { + p.print(blank) + needsBlank := false + if init == nil && post == nil { + // no semicolons required + if expr != nil { + p.expr(stripParens(expr)) + needsBlank = true + } + } else { + // all semicolons required + // (they are not separators, print them explicitly) + if init != nil { + p.stmt(init, false) + } + p.print(token.SEMICOLON, blank) + if expr != nil { + p.expr(stripParens(expr)) + needsBlank = true + } + if isForStmt { + p.print(token.SEMICOLON, blank) + needsBlank = false + if post != nil { + p.stmt(post, false) + needsBlank = true + } + } + } + if needsBlank { + p.print(blank) + } +} + +// indentList reports whether an expression list would look better if it +// were indented wholesale (starting with the very first element, rather +// than starting at the first line break). +func (p *printer) indentList(list []ast.Expr) bool { + // Heuristic: indentList reports whether there are more than one multi- + // line element in the list, or if there is any element that is not + // starting on the same line as the previous one ends. + if len(list) >= 2 { + b := p.lineFor(list[0].Pos()) + e := p.lineFor(list[len(list)-1].End()) + if 0 < b && b < e { + // list spans multiple lines + n := 0 // multi-line element count + line := b + for _, x := range list { + xb := p.lineFor(x.Pos()) + xe := p.lineFor(x.End()) + if line < xb { + // x is not starting on the same + // line as the previous one ended + return true + } + if xb < xe { + // x is a multi-line element + n++ + } + line = xe + } + return n > 1 + } + } + return false +} + +func (p *printer) stmt(stmt ast.Stmt, nextIsRBrace bool) { + p.setPos(stmt.Pos()) + + switch s := stmt.(type) { + case *ast.BadStmt: + p.print("BadStmt") + + case *ast.DeclStmt: + p.decl(s.Decl) + + case *ast.EmptyStmt: + // nothing to do + + case *ast.LabeledStmt: + // a "correcting" unindent immediately following a line break + // is applied before the line break if there is no comment + // between (see writeWhitespace) + p.print(unindent) + p.expr(s.Label) + p.setPos(s.Colon) + p.print(token.COLON, indent) + if e, isEmpty := s.Stmt.(*ast.EmptyStmt); isEmpty { + if !nextIsRBrace { + p.print(newline) + p.setPos(e.Pos()) + p.print(token.SEMICOLON) + break + } + } else { + p.linebreak(p.lineFor(s.Stmt.Pos()), 1, ignore, true) + } + p.stmt(s.Stmt, nextIsRBrace) + + case *ast.ExprStmt: + const depth = 1 + p.expr0(s.X, depth) + + case *ast.SendStmt: + const depth = 1 + p.expr0(s.Chan, depth) + p.print(blank) + p.setPos(s.Arrow) + p.print(token.ARROW, blank) + p.expr0(s.Value, depth) + + case *ast.IncDecStmt: + const depth = 1 + p.expr0(s.X, depth+1) + p.setPos(s.TokPos) + p.print(s.Tok) + + case *ast.AssignStmt: + depth := 1 + if len(s.Lhs) > 1 && len(s.Rhs) > 1 { + depth++ + } + p.exprList(s.Pos(), s.Lhs, depth, 0, s.TokPos, false) + p.print(blank) + p.setPos(s.TokPos) + p.print(s.Tok, blank) + p.exprList(s.TokPos, s.Rhs, depth, 0, token.NoPos, false) + + case *ast.GoStmt: + p.print(token.GO, blank) + p.expr(s.Call) + + case *ast.DeferStmt: + p.print(token.DEFER, blank) + p.expr(s.Call) + + case *ast.ReturnStmt: + p.print(token.RETURN) + if s.Results != nil { + p.print(blank) + // Use indentList heuristic to make corner cases look + // better (issue 1207). A more systematic approach would + // always indent, but this would cause significant + // reformatting of the code base and not necessarily + // lead to more nicely formatted code in general. + if p.indentList(s.Results) { + p.print(indent) + // Use NoPos so that a newline never goes before + // the results (see issue #32854). + p.exprList(token.NoPos, s.Results, 1, noIndent, token.NoPos, false) + p.print(unindent) + } else { + p.exprList(token.NoPos, s.Results, 1, 0, token.NoPos, false) + } + } + + case *ast.BranchStmt: + p.print(s.Tok) + if s.Label != nil { + p.print(blank) + p.expr(s.Label) + } + + case *ast.BlockStmt: + p.block(s, 1) + + case *ast.IfStmt: + p.print(token.IF) + p.controlClause(false, s.Init, s.Cond, nil) + p.block(s.Body, 1) + if s.Else != nil { + p.print(blank, token.ELSE, blank) + switch s.Else.(type) { + case *ast.BlockStmt, *ast.IfStmt: + p.stmt(s.Else, nextIsRBrace) + default: + // This can only happen with an incorrectly + // constructed AST. Permit it but print so + // that it can be parsed without errors. + p.print(token.LBRACE, indent, formfeed) + p.stmt(s.Else, true) + p.print(unindent, formfeed, token.RBRACE) + } + } + + case *ast.CaseClause: + if s.List != nil { + p.print(token.CASE, blank) + p.exprList(s.Pos(), s.List, 1, 0, s.Colon, false) + } else { + p.print(token.DEFAULT) + } + p.setPos(s.Colon) + p.print(token.COLON) + p.stmtList(s.Body, 1, nextIsRBrace) + + case *ast.SwitchStmt: + p.print(token.SWITCH) + p.controlClause(false, s.Init, s.Tag, nil) + p.block(s.Body, 0) + + case *ast.TypeSwitchStmt: + p.print(token.SWITCH) + if s.Init != nil { + p.print(blank) + p.stmt(s.Init, false) + p.print(token.SEMICOLON) + } + p.print(blank) + p.stmt(s.Assign, false) + p.print(blank) + p.block(s.Body, 0) + + case *ast.CommClause: + if s.Comm != nil { + p.print(token.CASE, blank) + p.stmt(s.Comm, false) + } else { + p.print(token.DEFAULT) + } + p.setPos(s.Colon) + p.print(token.COLON) + p.stmtList(s.Body, 1, nextIsRBrace) + + case *ast.SelectStmt: + p.print(token.SELECT, blank) + body := s.Body + if len(body.List) == 0 && !p.commentBefore(p.posFor(body.Rbrace)) { + // print empty select statement w/o comments on one line + p.setPos(body.Lbrace) + p.print(token.LBRACE) + p.setPos(body.Rbrace) + p.print(token.RBRACE) + } else { + p.block(body, 0) + } + + case *ast.ForStmt: + p.print(token.FOR) + p.controlClause(true, s.Init, s.Cond, s.Post) + p.block(s.Body, 1) + + case *ast.RangeStmt: + p.print(token.FOR, blank) + if s.Key != nil { + p.expr(s.Key) + if s.Value != nil { + // use position of value following the comma as + // comma position for correct comment placement + p.setPos(s.Value.Pos()) + p.print(token.COMMA, blank) + p.expr(s.Value) + } + p.print(blank) + p.setPos(s.TokPos) + p.print(s.Tok, blank) + } + p.print(token.RANGE, blank) + p.expr(stripParens(s.X)) + p.print(blank) + p.block(s.Body, 1) + + default: + panic("unreachable") + } +} + +// ---------------------------------------------------------------------------- +// Declarations + +// The keepTypeColumn function determines if the type column of a series of +// consecutive const or var declarations must be kept, or if initialization +// values (V) can be placed in the type column (T) instead. The i'th entry +// in the result slice is true if the type column in spec[i] must be kept. +// +// For example, the declaration: +// +// const ( +// foobar int = 42 // comment +// x = 7 // comment +// foo +// bar = 991 +// ) +// +// leads to the type/values matrix below. A run of value columns (V) can +// be moved into the type column if there is no type for any of the values +// in that column (we only move entire columns so that they align properly). +// +// matrix formatted result +// matrix +// T V -> T V -> true there is a T and so the type +// - V - V true column must be kept +// - - - - false +// - V V - false V is moved into T column +func keepTypeColumn(specs []ast.Spec) []bool { + m := make([]bool, len(specs)) + + populate := func(i, j int, keepType bool) { + if keepType { + for ; i < j; i++ { + m[i] = true + } + } + } + + i0 := -1 // if i0 >= 0 we are in a run and i0 is the start of the run + var keepType bool + for i, s := range specs { + t := s.(*ast.ValueSpec) + if t.Values != nil { + if i0 < 0 { + // start of a run of ValueSpecs with non-nil Values + i0 = i + keepType = false + } + } else { + if i0 >= 0 { + // end of a run + populate(i0, i, keepType) + i0 = -1 + } + } + if t.Type != nil { + keepType = true + } + } + if i0 >= 0 { + // end of a run + populate(i0, len(specs), keepType) + } + + return m +} + +func (p *printer) valueSpec(s *ast.ValueSpec, keepType bool) { + p.setComment(s.Doc) + p.identList(s.Names, false) // always present + extraTabs := 3 + if s.Type != nil || keepType { + p.print(vtab) + extraTabs-- + } + if s.Type != nil { + p.expr(s.Type) + } + if s.Values != nil { + p.print(vtab, token.ASSIGN, blank) + p.exprList(token.NoPos, s.Values, 1, 0, token.NoPos, false) + extraTabs-- + } + if s.Comment != nil { + for ; extraTabs > 0; extraTabs-- { + p.print(vtab) + } + p.setComment(s.Comment) + } +} + +func sanitizeImportPath(lit *ast.BasicLit) *ast.BasicLit { + // Note: An unmodified AST generated by go/parser will already + // contain a backward- or double-quoted path string that does + // not contain any invalid characters, and most of the work + // here is not needed. However, a modified or generated AST + // may possibly contain non-canonical paths. Do the work in + // all cases since it's not too hard and not speed-critical. + + // if we don't have a proper string, be conservative and return whatever we have + if lit.Kind != token.STRING { + return lit + } + s, err := strconv.Unquote(lit.Value) + if err != nil { + return lit + } + + // if the string is an invalid path, return whatever we have + // + // spec: "Implementation restriction: A compiler may restrict + // ImportPaths to non-empty strings using only characters belonging + // to Unicode's L, M, N, P, and S general categories (the Graphic + // characters without spaces) and may also exclude the characters + // !"#$%&'()*,:;<=>?[\]^`{|} and the Unicode replacement character + // U+FFFD." + if s == "" { + return lit + } + const illegalChars = `!"#$%&'()*,:;<=>?[\]^{|}` + "`\uFFFD" + for _, r := range s { + if !unicode.IsGraphic(r) || unicode.IsSpace(r) || strings.ContainsRune(illegalChars, r) { + return lit + } + } + + // otherwise, return the double-quoted path + s = strconv.Quote(s) + if s == lit.Value { + return lit // nothing wrong with lit + } + return &ast.BasicLit{ValuePos: lit.ValuePos, Kind: token.STRING, Value: s} +} + +// The parameter n is the number of specs in the group. If doIndent is set, +// multi-line identifier lists in the spec are indented when the first +// linebreak is encountered. +func (p *printer) spec(spec ast.Spec, n int, doIndent bool) { + switch s := spec.(type) { + case *ast.ImportSpec: + p.setComment(s.Doc) + if s.Name != nil { + p.expr(s.Name) + p.print(blank) + } + p.expr(sanitizeImportPath(s.Path)) + p.setComment(s.Comment) + p.setPos(s.EndPos) + + case *ast.ValueSpec: + if n != 1 { + p.internalError("expected n = 1; got", n) + } + p.setComment(s.Doc) + p.identList(s.Names, doIndent) // always present + if s.Type != nil { + p.print(blank) + p.expr(s.Type) + } + if s.Values != nil { + p.print(blank, token.ASSIGN, blank) + p.exprList(token.NoPos, s.Values, 1, 0, token.NoPos, false) + } + p.setComment(s.Comment) + + case *ast.TypeSpec: + p.setComment(s.Doc) + p.expr(s.Name) + if s.TypeParams != nil { + p.parameters(s.TypeParams, typeTParam) + } + if n == 1 { + p.print(blank) + } else { + p.print(vtab) + } + if s.Assign.IsValid() { + p.print(token.ASSIGN, blank) + } + p.expr(s.Type) + p.setComment(s.Comment) + + default: + panic("unreachable") + } +} + +func (p *printer) genDecl(d *ast.GenDecl) { + p.setComment(d.Doc) + p.setPos(d.Pos()) + p.print(d.Tok, blank) + + if d.Lparen.IsValid() || len(d.Specs) > 1 { + // group of parenthesized declarations + p.setPos(d.Lparen) + p.print(token.LPAREN) + if n := len(d.Specs); n > 0 { + p.print(indent, formfeed) + if n > 1 && (d.Tok == token.CONST || d.Tok == token.VAR) { + // two or more grouped const/var declarations: + // determine if the type column must be kept + keepType := keepTypeColumn(d.Specs) + var line int + for i, s := range d.Specs { + if i > 0 { + p.linebreak(p.lineFor(s.Pos()), 1, ignore, p.linesFrom(line) > 0) + } + p.recordLine(&line) + p.valueSpec(s.(*ast.ValueSpec), keepType[i]) + } + } else { + var line int + for i, s := range d.Specs { + if i > 0 { + p.linebreak(p.lineFor(s.Pos()), 1, ignore, p.linesFrom(line) > 0) + } + p.recordLine(&line) + p.spec(s, n, false) + } + } + p.print(unindent, formfeed) + } + p.setPos(d.Rparen) + p.print(token.RPAREN) + + } else if len(d.Specs) > 0 { + // single declaration + p.spec(d.Specs[0], 1, true) + } +} + +// sizeCounter is an io.Writer which counts the number of bytes written, +// as well as whether a newline character was seen. +type sizeCounter struct { + hasNewline bool + size int +} + +func (c *sizeCounter) Write(p []byte) (int, error) { + if !c.hasNewline { + for _, b := range p { + if b == '\n' || b == '\f' { + c.hasNewline = true + break + } + } + } + c.size += len(p) + return len(p), nil +} + +// nodeSize determines the size of n in chars after formatting. +// The result is <= maxSize if the node fits on one line with at +// most maxSize chars and the formatted output doesn't contain +// any control chars. Otherwise, the result is > maxSize. +func (p *printer) nodeSize(n ast.Node, maxSize int) (size int) { + // nodeSize invokes the printer, which may invoke nodeSize + // recursively. For deep composite literal nests, this can + // lead to an exponential algorithm. Remember previous + // results to prune the recursion (was issue 1628). + if size, found := p.nodeSizes[n]; found { + return size + } + + size = maxSize + 1 // assume n doesn't fit + p.nodeSizes[n] = size + + // nodeSize computation must be independent of particular + // style so that we always get the same decision; print + // in RawFormat + cfg := Config{Mode: RawFormat} + var counter sizeCounter + if err := cfg.fprint(&counter, p.fset, n, p.nodeSizes); err != nil { + return + } + if counter.size <= maxSize && !counter.hasNewline { + // n fits in a single line + size = counter.size + p.nodeSizes[n] = size + } + return +} + +// numLines returns the number of lines spanned by node n in the original source. +func (p *printer) numLines(n ast.Node) int { + if from := n.Pos(); from.IsValid() { + if to := n.End(); to.IsValid() { + return p.lineFor(to) - p.lineFor(from) + 1 + } + } + return infinity +} + +// bodySize is like nodeSize but it is specialized for *ast.BlockStmt's. +func (p *printer) bodySize(b *ast.BlockStmt, maxSize int) int { + pos1 := b.Pos() + pos2 := b.Rbrace + if pos1.IsValid() && pos2.IsValid() && p.lineFor(pos1) != p.lineFor(pos2) { + // opening and closing brace are on different lines - don't make it a one-liner + return maxSize + 1 + } + if len(b.List) > 5 { + // too many statements - don't make it a one-liner + return maxSize + 1 + } + // otherwise, estimate body size + bodySize := p.commentSizeBefore(p.posFor(pos2)) + for i, s := range b.List { + if bodySize > maxSize { + break // no need to continue + } + if i > 0 { + bodySize += 2 // space for a semicolon and blank + } + bodySize += p.nodeSize(s, maxSize) + } + return bodySize +} + +// funcBody prints a function body following a function header of given headerSize. +// If the header's and block's size are "small enough" and the block is "simple enough", +// the block is printed on the current line, without line breaks, spaced from the header +// by sep. Otherwise the block's opening "{" is printed on the current line, followed by +// lines for the block's statements and its closing "}". +func (p *printer) funcBody(headerSize int, sep whiteSpace, b *ast.BlockStmt) { + if b == nil { + return + } + + // save/restore composite literal nesting level + defer func(level int) { + p.level = level + }(p.level) + p.level = 0 + + const maxSize = 100 + if headerSize+p.bodySize(b, maxSize) <= maxSize { + p.print(sep) + p.setPos(b.Lbrace) + p.print(token.LBRACE) + if len(b.List) > 0 { + p.print(blank) + for i, s := range b.List { + if i > 0 { + p.print(token.SEMICOLON, blank) + } + p.stmt(s, i == len(b.List)-1) + } + p.print(blank) + } + p.print(noExtraLinebreak) + p.setPos(b.Rbrace) + p.print(token.RBRACE, noExtraLinebreak) + return + } + + if sep != ignore { + p.print(blank) // always use blank + } + p.block(b, 1) +} + +// distanceFrom returns the column difference between p.out (the current output +// position) and startOutCol. If the start position is on a different line from +// the current position (or either is unknown), the result is infinity. +func (p *printer) distanceFrom(startPos token.Pos, startOutCol int) int { + if startPos.IsValid() && p.pos.IsValid() && p.posFor(startPos).Line == p.pos.Line { + return p.out.Column - startOutCol + } + return infinity +} + +func (p *printer) funcDecl(d *ast.FuncDecl) { + p.setComment(d.Doc) + p.setPos(d.Pos()) + p.print(token.FUNC, blank) + // We have to save startCol only after emitting FUNC; otherwise it can be on a + // different line (all whitespace preceding the FUNC is emitted only when the + // FUNC is emitted). + startCol := p.out.Column - len("func ") + if d.Recv != nil { + p.parameters(d.Recv, funcParam) // method: print receiver + p.print(blank) + } + p.expr(d.Name) + p.signature(d.Type) + p.funcBody(p.distanceFrom(d.Pos(), startCol), vtab, d.Body) +} + +func (p *printer) decl(decl ast.Decl) { + switch d := decl.(type) { + case *ast.BadDecl: + p.setPos(d.Pos()) + p.print("BadDecl") + case *ast.GenDecl: + p.genDecl(d) + case *ast.FuncDecl: + p.funcDecl(d) + default: + panic("unreachable") + } +} + +// ---------------------------------------------------------------------------- +// Files + +func declToken(decl ast.Decl) (tok token.Token) { + tok = token.ILLEGAL + switch d := decl.(type) { + case *ast.GenDecl: + tok = d.Tok + case *ast.FuncDecl: + tok = token.FUNC + } + return +} + +func (p *printer) declList(list []ast.Decl) { + tok := token.ILLEGAL + for _, d := range list { + prev := tok + tok = declToken(d) + // If the declaration token changed (e.g., from CONST to TYPE) + // or the next declaration has documentation associated with it, + // print an empty line between top-level declarations. + // (because p.linebreak is called with the position of d, which + // is past any documentation, the minimum requirement is satisfied + // even w/o the extra getDoc(d) nil-check - leave it in case the + // linebreak logic improves - there's already a TODO). + if len(p.output) > 0 { + // only print line break if we are not at the beginning of the output + // (i.e., we are not printing only a partial program) + min := 1 + if prev != tok || getDoc(d) != nil { + min = 2 + } + // start a new section if the next declaration is a function + // that spans multiple lines (see also issue #19544) + p.linebreak(p.lineFor(d.Pos()), min, ignore, tok == token.FUNC && p.numLines(d) > 1) + } + p.decl(d) + } +} + +func (p *printer) file(src *ast.File) { + p.setComment(src.Doc) + p.setPos(src.Pos()) + p.print(token.PACKAGE, blank) + p.expr(src.Name) + p.declList(src.Decls) + p.print(newline) +} diff --git a/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/printer.go b/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/printer.go new file mode 100644 index 000000000..576f9690d --- /dev/null +++ b/vendor/mvdan.cc/gofumpt/internal/govendor/go/printer/printer.go @@ -0,0 +1,1427 @@ +// Copyright 2009 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 printer implements printing of AST nodes. +package printer + +import ( + "fmt" + "go/ast" + "go/build/constraint" + "go/token" + "io" + "os" + "strings" + "sync" + "text/tabwriter" + "unicode" +) + +const ( + maxNewlines = 2 // max. number of newlines between source text + debug = false // enable for debugging + infinity = 1 << 30 +) + +type whiteSpace byte + +const ( + ignore = whiteSpace(0) + blank = whiteSpace(' ') + vtab = whiteSpace('\v') + newline = whiteSpace('\n') + formfeed = whiteSpace('\f') + indent = whiteSpace('>') + unindent = whiteSpace('<') +) + +// A pmode value represents the current printer mode. +type pmode int + +const ( + noExtraBlank pmode = 1 << iota // disables extra blank after /*-style comment + noExtraLinebreak // disables extra line break after /*-style comment +) + +type commentInfo struct { + cindex int // current comment index + comment *ast.CommentGroup // = printer.comments[cindex]; or nil + commentOffset int // = printer.posFor(printer.comments[cindex].List[0].Pos()).Offset; or infinity + commentNewline bool // true if the comment group contains newlines +} + +type printer struct { + // Configuration (does not change after initialization) + Config + fset *token.FileSet + + // Current state + output []byte // raw printer result + indent int // current indentation + level int // level == 0: outside composite literal; level > 0: inside composite literal + mode pmode // current printer mode + endAlignment bool // if set, terminate alignment immediately + impliedSemi bool // if set, a linebreak implies a semicolon + lastTok token.Token // last token printed (token.ILLEGAL if it's whitespace) + prevOpen token.Token // previous non-brace "open" token (, [, or token.ILLEGAL + wsbuf []whiteSpace // delayed white space + goBuild []int // start index of all //go:build comments in output + plusBuild []int // start index of all // +build comments in output + + // Positions + // The out position differs from the pos position when the result + // formatting differs from the source formatting (in the amount of + // white space). If there's a difference and SourcePos is set in + // ConfigMode, //line directives are used in the output to restore + // original source positions for a reader. + pos token.Position // current position in AST (source) space + out token.Position // current position in output space + last token.Position // value of pos after calling writeString + linePtr *int // if set, record out.Line for the next token in *linePtr + + // The list of all source comments, in order of appearance. + comments []*ast.CommentGroup // may be nil + useNodeComments bool // if not set, ignore lead and line comments of nodes + + // Information about p.comments[p.cindex]; set up by nextComment. + commentInfo + + // Cache of already computed node sizes. + nodeSizes map[ast.Node]int + + // Cache of most recently computed line position. + cachedPos token.Pos + cachedLine int // line corresponding to cachedPos +} + +func (p *printer) internalError(msg ...any) { + if debug { + fmt.Print(p.pos.String() + ": ") + fmt.Println(msg...) + panic("mvdan.cc/gofumpt/internal/govendor/go/printer") + } +} + +// commentsHaveNewline reports whether a list of comments belonging to +// an *ast.CommentGroup contains newlines. Because the position information +// may only be partially correct, we also have to read the comment text. +func (p *printer) commentsHaveNewline(list []*ast.Comment) bool { + // len(list) > 0 + line := p.lineFor(list[0].Pos()) + for i, c := range list { + if i > 0 && p.lineFor(list[i].Pos()) != line { + // not all comments on the same line + return true + } + if t := c.Text; len(t) >= 2 && (t[1] == '/' || strings.Contains(t, "\n")) { + return true + } + } + _ = line + return false +} + +func (p *printer) nextComment() { + for p.cindex < len(p.comments) { + c := p.comments[p.cindex] + p.cindex++ + if list := c.List; len(list) > 0 { + p.comment = c + p.commentOffset = p.posFor(list[0].Pos()).Offset + p.commentNewline = p.commentsHaveNewline(list) + return + } + // we should not reach here (correct ASTs don't have empty + // ast.CommentGroup nodes), but be conservative and try again + } + // no more comments + p.commentOffset = infinity +} + +// commentBefore reports whether the current comment group occurs +// before the next position in the source code and printing it does +// not introduce implicit semicolons. +func (p *printer) commentBefore(next token.Position) bool { + return p.commentOffset < next.Offset && (!p.impliedSemi || !p.commentNewline) +} + +// commentSizeBefore returns the estimated size of the +// comments on the same line before the next position. +func (p *printer) commentSizeBefore(next token.Position) int { + // save/restore current p.commentInfo (p.nextComment() modifies it) + defer func(info commentInfo) { + p.commentInfo = info + }(p.commentInfo) + + size := 0 + for p.commentBefore(next) { + for _, c := range p.comment.List { + size += len(c.Text) + } + p.nextComment() + } + return size +} + +// recordLine records the output line number for the next non-whitespace +// token in *linePtr. It is used to compute an accurate line number for a +// formatted construct, independent of pending (not yet emitted) whitespace +// or comments. +func (p *printer) recordLine(linePtr *int) { + p.linePtr = linePtr +} + +// linesFrom returns the number of output lines between the current +// output line and the line argument, ignoring any pending (not yet +// emitted) whitespace or comments. It is used to compute an accurate +// size (in number of lines) for a formatted construct. +func (p *printer) linesFrom(line int) int { + return p.out.Line - line +} + +func (p *printer) posFor(pos token.Pos) token.Position { + // not used frequently enough to cache entire token.Position + return p.fset.PositionFor(pos, false /* absolute position */) +} + +func (p *printer) lineFor(pos token.Pos) int { + if pos != p.cachedPos { + p.cachedPos = pos + p.cachedLine = p.fset.PositionFor(pos, false /* absolute position */).Line + } + return p.cachedLine +} + +// writeLineDirective writes a //line directive if necessary. +func (p *printer) writeLineDirective(pos token.Position) { + if pos.IsValid() && (p.out.Line != pos.Line || p.out.Filename != pos.Filename) { + p.output = append(p.output, tabwriter.Escape) // protect '\n' in //line from tabwriter interpretation + p.output = append(p.output, fmt.Sprintf("//line %s:%d\n", pos.Filename, pos.Line)...) + p.output = append(p.output, tabwriter.Escape) + // p.out must match the //line directive + p.out.Filename = pos.Filename + p.out.Line = pos.Line + } +} + +// writeIndent writes indentation. +func (p *printer) writeIndent() { + // use "hard" htabs - indentation columns + // must not be discarded by the tabwriter + n := p.Config.Indent + p.indent // include base indentation + for i := 0; i < n; i++ { + p.output = append(p.output, '\t') + } + + // update positions + p.pos.Offset += n + p.pos.Column += n + p.out.Column += n +} + +// writeByte writes ch n times to p.output and updates p.pos. +// Only used to write formatting (white space) characters. +func (p *printer) writeByte(ch byte, n int) { + if p.endAlignment { + // Ignore any alignment control character; + // and at the end of the line, break with + // a formfeed to indicate termination of + // existing columns. + switch ch { + case '\t', '\v': + ch = ' ' + case '\n', '\f': + ch = '\f' + p.endAlignment = false + } + } + + if p.out.Column == 1 { + // no need to write line directives before white space + p.writeIndent() + } + + for i := 0; i < n; i++ { + p.output = append(p.output, ch) + } + + // update positions + p.pos.Offset += n + if ch == '\n' || ch == '\f' { + p.pos.Line += n + p.out.Line += n + p.pos.Column = 1 + p.out.Column = 1 + return + } + p.pos.Column += n + p.out.Column += n +} + +// writeString writes the string s to p.output and updates p.pos, p.out, +// and p.last. If isLit is set, s is escaped w/ tabwriter.Escape characters +// to protect s from being interpreted by the tabwriter. +// +// Note: writeString is only used to write Go tokens, literals, and +// comments, all of which must be written literally. Thus, it is correct +// to always set isLit = true. However, setting it explicitly only when +// needed (i.e., when we don't know that s contains no tabs or line breaks) +// avoids processing extra escape characters and reduces run time of the +// printer benchmark by up to 10%. +func (p *printer) writeString(pos token.Position, s string, isLit bool) { + if p.out.Column == 1 { + if p.Config.Mode&SourcePos != 0 { + p.writeLineDirective(pos) + } + p.writeIndent() + } + + if pos.IsValid() { + // update p.pos (if pos is invalid, continue with existing p.pos) + // Note: Must do this after handling line beginnings because + // writeIndent updates p.pos if there's indentation, but p.pos + // is the position of s. + p.pos = pos + } + + if isLit { + // Protect s such that is passes through the tabwriter + // unchanged. Note that valid Go programs cannot contain + // tabwriter.Escape bytes since they do not appear in legal + // UTF-8 sequences. + p.output = append(p.output, tabwriter.Escape) + } + + if debug { + p.output = append(p.output, fmt.Sprintf("/*%s*/", pos)...) // do not update p.pos! + } + p.output = append(p.output, s...) + + // update positions + nlines := 0 + var li int // index of last newline; valid if nlines > 0 + for i := 0; i < len(s); i++ { + // Raw string literals may contain any character except back quote (`). + if ch := s[i]; ch == '\n' || ch == '\f' { + // account for line break + nlines++ + li = i + // A line break inside a literal will break whatever column + // formatting is in place; ignore any further alignment through + // the end of the line. + p.endAlignment = true + } + } + p.pos.Offset += len(s) + if nlines > 0 { + p.pos.Line += nlines + p.out.Line += nlines + c := len(s) - li + p.pos.Column = c + p.out.Column = c + } else { + p.pos.Column += len(s) + p.out.Column += len(s) + } + + if isLit { + p.output = append(p.output, tabwriter.Escape) + } + + p.last = p.pos +} + +// writeCommentPrefix writes the whitespace before a comment. +// If there is any pending whitespace, it consumes as much of +// it as is likely to help position the comment nicely. +// pos is the comment position, next the position of the item +// after all pending comments, prev is the previous comment in +// a group of comments (or nil), and tok is the next token. +func (p *printer) writeCommentPrefix(pos, next token.Position, prev *ast.Comment, tok token.Token) { + if len(p.output) == 0 { + // the comment is the first item to be printed - don't write any whitespace + return + } + + if pos.IsValid() && pos.Filename != p.last.Filename { + // comment in a different file - separate with newlines + p.writeByte('\f', maxNewlines) + return + } + + if pos.Line == p.last.Line && (prev == nil || prev.Text[1] != '/') { + // comment on the same line as last item: + // separate with at least one separator + hasSep := false + if prev == nil { + // first comment of a comment group + j := 0 + for i, ch := range p.wsbuf { + switch ch { + case blank: + // ignore any blanks before a comment + p.wsbuf[i] = ignore + continue + case vtab: + // respect existing tabs - important + // for proper formatting of commented structs + hasSep = true + continue + case indent: + // apply pending indentation + continue + } + j = i + break + } + p.writeWhitespace(j) + } + // make sure there is at least one separator + if !hasSep { + sep := byte('\t') + if pos.Line == next.Line { + // next item is on the same line as the comment + // (which must be a /*-style comment): separate + // with a blank instead of a tab + sep = ' ' + } + p.writeByte(sep, 1) + } + + } else { + // comment on a different line: + // separate with at least one line break + droppedLinebreak := false + j := 0 + for i, ch := range p.wsbuf { + switch ch { + case blank, vtab: + // ignore any horizontal whitespace before line breaks + p.wsbuf[i] = ignore + continue + case indent: + // apply pending indentation + continue + case unindent: + // if this is not the last unindent, apply it + // as it is (likely) belonging to the last + // construct (e.g., a multi-line expression list) + // and is not part of closing a block + if i+1 < len(p.wsbuf) && p.wsbuf[i+1] == unindent { + continue + } + // if the next token is not a closing }, apply the unindent + // if it appears that the comment is aligned with the + // token; otherwise assume the unindent is part of a + // closing block and stop (this scenario appears with + // comments before a case label where the comments + // apply to the next case instead of the current one) + if tok != token.RBRACE && pos.Column == next.Column { + continue + } + case newline, formfeed: + p.wsbuf[i] = ignore + droppedLinebreak = prev == nil // record only if first comment of a group + } + j = i + break + } + p.writeWhitespace(j) + + // determine number of linebreaks before the comment + n := 0 + if pos.IsValid() && p.last.IsValid() { + n = pos.Line - p.last.Line + if n < 0 { // should never happen + n = 0 + } + } + + // at the package scope level only (p.indent == 0), + // add an extra newline if we dropped one before: + // this preserves a blank line before documentation + // comments at the package scope level (issue 2570) + if p.indent == 0 && droppedLinebreak { + n++ + } + + // make sure there is at least one line break + // if the previous comment was a line comment + if n == 0 && prev != nil && prev.Text[1] == '/' { + n = 1 + } + + if n > 0 { + // use formfeeds to break columns before a comment; + // this is analogous to using formfeeds to separate + // individual lines of /*-style comments + p.writeByte('\f', nlimit(n)) + } + } +} + +// Returns true if s contains only white space +// (only tabs and blanks can appear in the printer's context). +func isBlank(s string) bool { + for i := 0; i < len(s); i++ { + if s[i] > ' ' { + return false + } + } + return true +} + +// commonPrefix returns the common prefix of a and b. +func commonPrefix(a, b string) string { + i := 0 + for i < len(a) && i < len(b) && a[i] == b[i] && (a[i] <= ' ' || a[i] == '*') { + i++ + } + return a[0:i] +} + +// trimRight returns s with trailing whitespace removed. +func trimRight(s string) string { + return strings.TrimRightFunc(s, unicode.IsSpace) +} + +// stripCommonPrefix removes a common prefix from /*-style comment lines (unless no +// comment line is indented, all but the first line have some form of space prefix). +// The prefix is computed using heuristics such that is likely that the comment +// contents are nicely laid out after re-printing each line using the printer's +// current indentation. +func stripCommonPrefix(lines []string) { + if len(lines) <= 1 { + return // at most one line - nothing to do + } + // len(lines) > 1 + + // The heuristic in this function tries to handle a few + // common patterns of /*-style comments: Comments where + // the opening /* and closing */ are aligned and the + // rest of the comment text is aligned and indented with + // blanks or tabs, cases with a vertical "line of stars" + // on the left, and cases where the closing */ is on the + // same line as the last comment text. + + // Compute maximum common white prefix of all but the first, + // last, and blank lines, and replace blank lines with empty + // lines (the first line starts with /* and has no prefix). + // In cases where only the first and last lines are not blank, + // such as two-line comments, or comments where all inner lines + // are blank, consider the last line for the prefix computation + // since otherwise the prefix would be empty. + // + // Note that the first and last line are never empty (they + // contain the opening /* and closing */ respectively) and + // thus they can be ignored by the blank line check. + prefix := "" + prefixSet := false + if len(lines) > 2 { + for i, line := range lines[1 : len(lines)-1] { + if isBlank(line) { + lines[1+i] = "" // range starts with lines[1] + } else { + if !prefixSet { + prefix = line + prefixSet = true + } + prefix = commonPrefix(prefix, line) + } + } + } + // If we don't have a prefix yet, consider the last line. + if !prefixSet { + line := lines[len(lines)-1] + prefix = commonPrefix(line, line) + } + + /* + * Check for vertical "line of stars" and correct prefix accordingly. + */ + lineOfStars := false + if p, _, ok := strings.Cut(prefix, "*"); ok { + // remove trailing blank from prefix so stars remain aligned + prefix = strings.TrimSuffix(p, " ") + lineOfStars = true + } else { + // No line of stars present. + // Determine the white space on the first line after the /* + // and before the beginning of the comment text, assume two + // blanks instead of the /* unless the first character after + // the /* is a tab. If the first comment line is empty but + // for the opening /*, assume up to 3 blanks or a tab. This + // whitespace may be found as suffix in the common prefix. + first := lines[0] + if isBlank(first[2:]) { + // no comment text on the first line: + // reduce prefix by up to 3 blanks or a tab + // if present - this keeps comment text indented + // relative to the /* and */'s if it was indented + // in the first place + i := len(prefix) + for n := 0; n < 3 && i > 0 && prefix[i-1] == ' '; n++ { + i-- + } + if i == len(prefix) && i > 0 && prefix[i-1] == '\t' { + i-- + } + prefix = prefix[0:i] + } else { + // comment text on the first line + suffix := make([]byte, len(first)) + n := 2 // start after opening /* + for n < len(first) && first[n] <= ' ' { + suffix[n] = first[n] + n++ + } + if n > 2 && suffix[2] == '\t' { + // assume the '\t' compensates for the /* + suffix = suffix[2:n] + } else { + // otherwise assume two blanks + suffix[0], suffix[1] = ' ', ' ' + suffix = suffix[0:n] + } + // Shorten the computed common prefix by the length of + // suffix, if it is found as suffix of the prefix. + prefix = strings.TrimSuffix(prefix, string(suffix)) + } + } + + // Handle last line: If it only contains a closing */, align it + // with the opening /*, otherwise align the text with the other + // lines. + last := lines[len(lines)-1] + closing := "*/" + before, _, _ := strings.Cut(last, closing) // closing always present + if isBlank(before) { + // last line only contains closing */ + if lineOfStars { + closing = " */" // add blank to align final star + } + lines[len(lines)-1] = prefix + closing + } else { + // last line contains more comment text - assume + // it is aligned like the other lines and include + // in prefix computation + prefix = commonPrefix(prefix, last) + } + + // Remove the common prefix from all but the first and empty lines. + for i, line := range lines { + if i > 0 && line != "" { + lines[i] = line[len(prefix):] + } + } +} + +func (p *printer) writeComment(comment *ast.Comment) { + text := comment.Text + pos := p.posFor(comment.Pos()) + + const linePrefix = "//line " + if strings.HasPrefix(text, linePrefix) && (!pos.IsValid() || pos.Column == 1) { + // Possibly a //-style line directive. + // Suspend indentation temporarily to keep line directive valid. + defer func(indent int) { p.indent = indent }(p.indent) + p.indent = 0 + } + + // shortcut common case of //-style comments + if text[1] == '/' { + if constraint.IsGoBuild(text) { + p.goBuild = append(p.goBuild, len(p.output)) + } else if constraint.IsPlusBuild(text) { + p.plusBuild = append(p.plusBuild, len(p.output)) + } + p.writeString(pos, trimRight(text), true) + return + } + + // for /*-style comments, print line by line and let the + // write function take care of the proper indentation + lines := strings.Split(text, "\n") + + // The comment started in the first column but is going + // to be indented. For an idempotent result, add indentation + // to all lines such that they look like they were indented + // before - this will make sure the common prefix computation + // is the same independent of how many times formatting is + // applied (was issue 1835). + if pos.IsValid() && pos.Column == 1 && p.indent > 0 { + for i, line := range lines[1:] { + lines[1+i] = " " + line + } + } + + stripCommonPrefix(lines) + + // write comment lines, separated by formfeed, + // without a line break after the last line + for i, line := range lines { + if i > 0 { + p.writeByte('\f', 1) + pos = p.pos + } + if len(line) > 0 { + p.writeString(pos, trimRight(line), true) + } + } +} + +// writeCommentSuffix writes a line break after a comment if indicated +// and processes any leftover indentation information. If a line break +// is needed, the kind of break (newline vs formfeed) depends on the +// pending whitespace. The writeCommentSuffix result indicates if a +// newline was written or if a formfeed was dropped from the whitespace +// buffer. +func (p *printer) writeCommentSuffix(needsLinebreak bool) (wroteNewline, droppedFF bool) { + for i, ch := range p.wsbuf { + switch ch { + case blank, vtab: + // ignore trailing whitespace + p.wsbuf[i] = ignore + case indent, unindent: + // don't lose indentation information + case newline, formfeed: + // if we need a line break, keep exactly one + // but remember if we dropped any formfeeds + if needsLinebreak { + needsLinebreak = false + wroteNewline = true + } else { + if ch == formfeed { + droppedFF = true + } + p.wsbuf[i] = ignore + } + } + } + p.writeWhitespace(len(p.wsbuf)) + + // make sure we have a line break + if needsLinebreak { + p.writeByte('\n', 1) + wroteNewline = true + } + + return +} + +// containsLinebreak reports whether the whitespace buffer contains any line breaks. +func (p *printer) containsLinebreak() bool { + for _, ch := range p.wsbuf { + if ch == newline || ch == formfeed { + return true + } + } + return false +} + +// intersperseComments consumes all comments that appear before the next token +// tok and prints it together with the buffered whitespace (i.e., the whitespace +// that needs to be written before the next token). A heuristic is used to mix +// the comments and whitespace. The intersperseComments result indicates if a +// newline was written or if a formfeed was dropped from the whitespace buffer. +func (p *printer) intersperseComments(next token.Position, tok token.Token) (wroteNewline, droppedFF bool) { + var last *ast.Comment + for p.commentBefore(next) { + list := p.comment.List + changed := false + if p.lastTok != token.IMPORT && // do not rewrite cgo's import "C" comments + p.posFor(p.comment.Pos()).Column == 1 && + p.posFor(p.comment.End()+1) == next { + // Unindented comment abutting next token position: + // a top-level doc comment. + list = formatDocComment(list) + changed = true + + if len(p.comment.List) > 0 && len(list) == 0 { + // The doc comment was removed entirely. + // Keep preceding whitespace. + p.writeCommentPrefix(p.posFor(p.comment.Pos()), next, last, tok) + // Change print state to continue at next. + p.pos = next + p.last = next + // There can't be any more comments. + p.nextComment() + return p.writeCommentSuffix(false) + } + } + for _, c := range list { + p.writeCommentPrefix(p.posFor(c.Pos()), next, last, tok) + p.writeComment(c) + last = c + } + // In case list was rewritten, change print state to where + // the original list would have ended. + if len(p.comment.List) > 0 && changed { + last = p.comment.List[len(p.comment.List)-1] + p.pos = p.posFor(last.End()) + p.last = p.pos + } + p.nextComment() + } + + if last != nil { + // If the last comment is a /*-style comment and the next item + // follows on the same line but is not a comma, and not a "closing" + // token immediately following its corresponding "opening" token, + // add an extra separator unless explicitly disabled. Use a blank + // as separator unless we have pending linebreaks, they are not + // disabled, and we are outside a composite literal, in which case + // we want a linebreak (issue 15137). + // TODO(gri) This has become overly complicated. We should be able + // to track whether we're inside an expression or statement and + // use that information to decide more directly. + needsLinebreak := false + if p.mode&noExtraBlank == 0 && + last.Text[1] == '*' && p.lineFor(last.Pos()) == next.Line && + tok != token.COMMA && + (tok != token.RPAREN || p.prevOpen == token.LPAREN) && + (tok != token.RBRACK || p.prevOpen == token.LBRACK) { + if p.containsLinebreak() && p.mode&noExtraLinebreak == 0 && p.level == 0 { + needsLinebreak = true + } else { + p.writeByte(' ', 1) + } + } + // Ensure that there is a line break after a //-style comment, + // before EOF, and before a closing '}' unless explicitly disabled. + if last.Text[1] == '/' || + tok == token.EOF || + tok == token.RBRACE && p.mode&noExtraLinebreak == 0 { + needsLinebreak = true + } + return p.writeCommentSuffix(needsLinebreak) + } + + // no comment was written - we should never reach here since + // intersperseComments should not be called in that case + p.internalError("intersperseComments called without pending comments") + return +} + +// whiteWhitespace writes the first n whitespace entries. +func (p *printer) writeWhitespace(n int) { + // write entries + for i := 0; i < n; i++ { + switch ch := p.wsbuf[i]; ch { + case ignore: + // ignore! + case indent: + p.indent++ + case unindent: + p.indent-- + if p.indent < 0 { + p.internalError("negative indentation:", p.indent) + p.indent = 0 + } + case newline, formfeed: + // A line break immediately followed by a "correcting" + // unindent is swapped with the unindent - this permits + // proper label positioning. If a comment is between + // the line break and the label, the unindent is not + // part of the comment whitespace prefix and the comment + // will be positioned correctly indented. + if i+1 < n && p.wsbuf[i+1] == unindent { + // Use a formfeed to terminate the current section. + // Otherwise, a long label name on the next line leading + // to a wide column may increase the indentation column + // of lines before the label; effectively leading to wrong + // indentation. + p.wsbuf[i], p.wsbuf[i+1] = unindent, formfeed + i-- // do it again + continue + } + fallthrough + default: + p.writeByte(byte(ch), 1) + } + } + + // shift remaining entries down + l := copy(p.wsbuf, p.wsbuf[n:]) + p.wsbuf = p.wsbuf[:l] +} + +// ---------------------------------------------------------------------------- +// Printing interface + +// nlimit limits n to maxNewlines. +func nlimit(n int) int { + if n > maxNewlines { + n = maxNewlines + } + return n +} + +func mayCombine(prev token.Token, next byte) (b bool) { + switch prev { + case token.INT: + b = next == '.' // 1. + case token.ADD: + b = next == '+' // ++ + case token.SUB: + b = next == '-' // -- + case token.QUO: + b = next == '*' // /* + case token.LSS: + b = next == '-' || next == '<' // <- or << + case token.AND: + b = next == '&' || next == '^' // && or &^ + } + return +} + +func (p *printer) setPos(pos token.Pos) { + if pos.IsValid() { + p.pos = p.posFor(pos) // accurate position of next item + } +} + +// print prints a list of "items" (roughly corresponding to syntactic +// tokens, but also including whitespace and formatting information). +// It is the only print function that should be called directly from +// any of the AST printing functions in nodes.go. +// +// Whitespace is accumulated until a non-whitespace token appears. Any +// comments that need to appear before that token are printed first, +// taking into account the amount and structure of any pending white- +// space for best comment placement. Then, any leftover whitespace is +// printed, followed by the actual token. +func (p *printer) print(args ...any) { + for _, arg := range args { + // information about the current arg + var data string + var isLit bool + var impliedSemi bool // value for p.impliedSemi after this arg + + // record previous opening token, if any + switch p.lastTok { + case token.ILLEGAL: + // ignore (white space) + case token.LPAREN, token.LBRACK: + p.prevOpen = p.lastTok + default: + // other tokens followed any opening token + p.prevOpen = token.ILLEGAL + } + + switch x := arg.(type) { + case pmode: + // toggle printer mode + p.mode ^= x + continue + + case whiteSpace: + if x == ignore { + // don't add ignore's to the buffer; they + // may screw up "correcting" unindents (see + // LabeledStmt) + continue + } + i := len(p.wsbuf) + if i == cap(p.wsbuf) { + // Whitespace sequences are very short so this should + // never happen. Handle gracefully (but possibly with + // bad comment placement) if it does happen. + p.writeWhitespace(i) + i = 0 + } + p.wsbuf = p.wsbuf[0 : i+1] + p.wsbuf[i] = x + if x == newline || x == formfeed { + // newlines affect the current state (p.impliedSemi) + // and not the state after printing arg (impliedSemi) + // because comments can be interspersed before the arg + // in this case + p.impliedSemi = false + } + p.lastTok = token.ILLEGAL + continue + + case *ast.Ident: + data = x.Name + impliedSemi = true + p.lastTok = token.IDENT + + case *ast.BasicLit: + data = x.Value + isLit = true + impliedSemi = true + p.lastTok = x.Kind + + case token.Token: + s := x.String() + if mayCombine(p.lastTok, s[0]) { + // the previous and the current token must be + // separated by a blank otherwise they combine + // into a different incorrect token sequence + // (except for token.INT followed by a '.' this + // should never happen because it is taken care + // of via binary expression formatting) + if len(p.wsbuf) != 0 { + p.internalError("whitespace buffer not empty") + } + p.wsbuf = p.wsbuf[0:1] + p.wsbuf[0] = ' ' + } + data = s + // some keywords followed by a newline imply a semicolon + switch x { + case token.BREAK, token.CONTINUE, token.FALLTHROUGH, token.RETURN, + token.INC, token.DEC, token.RPAREN, token.RBRACK, token.RBRACE: + impliedSemi = true + } + p.lastTok = x + + case string: + // incorrect AST - print error message + data = x + isLit = true + impliedSemi = true + p.lastTok = token.STRING + + default: + fmt.Fprintf(os.Stderr, "print: unsupported argument %v (%T)\n", arg, arg) + panic("mvdan.cc/gofumpt/internal/govendor/go/printer type") + } + // data != "" + + next := p.pos // estimated/accurate position of next item + wroteNewline, droppedFF := p.flush(next, p.lastTok) + + // intersperse extra newlines if present in the source and + // if they don't cause extra semicolons (don't do this in + // flush as it will cause extra newlines at the end of a file) + if !p.impliedSemi { + n := nlimit(next.Line - p.pos.Line) + // don't exceed maxNewlines if we already wrote one + if wroteNewline && n == maxNewlines { + n = maxNewlines - 1 + } + if n > 0 { + ch := byte('\n') + if droppedFF { + ch = '\f' // use formfeed since we dropped one before + } + p.writeByte(ch, n) + impliedSemi = false + } + } + + // the next token starts now - record its line number if requested + if p.linePtr != nil { + *p.linePtr = p.out.Line + p.linePtr = nil + } + + p.writeString(next, data, isLit) + p.impliedSemi = impliedSemi + } +} + +// flush prints any pending comments and whitespace occurring textually +// before the position of the next token tok. The flush result indicates +// if a newline was written or if a formfeed was dropped from the whitespace +// buffer. +func (p *printer) flush(next token.Position, tok token.Token) (wroteNewline, droppedFF bool) { + if p.commentBefore(next) { + // if there are comments before the next item, intersperse them + wroteNewline, droppedFF = p.intersperseComments(next, tok) + } else { + // otherwise, write any leftover whitespace + p.writeWhitespace(len(p.wsbuf)) + } + return +} + +// getDoc returns the ast.CommentGroup associated with n, if any. +func getDoc(n ast.Node) *ast.CommentGroup { + switch n := n.(type) { + case *ast.Field: + return n.Doc + case *ast.ImportSpec: + return n.Doc + case *ast.ValueSpec: + return n.Doc + case *ast.TypeSpec: + return n.Doc + case *ast.GenDecl: + return n.Doc + case *ast.FuncDecl: + return n.Doc + case *ast.File: + return n.Doc + } + return nil +} + +func getLastComment(n ast.Node) *ast.CommentGroup { + switch n := n.(type) { + case *ast.Field: + return n.Comment + case *ast.ImportSpec: + return n.Comment + case *ast.ValueSpec: + return n.Comment + case *ast.TypeSpec: + return n.Comment + case *ast.GenDecl: + if len(n.Specs) > 0 { + return getLastComment(n.Specs[len(n.Specs)-1]) + } + case *ast.File: + if len(n.Comments) > 0 { + return n.Comments[len(n.Comments)-1] + } + } + return nil +} + +func (p *printer) printNode(node any) error { + // unpack *CommentedNode, if any + var comments []*ast.CommentGroup + if cnode, ok := node.(*CommentedNode); ok { + node = cnode.Node + comments = cnode.Comments + } + + if comments != nil { + // commented node - restrict comment list to relevant range + n, ok := node.(ast.Node) + if !ok { + goto unsupported + } + beg := n.Pos() + end := n.End() + // if the node has associated documentation, + // include that commentgroup in the range + // (the comment list is sorted in the order + // of the comment appearance in the source code) + if doc := getDoc(n); doc != nil { + beg = doc.Pos() + } + if com := getLastComment(n); com != nil { + if e := com.End(); e > end { + end = e + } + } + // token.Pos values are global offsets, we can + // compare them directly + i := 0 + for i < len(comments) && comments[i].End() < beg { + i++ + } + j := i + for j < len(comments) && comments[j].Pos() < end { + j++ + } + if i < j { + p.comments = comments[i:j] + } + } else if n, ok := node.(*ast.File); ok { + // use ast.File comments, if any + p.comments = n.Comments + } + + // if there are no comments, use node comments + p.useNodeComments = p.comments == nil + + // get comments ready for use + p.nextComment() + + p.print(pmode(0)) + + // format node + switch n := node.(type) { + case ast.Expr: + p.expr(n) + case ast.Stmt: + // A labeled statement will un-indent to position the label. + // Set p.indent to 1 so we don't get indent "underflow". + if _, ok := n.(*ast.LabeledStmt); ok { + p.indent = 1 + } + p.stmt(n, false) + case ast.Decl: + p.decl(n) + case ast.Spec: + p.spec(n, 1, false) + case []ast.Stmt: + // A labeled statement will un-indent to position the label. + // Set p.indent to 1 so we don't get indent "underflow". + for _, s := range n { + if _, ok := s.(*ast.LabeledStmt); ok { + p.indent = 1 + } + } + p.stmtList(n, 0, false) + case []ast.Decl: + p.declList(n) + case *ast.File: + p.file(n) + default: + goto unsupported + } + + return nil + +unsupported: + return fmt.Errorf("mvdan.cc/gofumpt/internal/govendor/go/printer: unsupported node type %T", node) +} + +// ---------------------------------------------------------------------------- +// Trimmer + +// A trimmer is an io.Writer filter for stripping tabwriter.Escape +// characters, trailing blanks and tabs, and for converting formfeed +// and vtab characters into newlines and htabs (in case no tabwriter +// is used). Text bracketed by tabwriter.Escape characters is passed +// through unchanged. +type trimmer struct { + output io.Writer + state int + space []byte +} + +// trimmer is implemented as a state machine. +// It can be in one of the following states: +const ( + inSpace = iota // inside space + inEscape // inside text bracketed by tabwriter.Escapes + inText // inside text +) + +func (p *trimmer) resetSpace() { + p.state = inSpace + p.space = p.space[0:0] +} + +// Design note: It is tempting to eliminate extra blanks occurring in +// whitespace in this function as it could simplify some +// of the blanks logic in the node printing functions. +// However, this would mess up any formatting done by +// the tabwriter. + +var aNewline = []byte("\n") + +func (p *trimmer) Write(data []byte) (n int, err error) { + // invariants: + // p.state == inSpace: + // p.space is unwritten + // p.state == inEscape, inText: + // data[m:n] is unwritten + m := 0 + var b byte + for n, b = range data { + if b == '\v' { + b = '\t' // convert to htab + } + switch p.state { + case inSpace: + switch b { + case '\t', ' ': + p.space = append(p.space, b) + case '\n', '\f': + p.resetSpace() // discard trailing space + _, err = p.output.Write(aNewline) + case tabwriter.Escape: + _, err = p.output.Write(p.space) + p.state = inEscape + m = n + 1 // +1: skip tabwriter.Escape + default: + _, err = p.output.Write(p.space) + p.state = inText + m = n + } + case inEscape: + if b == tabwriter.Escape { + _, err = p.output.Write(data[m:n]) + p.resetSpace() + } + case inText: + switch b { + case '\t', ' ': + _, err = p.output.Write(data[m:n]) + p.resetSpace() + p.space = append(p.space, b) + case '\n', '\f': + _, err = p.output.Write(data[m:n]) + p.resetSpace() + if err == nil { + _, err = p.output.Write(aNewline) + } + case tabwriter.Escape: + _, err = p.output.Write(data[m:n]) + p.state = inEscape + m = n + 1 // +1: skip tabwriter.Escape + } + default: + panic("unreachable") + } + if err != nil { + return + } + } + n = len(data) + + switch p.state { + case inEscape, inText: + _, err = p.output.Write(data[m:n]) + p.resetSpace() + } + + return +} + +// ---------------------------------------------------------------------------- +// Public interface + +// A Mode value is a set of flags (or 0). They control printing. +type Mode uint + +const ( + RawFormat Mode = 1 << iota // do not use a tabwriter; if set, UseSpaces is ignored + TabIndent // use tabs for indentation independent of UseSpaces + UseSpaces // use spaces instead of tabs for alignment + SourcePos // emit //line directives to preserve original source positions +) + +// The mode below is not included in printer's public API because +// editing code text is deemed out of scope. Because this mode is +// unexported, it's also possible to modify or remove it based on +// the evolving needs of mvdan.cc/gofumpt/internal/govendor/go/format and cmd/gofmt without breaking +// users. See discussion in CL 240683. +const ( + // normalizeNumbers means to canonicalize number + // literal prefixes and exponents while printing. + // + // This value is known in and used by mvdan.cc/gofumpt/internal/govendor/go/format and cmd/gofmt. + // It is currently more convenient and performant for those + // packages to apply number normalization during printing, + // rather than by modifying the AST in advance. + normalizeNumbers Mode = 1 << 30 +) + +// A Config node controls the output of Fprint. +type Config struct { + Mode Mode // default: 0 + Tabwidth int // default: 8 + Indent int // default: 0 (all code is indented at least by this much) +} + +var printerPool = sync.Pool{ + New: func() any { + return &printer{ + // Whitespace sequences are short. + wsbuf: make([]whiteSpace, 0, 16), + // We start the printer with a 16K output buffer, which is currently + // larger than about 80% of Go files in the standard library. + output: make([]byte, 0, 16<<10), + } + }, +} + +func newPrinter(cfg *Config, fset *token.FileSet, nodeSizes map[ast.Node]int) *printer { + p := printerPool.Get().(*printer) + *p = printer{ + Config: *cfg, + fset: fset, + pos: token.Position{Line: 1, Column: 1}, + out: token.Position{Line: 1, Column: 1}, + wsbuf: p.wsbuf[:0], + nodeSizes: nodeSizes, + cachedPos: -1, + output: p.output[:0], + } + return p +} + +func (p *printer) free() { + // Hard limit on buffer size; see https://golang.org/issue/23199. + if cap(p.output) > 64<<10 { + return + } + + printerPool.Put(p) +} + +// fprint implements Fprint and takes a nodesSizes map for setting up the printer state. +func (cfg *Config) fprint(output io.Writer, fset *token.FileSet, node any, nodeSizes map[ast.Node]int) (err error) { + // print node + p := newPrinter(cfg, fset, nodeSizes) + defer p.free() + if err = p.printNode(node); err != nil { + return + } + // print outstanding comments + p.impliedSemi = false // EOF acts like a newline + p.flush(token.Position{Offset: infinity, Line: infinity}, token.EOF) + + // output is buffered in p.output now. + // fix //go:build and // +build comments if needed. + p.fixGoBuildLines() + + // redirect output through a trimmer to eliminate trailing whitespace + // (Input to a tabwriter must be untrimmed since trailing tabs provide + // formatting information. The tabwriter could provide trimming + // functionality but no tabwriter is used when RawFormat is set.) + output = &trimmer{output: output} + + // redirect output through a tabwriter if necessary + if cfg.Mode&RawFormat == 0 { + minwidth := cfg.Tabwidth + + padchar := byte('\t') + if cfg.Mode&UseSpaces != 0 { + padchar = ' ' + } + + twmode := tabwriter.DiscardEmptyColumns + if cfg.Mode&TabIndent != 0 { + minwidth = 0 + twmode |= tabwriter.TabIndent + } + + output = tabwriter.NewWriter(output, minwidth, cfg.Tabwidth, 1, padchar, twmode) + } + + // write printer result via tabwriter/trimmer to output + if _, err = output.Write(p.output); err != nil { + return + } + + // flush tabwriter, if any + if tw, _ := output.(*tabwriter.Writer); tw != nil { + err = tw.Flush() + } + + return +} + +// A CommentedNode bundles an AST node and corresponding comments. +// It may be provided as argument to any of the Fprint functions. +type CommentedNode struct { + Node any // *ast.File, or ast.Expr, ast.Decl, ast.Spec, or ast.Stmt + Comments []*ast.CommentGroup +} + +// Fprint "pretty-prints" an AST node to output for a given configuration cfg. +// Position information is interpreted relative to the file set fset. +// The node type must be *ast.File, *CommentedNode, []ast.Decl, []ast.Stmt, +// or assignment-compatible to ast.Expr, ast.Decl, ast.Spec, or ast.Stmt. +func (cfg *Config) Fprint(output io.Writer, fset *token.FileSet, node any) error { + return cfg.fprint(output, fset, node, make(map[ast.Node]int)) +} + +// Fprint "pretty-prints" an AST node to output. +// It calls Config.Fprint with default settings. +// Note that gofmt uses tabs for indentation but spaces for alignment; +// use format.Node (package mvdan.cc/gofumpt/internal/govendor/go/format) for output that matches gofmt. +func Fprint(output io.Writer, fset *token.FileSet, node any) error { + return (&Config{Tabwidth: 8}).Fprint(output, fset, node) +} diff --git a/vendor/mvdan.cc/gofumpt/internal/version/version.go b/vendor/mvdan.cc/gofumpt/internal/version/version.go index 992930480..785b6b317 100644 --- a/vendor/mvdan.cc/gofumpt/internal/version/version.go +++ b/vendor/mvdan.cc/gofumpt/internal/version/version.go @@ -97,6 +97,9 @@ func goVersion() string { return runtime.Version() } -func String() string { +func String(injected string) string { + if injected != "" { + return fmt.Sprintf("%s (%s)", injected, goVersion()) + } return fmt.Sprintf("%s (%s)", gofumptVersion(), goVersion()) }