From 8b54a9bd7d7ac08c3a069ba4c95e217643321432 Mon Sep 17 00:00:00 2001 From: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:02:57 +0100 Subject: [PATCH 1/3] vendor: github.com/docker/secrets-engine/client v1.0.0 Add the Docker secrets engine client, used to read the Docker Desktop session for Docker Hub. It brings in github.com/docker/secrets-engine/secrets v1.0.0. The client module requires go1.26.11, which raises the go directive in vendor.mod from 1.26.10. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> --- vendor.mod | 4 +- vendor.sum | 4 + .../secrets-engine/client/.gomodguard.yaml | 17 + .../docker/secrets-engine/client/LICENSE | 202 ++++ .../client/api/health/v1/api.pb.go | 264 +++++ .../api/health/v1/healthv1rpc/api.rpc.go | 39 + .../client/api/plugins/v1/management.pb.go | 924 ++++++++++++++++++ .../client/api/plugins/v1/metadata.pb.go | 193 ++++ .../plugins/v1/pluginsv1rpc/management.rpc.go | 63 ++ .../client/api/resolver/resolver.go | 44 + .../client/api/resolver/v1/api.pb.go | 728 ++++++++++++++ .../api/resolver/v1/resolverv1rpc/api.rpc.go | 65 ++ .../docker/secrets-engine/client/client.go | 387 ++++++++ .../secrets-engine/client/config/defaults.go | 42 + .../secrets-engine/client/config/socket.go | 37 + .../client/config/socket_darwin.go | 33 + .../client/config/socket_linux.go | 37 + .../client/config/socket_windows.go | 34 + .../client/dockerhub/dockerhub.go | 416 ++++++++ .../secrets-engine/client/errno_unix.go | 22 + .../secrets-engine/client/errno_windows.go | 20 + .../docker/secrets-engine/client/errors.go | 173 ++++ .../secrets-engine/client/realms/docker.go | 93 ++ .../secrets-engine/client/rpc/client.go | 149 +++ .../docker/secrets-engine/client/rpc/error.go | 117 +++ .../secrets-engine/client/version/name.go | 62 ++ .../secrets-engine/client/version/semver.go | 158 +++ .../secrets-engine/client/version/version.go | 86 ++ .../docker/secrets-engine/secrets/LICENSE | 202 ++++ .../docker/secrets-engine/secrets/README.md | 96 ++ .../docker/secrets-engine/secrets/doc.go | 52 + .../secrets-engine/secrets/identifiers.go | 179 ++++ .../docker/secrets-engine/secrets/minimize.go | 128 +++ .../docker/secrets-engine/secrets/pattern.go | 297 ++++++ .../docker/secrets-engine/secrets/secrets.go | 65 ++ .../docker/secrets-engine/secrets/store.go | 98 ++ vendor/modules.txt | 18 + 37 files changed, 5547 insertions(+), 1 deletion(-) create mode 100644 vendor/github.com/docker/secrets-engine/client/.gomodguard.yaml create mode 100644 vendor/github.com/docker/secrets-engine/client/LICENSE create mode 100644 vendor/github.com/docker/secrets-engine/client/api/health/v1/api.pb.go create mode 100644 vendor/github.com/docker/secrets-engine/client/api/health/v1/healthv1rpc/api.rpc.go create mode 100644 vendor/github.com/docker/secrets-engine/client/api/plugins/v1/management.pb.go create mode 100644 vendor/github.com/docker/secrets-engine/client/api/plugins/v1/metadata.pb.go create mode 100644 vendor/github.com/docker/secrets-engine/client/api/plugins/v1/pluginsv1rpc/management.rpc.go create mode 100644 vendor/github.com/docker/secrets-engine/client/api/resolver/resolver.go create mode 100644 vendor/github.com/docker/secrets-engine/client/api/resolver/v1/api.pb.go create mode 100644 vendor/github.com/docker/secrets-engine/client/api/resolver/v1/resolverv1rpc/api.rpc.go create mode 100644 vendor/github.com/docker/secrets-engine/client/client.go create mode 100644 vendor/github.com/docker/secrets-engine/client/config/defaults.go create mode 100644 vendor/github.com/docker/secrets-engine/client/config/socket.go create mode 100644 vendor/github.com/docker/secrets-engine/client/config/socket_darwin.go create mode 100644 vendor/github.com/docker/secrets-engine/client/config/socket_linux.go create mode 100644 vendor/github.com/docker/secrets-engine/client/config/socket_windows.go create mode 100644 vendor/github.com/docker/secrets-engine/client/dockerhub/dockerhub.go create mode 100644 vendor/github.com/docker/secrets-engine/client/errno_unix.go create mode 100644 vendor/github.com/docker/secrets-engine/client/errno_windows.go create mode 100644 vendor/github.com/docker/secrets-engine/client/errors.go create mode 100644 vendor/github.com/docker/secrets-engine/client/realms/docker.go create mode 100644 vendor/github.com/docker/secrets-engine/client/rpc/client.go create mode 100644 vendor/github.com/docker/secrets-engine/client/rpc/error.go create mode 100644 vendor/github.com/docker/secrets-engine/client/version/name.go create mode 100644 vendor/github.com/docker/secrets-engine/client/version/semver.go create mode 100644 vendor/github.com/docker/secrets-engine/client/version/version.go create mode 100644 vendor/github.com/docker/secrets-engine/secrets/LICENSE create mode 100644 vendor/github.com/docker/secrets-engine/secrets/README.md create mode 100644 vendor/github.com/docker/secrets-engine/secrets/doc.go create mode 100644 vendor/github.com/docker/secrets-engine/secrets/identifiers.go create mode 100644 vendor/github.com/docker/secrets-engine/secrets/minimize.go create mode 100644 vendor/github.com/docker/secrets-engine/secrets/pattern.go create mode 100644 vendor/github.com/docker/secrets-engine/secrets/secrets.go create mode 100644 vendor/github.com/docker/secrets-engine/secrets/store.go diff --git a/vendor.mod b/vendor.mod index f4263f736120..531b88b06fbf 100644 --- a/vendor.mod +++ b/vendor.mod @@ -4,7 +4,7 @@ module github.com/docker/cli // There is no 'go.mod' file, as that would imply opting in for all the rules // around SemVer, which this repo cannot abide by as it uses CalVer. -go 1.26.0 +go 1.26.11 tool ( github.com/cpuguy83/go-md2man/v2 // for scripts/docs/generate-man.sh @@ -24,6 +24,7 @@ require ( github.com/docker/docker-credential-helpers v0.9.9 github.com/docker/go-connections v0.8.2 github.com/docker/go-units v0.5.0 + github.com/docker/secrets-engine/client v1.0.0 github.com/fvbommel/sortorder v1.2.1 github.com/go-jose/go-jose/v4 v4.1.5 github.com/go-viper/mapstructure/v2 v2.5.0 @@ -80,6 +81,7 @@ require ( github.com/docker/go-events v0.1.0 // indirect github.com/docker/go-metrics v0.1.0 // indirect github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect + github.com/docker/secrets-engine/secrets v1.0.0 // indirect github.com/felixge/httpsnoop v1.1.0 // indirect github.com/go-logr/logr v1.4.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect diff --git a/vendor.sum b/vendor.sum index f0f2426bf585..c8a30396d909 100644 --- a/vendor.sum +++ b/vendor.sum @@ -47,6 +47,10 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= +github.com/docker/secrets-engine/client v1.0.0 h1:/zMCWoch4OOoMQoCo257H6siYUuUcQiTZBcX081uQm0= +github.com/docker/secrets-engine/client v1.0.0/go.mod h1:EGa8hWWhSWBQ4+Yn2BHO4xeXZ4wYCI9eAQ3U1Fy1sIA= +github.com/docker/secrets-engine/secrets v1.0.0 h1:29fYA7dLYYN6dbyCoDUX7VVu0usZ8bKvpJolCbs8TAw= +github.com/docker/secrets-engine/secrets v1.0.0/go.mod h1:xGWoZkaQpSd/PP5s8etspPkrs8Qa07jVblo2UEQZi5w= github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc= github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE= github.com/fvbommel/sortorder v1.2.1 h1:ASc85RbthwLEqzuiCk7WQQiopfyGWQiEYZVJ3Qa4A+U= diff --git a/vendor/github.com/docker/secrets-engine/client/.gomodguard.yaml b/vendor/github.com/docker/secrets-engine/client/.gomodguard.yaml new file mode 100644 index 000000000000..f8e5e4b7a155 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/.gomodguard.yaml @@ -0,0 +1,17 @@ +--- +blocked: + modules: + - github.com/docker/secrets-engine/runtime: + reason: "Forbidden dependency" + - github.com/docker/secrets-engine/injector: + reason: "Forbidden dependency" + - github.com/docker/secrets-engine/plugin: + reason: "Forbidden dependency" + - github.com/docker/secrets-engine/plugins/pass: + reason: "Forbidden dependency" + - github.com/docker/secrets-engine/store: + reason: "Forbidden dependency" + - github.com/docker/secrets-engine/x: + reason: "Forbidden dependency" + - connectrpc.com/connect: + reason: "Forbidden dependency" \ No newline at end of file diff --git a/vendor/github.com/docker/secrets-engine/client/LICENSE b/vendor/github.com/docker/secrets-engine/client/LICENSE new file mode 100644 index 000000000000..3c6f5a21a864 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/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 2025 Docker, 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/docker/secrets-engine/client/api/health/v1/api.pb.go b/vendor/github.com/docker/secrets-engine/client/api/health/v1/api.pb.go new file mode 100644 index 000000000000..84071a8de792 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/api/health/v1/api.pb.go @@ -0,0 +1,264 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.7 +// protoc (unknown) +// source: health/v1/api.proto + +package healthv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + unsafe "unsafe" +) + +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 GetVersionRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetVersionRequest) Reset() { + *x = GetVersionRequest{} + mi := &file_health_v1_api_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetVersionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetVersionRequest) ProtoMessage() {} + +func (x *GetVersionRequest) ProtoReflect() protoreflect.Message { + mi := &file_health_v1_api_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type GetVersionRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 GetVersionRequest_builder) Build() *GetVersionRequest { + m0 := &GetVersionRequest{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +type GetVersionResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Version *string `protobuf:"bytes,1,opt,name=version"` + xxx_hidden_Date *string `protobuf:"bytes,2,opt,name=date"` + xxx_hidden_CommitHash *string `protobuf:"bytes,3,opt,name=commit_hash,json=commitHash"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetVersionResponse) Reset() { + *x = GetVersionResponse{} + mi := &file_health_v1_api_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetVersionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetVersionResponse) ProtoMessage() {} + +func (x *GetVersionResponse) ProtoReflect() protoreflect.Message { + mi := &file_health_v1_api_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *GetVersionResponse) GetVersion() string { + if x != nil { + if x.xxx_hidden_Version != nil { + return *x.xxx_hidden_Version + } + return "" + } + return "" +} + +func (x *GetVersionResponse) GetDate() string { + if x != nil { + if x.xxx_hidden_Date != nil { + return *x.xxx_hidden_Date + } + return "" + } + return "" +} + +func (x *GetVersionResponse) GetCommitHash() string { + if x != nil { + if x.xxx_hidden_CommitHash != nil { + return *x.xxx_hidden_CommitHash + } + return "" + } + return "" +} + +func (x *GetVersionResponse) SetVersion(v string) { + x.xxx_hidden_Version = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 3) +} + +func (x *GetVersionResponse) SetDate(v string) { + x.xxx_hidden_Date = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 3) +} + +func (x *GetVersionResponse) SetCommitHash(v string) { + x.xxx_hidden_CommitHash = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 3) +} + +func (x *GetVersionResponse) HasVersion() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *GetVersionResponse) HasDate() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 1) +} + +func (x *GetVersionResponse) HasCommitHash() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 2) +} + +func (x *GetVersionResponse) ClearVersion() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Version = nil +} + +func (x *GetVersionResponse) ClearDate() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) + x.xxx_hidden_Date = nil +} + +func (x *GetVersionResponse) ClearCommitHash() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) + x.xxx_hidden_CommitHash = nil +} + +type GetVersionResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Version *string + Date *string + CommitHash *string +} + +func (b0 GetVersionResponse_builder) Build() *GetVersionResponse { + m0 := &GetVersionResponse{} + b, x := &b0, m0 + _, _ = b, x + if b.Version != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 3) + x.xxx_hidden_Version = b.Version + } + if b.Date != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 3) + x.xxx_hidden_Date = b.Date + } + if b.CommitHash != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 3) + x.xxx_hidden_CommitHash = b.CommitHash + } + return m0 +} + +var File_health_v1_api_proto protoreflect.FileDescriptor + +const file_health_v1_api_proto_rawDesc = "" + + "\n" + + "\x13health/v1/api.proto\x12\thealth.v1\"\x13\n" + + "\x11GetVersionRequest\"c\n" + + "\x12GetVersionResponse\x12\x18\n" + + "\aversion\x18\x01 \x01(\tR\aversion\x12\x12\n" + + "\x04date\x18\x02 \x01(\tR\x04date\x12\x1f\n" + + "\vcommit_hash\x18\x03 \x01(\tR\n" + + "commitHash2[\n" + + "\x0eVersionService\x12I\n" + + "\n" + + "GetVersion\x12\x1c.health.v1.GetVersionRequest\x1a\x1d.health.v1.GetVersionResponseB\x9e\x01\n" + + "\rcom.health.v1B\bApiProtoP\x01Z>github.com/docker/secrets-engine/client/api/health/v1;healthv1\xa2\x02\x03HXX\xaa\x02\tHealth.V1\xca\x02\tHealth\\V1\xe2\x02\x15Health\\V1\\GPBMetadata\xea\x02\n" + + "Health::V1b\beditionsp\xe8\a" + +var file_health_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_health_v1_api_proto_goTypes = []any{ + (*GetVersionRequest)(nil), // 0: health.v1.GetVersionRequest + (*GetVersionResponse)(nil), // 1: health.v1.GetVersionResponse +} +var file_health_v1_api_proto_depIdxs = []int32{ + 0, // 0: health.v1.VersionService.GetVersion:input_type -> health.v1.GetVersionRequest + 1, // 1: health.v1.VersionService.GetVersion:output_type -> health.v1.GetVersionResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_health_v1_api_proto_init() } +func file_health_v1_api_proto_init() { + if File_health_v1_api_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_health_v1_api_proto_rawDesc), len(file_health_v1_api_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_health_v1_api_proto_goTypes, + DependencyIndexes: file_health_v1_api_proto_depIdxs, + MessageInfos: file_health_v1_api_proto_msgTypes, + }.Build() + File_health_v1_api_proto = out.File + file_health_v1_api_proto_goTypes = nil + file_health_v1_api_proto_depIdxs = nil +} diff --git a/vendor/github.com/docker/secrets-engine/client/api/health/v1/healthv1rpc/api.rpc.go b/vendor/github.com/docker/secrets-engine/client/api/health/v1/healthv1rpc/api.rpc.go new file mode 100644 index 000000000000..1ded4b142190 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/api/health/v1/healthv1rpc/api.rpc.go @@ -0,0 +1,39 @@ +// Code generated by protoc-gen-go-rpc. DO NOT EDIT. +// +// Source: health/v1/api.proto + +package healthv1rpc + +import ( + context "context" + v1 "github.com/docker/secrets-engine/client/api/health/v1" + proto "google.golang.org/protobuf/proto" +) + +const ( + // VersionServiceGetVersionProcedure is the fully-qualified name of the VersionService's GetVersion RPC. + VersionServiceGetVersionProcedure = "/health.v1.VersionService/GetVersion" +) + +// VersionServiceClient is a client for the health.v1.VersionService service. +type VersionServiceClient interface { + // GetVersion returns the version of the daemon. + GetVersion(context.Context, *v1.GetVersionRequest) (*v1.GetVersionResponse, error) +} + +// NewVersionServiceClient constructs a client for the health.v1.VersionService service that sends each request through call. +func NewVersionServiceClient(call func(ctx context.Context, procedure string, req, res proto.Message) error) VersionServiceClient { + return &versionServiceClient{call} +} + +type versionServiceClient struct { + call func(ctx context.Context, procedure string, req, res proto.Message) error +} + +func (c *versionServiceClient) GetVersion(ctx context.Context, req *v1.GetVersionRequest) (*v1.GetVersionResponse, error) { + res := &v1.GetVersionResponse{} + if err := c.call(ctx, VersionServiceGetVersionProcedure, req, res); err != nil { + return nil, err + } + return res, nil +} diff --git a/vendor/github.com/docker/secrets-engine/client/api/plugins/v1/management.pb.go b/vendor/github.com/docker/secrets-engine/client/api/plugins/v1/management.pb.go new file mode 100644 index 000000000000..09f765a855d1 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/api/plugins/v1/management.pb.go @@ -0,0 +1,924 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.7 +// protoc (unknown) +// source: plugins/v1/management.proto + +package pluginsv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + unsafe "unsafe" +) + +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 RunStatus int32 + +const ( + RunStatus_RUN_STATUS_UNSPECIFIED RunStatus = 0 + RunStatus_RUN_STATUS_RUNNING RunStatus = 1 + RunStatus_RUN_STATUS_STOPPED RunStatus = 2 + RunStatus_RUN_STATUS_CRASHED RunStatus = 3 + RunStatus_RUN_STATUS_RETRIES_EXCEEDED RunStatus = 4 +) + +// Enum value maps for RunStatus. +var ( + RunStatus_name = map[int32]string{ + 0: "RUN_STATUS_UNSPECIFIED", + 1: "RUN_STATUS_RUNNING", + 2: "RUN_STATUS_STOPPED", + 3: "RUN_STATUS_CRASHED", + 4: "RUN_STATUS_RETRIES_EXCEEDED", + } + RunStatus_value = map[string]int32{ + "RUN_STATUS_UNSPECIFIED": 0, + "RUN_STATUS_RUNNING": 1, + "RUN_STATUS_STOPPED": 2, + "RUN_STATUS_CRASHED": 3, + "RUN_STATUS_RETRIES_EXCEEDED": 4, + } +) + +func (x RunStatus) Enum() *RunStatus { + p := new(RunStatus) + *p = x + return p +} + +func (x RunStatus) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (RunStatus) Descriptor() protoreflect.EnumDescriptor { + return file_plugins_v1_management_proto_enumTypes[0].Descriptor() +} + +func (RunStatus) Type() protoreflect.EnumType { + return &file_plugins_v1_management_proto_enumTypes[0] +} + +func (x RunStatus) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +type Plugin struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name *string `protobuf:"bytes,1,opt,name=name"` + xxx_hidden_Version *string `protobuf:"bytes,2,opt,name=version"` + xxx_hidden_Disabled bool `protobuf:"varint,3,opt,name=disabled"` + xxx_hidden_External bool `protobuf:"varint,4,opt,name=external"` + xxx_hidden_Configurable bool `protobuf:"varint,5,opt,name=configurable"` + xxx_hidden_RunStatus RunStatus `protobuf:"varint,6,opt,name=run_status,json=runStatus,enum=plugins.v1.RunStatus"` + xxx_hidden_StatusMessage *string `protobuf:"bytes,7,opt,name=status_message,json=statusMessage"` + xxx_hidden_Metadata isPlugin_Metadata `protobuf_oneof:"metadata"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Plugin) Reset() { + *x = Plugin{} + mi := &file_plugins_v1_management_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Plugin) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Plugin) ProtoMessage() {} + +func (x *Plugin) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_management_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *Plugin) GetName() string { + if x != nil { + if x.xxx_hidden_Name != nil { + return *x.xxx_hidden_Name + } + return "" + } + return "" +} + +func (x *Plugin) GetVersion() string { + if x != nil { + if x.xxx_hidden_Version != nil { + return *x.xxx_hidden_Version + } + return "" + } + return "" +} + +func (x *Plugin) GetDisabled() bool { + if x != nil { + return x.xxx_hidden_Disabled + } + return false +} + +func (x *Plugin) GetExternal() bool { + if x != nil { + return x.xxx_hidden_External + } + return false +} + +func (x *Plugin) GetConfigurable() bool { + if x != nil { + return x.xxx_hidden_Configurable + } + return false +} + +func (x *Plugin) GetRunStatus() RunStatus { + if x != nil { + if protoimpl.X.Present(&(x.XXX_presence[0]), 5) { + return x.xxx_hidden_RunStatus + } + } + return RunStatus_RUN_STATUS_UNSPECIFIED +} + +func (x *Plugin) GetStatusMessage() string { + if x != nil { + if x.xxx_hidden_StatusMessage != nil { + return *x.xxx_hidden_StatusMessage + } + return "" + } + return "" +} + +func (x *Plugin) GetSecretsProvider() *SecretsProvider { + if x != nil { + if x, ok := x.xxx_hidden_Metadata.(*plugin_SecretsProvider); ok { + return x.SecretsProvider + } + } + return nil +} + +func (x *Plugin) GetAccessControlModule() *AccessControlModule { + if x != nil { + if x, ok := x.xxx_hidden_Metadata.(*plugin_AccessControlModule); ok { + return x.AccessControlModule + } + } + return nil +} + +func (x *Plugin) SetName(v string) { + x.xxx_hidden_Name = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 8) +} + +func (x *Plugin) SetVersion(v string) { + x.xxx_hidden_Version = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 8) +} + +func (x *Plugin) SetDisabled(v bool) { + x.xxx_hidden_Disabled = v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 8) +} + +func (x *Plugin) SetExternal(v bool) { + x.xxx_hidden_External = v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 8) +} + +func (x *Plugin) SetConfigurable(v bool) { + x.xxx_hidden_Configurable = v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 4, 8) +} + +func (x *Plugin) SetRunStatus(v RunStatus) { + x.xxx_hidden_RunStatus = v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 5, 8) +} + +func (x *Plugin) SetStatusMessage(v string) { + x.xxx_hidden_StatusMessage = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 6, 8) +} + +func (x *Plugin) SetSecretsProvider(v *SecretsProvider) { + if v == nil { + x.xxx_hidden_Metadata = nil + return + } + x.xxx_hidden_Metadata = &plugin_SecretsProvider{v} +} + +func (x *Plugin) SetAccessControlModule(v *AccessControlModule) { + if v == nil { + x.xxx_hidden_Metadata = nil + return + } + x.xxx_hidden_Metadata = &plugin_AccessControlModule{v} +} + +func (x *Plugin) HasName() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *Plugin) HasVersion() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 1) +} + +func (x *Plugin) HasDisabled() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 2) +} + +func (x *Plugin) HasExternal() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 3) +} + +func (x *Plugin) HasConfigurable() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 4) +} + +func (x *Plugin) HasRunStatus() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 5) +} + +func (x *Plugin) HasStatusMessage() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 6) +} + +func (x *Plugin) HasMetadata() bool { + if x == nil { + return false + } + return x.xxx_hidden_Metadata != nil +} + +func (x *Plugin) HasSecretsProvider() bool { + if x == nil { + return false + } + _, ok := x.xxx_hidden_Metadata.(*plugin_SecretsProvider) + return ok +} + +func (x *Plugin) HasAccessControlModule() bool { + if x == nil { + return false + } + _, ok := x.xxx_hidden_Metadata.(*plugin_AccessControlModule) + return ok +} + +func (x *Plugin) ClearName() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Name = nil +} + +func (x *Plugin) ClearVersion() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) + x.xxx_hidden_Version = nil +} + +func (x *Plugin) ClearDisabled() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) + x.xxx_hidden_Disabled = false +} + +func (x *Plugin) ClearExternal() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) + x.xxx_hidden_External = false +} + +func (x *Plugin) ClearConfigurable() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 4) + x.xxx_hidden_Configurable = false +} + +func (x *Plugin) ClearRunStatus() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 5) + x.xxx_hidden_RunStatus = RunStatus_RUN_STATUS_UNSPECIFIED +} + +func (x *Plugin) ClearStatusMessage() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 6) + x.xxx_hidden_StatusMessage = nil +} + +func (x *Plugin) ClearMetadata() { + x.xxx_hidden_Metadata = nil +} + +func (x *Plugin) ClearSecretsProvider() { + if _, ok := x.xxx_hidden_Metadata.(*plugin_SecretsProvider); ok { + x.xxx_hidden_Metadata = nil + } +} + +func (x *Plugin) ClearAccessControlModule() { + if _, ok := x.xxx_hidden_Metadata.(*plugin_AccessControlModule); ok { + x.xxx_hidden_Metadata = nil + } +} + +const Plugin_Metadata_not_set_case case_Plugin_Metadata = 0 +const Plugin_SecretsProvider_case case_Plugin_Metadata = 8 +const Plugin_AccessControlModule_case case_Plugin_Metadata = 9 + +func (x *Plugin) WhichMetadata() case_Plugin_Metadata { + if x == nil { + return Plugin_Metadata_not_set_case + } + switch x.xxx_hidden_Metadata.(type) { + case *plugin_SecretsProvider: + return Plugin_SecretsProvider_case + case *plugin_AccessControlModule: + return Plugin_AccessControlModule_case + default: + return Plugin_Metadata_not_set_case + } +} + +type Plugin_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // Name + Name *string + // Version + Version *string + // Enabled vs disabled + Disabled *bool + // External vs builtin + External *bool + // Configurable + Configurable *bool + // Run status + RunStatus *RunStatus + // Human-readable detail for the current run_status. Populated for + // terminal/error statuses (CRASHED, RETRIES_EXCEEDED); typically empty + // otherwise. Not machine-parseable — intended for display only. + StatusMessage *string + // Type-specific fields + + // Fields of oneof xxx_hidden_Metadata: + SecretsProvider *SecretsProvider + AccessControlModule *AccessControlModule + // -- end of xxx_hidden_Metadata +} + +func (b0 Plugin_builder) Build() *Plugin { + m0 := &Plugin{} + b, x := &b0, m0 + _, _ = b, x + if b.Name != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 8) + x.xxx_hidden_Name = b.Name + } + if b.Version != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 8) + x.xxx_hidden_Version = b.Version + } + if b.Disabled != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 8) + x.xxx_hidden_Disabled = *b.Disabled + } + if b.External != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 8) + x.xxx_hidden_External = *b.External + } + if b.Configurable != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 4, 8) + x.xxx_hidden_Configurable = *b.Configurable + } + if b.RunStatus != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 5, 8) + x.xxx_hidden_RunStatus = *b.RunStatus + } + if b.StatusMessage != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 6, 8) + x.xxx_hidden_StatusMessage = b.StatusMessage + } + if b.SecretsProvider != nil { + x.xxx_hidden_Metadata = &plugin_SecretsProvider{b.SecretsProvider} + } + if b.AccessControlModule != nil { + x.xxx_hidden_Metadata = &plugin_AccessControlModule{b.AccessControlModule} + } + return m0 +} + +type case_Plugin_Metadata protoreflect.FieldNumber + +func (x case_Plugin_Metadata) String() string { + md := file_plugins_v1_management_proto_msgTypes[0].Descriptor() + if x == 0 { + return "not set" + } + return protoimpl.X.MessageFieldStringOf(md, protoreflect.FieldNumber(x)) +} + +type isPlugin_Metadata interface { + isPlugin_Metadata() +} + +type plugin_SecretsProvider struct { + SecretsProvider *SecretsProvider `protobuf:"bytes,8,opt,name=secrets_provider,json=secretsProvider,oneof"` +} + +type plugin_AccessControlModule struct { + AccessControlModule *AccessControlModule `protobuf:"bytes,9,opt,name=access_control_module,json=accessControlModule,oneof"` +} + +func (*plugin_SecretsProvider) isPlugin_Metadata() {} + +func (*plugin_AccessControlModule) isPlugin_Metadata() {} + +type ListPluginsRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPluginsRequest) Reset() { + *x = ListPluginsRequest{} + mi := &file_plugins_v1_management_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPluginsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPluginsRequest) ProtoMessage() {} + +func (x *ListPluginsRequest) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_management_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type ListPluginsRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 ListPluginsRequest_builder) Build() *ListPluginsRequest { + m0 := &ListPluginsRequest{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +type ListPluginsResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Plugins *[]*Plugin `protobuf:"bytes,1,rep,name=plugins"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPluginsResponse) Reset() { + *x = ListPluginsResponse{} + mi := &file_plugins_v1_management_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPluginsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPluginsResponse) ProtoMessage() {} + +func (x *ListPluginsResponse) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_management_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *ListPluginsResponse) GetPlugins() []*Plugin { + if x != nil { + if x.xxx_hidden_Plugins != nil { + return *x.xxx_hidden_Plugins + } + } + return nil +} + +func (x *ListPluginsResponse) SetPlugins(v []*Plugin) { + x.xxx_hidden_Plugins = &v +} + +type ListPluginsResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Plugins []*Plugin +} + +func (b0 ListPluginsResponse_builder) Build() *ListPluginsResponse { + m0 := &ListPluginsResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Plugins = &b.Plugins + return m0 +} + +type EnablePluginRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name *string `protobuf:"bytes,1,opt,name=name"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EnablePluginRequest) Reset() { + *x = EnablePluginRequest{} + mi := &file_plugins_v1_management_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EnablePluginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EnablePluginRequest) ProtoMessage() {} + +func (x *EnablePluginRequest) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_management_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *EnablePluginRequest) GetName() string { + if x != nil { + if x.xxx_hidden_Name != nil { + return *x.xxx_hidden_Name + } + return "" + } + return "" +} + +func (x *EnablePluginRequest) SetName(v string) { + x.xxx_hidden_Name = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 1) +} + +func (x *EnablePluginRequest) HasName() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *EnablePluginRequest) ClearName() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Name = nil +} + +type EnablePluginRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Name *string +} + +func (b0 EnablePluginRequest_builder) Build() *EnablePluginRequest { + m0 := &EnablePluginRequest{} + b, x := &b0, m0 + _, _ = b, x + if b.Name != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 1) + x.xxx_hidden_Name = b.Name + } + return m0 +} + +type EnablePluginResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EnablePluginResponse) Reset() { + *x = EnablePluginResponse{} + mi := &file_plugins_v1_management_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EnablePluginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EnablePluginResponse) ProtoMessage() {} + +func (x *EnablePluginResponse) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_management_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type EnablePluginResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 EnablePluginResponse_builder) Build() *EnablePluginResponse { + m0 := &EnablePluginResponse{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +type DisablePluginRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name *string `protobuf:"bytes,1,opt,name=name"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DisablePluginRequest) Reset() { + *x = DisablePluginRequest{} + mi := &file_plugins_v1_management_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DisablePluginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DisablePluginRequest) ProtoMessage() {} + +func (x *DisablePluginRequest) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_management_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *DisablePluginRequest) GetName() string { + if x != nil { + if x.xxx_hidden_Name != nil { + return *x.xxx_hidden_Name + } + return "" + } + return "" +} + +func (x *DisablePluginRequest) SetName(v string) { + x.xxx_hidden_Name = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 1) +} + +func (x *DisablePluginRequest) HasName() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *DisablePluginRequest) ClearName() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Name = nil +} + +type DisablePluginRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Name *string +} + +func (b0 DisablePluginRequest_builder) Build() *DisablePluginRequest { + m0 := &DisablePluginRequest{} + b, x := &b0, m0 + _, _ = b, x + if b.Name != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 1) + x.xxx_hidden_Name = b.Name + } + return m0 +} + +type DisablePluginResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DisablePluginResponse) Reset() { + *x = DisablePluginResponse{} + mi := &file_plugins_v1_management_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DisablePluginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DisablePluginResponse) ProtoMessage() {} + +func (x *DisablePluginResponse) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_management_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type DisablePluginResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 DisablePluginResponse_builder) Build() *DisablePluginResponse { + m0 := &DisablePluginResponse{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +var File_plugins_v1_management_proto protoreflect.FileDescriptor + +const file_plugins_v1_management_proto_rawDesc = "" + + "\n" + + "\x1bplugins/v1/management.proto\x12\n" + + "plugins.v1\x1a\x19plugins/v1/metadata.proto\"\x9c\x03\n" + + "\x06Plugin\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + + "\aversion\x18\x02 \x01(\tR\aversion\x12\x1a\n" + + "\bdisabled\x18\x03 \x01(\bR\bdisabled\x12\x1a\n" + + "\bexternal\x18\x04 \x01(\bR\bexternal\x12\"\n" + + "\fconfigurable\x18\x05 \x01(\bR\fconfigurable\x124\n" + + "\n" + + "run_status\x18\x06 \x01(\x0e2\x15.plugins.v1.RunStatusR\trunStatus\x12%\n" + + "\x0estatus_message\x18\a \x01(\tR\rstatusMessage\x12H\n" + + "\x10secrets_provider\x18\b \x01(\v2\x1b.plugins.v1.SecretsProviderH\x00R\x0fsecretsProvider\x12U\n" + + "\x15access_control_module\x18\t \x01(\v2\x1f.plugins.v1.AccessControlModuleH\x00R\x13accessControlModuleB\n" + + "\n" + + "\bmetadata\"\x14\n" + + "\x12ListPluginsRequest\"C\n" + + "\x13ListPluginsResponse\x12,\n" + + "\aplugins\x18\x01 \x03(\v2\x12.plugins.v1.PluginR\aplugins\")\n" + + "\x13EnablePluginRequest\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\"\x16\n" + + "\x14EnablePluginResponse\"*\n" + + "\x14DisablePluginRequest\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\"\x17\n" + + "\x15DisablePluginResponse*\x90\x01\n" + + "\tRunStatus\x12\x1a\n" + + "\x16RUN_STATUS_UNSPECIFIED\x10\x00\x12\x16\n" + + "\x12RUN_STATUS_RUNNING\x10\x01\x12\x16\n" + + "\x12RUN_STATUS_STOPPED\x10\x02\x12\x16\n" + + "\x12RUN_STATUS_CRASHED\x10\x03\x12\x1f\n" + + "\x1bRUN_STATUS_RETRIES_EXCEEDED\x10\x042\x92\x02\n" + + "\x17PluginManagementService\x12N\n" + + "\vListPlugins\x12\x1e.plugins.v1.ListPluginsRequest\x1a\x1f.plugins.v1.ListPluginsResponse\x12Q\n" + + "\fEnablePlugin\x12\x1f.plugins.v1.EnablePluginRequest\x1a .plugins.v1.EnablePluginResponse\x12T\n" + + "\rDisablePlugin\x12 .plugins.v1.DisablePluginRequest\x1a!.plugins.v1.DisablePluginResponseB\xac\x01\n" + + "\x0ecom.plugins.v1B\x0fManagementProtoP\x01Z@github.com/docker/secrets-engine/client/api/plugins/v1;pluginsv1\xa2\x02\x03PXX\xaa\x02\n" + + "Plugins.V1\xca\x02\n" + + "Plugins\\V1\xe2\x02\x16Plugins\\V1\\GPBMetadata\xea\x02\vPlugins::V1b\beditionsp\xe8\a" + +var file_plugins_v1_management_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_plugins_v1_management_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_plugins_v1_management_proto_goTypes = []any{ + (RunStatus)(0), // 0: plugins.v1.RunStatus + (*Plugin)(nil), // 1: plugins.v1.Plugin + (*ListPluginsRequest)(nil), // 2: plugins.v1.ListPluginsRequest + (*ListPluginsResponse)(nil), // 3: plugins.v1.ListPluginsResponse + (*EnablePluginRequest)(nil), // 4: plugins.v1.EnablePluginRequest + (*EnablePluginResponse)(nil), // 5: plugins.v1.EnablePluginResponse + (*DisablePluginRequest)(nil), // 6: plugins.v1.DisablePluginRequest + (*DisablePluginResponse)(nil), // 7: plugins.v1.DisablePluginResponse + (*SecretsProvider)(nil), // 8: plugins.v1.SecretsProvider + (*AccessControlModule)(nil), // 9: plugins.v1.AccessControlModule +} +var file_plugins_v1_management_proto_depIdxs = []int32{ + 0, // 0: plugins.v1.Plugin.run_status:type_name -> plugins.v1.RunStatus + 8, // 1: plugins.v1.Plugin.secrets_provider:type_name -> plugins.v1.SecretsProvider + 9, // 2: plugins.v1.Plugin.access_control_module:type_name -> plugins.v1.AccessControlModule + 1, // 3: plugins.v1.ListPluginsResponse.plugins:type_name -> plugins.v1.Plugin + 2, // 4: plugins.v1.PluginManagementService.ListPlugins:input_type -> plugins.v1.ListPluginsRequest + 4, // 5: plugins.v1.PluginManagementService.EnablePlugin:input_type -> plugins.v1.EnablePluginRequest + 6, // 6: plugins.v1.PluginManagementService.DisablePlugin:input_type -> plugins.v1.DisablePluginRequest + 3, // 7: plugins.v1.PluginManagementService.ListPlugins:output_type -> plugins.v1.ListPluginsResponse + 5, // 8: plugins.v1.PluginManagementService.EnablePlugin:output_type -> plugins.v1.EnablePluginResponse + 7, // 9: plugins.v1.PluginManagementService.DisablePlugin:output_type -> plugins.v1.DisablePluginResponse + 7, // [7:10] is the sub-list for method output_type + 4, // [4:7] 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_plugins_v1_management_proto_init() } +func file_plugins_v1_management_proto_init() { + if File_plugins_v1_management_proto != nil { + return + } + file_plugins_v1_metadata_proto_init() + file_plugins_v1_management_proto_msgTypes[0].OneofWrappers = []any{ + (*plugin_SecretsProvider)(nil), + (*plugin_AccessControlModule)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugins_v1_management_proto_rawDesc), len(file_plugins_v1_management_proto_rawDesc)), + NumEnums: 1, + NumMessages: 7, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_plugins_v1_management_proto_goTypes, + DependencyIndexes: file_plugins_v1_management_proto_depIdxs, + EnumInfos: file_plugins_v1_management_proto_enumTypes, + MessageInfos: file_plugins_v1_management_proto_msgTypes, + }.Build() + File_plugins_v1_management_proto = out.File + file_plugins_v1_management_proto_goTypes = nil + file_plugins_v1_management_proto_depIdxs = nil +} diff --git a/vendor/github.com/docker/secrets-engine/client/api/plugins/v1/metadata.pb.go b/vendor/github.com/docker/secrets-engine/client/api/plugins/v1/metadata.pb.go new file mode 100644 index 000000000000..9bb99fb19f99 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/api/plugins/v1/metadata.pb.go @@ -0,0 +1,193 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.7 +// protoc (unknown) +// source: plugins/v1/metadata.proto + +package pluginsv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + unsafe "unsafe" +) + +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 SecretsProvider struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Pattern *string `protobuf:"bytes,1,opt,name=pattern"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SecretsProvider) Reset() { + *x = SecretsProvider{} + mi := &file_plugins_v1_metadata_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SecretsProvider) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SecretsProvider) ProtoMessage() {} + +func (x *SecretsProvider) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_metadata_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *SecretsProvider) GetPattern() string { + if x != nil { + if x.xxx_hidden_Pattern != nil { + return *x.xxx_hidden_Pattern + } + return "" + } + return "" +} + +func (x *SecretsProvider) SetPattern(v string) { + x.xxx_hidden_Pattern = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 1) +} + +func (x *SecretsProvider) HasPattern() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *SecretsProvider) ClearPattern() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Pattern = nil +} + +type SecretsProvider_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // Pattern + Pattern *string +} + +func (b0 SecretsProvider_builder) Build() *SecretsProvider { + m0 := &SecretsProvider{} + b, x := &b0, m0 + _, _ = b, x + if b.Pattern != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 1) + x.xxx_hidden_Pattern = b.Pattern + } + return m0 +} + +type AccessControlModule struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AccessControlModule) Reset() { + *x = AccessControlModule{} + mi := &file_plugins_v1_metadata_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AccessControlModule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccessControlModule) ProtoMessage() {} + +func (x *AccessControlModule) ProtoReflect() protoreflect.Message { + mi := &file_plugins_v1_metadata_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +type AccessControlModule_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 AccessControlModule_builder) Build() *AccessControlModule { + m0 := &AccessControlModule{} + b, x := &b0, m0 + _, _ = b, x + return m0 +} + +var File_plugins_v1_metadata_proto protoreflect.FileDescriptor + +const file_plugins_v1_metadata_proto_rawDesc = "" + + "\n" + + "\x19plugins/v1/metadata.proto\x12\n" + + "plugins.v1\"+\n" + + "\x0fSecretsProvider\x12\x18\n" + + "\apattern\x18\x01 \x01(\tR\apattern\"\x15\n" + + "\x13AccessControlModuleB\xaa\x01\n" + + "\x0ecom.plugins.v1B\rMetadataProtoP\x01Z@github.com/docker/secrets-engine/client/api/plugins/v1;pluginsv1\xa2\x02\x03PXX\xaa\x02\n" + + "Plugins.V1\xca\x02\n" + + "Plugins\\V1\xe2\x02\x16Plugins\\V1\\GPBMetadata\xea\x02\vPlugins::V1b\beditionsp\xe8\a" + +var file_plugins_v1_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_plugins_v1_metadata_proto_goTypes = []any{ + (*SecretsProvider)(nil), // 0: plugins.v1.SecretsProvider + (*AccessControlModule)(nil), // 1: plugins.v1.AccessControlModule +} +var file_plugins_v1_metadata_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_plugins_v1_metadata_proto_init() } +func file_plugins_v1_metadata_proto_init() { + if File_plugins_v1_metadata_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugins_v1_metadata_proto_rawDesc), len(file_plugins_v1_metadata_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_plugins_v1_metadata_proto_goTypes, + DependencyIndexes: file_plugins_v1_metadata_proto_depIdxs, + MessageInfos: file_plugins_v1_metadata_proto_msgTypes, + }.Build() + File_plugins_v1_metadata_proto = out.File + file_plugins_v1_metadata_proto_goTypes = nil + file_plugins_v1_metadata_proto_depIdxs = nil +} diff --git a/vendor/github.com/docker/secrets-engine/client/api/plugins/v1/pluginsv1rpc/management.rpc.go b/vendor/github.com/docker/secrets-engine/client/api/plugins/v1/pluginsv1rpc/management.rpc.go new file mode 100644 index 000000000000..edbc638b82ee --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/api/plugins/v1/pluginsv1rpc/management.rpc.go @@ -0,0 +1,63 @@ +// Code generated by protoc-gen-go-rpc. DO NOT EDIT. +// +// Source: plugins/v1/management.proto + +package pluginsv1rpc + +import ( + context "context" + v1 "github.com/docker/secrets-engine/client/api/plugins/v1" + proto "google.golang.org/protobuf/proto" +) + +const ( + // PluginManagementServiceListPluginsProcedure is the fully-qualified name of the PluginManagementService's ListPlugins RPC. + PluginManagementServiceListPluginsProcedure = "/plugins.v1.PluginManagementService/ListPlugins" + // PluginManagementServiceEnablePluginProcedure is the fully-qualified name of the PluginManagementService's EnablePlugin RPC. + PluginManagementServiceEnablePluginProcedure = "/plugins.v1.PluginManagementService/EnablePlugin" + // PluginManagementServiceDisablePluginProcedure is the fully-qualified name of the PluginManagementService's DisablePlugin RPC. + PluginManagementServiceDisablePluginProcedure = "/plugins.v1.PluginManagementService/DisablePlugin" +) + +// PluginManagementServiceClient is a client for the plugins.v1.PluginManagementService service. +type PluginManagementServiceClient interface { + // ListPlugins returns all plugins registered with the engine. + ListPlugins(context.Context, *v1.ListPluginsRequest) (*v1.ListPluginsResponse, error) + // EnablePlugin enables a plugin by name. + EnablePlugin(context.Context, *v1.EnablePluginRequest) (*v1.EnablePluginResponse, error) + // DisablePlugin disables a plugin by name. + DisablePlugin(context.Context, *v1.DisablePluginRequest) (*v1.DisablePluginResponse, error) +} + +// NewPluginManagementServiceClient constructs a client for the plugins.v1.PluginManagementService service that sends each request through call. +func NewPluginManagementServiceClient(call func(ctx context.Context, procedure string, req, res proto.Message) error) PluginManagementServiceClient { + return &pluginManagementServiceClient{call} +} + +type pluginManagementServiceClient struct { + call func(ctx context.Context, procedure string, req, res proto.Message) error +} + +func (c *pluginManagementServiceClient) ListPlugins(ctx context.Context, req *v1.ListPluginsRequest) (*v1.ListPluginsResponse, error) { + res := &v1.ListPluginsResponse{} + if err := c.call(ctx, PluginManagementServiceListPluginsProcedure, req, res); err != nil { + return nil, err + } + return res, nil +} + +func (c *pluginManagementServiceClient) EnablePlugin(ctx context.Context, req *v1.EnablePluginRequest) (*v1.EnablePluginResponse, error) { + res := &v1.EnablePluginResponse{} + if err := c.call(ctx, PluginManagementServiceEnablePluginProcedure, req, res); err != nil { + return nil, err + } + return res, nil +} + +func (c *pluginManagementServiceClient) DisablePlugin(ctx context.Context, req *v1.DisablePluginRequest) (*v1.DisablePluginResponse, error) { + res := &v1.DisablePluginResponse{} + if err := c.call(ctx, PluginManagementServiceDisablePluginProcedure, req, res); err != nil { + return nil, err + } + return res, nil +} diff --git a/vendor/github.com/docker/secrets-engine/client/api/resolver/resolver.go b/vendor/github.com/docker/secrets-engine/client/api/resolver/resolver.go new file mode 100644 index 000000000000..625bc20286ff --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/api/resolver/resolver.go @@ -0,0 +1,44 @@ +// Copyright 2025-2026 Docker, 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 resolver + +import ( + "context" + "time" + + "github.com/docker/secrets-engine/secrets" +) + +// Resolver resolves secrets by pattern. +type Resolver interface { + // GetSecrets returns an Envelope for every secret matching pattern. + GetSecrets(ctx context.Context, pattern secrets.Pattern) ([]secrets.Envelope, error) +} + +// AuthorizeResponse is the access decision returned by an [Authorizer]. +type AuthorizeResponse struct { + // Expiry is when the decision stops holding. A zero Expiry means the + // decision never expires, and the wire message then carries no timestamp. + Expiry time.Time + // Allow reports whether access is granted. A deny decision is returned + // with Allow false and a nil error. + Allow bool +} + +// Authorizer decides access to secrets. +type Authorizer interface { + // Authorize decides access to all of the given patterns at once. + Authorize(ctx context.Context, pattern ...secrets.Pattern) (AuthorizeResponse, error) +} diff --git a/vendor/github.com/docker/secrets-engine/client/api/resolver/v1/api.pb.go b/vendor/github.com/docker/secrets-engine/client/api/resolver/v1/api.pb.go new file mode 100644 index 000000000000..170610409560 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/api/resolver/v1/api.pb.go @@ -0,0 +1,728 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.7 +// protoc (unknown) +// source: resolver/v1/api.proto + +package resolverv1 + +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" + unsafe "unsafe" +) + +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 Decision int32 + +const ( + // buf:lint:ignore ENUM_ZERO_VALUE_SUFFIX + Decision_DECISION_DENY Decision = 0 + Decision_DECISION_ALLOW Decision = 1 +) + +// Enum value maps for Decision. +var ( + Decision_name = map[int32]string{ + 0: "DECISION_DENY", + 1: "DECISION_ALLOW", + } + Decision_value = map[string]int32{ + "DECISION_DENY": 0, + "DECISION_ALLOW": 1, + } +) + +func (x Decision) Enum() *Decision { + p := new(Decision) + *p = x + return p +} + +func (x Decision) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Decision) Descriptor() protoreflect.EnumDescriptor { + return file_resolver_v1_api_proto_enumTypes[0].Descriptor() +} + +func (Decision) Type() protoreflect.EnumType { + return &file_resolver_v1_api_proto_enumTypes[0] +} + +func (x Decision) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +type GetSecretsRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Pattern *string `protobuf:"bytes,1,opt,name=pattern"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSecretsRequest) Reset() { + *x = GetSecretsRequest{} + mi := &file_resolver_v1_api_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSecretsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSecretsRequest) ProtoMessage() {} + +func (x *GetSecretsRequest) ProtoReflect() protoreflect.Message { + mi := &file_resolver_v1_api_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *GetSecretsRequest) GetPattern() string { + if x != nil { + if x.xxx_hidden_Pattern != nil { + return *x.xxx_hidden_Pattern + } + return "" + } + return "" +} + +func (x *GetSecretsRequest) SetPattern(v string) { + x.xxx_hidden_Pattern = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 1) +} + +func (x *GetSecretsRequest) HasPattern() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *GetSecretsRequest) ClearPattern() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Pattern = nil +} + +type GetSecretsRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // ID of the secret to resolve. + Pattern *string +} + +func (b0 GetSecretsRequest_builder) Build() *GetSecretsRequest { + m0 := &GetSecretsRequest{} + b, x := &b0, m0 + _, _ = b, x + if b.Pattern != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 1) + x.xxx_hidden_Pattern = b.Pattern + } + return m0 +} + +type AuthorizeRequest struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Patterns []string `protobuf:"bytes,1,rep,name=patterns"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AuthorizeRequest) Reset() { + *x = AuthorizeRequest{} + mi := &file_resolver_v1_api_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AuthorizeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthorizeRequest) ProtoMessage() {} + +func (x *AuthorizeRequest) ProtoReflect() protoreflect.Message { + mi := &file_resolver_v1_api_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *AuthorizeRequest) GetPatterns() []string { + if x != nil { + return x.xxx_hidden_Patterns + } + return nil +} + +func (x *AuthorizeRequest) SetPatterns(v []string) { + x.xxx_hidden_Patterns = v +} + +type AuthorizeRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // Patterns to authorize; at least one required. + Patterns []string +} + +func (b0 AuthorizeRequest_builder) Build() *AuthorizeRequest { + m0 := &AuthorizeRequest{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Patterns = b.Patterns + return m0 +} + +type AuthorizeResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Decision Decision `protobuf:"varint,1,opt,name=decision,enum=resolver.v1.Decision"` + xxx_hidden_ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=expires_at,json=expiresAt"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AuthorizeResponse) Reset() { + *x = AuthorizeResponse{} + mi := &file_resolver_v1_api_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AuthorizeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthorizeResponse) ProtoMessage() {} + +func (x *AuthorizeResponse) ProtoReflect() protoreflect.Message { + mi := &file_resolver_v1_api_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *AuthorizeResponse) GetDecision() Decision { + if x != nil { + if protoimpl.X.Present(&(x.XXX_presence[0]), 0) { + return x.xxx_hidden_Decision + } + } + return Decision_DECISION_DENY +} + +func (x *AuthorizeResponse) GetExpiresAt() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_ExpiresAt + } + return nil +} + +func (x *AuthorizeResponse) SetDecision(v Decision) { + x.xxx_hidden_Decision = v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 2) +} + +func (x *AuthorizeResponse) SetExpiresAt(v *timestamppb.Timestamp) { + x.xxx_hidden_ExpiresAt = v +} + +func (x *AuthorizeResponse) HasDecision() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *AuthorizeResponse) HasExpiresAt() bool { + if x == nil { + return false + } + return x.xxx_hidden_ExpiresAt != nil +} + +func (x *AuthorizeResponse) ClearDecision() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Decision = Decision_DECISION_DENY +} + +func (x *AuthorizeResponse) ClearExpiresAt() { + x.xxx_hidden_ExpiresAt = nil +} + +type AuthorizeResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // The authorization decision. + Decision *Decision + // When the authorization decision expires. + ExpiresAt *timestamppb.Timestamp +} + +func (b0 AuthorizeResponse_builder) Build() *AuthorizeResponse { + m0 := &AuthorizeResponse{} + b, x := &b0, m0 + _, _ = b, x + if b.Decision != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 2) + x.xxx_hidden_Decision = *b.Decision + } + x.xxx_hidden_ExpiresAt = b.ExpiresAt + return m0 +} + +type GetSecretsResponse struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Envelopes *[]*GetSecretsResponse_Envelope `protobuf:"bytes,1,rep,name=envelopes"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSecretsResponse) Reset() { + *x = GetSecretsResponse{} + mi := &file_resolver_v1_api_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSecretsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSecretsResponse) ProtoMessage() {} + +func (x *GetSecretsResponse) ProtoReflect() protoreflect.Message { + mi := &file_resolver_v1_api_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *GetSecretsResponse) GetEnvelopes() []*GetSecretsResponse_Envelope { + if x != nil { + if x.xxx_hidden_Envelopes != nil { + return *x.xxx_hidden_Envelopes + } + } + return nil +} + +func (x *GetSecretsResponse) SetEnvelopes(v []*GetSecretsResponse_Envelope) { + x.xxx_hidden_Envelopes = &v +} + +type GetSecretsResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Envelopes []*GetSecretsResponse_Envelope +} + +func (b0 GetSecretsResponse_builder) Build() *GetSecretsResponse { + m0 := &GetSecretsResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Envelopes = &b.Envelopes + return m0 +} + +type GetSecretsResponse_Envelope struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Id *string `protobuf:"bytes,1,opt,name=id"` + xxx_hidden_Value []byte `protobuf:"bytes,2,opt,name=value"` + xxx_hidden_Provider *string `protobuf:"bytes,3,opt,name=provider"` + xxx_hidden_Version *string `protobuf:"bytes,4,opt,name=version"` + xxx_hidden_CreatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created_at,json=createdAt"` + xxx_hidden_ResolvedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=resolved_at,json=resolvedAt"` + xxx_hidden_ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=expires_at,json=expiresAt"` + xxx_hidden_Metadata map[string]string `protobuf:"bytes,8,rep,name=metadata" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + XXX_raceDetectHookData protoimpl.RaceDetectHookData + XXX_presence [1]uint32 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSecretsResponse_Envelope) Reset() { + *x = GetSecretsResponse_Envelope{} + mi := &file_resolver_v1_api_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSecretsResponse_Envelope) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSecretsResponse_Envelope) ProtoMessage() {} + +func (x *GetSecretsResponse_Envelope) ProtoReflect() protoreflect.Message { + mi := &file_resolver_v1_api_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +func (x *GetSecretsResponse_Envelope) GetId() string { + if x != nil { + if x.xxx_hidden_Id != nil { + return *x.xxx_hidden_Id + } + return "" + } + return "" +} + +func (x *GetSecretsResponse_Envelope) GetValue() []byte { + if x != nil { + return x.xxx_hidden_Value + } + return nil +} + +func (x *GetSecretsResponse_Envelope) GetProvider() string { + if x != nil { + if x.xxx_hidden_Provider != nil { + return *x.xxx_hidden_Provider + } + return "" + } + return "" +} + +func (x *GetSecretsResponse_Envelope) GetVersion() string { + if x != nil { + if x.xxx_hidden_Version != nil { + return *x.xxx_hidden_Version + } + return "" + } + return "" +} + +func (x *GetSecretsResponse_Envelope) GetCreatedAt() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_CreatedAt + } + return nil +} + +func (x *GetSecretsResponse_Envelope) GetResolvedAt() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_ResolvedAt + } + return nil +} + +func (x *GetSecretsResponse_Envelope) GetExpiresAt() *timestamppb.Timestamp { + if x != nil { + return x.xxx_hidden_ExpiresAt + } + return nil +} + +func (x *GetSecretsResponse_Envelope) GetMetadata() map[string]string { + if x != nil { + return x.xxx_hidden_Metadata + } + return nil +} + +func (x *GetSecretsResponse_Envelope) SetId(v string) { + x.xxx_hidden_Id = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 8) +} + +func (x *GetSecretsResponse_Envelope) SetValue(v []byte) { + if v == nil { + v = []byte{} + } + x.xxx_hidden_Value = v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 8) +} + +func (x *GetSecretsResponse_Envelope) SetProvider(v string) { + x.xxx_hidden_Provider = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 8) +} + +func (x *GetSecretsResponse_Envelope) SetVersion(v string) { + x.xxx_hidden_Version = &v + protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 8) +} + +func (x *GetSecretsResponse_Envelope) SetCreatedAt(v *timestamppb.Timestamp) { + x.xxx_hidden_CreatedAt = v +} + +func (x *GetSecretsResponse_Envelope) SetResolvedAt(v *timestamppb.Timestamp) { + x.xxx_hidden_ResolvedAt = v +} + +func (x *GetSecretsResponse_Envelope) SetExpiresAt(v *timestamppb.Timestamp) { + x.xxx_hidden_ExpiresAt = v +} + +func (x *GetSecretsResponse_Envelope) SetMetadata(v map[string]string) { + x.xxx_hidden_Metadata = v +} + +func (x *GetSecretsResponse_Envelope) HasId() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 0) +} + +func (x *GetSecretsResponse_Envelope) HasValue() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 1) +} + +func (x *GetSecretsResponse_Envelope) HasProvider() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 2) +} + +func (x *GetSecretsResponse_Envelope) HasVersion() bool { + if x == nil { + return false + } + return protoimpl.X.Present(&(x.XXX_presence[0]), 3) +} + +func (x *GetSecretsResponse_Envelope) HasCreatedAt() bool { + if x == nil { + return false + } + return x.xxx_hidden_CreatedAt != nil +} + +func (x *GetSecretsResponse_Envelope) HasResolvedAt() bool { + if x == nil { + return false + } + return x.xxx_hidden_ResolvedAt != nil +} + +func (x *GetSecretsResponse_Envelope) HasExpiresAt() bool { + if x == nil { + return false + } + return x.xxx_hidden_ExpiresAt != nil +} + +func (x *GetSecretsResponse_Envelope) ClearId() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) + x.xxx_hidden_Id = nil +} + +func (x *GetSecretsResponse_Envelope) ClearValue() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) + x.xxx_hidden_Value = nil +} + +func (x *GetSecretsResponse_Envelope) ClearProvider() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) + x.xxx_hidden_Provider = nil +} + +func (x *GetSecretsResponse_Envelope) ClearVersion() { + protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) + x.xxx_hidden_Version = nil +} + +func (x *GetSecretsResponse_Envelope) ClearCreatedAt() { + x.xxx_hidden_CreatedAt = nil +} + +func (x *GetSecretsResponse_Envelope) ClearResolvedAt() { + x.xxx_hidden_ResolvedAt = nil +} + +func (x *GetSecretsResponse_Envelope) ClearExpiresAt() { + x.xxx_hidden_ExpiresAt = nil +} + +type GetSecretsResponse_Envelope_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + // ID of the secret to resolve. + Id *string + // The resolved secret value. + Value []byte + Provider *string + Version *string + CreatedAt *timestamppb.Timestamp + ResolvedAt *timestamppb.Timestamp + ExpiresAt *timestamppb.Timestamp + Metadata map[string]string +} + +func (b0 GetSecretsResponse_Envelope_builder) Build() *GetSecretsResponse_Envelope { + m0 := &GetSecretsResponse_Envelope{} + b, x := &b0, m0 + _, _ = b, x + if b.Id != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 8) + x.xxx_hidden_Id = b.Id + } + if b.Value != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 8) + x.xxx_hidden_Value = b.Value + } + if b.Provider != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 8) + x.xxx_hidden_Provider = b.Provider + } + if b.Version != nil { + protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 8) + x.xxx_hidden_Version = b.Version + } + x.xxx_hidden_CreatedAt = b.CreatedAt + x.xxx_hidden_ResolvedAt = b.ResolvedAt + x.xxx_hidden_ExpiresAt = b.ExpiresAt + x.xxx_hidden_Metadata = b.Metadata + return m0 +} + +var File_resolver_v1_api_proto protoreflect.FileDescriptor + +const file_resolver_v1_api_proto_rawDesc = "" + + "\n" + + "\x15resolver/v1/api.proto\x12\vresolver.v1\x1a\x1fgoogle/protobuf/timestamp.proto\"-\n" + + "\x11GetSecretsRequest\x12\x18\n" + + "\apattern\x18\x01 \x01(\tR\apattern\".\n" + + "\x10AuthorizeRequest\x12\x1a\n" + + "\bpatterns\x18\x01 \x03(\tR\bpatterns\"\x81\x01\n" + + "\x11AuthorizeResponse\x121\n" + + "\bdecision\x18\x01 \x01(\x0e2\x15.resolver.v1.DecisionR\bdecision\x129\n" + + "\n" + + "expires_at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\"\x89\x04\n" + + "\x12GetSecretsResponse\x12F\n" + + "\tenvelopes\x18\x01 \x03(\v2(.resolver.v1.GetSecretsResponse.EnvelopeR\tenvelopes\x1a\xaa\x03\n" + + "\bEnvelope\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x14\n" + + "\x05value\x18\x02 \x01(\fR\x05value\x12\x1a\n" + + "\bprovider\x18\x03 \x01(\tR\bprovider\x12\x18\n" + + "\aversion\x18\x04 \x01(\tR\aversion\x129\n" + + "\n" + + "created_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x12;\n" + + "\vresolved_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\n" + + "resolvedAt\x129\n" + + "\n" + + "expires_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\x12R\n" + + "\bmetadata\x18\b \x03(\v26.resolver.v1.GetSecretsResponse.Envelope.MetadataEntryR\bmetadata\x1a;\n" + + "\rMetadataEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01*1\n" + + "\bDecision\x12\x11\n" + + "\rDECISION_DENY\x10\x00\x12\x12\n" + + "\x0eDECISION_ALLOW\x10\x012`\n" + + "\x0fResolverService\x12M\n" + + "\n" + + "GetSecrets\x12\x1e.resolver.v1.GetSecretsRequest\x1a\x1f.resolver.v1.GetSecretsResponse2_\n" + + "\x11AuthorizerService\x12J\n" + + "\tAuthorize\x12\x1d.resolver.v1.AuthorizeRequest\x1a\x1e.resolver.v1.AuthorizeResponseB\xac\x01\n" + + "\x0fcom.resolver.v1B\bApiProtoP\x01ZBgithub.com/docker/secrets-engine/client/api/resolver/v1;resolverv1\xa2\x02\x03RXX\xaa\x02\vResolver.V1\xca\x02\vResolver\\V1\xe2\x02\x17Resolver\\V1\\GPBMetadata\xea\x02\fResolver::V1b\beditionsp\xe8\a" + +var file_resolver_v1_api_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_resolver_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_resolver_v1_api_proto_goTypes = []any{ + (Decision)(0), // 0: resolver.v1.Decision + (*GetSecretsRequest)(nil), // 1: resolver.v1.GetSecretsRequest + (*AuthorizeRequest)(nil), // 2: resolver.v1.AuthorizeRequest + (*AuthorizeResponse)(nil), // 3: resolver.v1.AuthorizeResponse + (*GetSecretsResponse)(nil), // 4: resolver.v1.GetSecretsResponse + (*GetSecretsResponse_Envelope)(nil), // 5: resolver.v1.GetSecretsResponse.Envelope + nil, // 6: resolver.v1.GetSecretsResponse.Envelope.MetadataEntry + (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp +} +var file_resolver_v1_api_proto_depIdxs = []int32{ + 0, // 0: resolver.v1.AuthorizeResponse.decision:type_name -> resolver.v1.Decision + 7, // 1: resolver.v1.AuthorizeResponse.expires_at:type_name -> google.protobuf.Timestamp + 5, // 2: resolver.v1.GetSecretsResponse.envelopes:type_name -> resolver.v1.GetSecretsResponse.Envelope + 7, // 3: resolver.v1.GetSecretsResponse.Envelope.created_at:type_name -> google.protobuf.Timestamp + 7, // 4: resolver.v1.GetSecretsResponse.Envelope.resolved_at:type_name -> google.protobuf.Timestamp + 7, // 5: resolver.v1.GetSecretsResponse.Envelope.expires_at:type_name -> google.protobuf.Timestamp + 6, // 6: resolver.v1.GetSecretsResponse.Envelope.metadata:type_name -> resolver.v1.GetSecretsResponse.Envelope.MetadataEntry + 1, // 7: resolver.v1.ResolverService.GetSecrets:input_type -> resolver.v1.GetSecretsRequest + 2, // 8: resolver.v1.AuthorizerService.Authorize:input_type -> resolver.v1.AuthorizeRequest + 4, // 9: resolver.v1.ResolverService.GetSecrets:output_type -> resolver.v1.GetSecretsResponse + 3, // 10: resolver.v1.AuthorizerService.Authorize:output_type -> resolver.v1.AuthorizeResponse + 9, // [9:11] is the sub-list for method output_type + 7, // [7:9] 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 +} + +func init() { file_resolver_v1_api_proto_init() } +func file_resolver_v1_api_proto_init() { + if File_resolver_v1_api_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_resolver_v1_api_proto_rawDesc), len(file_resolver_v1_api_proto_rawDesc)), + NumEnums: 1, + NumMessages: 6, + NumExtensions: 0, + NumServices: 2, + }, + GoTypes: file_resolver_v1_api_proto_goTypes, + DependencyIndexes: file_resolver_v1_api_proto_depIdxs, + EnumInfos: file_resolver_v1_api_proto_enumTypes, + MessageInfos: file_resolver_v1_api_proto_msgTypes, + }.Build() + File_resolver_v1_api_proto = out.File + file_resolver_v1_api_proto_goTypes = nil + file_resolver_v1_api_proto_depIdxs = nil +} diff --git a/vendor/github.com/docker/secrets-engine/client/api/resolver/v1/resolverv1rpc/api.rpc.go b/vendor/github.com/docker/secrets-engine/client/api/resolver/v1/resolverv1rpc/api.rpc.go new file mode 100644 index 000000000000..6a470f5c7422 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/api/resolver/v1/resolverv1rpc/api.rpc.go @@ -0,0 +1,65 @@ +// Code generated by protoc-gen-go-rpc. DO NOT EDIT. +// +// Source: resolver/v1/api.proto + +package resolverv1rpc + +import ( + context "context" + v1 "github.com/docker/secrets-engine/client/api/resolver/v1" + proto "google.golang.org/protobuf/proto" +) + +const ( + // ResolverServiceGetSecretsProcedure is the fully-qualified name of the ResolverService's GetSecrets RPC. + ResolverServiceGetSecretsProcedure = "/resolver.v1.ResolverService/GetSecrets" + // AuthorizerServiceAuthorizeProcedure is the fully-qualified name of the AuthorizerService's Authorize RPC. + AuthorizerServiceAuthorizeProcedure = "/resolver.v1.AuthorizerService/Authorize" +) + +// ResolverServiceClient is a client for the resolver.v1.ResolverService service. +type ResolverServiceClient interface { + // Resolve a secret by its ID. + GetSecrets(context.Context, *v1.GetSecretsRequest) (*v1.GetSecretsResponse, error) +} + +// NewResolverServiceClient constructs a client for the resolver.v1.ResolverService service that sends each request through call. +func NewResolverServiceClient(call func(ctx context.Context, procedure string, req, res proto.Message) error) ResolverServiceClient { + return &resolverServiceClient{call} +} + +type resolverServiceClient struct { + call func(ctx context.Context, procedure string, req, res proto.Message) error +} + +func (c *resolverServiceClient) GetSecrets(ctx context.Context, req *v1.GetSecretsRequest) (*v1.GetSecretsResponse, error) { + res := &v1.GetSecretsResponse{} + if err := c.call(ctx, ResolverServiceGetSecretsProcedure, req, res); err != nil { + return nil, err + } + return res, nil +} + +// AuthorizerServiceClient is a client for the resolver.v1.AuthorizerService service. +type AuthorizerServiceClient interface { + // Preflight: authorizes the caller for the patterns ahead of use, valid + // until the returned expiry. + Authorize(context.Context, *v1.AuthorizeRequest) (*v1.AuthorizeResponse, error) +} + +// NewAuthorizerServiceClient constructs a client for the resolver.v1.AuthorizerService service that sends each request through call. +func NewAuthorizerServiceClient(call func(ctx context.Context, procedure string, req, res proto.Message) error) AuthorizerServiceClient { + return &authorizerServiceClient{call} +} + +type authorizerServiceClient struct { + call func(ctx context.Context, procedure string, req, res proto.Message) error +} + +func (c *authorizerServiceClient) Authorize(ctx context.Context, req *v1.AuthorizeRequest) (*v1.AuthorizeResponse, error) { + res := &v1.AuthorizeResponse{} + if err := c.call(ctx, AuthorizerServiceAuthorizeProcedure, req, res); err != nil { + return nil, err + } + return res, nil +} diff --git a/vendor/github.com/docker/secrets-engine/client/client.go b/vendor/github.com/docker/secrets-engine/client/client.go new file mode 100644 index 000000000000..0536ddfcbaec --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/client.go @@ -0,0 +1,387 @@ +// Copyright 2025-2026 Docker, 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 client + +import ( + "context" + "errors" + "fmt" + "net" + "net/http" + "time" + + "google.golang.org/protobuf/proto" + + healthv1 "github.com/docker/secrets-engine/client/api/health/v1" + "github.com/docker/secrets-engine/client/api/health/v1/healthv1rpc" + pluginsv1 "github.com/docker/secrets-engine/client/api/plugins/v1" + "github.com/docker/secrets-engine/client/api/plugins/v1/pluginsv1rpc" + "github.com/docker/secrets-engine/client/api/resolver" + resolverv1 "github.com/docker/secrets-engine/client/api/resolver/v1" + "github.com/docker/secrets-engine/client/api/resolver/v1/resolverv1rpc" + clientconfig "github.com/docker/secrets-engine/client/config" + "github.com/docker/secrets-engine/client/dockerhub" + "github.com/docker/secrets-engine/client/rpc" + "github.com/docker/secrets-engine/client/version" + "github.com/docker/secrets-engine/secrets" +) + +type ( + Envelope = secrets.Envelope + ID = secrets.ID + Pattern = secrets.Pattern + AuthorizeResponse = resolver.AuthorizeResponse + DaemonVersion = version.DaemonVersion +) + +var ( + ParseID = secrets.ParseID + MustParseID = secrets.MustParseID + + ParsePattern = secrets.ParsePattern + MustParsePattern = secrets.MustParsePattern + + ErrSecretNotFound = secrets.ErrNotFound + ErrAccessDenied = secrets.ErrAccessDenied +) + +var _ resolver.Resolver = &client{} + +type Option func(c *config) error + +func WithSocketPath(path string) Option { + return func(s *config) error { + if path == "" { + return errors.New("no path provided") + } + if s.dialContext != nil { + return errors.New("cannot set socket path and dial") + } + s.socketPath = path + s.dialContext = dialFromPath(path) + return nil + } +} + +func WithDialContext(dialContext func(ctx context.Context, network, addr string) (net.Conn, error)) Option { + return func(s *config) error { + if s.dialContext != nil { + return errors.New("cannot set socket path and dial") + } + s.dialContext = dialContext + return nil + } +} + +// WithTimeout overrides the request timeout of the client. +// +// It is useful to set if there are hard-limits to when the client must wait +// for the server to accept the request. +// +// A timeout of 0 means no request timeout will be applied. +// Negative durations are not allowed and will result in an error. +func WithTimeout(timeout time.Duration) Option { + return func(s *config) error { + if timeout < 0 { + return errors.New("request timeout duration cannot be negative") + } + s.requestTimeout = timeout + return nil + } +} + +// WithResponseTimeout overrides the response header timeout of the client. +// By default no timeout is applied, because a request may block on user +// interaction. 0 means no timeout; negative durations return an error. +func WithResponseTimeout(responseTimeout time.Duration) Option { + return func(s *config) error { + if responseTimeout < 0 { + return errors.New("response timeout duration cannot be negative") + } + s.responseTimeout = responseTimeout + return nil + } +} + +type dial func(ctx context.Context, network, addr string) (net.Conn, error) + +type config struct { + socketPath string + dialContext dial + requestTimeout time.Duration + responseTimeout time.Duration +} + +var ( + _ Client = &client{} + _ PluginManagement = &client{} +) + +type client struct { + resolverClient resolverv1rpc.ResolverServiceClient + authorizerClient resolverv1rpc.AuthorizerServiceClient + versionClient healthv1rpc.VersionServiceClient + pluginsClient pluginsv1rpc.PluginManagementServiceClient +} + +// Authorize decides access to the patterns. The decision holds until the +// response expiry. A zero expiry means the decision never expires. +func (c client) Authorize(ctx context.Context, patterns ...secrets.Pattern) (resolver.AuthorizeResponse, error) { + msgPatterns := make([]string, 0, len(patterns)) + for _, p := range patterns { + msgPatterns = append(msgPatterns, p.String()) + } + resp, err := c.authorizerClient.Authorize(ctx, resolverv1.AuthorizeRequest_builder{Patterns: msgPatterns}.Build()) + if err != nil { + if rpc.CodeOf(err) == rpc.CodePermissionDenied { + return resolver.AuthorizeResponse{}, secrets.ErrAccessDenied + } + return resolver.AuthorizeResponse{}, err + } + var expiry time.Time + if resp.HasExpiresAt() { + expiry = resp.GetExpiresAt().AsTime() + } + return resolver.AuthorizeResponse{ + Expiry: expiry, + Allow: resp.GetDecision() == resolverv1.Decision_DECISION_ALLOW, + }, nil +} + +func (c client) GetSecrets(ctx context.Context, pattern secrets.Pattern) ([]secrets.Envelope, error) { + resp, err := c.resolverClient.GetSecrets(ctx, resolverv1.GetSecretsRequest_builder{Pattern: proto.String(pattern.String())}.Build()) + if err != nil { + if rpc.CodeOf(err) == rpc.CodeNotFound { + return nil, secrets.ErrNotFound + } + return nil, err + } + var envelopes []secrets.Envelope + for _, item := range resp.GetEnvelopes() { + id, err := secrets.ParseID(item.GetId()) + if err != nil { + continue + } + envelopes = append(envelopes, secrets.Envelope{ + ID: id, + Value: item.GetValue(), + Metadata: item.GetMetadata(), + Provider: item.GetProvider(), + Version: item.GetVersion(), + CreatedAt: item.GetCreatedAt().AsTime(), + ResolvedAt: item.GetResolvedAt().AsTime(), + ExpiresAt: item.GetExpiresAt().AsTime(), + }) + } + return envelopes, nil +} + +func (c client) HubAuth(opts ...dockerhub.Option) dockerhub.ClientAuth { + return dockerhub.New(c, opts...) +} + +func (c client) Version(ctx context.Context) (DaemonVersion, error) { + resp, err := c.versionClient.GetVersion(ctx, healthv1.GetVersionRequest_builder{}.Build()) + if err != nil { + return DaemonVersion{}, err + } + ver, err := version.NewVersion(resp.GetVersion()) + if err != nil { + return DaemonVersion{}, fmt.Errorf("parsing daemon version %q: %w", resp.GetVersion(), err) + } + return DaemonVersion{Version: ver, Date: resp.GetDate(), CommitHash: resp.GetCommitHash()}, nil +} + +// Client is the interface for interacting with the secrets engine daemon. +type Client interface { + resolver.Resolver + resolver.Authorizer + + // Version returns the name and version reported by the daemon. + Version(ctx context.Context) (DaemonVersion, error) + + // HubAuth returns a Docker Hub authentication accessor backed by this client. + HubAuth(opts ...dockerhub.Option) dockerhub.ClientAuth +} + +type PluginManagement interface { + ListPlugins(ctx context.Context) ([]PluginInfo, error) + EnablePlugin(ctx context.Context, name string) error + DisablePlugin(ctx context.Context, name string) error +} + +func PluginManagementFromClient(c Client) (PluginManagement, error) { + m, ok := c.(PluginManagement) + if !ok { + return nil, errors.New("client does not implement PluginManagement") + } + return m, nil +} + +const baseURL = "http://unix" + +// call sends a unary request in the Connect protocol: +// https://connectrpc.com/docs/protocol#unary-request +func call(rpcClient *rpc.Client, socketPath string) func(ctx context.Context, procedure string, req, resp proto.Message) error { + return func(ctx context.Context, procedure string, req, resp proto.Message) error { + err := rpcClient.Call(ctx, procedure, req, resp) + if isDialError(err) { + return connectError(socketPath, err) + } + return err + } +} + +func isDialError(err error) bool { + if err == nil { + return false + } + var oe *net.OpError + if errors.As(err, &oe) && (oe.Op == "dial" || oe.Op == "connect") { + return true + } + return false +} + +func connectError(socketPath string, err error) error { + if errors.Is(err, context.Canceled) { + return err + } + return &ConnectError{Reason: connectReason(err), SocketPath: socketPath, Err: err} +} + +// New creates a client that connects to config.StandaloneSocketPath by default. +// To connect to Docker Desktop, use WithSocketPath(config.DesktopSocketPath()). +func New(options ...Option) (Client, error) { + cfg := &config{ + requestTimeout: clientconfig.DefaultClientRequestTimeout, + responseTimeout: clientconfig.DefaultClientResponseHeaderTimeout, + } + for _, opt := range options { + if err := opt(cfg); err != nil { + return nil, err + } + } + if cfg.dialContext == nil { + cfg.socketPath = clientconfig.StandaloneSocketPath() + cfg.dialContext = dialFromPath(cfg.socketPath) + } + c := &http.Client{ + Transport: &http.Transport{ + // re-use the same connection to the runtime, this speeds up subsequent + // calls. + MaxConnsPerHost: clientconfig.DefaultClientMaxConnsPerHost, + MaxIdleConnsPerHost: clientconfig.DefaultClientMaxIdleConnsPerHost, + // keep the connection alive (good for long-lived clients) + IdleConnTimeout: clientconfig.DefaultClientIdleConnTimeout, + // no timeout by default; override with [WithResponseTimeout] + ResponseHeaderTimeout: cfg.responseTimeout, + TLSHandshakeTimeout: clientconfig.DefaultClientTLSHandshakeTimeout, + + DialContext: cfg.dialContext, + DisableKeepAlives: false, + DisableCompression: false, + ForceAttemptHTTP2: true, + }, + // by default Timeout will be 0 (meaning no timeout) + // it can be overwritten with [WithTimeout] + Timeout: cfg.requestTimeout, + } + callEngine := call(rpc.NewClient(c, baseURL), cfg.socketPath) + return &client{ + resolverClient: resolverv1rpc.NewResolverServiceClient(callEngine), + authorizerClient: resolverv1rpc.NewAuthorizerServiceClient(callEngine), + versionClient: healthv1rpc.NewVersionServiceClient(callEngine), + pluginsClient: pluginsv1rpc.NewPluginManagementServiceClient(callEngine), + }, nil +} + +func (c client) ListPlugins(ctx context.Context) ([]PluginInfo, error) { + resp, err := c.pluginsClient.ListPlugins(ctx, pluginsv1.ListPluginsRequest_builder{}.Build()) + if err != nil { + return nil, err + } + var result []PluginInfo + for _, item := range resp.GetPlugins() { + name, err := version.NewName(item.GetName()) + if err != nil { + continue + } + ver, err := version.NewVersion(item.GetVersion()) + if err != nil { + continue + } + info := PluginInfo{ + Name: name, + Version: ver, + Disabled: item.GetDisabled(), + External: item.GetExternal(), + Configurable: item.GetConfigurable(), + RunStatus: item.GetRunStatus(), + StatusMessage: item.GetStatusMessage(), + } + switch item.WhichMetadata() { + case pluginsv1.Plugin_SecretsProvider_case: + pattern, err := secrets.ParsePattern(item.GetSecretsProvider().GetPattern()) + if err != nil { + continue + } + info.SecretsProvider = &SecretsProviderMetadata{Pattern: pattern} + case pluginsv1.Plugin_AccessControlModule_case: + info.AccessControlModule = &AccessControlModuleMetadata{} + } + result = append(result, info) + } + return result, nil +} + +func (c client) EnablePlugin(ctx context.Context, name string) error { + r := pluginsv1.EnablePluginRequest_builder{}.Build() + r.SetName(name) + _, err := c.pluginsClient.EnablePlugin(ctx, r) + return err +} + +func (c client) DisablePlugin(ctx context.Context, name string) error { + r := pluginsv1.DisablePluginRequest_builder{}.Build() + r.SetName(name) + _, err := c.pluginsClient.DisablePlugin(ctx, r) + return err +} + +type PluginInfo struct { + Name version.Name + Version version.Version + Disabled bool + External bool + Configurable bool + RunStatus pluginsv1.RunStatus + StatusMessage string + SecretsProvider *SecretsProviderMetadata + AccessControlModule *AccessControlModuleMetadata +} + +type AccessControlModuleMetadata struct{} + +type SecretsProviderMetadata struct { + Pattern secrets.Pattern +} + +func dialFromPath(path string) dial { + return func(ctx context.Context, _, _ string) (net.Conn, error) { + d := &net.Dialer{} + return d.DialContext(ctx, "unix", path) + } +} diff --git a/vendor/github.com/docker/secrets-engine/client/config/defaults.go b/vendor/github.com/docker/secrets-engine/client/config/defaults.go new file mode 100644 index 000000000000..44e20aee0f3f --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/config/defaults.go @@ -0,0 +1,42 @@ +// Copyright 2025-2026 Docker, 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 config + +import "time" + +const ( + // DefaultClientRequestTimeout is the default timeout for clients to handle a request. + DefaultClientRequestTimeout = time.Duration(0) // 0 means no limit + // DefaultClientResponseHeaderTimeout is the default timeout for response + // headers, excluding the body. No limit by default: a request may block + // on user interaction daemon-side. Use + // [github.com/docker/secrets-engine/client.WithResponseTimeout] or a + // context deadline for a hard bound. + DefaultClientResponseHeaderTimeout = time.Duration(0) // 0 means no limit + // DefaultClientTLSHandshakeTimeout is the default timeout for clients to handle + // tls handshakes. It should usually be short. + DefaultClientTLSHandshakeTimeout = time.Second + // DefaultClientIdleConnTimeout is the time a connection may stay alive for. + // Clients that are long-lived take advantage of re-using the same connection + // when making subsequent requests. This reduces latency. + DefaultClientIdleConnTimeout = 90 * time.Second + // DefaultClientMaxConnsPerHost is the maximum number of open connections + // to the same host. + DefaultClientMaxConnsPerHost = 100 + // DefaultClientMaxIdleConnsPerHost is the maximum number of idle connections + // to the same host. Long-lived clients can re-use a connection from the + // connection pool. + DefaultClientMaxIdleConnsPerHost = 10 +) diff --git a/vendor/github.com/docker/secrets-engine/client/config/socket.go b/vendor/github.com/docker/secrets-engine/client/config/socket.go new file mode 100644 index 000000000000..144e5f63fbec --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/config/socket.go @@ -0,0 +1,37 @@ +// Copyright 2025-2026 Docker, 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 config + +import ( + "os" + "path/filepath" +) + +// DesktopSocketPath returns the Secrets Engine socket path used by Docker Desktop. +// +// - Linux: $XDG_CACHE_HOME/docker-secrets-engine/engine.sock, or +// $HOME/.cache/docker-secrets-engine/engine.sock when XDG_CACHE_HOME is unset. +// - macOS: $HOME/Library/Caches/docker-secrets-engine/engine.sock. +// - Windows: %LOCALAPPDATA%\docker-secrets-engine\engine.sock. +// +// If the user cache directory cannot be determined, it returns +// /docker-secrets-engine/engine.sock, where is the directory returned +// by [os.TempDir]. +func DesktopSocketPath() string { + if dir, err := os.UserCacheDir(); err == nil { + return filepath.Join(dir, "docker-secrets-engine", "engine.sock") + } + return filepath.Join(os.TempDir(), "docker-secrets-engine", "engine.sock") +} diff --git a/vendor/github.com/docker/secrets-engine/client/config/socket_darwin.go b/vendor/github.com/docker/secrets-engine/client/config/socket_darwin.go new file mode 100644 index 000000000000..83b1cf698811 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/config/socket_darwin.go @@ -0,0 +1,33 @@ +// Copyright 2025-2026 Docker, 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 darwin + +package config + +import ( + "os" + "path/filepath" +) + +// StandaloneSocketPath returns the standalone Secrets Engine's listening socket +// path, $HOME/Library/Caches/docker-secrets-engine/daemon.sock. +// If HOME is unset, it uses $TMPDIR/docker-secrets-engine/daemon.sock, or +// /tmp/docker-secrets-engine/daemon.sock when TMPDIR is also unset. +func StandaloneSocketPath() string { + if dir, err := os.UserCacheDir(); err == nil { + return filepath.Join(dir, "docker-secrets-engine", "daemon.sock") + } + return filepath.Join(os.TempDir(), "docker-secrets-engine", "daemon.sock") +} diff --git a/vendor/github.com/docker/secrets-engine/client/config/socket_linux.go b/vendor/github.com/docker/secrets-engine/client/config/socket_linux.go new file mode 100644 index 000000000000..6055c4cd22d4 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/config/socket_linux.go @@ -0,0 +1,37 @@ +// Copyright 2025-2026 Docker, 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 linux + +package config + +import ( + "fmt" + "os" +) + +// StandaloneSocketPath returns the address of the standalone Secrets Engine's +// listening socket, @docker-secrets-engine//daemon.sock. +// For example, UID 1000 uses @docker-secrets-engine/1000/daemon.sock. +// +// On Linux it is an abstract Unix domain socket: the address has a leading +// "@", which Go's net package maps to a NUL byte, placing the socket in the +// abstract namespace instead of on the filesystem. +// +// The address is namespaced by the user's UID so daemons run by different +// users on the same host do not collide (the abstract namespace is shared per +// network namespace, not per user as a filesystem path would be). +func StandaloneSocketPath() string { + return fmt.Sprintf("@docker-secrets-engine/%d/daemon.sock", os.Getuid()) +} diff --git a/vendor/github.com/docker/secrets-engine/client/config/socket_windows.go b/vendor/github.com/docker/secrets-engine/client/config/socket_windows.go new file mode 100644 index 000000000000..759dcfbf00ae --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/config/socket_windows.go @@ -0,0 +1,34 @@ +// Copyright 2025-2026 Docker, 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 windows + +package config + +import ( + "os" + "path/filepath" +) + +// StandaloneSocketPath returns the standalone Secrets Engine's listening socket +// path, %LOCALAPPDATA%\DockerSecretsEngine\service\daemon.sock. +// If LOCALAPPDATA is unset, it uses +// %USERPROFILE%\AppData\Local\DockerSecretsEngine\service\daemon.sock. +func StandaloneSocketPath() string { + base := os.Getenv("LOCALAPPDATA") + if base == "" { + base = filepath.Join(os.Getenv("USERPROFILE"), "AppData", "Local") + } + return filepath.Join(base, "DockerSecretsEngine", "service", "daemon.sock") +} diff --git a/vendor/github.com/docker/secrets-engine/client/dockerhub/dockerhub.go b/vendor/github.com/docker/secrets-engine/client/dockerhub/dockerhub.go new file mode 100644 index 000000000000..d25bc1325ae7 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/dockerhub/dockerhub.go @@ -0,0 +1,416 @@ +// Copyright 2026 Docker, 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 dockerhub reads Docker Hub access tokens and account profiles from +// the secrets engine. Obtain a [ClientAuth] from the client's HubAuth method, +// or from any [resolver.Resolver] via [New]. +package dockerhub + +import ( + "context" + "encoding/base64" + "encoding/json" + "errors" + "fmt" + "math" + "strconv" + "strings" + "time" + + "github.com/docker/secrets-engine/client/api/resolver" + "github.com/docker/secrets-engine/client/realms" + "github.com/docker/secrets-engine/secrets" +) + +var ( + // ErrNoSession means no Docker Hub credential is stored for the account. + ErrNoSession = errors.New("user is not authenticated for this application") + // ErrNoDefaultProfile means no account is set as the default. It wraps + // [ErrNoSession]. + ErrNoDefaultProfile = fmt.Errorf("no default account profile set: %w", ErrNoSession) + // ErrMissingAccessToken means the stored credential has no access token. + // It wraps [ErrNoSession]. + ErrMissingAccessToken error = &noSessionError{"no access token in payload"} + // ErrInvalidAccessToken means the stored access token is not a JWT. It + // wraps [ErrNoSession]. + ErrInvalidAccessToken error = &noSessionError{"access token is not a JWT"} +) + +type noSessionError struct{ msg string } + +func (e *noSessionError) Error() string { return e.msg } + +func (*noSessionError) Unwrap() error { return ErrNoSession } + +var ( + defaultProfileKey = secrets.MustParsePattern("default") + singleEntryKey = secrets.MustParsePattern("*") +) + +// UserSession is a stored Docker Hub credential. +type UserSession struct { + // AccessToken is a Docker Hub issued JWT. + AccessToken string `json:"access_token"` + // Claims are zero when the payload carries none. + Claims Claims `json:"claims"` +} + +// Expired reports whether the access token has expired. It is +// ExpiresWithin(0). +func (s UserSession) Expired() bool { + return s.ExpiresWithin(0) +} + +// ExpiresWithin reports whether the access token will expire within the next given duration. +// Sessions without [Claims.ExpiresAt] report as expired by default. +func (s UserSession) ExpiresWithin(leeway time.Duration) bool { + exp := s.Claims.ExpiresAt + if exp == nil || exp.IsZero() { + return true + } + return !time.Now().Add(leeway).Before(exp.Time) +} + +// Claims are the claims of a Docker Hub access token. +type Claims struct { + Issuer string `json:"iss,omitempty"` + Subject string `json:"sub,omitempty"` + Audience Audience `json:"aud,omitempty"` + ExpiresAt *NumericDate `json:"exp,omitempty"` + NotBefore *NumericDate `json:"nbf,omitempty"` + IssuedAt *NumericDate `json:"iat,omitempty"` + ID string `json:"jti,omitempty"` + + // Scope is a space-delimited list of granted scopes. + Scope string `json:"scope,omitempty"` + // AppName is the Docker client application the token was issued to. + AppName string `json:"app_name"` + UUID string `json:"uuid"` + // Source is formatted as `docker_{type}|{id}`. + Source string `json:"source"` + SessionID string `json:"session_id"` + ClientID string `json:"client_id,omitempty"` + ClientName string `json:"client_name,omitempty"` + Email string `json:"email"` + Username string `json:"username"` +} + +// NumericDate is an RFC 7519 numeric date: UNIX epoch seconds. It marshals +// truncated to whole seconds. +type NumericDate struct { + time.Time +} + +func (d NumericDate) MarshalJSON() ([]byte, error) { + return []byte(strconv.FormatInt(d.Unix(), 10)), nil +} + +func (d *NumericDate) UnmarshalJSON(data []byte) error { + if string(data) == "null" { + return nil + } + var epoch float64 + if err := json.Unmarshal(data, &epoch); err != nil { + return fmt.Errorf("parse numeric date: %w", err) + } + if math.Abs(epoch) > 1e15 { + return fmt.Errorf("parse numeric date: %v is out of range", epoch) + } + seconds, fraction := math.Modf(epoch) + d.Time = time.Unix(int64(seconds), int64(fraction*float64(time.Second))) + return nil +} + +// Audience is the "aud" claim: a single string or an array of strings. +type Audience []string + +func (a *Audience) UnmarshalJSON(data []byte) error { + var value any + if err := json.Unmarshal(data, &value); err != nil { + return fmt.Errorf("parse audience: %w", err) + } + switch v := value.(type) { + case nil: + case string: + *a = Audience{v} + case []any: + audience := make(Audience, 0, len(v)) + for _, item := range v { + s, ok := item.(string) + if !ok { + return fmt.Errorf("parse audience: unexpected element type %T", item) + } + audience = append(audience, s) + } + *a = audience + default: + return fmt.Errorf("parse audience: unexpected type %T", value) + } + return nil +} + +// Profile describes a signed-in Docker Hub account. +type Profile struct { + // UserID is the secret ID where the account's credential is stored. + UserID string `json:"user_id"` + // OriginalSignInApp is the Docker client application the user signed in from. + OriginalSignInApp string `json:"original_sign_in_app"` + Username string `json:"username"` + Email string `json:"email"` + SignInDate time.Time `json:"sign_in_date"` +} + +// parseUserSession decodes a docker/auth/hub/** envelope into a [UserSession]. +func parseUserSession(envelope secrets.Envelope) (UserSession, error) { + var session UserSession + if err := json.Unmarshal(envelope.Value, &session); err != nil { + return UserSession{}, fmt.Errorf("decode user session: %w", err) + } + if session.AccessToken == "" { + return UserSession{}, fmt.Errorf("decode user session: %w", ErrMissingAccessToken) + } + if err := checkJWT(session.AccessToken); err != nil { + return UserSession{}, fmt.Errorf("decode user session: %w: %w", ErrInvalidAccessToken, err) + } + return session, nil +} + +func checkJWT(token string) error { + segments := strings.Split(token, ".") + if len(segments) != 3 { + return fmt.Errorf("expected 3 dot-separated segments, got %d", len(segments)) + } + var header struct { + Alg string `json:"alg"` + } + if err := decodeSegment(segments[0], &header); err != nil { + return fmt.Errorf("header: %w", err) + } + if header.Alg == "" { + return errors.New("header: missing alg") + } + var payload map[string]json.RawMessage + if err := decodeSegment(segments[1], &payload); err != nil { + return fmt.Errorf("payload: %w", err) + } + if payload == nil { + return errors.New("payload: not a JSON object") + } + if segments[2] == "" { + return errors.New("missing signature") + } + if _, err := base64.RawURLEncoding.DecodeString(segments[2]); err != nil { + return fmt.Errorf("signature: %w", err) + } + return nil +} + +func decodeSegment(segment string, v any) error { + data, err := base64.RawURLEncoding.DecodeString(segment) + if err != nil { + return err + } + return json.Unmarshal(data, v) +} + +// parseProfile decodes a docker/auth/metadata/hub/** envelope into a [Profile]. +func parseProfile(envelope secrets.Envelope) (Profile, error) { + var profile Profile + if err := json.Unmarshal(envelope.Value, &profile); err != nil { + return Profile{}, fmt.Errorf("decode profile metadata: %w", err) + } + if profile.UserID == "" { + return Profile{}, errors.New("decode profile metadata: no user ID in payload") + } + return profile, nil +} + +// ClientAuth reads Docker Hub authentication state from the secrets engine. +type ClientAuth interface { + // ListProfiles returns the profiles of all signed-in accounts. + ListProfiles(ctx context.Context) ([]Profile, error) + // GetDefaultProfile returns the default account's profile, or + // [ErrNoDefaultProfile] when no default is set. + GetDefaultProfile(ctx context.Context) (Profile, error) + // GetDefaultSession returns the default account's session: + // [ErrNoDefaultProfile] when no default is set, [ErrNoSession] when its + // credential is missing. + GetDefaultSession(ctx context.Context) (UserSession, error) + // GetSession returns the session for username, or [ErrNoSession]. + GetSession(ctx context.Context, username string) (UserSession, error) +} + +// Option configures a [ClientAuth]. +type Option func(*config) + +type config struct { + accounts secrets.Pattern + profiles secrets.Pattern + defaultEntry secrets.Pattern + accountEntry secrets.Pattern +} + +// Staging switches the lookup to the Docker Hub staging realms. +func Staging() Option { + return func(c *config) { + c.accounts = realms.DockerHubStagingAuthentication + c.profiles = realms.DockerHubStagingAuthenticationMetadata + } +} + +func newConfig(opts []Option) config { + cfg := config{ + accounts: realms.DockerHubAuthentication, + profiles: realms.DockerHubAuthenticationMetadata, + } + for _, opt := range opts { + opt(&cfg) + } + cfg.defaultEntry = mustExpand(cfg.profiles, defaultProfileKey) + cfg.accountEntry = mustExpand(cfg.accounts, singleEntryKey) + return cfg +} + +func mustExpand(realm, key secrets.Pattern) secrets.Pattern { + expanded, err := realm.ExpandPattern(key) + if err != nil { + panic(fmt.Sprintf("dockerhub: expand %s in %s: %v", key, realm, err)) + } + return expanded +} + +var _ ClientAuth = clientAuth{} + +type clientAuth struct { + engine resolver.Resolver + cfg config +} + +// New returns a [ClientAuth] backed by engine. It panics on a nil engine. +func New(engine resolver.Resolver, opts ...Option) ClientAuth { + if engine == nil { + panic("dockerhub: secrets engine client is required") + } + return clientAuth{engine: engine, cfg: newConfig(opts)} +} + +func (c clientAuth) ListProfiles(ctx context.Context) ([]Profile, error) { + envelopes, err := c.engine.GetSecrets(ctx, c.cfg.profiles) + if errors.Is(err, secrets.ErrNotFound) { + return nil, nil + } + if err != nil { + return nil, fmt.Errorf("list account profiles: %w", err) + } + var profiles []Profile + var errs []error + seen := make(map[string]bool, len(envelopes)) + for _, envelope := range envelopes { + // The default entry duplicates an account's profile. + if envelope.ID != nil && c.cfg.defaultEntry.Match(envelope.ID) { + continue + } + profile, err := parseProfile(envelope) + if err != nil { + errs = append(errs, err) + continue + } + if seen[profile.UserID] { + continue + } + seen[profile.UserID] = true + profiles = append(profiles, profile) + } + if len(profiles) == 0 && len(errs) > 0 { + return nil, errors.Join(errs...) + } + return profiles, nil +} + +func (c clientAuth) GetDefaultProfile(ctx context.Context) (Profile, error) { + envelopes, err := c.engine.GetSecrets(ctx, c.cfg.defaultEntry) + if errors.Is(err, secrets.ErrNotFound) { + return Profile{}, ErrNoDefaultProfile + } + if err != nil { + return Profile{}, fmt.Errorf("retrieve default account metadata: %w", err) + } + return parseFirst(envelopes, parseProfile, ErrNoDefaultProfile) +} + +func (c clientAuth) GetDefaultSession(ctx context.Context) (UserSession, error) { + profile, err := c.GetDefaultProfile(ctx) + if err != nil { + return UserSession{}, err + } + // Require a wildcard-free ID naming one account entry in the accounts + // realm, so a tampered profile cannot address an arbitrary secret. + id, err := secrets.ParseID(profile.UserID) + if err != nil { + return UserSession{}, fmt.Errorf("default profile user id: %w", err) + } + if !c.cfg.accountEntry.Match(id) { + return UserSession{}, fmt.Errorf("default profile user id %q is not an account entry in the %s realm", profile.UserID, c.cfg.accounts) + } + return c.getSession(ctx, exactPattern(id)) +} + +func (c clientAuth) GetSession(ctx context.Context, username string) (UserSession, error) { + if strings.Contains(username, "/") { + return UserSession{}, fmt.Errorf("invalid username %q: must not contain '/'", username) + } + user, err := secrets.ParseID(username) + if err != nil { + return UserSession{}, fmt.Errorf("invalid username %q: %w", username, err) + } + id, err := c.cfg.accounts.ExpandID(user) + if err != nil { + return UserSession{}, err + } + return c.getSession(ctx, exactPattern(id)) +} + +func (c clientAuth) getSession(ctx context.Context, pattern secrets.Pattern) (UserSession, error) { + envelopes, err := c.engine.GetSecrets(ctx, pattern) + if errors.Is(err, secrets.ErrNotFound) { + return UserSession{}, ErrNoSession + } + if err != nil { + return UserSession{}, fmt.Errorf("retrieve user access token: %w", err) + } + return parseFirst(envelopes, parseUserSession, ErrNoSession) +} + +func exactPattern(id secrets.ID) secrets.Pattern { + return secrets.MustParsePattern(id.String()) +} + +// parseFirst returns the first envelope that parses. It returns notFound when +// there are no envelopes, and the joined decode errors when none parses. +func parseFirst[T any](envelopes []secrets.Envelope, parse func(secrets.Envelope) (T, error), notFound error) (T, error) { + var zero T + var errs []error + for _, envelope := range envelopes { + v, err := parse(envelope) + if err != nil { + errs = append(errs, err) + continue + } + return v, nil + } + if len(errs) == 0 { + return zero, notFound + } + return zero, errors.Join(errs...) +} diff --git a/vendor/github.com/docker/secrets-engine/client/errno_unix.go b/vendor/github.com/docker/secrets-engine/client/errno_unix.go new file mode 100644 index 000000000000..512f6aa7afce --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/errno_unix.go @@ -0,0 +1,22 @@ +// Copyright 2026 Docker, 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 !windows + +package client + +import "syscall" + +// errConnRefused is returned when dialing a socket nothing listens on. +const errConnRefused = syscall.ECONNREFUSED diff --git a/vendor/github.com/docker/secrets-engine/client/errno_windows.go b/vendor/github.com/docker/secrets-engine/client/errno_windows.go new file mode 100644 index 000000000000..f305cf75248a --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/errno_windows.go @@ -0,0 +1,20 @@ +// Copyright 2026 Docker, 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 client + +import "syscall" + +// errConnRefused is WSAECONNREFUSED; Winsock never returns syscall.ECONNREFUSED. +const errConnRefused = syscall.Errno(10061) diff --git a/vendor/github.com/docker/secrets-engine/client/errors.go b/vendor/github.com/docker/secrets-engine/client/errors.go new file mode 100644 index 000000000000..fa5f18235233 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/errors.go @@ -0,0 +1,173 @@ +// Copyright 2026 Docker, 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 client + +import ( + "context" + "errors" + "fmt" + "io/fs" + "net" + "path/filepath" + + clientconfig "github.com/docker/secrets-engine/client/config" +) + +var ( + ErrSecretsEngineNotRunning = errors.New("secrets engine is not running") + ErrSecretsEnginePermissionDenied = errors.New("permission denied connecting to the secrets engine") + ErrSecretsEngineTimeout = errors.New("secrets engine did not respond in time") +) + +type ConnectReason int + +const ( + ReasonUnknown ConnectReason = iota + ReasonNotRunning + ReasonPermissionDenied + ReasonTimeout +) + +func (r ConnectReason) String() string { + switch r { + case ReasonNotRunning: + return "not running" + case ReasonPermissionDenied: + return "permission denied" + case ReasonTimeout: + return "timeout" + default: + return "unknown" + } +} + +func (r ConnectReason) sentinel() error { + switch r { + case ReasonNotRunning: + return ErrSecretsEngineNotRunning + case ReasonPermissionDenied: + return ErrSecretsEnginePermissionDenied + case ReasonTimeout: + return ErrSecretsEngineTimeout + default: + return nil + } +} + +type ConnectError struct { + Reason ConnectReason + SocketPath string + Err error +} + +func (e *ConnectError) Error() string { + msg := "cannot connect to the secrets engine" + if s := e.Reason.sentinel(); s != nil { + msg = s.Error() + } + if e.SocketPath != "" { + msg += " at " + e.SocketPath + } + if e.Err != nil { + msg += ": " + e.Err.Error() + } + return msg +} + +func (e *ConnectError) Unwrap() error { return e.Err } + +func (e *ConnectError) Is(target error) bool { + s := e.Reason.sentinel() + return s != nil && target == s +} + +const ( + desktopNotRunningHint = "Start Docker Desktop and retry: the secrets engine runs as part of it." + desktopTimeoutHint = "The secrets engine did not respond. Restart Docker Desktop and retry." + standaloneNotRunningHint = "Start the standalone secrets engine and retry: nothing is listening on %s." + standaloneTimeoutHint = "The standalone secrets engine on %s did not respond. Restart it and retry." + customNotRunningHint = "Start the secrets engine and retry: nothing is listening on %s." + customTimeoutHint = "The secrets engine on %s did not respond. Restart it and retry." + permissionDeniedHint = "Your user lacks permission to connect to %s. Grant it read and write access to the socket and retry." +) + +// Hint returns a user friendly message to help recover from the error. +func (e *ConnectError) Hint() string { + socket := "the secrets engine socket" + if e.SocketPath != "" { + socket = fmt.Sprintf("%q", e.SocketPath) + } + kind := classifySocket(e.SocketPath) + switch e.Reason { + case ReasonNotRunning: + switch kind { + case engineDesktop: + return desktopNotRunningHint + case engineStandalone: + return fmt.Sprintf(standaloneNotRunningHint, socket) + default: + return fmt.Sprintf(customNotRunningHint, socket) + } + case ReasonTimeout: + switch kind { + case engineDesktop: + return desktopTimeoutHint + case engineStandalone: + return fmt.Sprintf(standaloneTimeoutHint, socket) + default: + return fmt.Sprintf(customTimeoutHint, socket) + } + case ReasonPermissionDenied: + return fmt.Sprintf(permissionDeniedHint, socket) + default: + return "" + } +} + +type engineKind int + +const ( + engineCustom engineKind = iota + engineDesktop + engineStandalone +) + +func classifySocket(path string) engineKind { + if path == "" { + return engineCustom + } + switch filepath.Clean(path) { + case filepath.Clean(clientconfig.DesktopSocketPath()): + return engineDesktop + case filepath.Clean(clientconfig.StandaloneSocketPath()): + return engineStandalone + default: + return engineCustom + } +} + +func connectReason(err error) ConnectReason { + var ne net.Error + switch { + case errors.Is(err, fs.ErrNotExist), errors.Is(err, errConnRefused): + return ReasonNotRunning + case errors.Is(err, fs.ErrPermission): + return ReasonPermissionDenied + case errors.Is(err, context.DeadlineExceeded), errors.As(err, &ne) && ne.Timeout(): + return ReasonTimeout + default: + return ReasonUnknown + } +} diff --git a/vendor/github.com/docker/secrets-engine/client/realms/docker.go b/vendor/github.com/docker/secrets-engine/client/realms/docker.go new file mode 100644 index 000000000000..e41a8ade431f --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/realms/docker.go @@ -0,0 +1,93 @@ +// Copyright 2026 Docker, 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 realms exposes the canonical set of Docker realm patterns that +// clients use to scope secret queries. +// +// A realm is a path-pattern contract - not a permission boundary. Clients use +// realms to declare which set of secrets they care about (e.g. Hub auth, +// registry auth, MCP OAuth). Once a realm is established its pattern MUST NOT +// change; clients may pin to a realm and treat it as a stable interface. +// +// The Docker realm hierarchy is: +// +// docker/ – all Docker secrets +// docker/auth/hub/** – Docker Hub authentication (OAuth login) +// docker/auth/hub-staging/** – Docker Hub staging authentication +// docker/auth/registry/docker/** – Docker Registry authentication +// docker/auth/metadata/hub/** – Hub account profile metadata +// docker/mcp/** – MCP-related secrets +// docker/mcp/oauth/** – MCP OAuth credentials +// docker/mcp/oauth-dcr/** – MCP Dynamic Client Registration configs +// docker/sandbox/** – Sandbox-related secrets +// docker/sandbox/oauth/** – Sandbox third-party OAuth tokens +// docker/secrets-engine/** – secrets-engine's own secrets +// +// All variables in this package are provided here as a stable, versioned +// surface for external consumers. +package realms + +import "github.com/docker/secrets-engine/secrets" + +// Docker realms all start with `docker/` as the prefix. +// +// Authentication flows done by the Docker CLI, Docker Desktop and Docker related +// products must go through `docker/auth`. +// +// Docker Hub authentication (browser based OAuth login) will be prefixed +// with `docker/auth/hub/`. +// +// Docker Registry authentication will be prefixed with +// `docker/auth/registry/docker/`. +var ( + DockerHubAuthentication = secrets.MustParsePattern("docker/auth/hub/**") + DockerHubStagingAuthentication = secrets.MustParsePattern("docker/auth/hub-staging/**") + DockerRegistryAuthentication = secrets.MustParsePattern("docker/auth/registry/docker/**") + DockerRegistryStagingAuthentication = secrets.MustParsePattern("docker/auth/registry/docker-staging/**") +) + +var ( + // DockerHubAuthenticationMetadata holds one profile entry per signed-in + // Docker Hub account, plus a default entry duplicating the default + // account's profile. + DockerHubAuthenticationMetadata = secrets.MustParsePattern("docker/auth/metadata/hub/**") + // DockerHubStagingAuthenticationMetadata is the staging variant of + // [DockerHubAuthenticationMetadata]. + DockerHubStagingAuthenticationMetadata = secrets.MustParsePattern("docker/auth/metadata/hub-staging/**") +) + +var ( + // DockerMCPDefault is the default realm used for MCP related secrets + DockerMCPDefault = secrets.MustParsePattern("docker/mcp/**") + // DockerMCPOAuth is the realm used for all MCP OAuth credentials retrieved by Docker. + DockerMCPOAuth = secrets.MustParsePattern("docker/mcp/oauth/**") + // DockerMCPOAuthDCR is the realm used to hold Dynamic Client Registered (DCR) + // OAuth configurations for supported MCP servers. + DockerMCPOAuthDCR = secrets.MustParsePattern("docker/mcp/oauth-dcr/**") +) + +var ( + // DockerSandbox is the default realm used for Sandbox related secrets + DockerSandbox = secrets.MustParsePattern("docker/sandbox/**") + // DockerSandboxOAuth is the realm used for all Sandbox OAuth credentials + // such as third-party tokens - this does not store the Docker Auth tokens. + DockerSandboxOAuth = secrets.MustParsePattern("docker/sandbox/oauth/**") +) + +var ( + // SecretsEngine is the default realm used for secrets-engine related secrets. + SecretsEngine = secrets.MustParsePattern("docker/secrets-engine/**") + // SecretsEnginePlugins is the realm used to store credentials and configuration for secrets-engine plugins. + SecretsEnginePlugins = secrets.MustParsePattern("docker/secrets-engine/plugins/**") +) diff --git a/vendor/github.com/docker/secrets-engine/client/rpc/client.go b/vendor/github.com/docker/secrets-engine/client/rpc/client.go new file mode 100644 index 000000000000..3643c37d4f60 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/rpc/client.go @@ -0,0 +1,149 @@ +// Copyright 2026 Docker, 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 rpc + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "mime" + "net/http" + "net/url" + "os" + "strconv" + "strings" + "time" + + "google.golang.org/protobuf/proto" +) + +const ( + contentTypeProto = "application/proto" + contentTypeJSON = "application/json" + + headerProtocolVersion = "Connect-Protocol-Version" + headerTimeout = "Connect-Timeout-Ms" + + protocolVersion = "1" + maxTimeoutMs = 9_999_999_999 +) + +// HTTPClient is the part of [http.Client] that a [Client] uses. +type HTTPClient interface { + Do(*http.Request) (*http.Response, error) +} + +type Client struct { + httpClient HTTPClient + baseURL string +} + +func NewClient(httpClient HTTPClient, baseURL string) *Client { + return &Client{httpClient: httpClient, baseURL: strings.TrimRight(baseURL, "/")} +} + +func (c *Client) Call(ctx context.Context, procedure string, req, res proto.Message) error { + body, err := proto.Marshal(req) + if err != nil { + return NewError(CodeInternal, fmt.Errorf("marshal request: %w", err)) + } + httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+procedure, bytes.NewReader(body)) + if err != nil { + return NewError(CodeUnknown, err) + } + httpReq.Header.Set("Content-Type", contentTypeProto) + httpReq.Header.Set(headerProtocolVersion, protocolVersion) + if deadline, ok := ctx.Deadline(); ok { + if ms := ceilMilliseconds(time.Until(deadline)); ms > 0 && ms <= maxTimeoutMs { + httpReq.Header.Set(headerTimeout, strconv.FormatInt(ms, 10)) + } + } + httpResp, err := c.httpClient.Do(httpReq) + if err != nil { + return transportError(ctx, err) + } + defer httpResp.Body.Close() + contentType, _, _ := mime.ParseMediaType(httpResp.Header.Get("Content-Type")) + if httpResp.StatusCode != http.StatusOK { + return errorFromResponse(ctx, httpResp, contentType) + } + if contentType != contentTypeProto { + return NewError(CodeUnknown, fmt.Errorf("invalid content-type %q: expecting %q", contentType, contentTypeProto)) + } + data, err := io.ReadAll(httpResp.Body) + if err != nil { + return transportError(ctx, fmt.Errorf("read response: %w", err)) + } + if err := proto.Unmarshal(data, res); err != nil { + return NewError(CodeInternal, fmt.Errorf("unmarshal response: %w", err)) + } + return nil +} + +func ceilMilliseconds(d time.Duration) int64 { + ms := d.Milliseconds() + if d%time.Millisecond > 0 { + ms++ + } + return ms +} + +func transportError(ctx context.Context, err error) *Error { + if e, ok := errors.AsType[*Error](err); ok && ctx.Err() == nil { + return e + } + if urlErr, ok := errors.AsType[*url.Error](err); ok { + err = urlErr.Err + } + if ctxErr := ctx.Err(); ctxErr != nil && !errors.Is(err, ctxErr) { + err = fmt.Errorf("%w: %w", ctxErr, err) + } + switch { + case errors.Is(err, context.Canceled): + return NewError(CodeCanceled, err) + case errors.Is(err, context.DeadlineExceeded), errors.Is(err, os.ErrDeadlineExceeded): + return NewError(CodeDeadlineExceeded, err) + default: + return NewError(CodeUnavailable, err) + } +} + +func errorFromResponse(ctx context.Context, resp *http.Response, contentType string) *Error { + if err := ctx.Err(); err != nil { + return transportError(ctx, err) + } + if deadline, ok := ctx.Deadline(); ok && !time.Now().Before(deadline) { + return NewError(CodeDeadlineExceeded, context.DeadlineExceeded) + } + code := codeFromStatus(resp.StatusCode) + if contentType != contentTypeJSON { + return NewError(code, errors.New(resp.Status)) + } + body, err := io.ReadAll(resp.Body) + if err != nil { + return transportError(ctx, fmt.Errorf("read response: %w", err)) + } + var wire wireError + if json.Unmarshal(body, &wire) != nil { + return NewError(code, errors.New(resp.Status)) + } + if wire.Code.valid() { + code = wire.Code + } + return NewError(code, errors.New(wire.Message)) +} diff --git a/vendor/github.com/docker/secrets-engine/client/rpc/error.go b/vendor/github.com/docker/secrets-engine/client/rpc/error.go new file mode 100644 index 000000000000..48495c4ebe13 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/rpc/error.go @@ -0,0 +1,117 @@ +// Copyright 2026 Docker, 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 rpc + +import ( + "errors" + "net/http" +) + +// Code is a Connect error code: https://connectrpc.com/docs/protocol#error-codes +type Code string + +const ( + CodeCanceled Code = "canceled" + CodeUnknown Code = "unknown" + CodeInvalidArgument Code = "invalid_argument" + CodeDeadlineExceeded Code = "deadline_exceeded" + CodeNotFound Code = "not_found" + CodeAlreadyExists Code = "already_exists" + CodePermissionDenied Code = "permission_denied" + CodeResourceExhausted Code = "resource_exhausted" + CodeFailedPrecondition Code = "failed_precondition" + CodeAborted Code = "aborted" + CodeOutOfRange Code = "out_of_range" + CodeUnimplemented Code = "unimplemented" + CodeInternal Code = "internal" + CodeUnavailable Code = "unavailable" + CodeDataLoss Code = "data_loss" + CodeUnauthenticated Code = "unauthenticated" +) + +func (c Code) valid() bool { + switch c { + case CodeCanceled, CodeUnknown, CodeInvalidArgument, CodeDeadlineExceeded, + CodeNotFound, CodeAlreadyExists, CodePermissionDenied, CodeResourceExhausted, + CodeFailedPrecondition, CodeAborted, CodeOutOfRange, CodeUnimplemented, + CodeInternal, CodeUnavailable, CodeDataLoss, CodeUnauthenticated: + return true + default: + return false + } +} + +// Error is a failed call. A handler returns one to choose the code its caller +// sees. A [Client] returns one for every call that fails. +type Error struct { + code Code + err error +} + +// NewError annotates err with code. +func NewError(code Code, err error) *Error { + return &Error{code: code, err: err} +} + +func (e *Error) Code() Code { return e.code } + +// Message returns the text of the underlying error, without the code. +func (e *Error) Message() string { + if e.err == nil { + return "" + } + return e.err.Error() +} + +func (e *Error) Error() string { + if msg := e.Message(); msg != "" { + return string(e.code) + ": " + msg + } + return string(e.code) +} + +func (e *Error) Unwrap() error { return e.err } + +// CodeOf returns the code of the first [Error] in err's chain, and +// CodeUnknown if the chain holds none. +func CodeOf(err error) Code { + if e, ok := errors.AsType[*Error](err); ok { + return e.code + } + return CodeUnknown +} + +type wireError struct { + Code Code `json:"code"` + Message string `json:"message,omitempty"` +} + +// https://connectrpc.com/docs/protocol#http-to-error-code +func codeFromStatus(status int) Code { + switch status { + case http.StatusBadRequest: + return CodeInternal + case http.StatusUnauthorized: + return CodeUnauthenticated + case http.StatusForbidden: + return CodePermissionDenied + case http.StatusNotFound: + return CodeUnimplemented + case http.StatusTooManyRequests, http.StatusBadGateway, http.StatusServiceUnavailable, http.StatusGatewayTimeout: + return CodeUnavailable + default: + return CodeUnknown + } +} diff --git a/vendor/github.com/docker/secrets-engine/client/version/name.go b/vendor/github.com/docker/secrets-engine/client/version/name.go new file mode 100644 index 000000000000..0eb1a52dce24 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/version/name.go @@ -0,0 +1,62 @@ +// Copyright 2025-2026 Docker, 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 version + +import ( + "errors" + "fmt" +) + +var ErrEmptyName = errors.New("empty name") + +type Name interface { + String() string +} + +type name struct { + value string +} + +func (n *name) String() string { + return n.value +} + +// NewName creates a new [Name] from a string +// If a validation error occurs, it returns nil and the error. +func NewName(s string) (Name, error) { + if err := validName(s); err != nil { + return nil, fmt.Errorf("parsing name: %w", err) + } + return &name{ + value: s, + }, nil +} + +// MustNewName creates a new Name as [NewName] does, but panics when a validation +// error occurs. +func MustNewName(s string) Name { + v, err := NewName(s) + if err != nil { + panic(err) + } + return v +} + +func validName(s string) error { + if s == "" { + return ErrEmptyName + } + return nil +} diff --git a/vendor/github.com/docker/secrets-engine/client/version/semver.go b/vendor/github.com/docker/secrets-engine/client/version/semver.go new file mode 100644 index 000000000000..075adb120851 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/version/semver.go @@ -0,0 +1,158 @@ +// Copyright 2026 Docker, 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 version + +import "strings" + +type semver struct { + major, minor, patch string + prerelease []string +} + +func parseSemver(v string) (semver, bool) { + s, ok := strings.CutPrefix(v, "v") + if !ok { + return semver{}, false + } + s, build, hasBuild := strings.Cut(s, "+") + if hasBuild && !validIdentifiers(build, false) { + return semver{}, false + } + core, pre, hasPre := strings.Cut(s, "-") + if hasPre && !validIdentifiers(pre, true) { + return semver{}, false + } + parts := strings.Split(core, ".") + if len(parts) > 3 || (len(parts) < 3 && (hasPre || hasBuild)) { + return semver{}, false + } + for _, p := range parts { + if !isNumeric(p) || (len(p) > 1 && p[0] == '0') { + return semver{}, false + } + } + for len(parts) < 3 { + parts = append(parts, "0") + } + sv := semver{major: parts[0], minor: parts[1], patch: parts[2]} + if hasPre { + sv.prerelease = strings.Split(pre, ".") + } + return sv, true +} + +func validIdentifiers(s string, prerelease bool) bool { + for id := range strings.SplitSeq(s, ".") { + if id == "" { + return false + } + for i := 0; i < len(id); i++ { + if !isIdentifierChar(id[i]) { + return false + } + } + if prerelease && len(id) > 1 && id[0] == '0' && isNumeric(id) { + return false + } + } + return true +} + +func isIdentifierChar(c byte) bool { + switch { + case '0' <= c && c <= '9', 'a' <= c && c <= 'z', 'A' <= c && c <= 'Z', c == '-': + return true + } + return false +} + +func isNumeric(s string) bool { + if s == "" { + return false + } + for i := 0; i < len(s); i++ { + if s[i] < '0' || s[i] > '9' { + return false + } + } + return true +} + +func compareNumeric(a, b string) int { + if c := len(a) - len(b); c != 0 { + return sign(c) + } + return strings.Compare(a, b) +} + +func sign(n int) int { + switch { + case n < 0: + return -1 + case n > 0: + return 1 + } + return 0 +} + +func comparePrerelease(a, b []string) int { + switch { + case len(a) == 0 && len(b) == 0: + return 0 + case len(a) == 0: + return 1 + case len(b) == 0: + return -1 + } + for i := 0; i < len(a) && i < len(b); i++ { + if a[i] == b[i] { + continue + } + an, bn := isNumeric(a[i]), isNumeric(b[i]) + switch { + case an && bn: + return compareNumeric(a[i], b[i]) + case an: + return -1 + case bn: + return 1 + } + return strings.Compare(a[i], b[i]) + } + return sign(len(a) - len(b)) +} + +func compareSemver(a, b string) int { + va, okA := parseSemver(a) + vb, okB := parseSemver(b) + switch { + case !okA && !okB: + return 0 + case !okA: + return -1 + case !okB: + return 1 + } + if c := compareNumeric(va.major, vb.major); c != 0 { + return c + } + if c := compareNumeric(va.minor, vb.minor); c != 0 { + return c + } + if c := compareNumeric(va.patch, vb.patch); c != 0 { + return c + } + return comparePrerelease(va.prerelease, vb.prerelease) +} diff --git a/vendor/github.com/docker/secrets-engine/client/version/version.go b/vendor/github.com/docker/secrets-engine/client/version/version.go new file mode 100644 index 000000000000..b5bfac624571 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/client/version/version.go @@ -0,0 +1,86 @@ +// Copyright 2025-2026 Docker, 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 version provides the version types of the Secrets Engine. +package version + +import ( + "errors" + "fmt" +) + +var ( + ErrEmptyVersion = errors.New("empty version") + ErrVPrefix = errors.New("missing version prefix") +) + +type Version interface { + String() string +} + +type version struct { + value string +} + +func (v *version) String() string { + return v.value +} + +// DaemonVersion holds version information reported by the daemon. +type DaemonVersion struct { + Version Version + Date string + CommitHash string +} + +// NewVersion creates a new [Version] from a string +// If a validation error occurs, it returns nil and the error. +func NewVersion(s string) (Version, error) { + if err := valid(s); err != nil { + return nil, fmt.Errorf("parsing version: %w", err) + } + return &version{ + value: s, + }, nil +} + +// MustNewVersion creates a new Version as [NewVersion] does, but panics when a validation +// error occurs. +func MustNewVersion(s string) Version { + v, err := NewVersion(s) + if err != nil { + panic(err) + } + return v +} + +// Compare returns an integer comparing two versions according to semantic versioning. +// The result will be 0 if a == b, -1 if a < b, or +1 if a > b. +// An invalid semver string is considered less than a valid one. +func Compare(a, b Version) int { + return compareSemver(a.String(), b.String()) +} + +func valid(s string) error { + if len(s) > 0 && s[0] != 'v' { + return ErrVPrefix + } + if s == "" { + return ErrEmptyVersion + } + if _, ok := parseSemver(s); !ok { + return fmt.Errorf("invalid version: %s", s) + } + return nil +} diff --git a/vendor/github.com/docker/secrets-engine/secrets/LICENSE b/vendor/github.com/docker/secrets-engine/secrets/LICENSE new file mode 100644 index 000000000000..3c6f5a21a864 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/secrets/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 2025 Docker, 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/docker/secrets-engine/secrets/README.md b/vendor/github.com/docker/secrets-engine/secrets/README.md new file mode 100644 index 000000000000..3ea81d290e2d --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/secrets/README.md @@ -0,0 +1,96 @@ +# secrets + +`github.com/docker/secrets-engine/secrets` holds the core types of the Secrets +Engine: secret IDs and patterns, resolved envelopes, and the `Secret` and +`Store` interfaces. + +It depends only on the standard library, so clients, plugins and store +backends can import it without pulling in the engine runtime or the keychain +bindings. Its API is stable and follows semantic versioning from `v1.0.0`. + +```shell +go get github.com/docker/secrets-engine/secrets +``` + +## Identifiers and patterns + +An `ID` contains a secret identifier. Valid secret identifiers must match the +format `^[A-Za-z0-9._:-]+(?:/[A-Za-z0-9._:-]+)*$`: + +- Components separated by `/` +- Each component is non-empty +- Only characters `A-Z`, `a-z`, `0-9`, `.`, `_`, `-` or `:` +- No leading, trailing, or double slashes + +For storage, we don't really differentiate much about the ID format but by +convention we do simple, slash-separated management, providing a groupable +access control system for management across plugins. + +A `Pattern` matches secret IDs. It follows the ID validation rules, except +that `*` matches one component and `**` matches zero or more. + +```go +id := secrets.MustParseID("docker/auth/hub/joe") +pattern := secrets.MustParsePattern("docker/auth/**") +pattern.Match(id) // true + +if _, err := secrets.ParsePattern(userInput); errors.Is(err, secrets.ErrInvalidPattern) { + // reject the input +} +``` + +## Implementing a secret + +Store backends such as [`store/keychain`](../store/keychain) and +[`store/posixage`](../store/posixage) persist any type that implements +`secrets.Secret`, and take a `secrets.Factory` that creates an empty one per +ID: + +```go +type token struct { + value []byte + metadata map[string]string +} + +func (t *token) Marshal() ([]byte, error) { return t.value, nil } + +// Copy the data: backends zero the buffer after Unmarshal returns. +func (t *token) Unmarshal(data []byte) error { + t.value = bytes.Clone(data) + return nil +} + +func (t *token) Metadata() map[string]string { return t.metadata } + +func (t *token) SetMetadata(m map[string]string) error { + t.metadata = m + return nil +} + +var factory secrets.Factory[*token] = func(context.Context, secrets.ID) *token { + return &token{} +} +``` + +## Migrating from `x/secrets` and `store` + +`github.com/docker/secrets-engine/x/secrets` and the type aliases in the root +`github.com/docker/secrets-engine/store` package are deprecated aliases of +this module. They carry `//go:fix inline` directives, so `go fix ./...` +rewrites callers to import `secrets` directly. `x/secrets` will be removed in a +future release of `x`. + +`x/secrets.Resolver`, `x/secrets.Authorizer` and `x/secrets.AuthorizeResponse` +are the exception: `go fix` leaves them alone, and their replacements live in +`github.com/docker/secrets-engine/client/api/resolver`. + +| Deprecated | Replacement | +|-------------------------------------------------------------|-----------------------------| +| `x/secrets.*` | `secrets.*` | +| `x/secrets.Resolver`, `x/secrets.Authorizer`, `x/secrets.AuthorizeResponse` | `client/api/resolver.Resolver`, `client/api/resolver.Authorizer`, `client/api/resolver.AuthorizeResponse` | +| `store.ID`, `store.Pattern`, `store.Secret`, `store.Store` | `secrets.ID`, `secrets.Pattern`, `secrets.Secret`, `secrets.Store` | +| `store.Factory[T]` | `secrets.Factory[T]` | +| `store.ParseID`, `store.MustParseID` | `secrets.ParseID`, `secrets.MustParseID` | +| `store.ParsePattern`, `store.MustParsePattern` | `secrets.ParsePattern`, `secrets.MustParsePattern` | +| `store.ErrCredentialNotFound` | `secrets.ErrNotFound` | +| `store.ErrEmptySecret` | `secrets.ErrEmptySecret` | diff --git a/vendor/github.com/docker/secrets-engine/secrets/doc.go b/vendor/github.com/docker/secrets-engine/secrets/doc.go new file mode 100644 index 000000000000..623b49b32d32 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/secrets/doc.go @@ -0,0 +1,52 @@ +// Copyright 2025-2026 Docker, 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 secrets defines the core types shared across the Secrets Engine: +// secret identifiers and patterns, resolved secret envelopes, and the +// interfaces implemented by secret stores. +// +// # Identifiers and patterns +// +// An [ID] contains a secret identifier. Valid secret identifiers must match +// the format ^[A-Za-z0-9._:-]+(?:/[A-Za-z0-9._:-]+)*$: +// +// - Components separated by '/' +// - Each component is non-empty +// - Only characters A-Z, a-z, 0-9, '.', '_', '-' or ':' +// - No leading, trailing, or double slashes +// +// For storage, we don't really differentiate much about the ID format but +// by convention we do simple, slash-separated management, providing a +// groupable access control system for management across plugins. +// +// A [Pattern] matches secret IDs. It follows the ID validation rules, except +// that '*' matches one component and '**' matches zero or more. +// +// id := secrets.MustParseID("docker/auth/hub/joe") +// pattern := secrets.MustParsePattern("docker/auth/**") +// pattern.Match(id) // true +// +// # Resolving secrets +// +// A [github.com/docker/secrets-engine/client/api/resolver.Resolver] returns +// the [Envelope] of every secret that matches a pattern. A +// [github.com/docker/secrets-engine/client/api/resolver.Authorizer] decides +// whether access to a set of patterns is allowed. +// +// # Storing secrets +// +// A [Store] persists values implementing [Secret], keyed by [ID]. Store +// backends take a [Factory] that creates an empty [Secret] for each ID they +// read, so callers decide how their secret values are encoded. +package secrets diff --git a/vendor/github.com/docker/secrets-engine/secrets/identifiers.go b/vendor/github.com/docker/secrets-engine/secrets/identifiers.go new file mode 100644 index 000000000000..cfce4720422f --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/secrets/identifiers.go @@ -0,0 +1,179 @@ +// Copyright 2025-2026 Docker, 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 secrets + +import ( + "fmt" + "strings" +) + +// ErrInvalidID is returned by [ParseID] when a string is not a valid [ID]. +type ErrInvalidID struct { + // ID is the rejected input. + ID string +} + +// Error describes the rejected input and the format an ID must match. +func (e ErrInvalidID) Error() string { + return fmt.Sprintf("invalid identifier: %q must match ^[A-Za-z0-9._:-]+(?:/[A-Za-z0-9._:-]+)*$", e.ID) +} + +// validIdentifier checks if an identifier is valid without using regexp or unicode. +// Rules: +// - Components separated by '/' +// - Each component is non-empty +// - Only characters A-Z, a-z, 0-9, '.', '_', '-' or ':' +// - No leading, trailing, or double slashes +func validIdentifier(s string) bool { + if len(s) == 0 { + return false + } + + componentLen := 0 + + for _, r := range s { + switch { + case r == '/': + if componentLen == 0 { + // Empty component (leading, trailing, or double slash) + return false + } + componentLen = 0 + case isValidRune(r): + componentLen++ + default: + return false + } + } + + // Final component must not be empty + return componentLen > 0 +} + +func isValidRune(c rune) bool { + return (c >= 'A' && c <= 'Z') || + (c >= 'a' && c <= 'z') || + (c >= '0' && c <= '9') || + c == '.' || c == '-' || c == '_' || c == ':' +} + +func split(s string) []string { + s = strings.Trim(s, "/") + if s == "" { + return []string{} + } + return strings.Split(s, "/") +} + +func match(pattern, path []string) bool { + pi, si := 0, 0 + for pi < len(pattern) && si < len(path) { + switch pattern[pi] { + case "**": + // Try to consume any number of path segments + if pi+1 == len(pattern) { + return true // trailing ** matches rest + } + // Try to find a match for the rest of the pattern + for skip := 0; si+skip <= len(path); skip++ { + if match(pattern[pi+1:], path[si+skip:]) { + return true + } + } + return false + case "*": + // Match exactly one path component + pi++ + si++ + default: + if pattern[pi] != path[si] { + return false + } + pi++ + si++ + } + } + + // Handle trailing pattern parts (like **) + for pi < len(pattern) && pattern[pi] == "**" { + pi++ + } + + return pi == len(pattern) && si == len(path) +} + +func valid(id string) error { + if !validIdentifier(id) { + return ErrInvalidID{ + ID: id, + } + } + + return nil +} + +// ID contains a secret identifier. +// Valid secret identifiers must match the format ^[A-Za-z0-9._:-]+(?:/[A-Za-z0-9._:-]+)*$. +// +// For storage, we don't really differentiate much about the ID format but +// by convention we do simple, slash-separated management, providing a +// groupable access control system for management across plugins. +type ID interface { + // String formats the [ID] as a string + String() string + // Match the [ID] against a [Pattern] + // It checks if a given identifier matches the pattern. + // - "*" matches a single component + // - "**" matches zero or more components + // - "/" is the separator + Match(pattern Pattern) bool +} + +type id string + +func (i id) Match(pattern Pattern) bool { + pathParts := split(string(i)) + patternParts := split(pattern.String()) + + return match(patternParts, pathParts) +} + +func (i id) String() string { + return string(i) +} + +// ParseID creates a new [ID] from a string +// If a validation error occurs, it returns nil and the error. +// Rules: +// - Components separated by '/' +// - Each component is non-empty +// - Only characters A-Z, a-z, 0-9, '.', '_', '-' or ':' +// - No leading, trailing, or double slashes +func ParseID(s string) (ID, error) { + if err := valid(s); err != nil { + return nil, err + } + + return id(s), nil +} + +// MustParseID parses a string into a [ID] and behaves similar to +// [ParseID], however, it panics when the id is invalid +func MustParseID(s string) ID { + if err := valid(s); err != nil { + panic(err) + } + return id(s) +} diff --git a/vendor/github.com/docker/secrets-engine/secrets/minimize.go b/vendor/github.com/docker/secrets-engine/secrets/minimize.go new file mode 100644 index 000000000000..53dcbdabd152 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/secrets/minimize.go @@ -0,0 +1,128 @@ +// Copyright 2026 Docker, 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 secrets + +import "strings" + +func canonicalKey(toks []token) string { + var sb strings.Builder + for i, t := range toks { + if i > 0 { + sb.WriteByte('/') + } + switch t.kind { + case tokenStar: + sb.WriteByte('*') + case tokenGap: + sb.WriteString("**") + case tokenLit: + sb.WriteString(t.lit) + } + } + return sb.String() +} + +// Minimize removes each pattern that another contains (see +// [Pattern.Contains]); when patterns match the same IDs, only the first +// stays. The result preserves input order. +// +// Examples: +// +// [** a/*] -> [**] +// [**/* */** **] -> [**/*] +// [a/** **/a] -> [a/** **/a] +// +// Complexity: O(n²·L²) for n patterns of at most L components each. +func Minimize(patterns []Pattern) []Pattern { + entries := make([]entry, 0, len(patterns)) + seen := make(map[string]struct{}, len(patterns)) + for _, p := range patterns { + toks := canonicalize(p.String()) + key := canonicalKey(toks) + if _, dup := seen[key]; dup { + continue + } + seen[key] = struct{}{} + entries = append(entries, newEntry(p, toks)) + } + + result := make([]Pattern, 0, len(entries)) + for i := range entries { + redundant := false + for j := range entries { + if i == j || !subsumes(&entries[j], &entries[i]) { + continue + } + if j < i || !covers(entries[i].toks, entries[j].toks) { + redundant = true + break + } + } + if !redundant { + result = append(result, entries[i].original) + } + } + return result +} + +type entry struct { + original Pattern + toks []token + minLen int + hasWild bool + hasGaps bool + firstLit string + lastLit string +} + +func newEntry(p Pattern, toks []token) entry { + e := entry{original: p, toks: toks} + for _, t := range toks { + if t.kind != tokenLit { + e.hasWild = true + } + if t.kind == tokenGap { + e.hasGaps = true + } else { + e.minLen++ + } + } + if len(toks) > 0 { + e.firstLit = toks[0].lit + e.lastLit = toks[len(toks)-1].lit + } + return e +} + +// subsumes reports whether other matches every ID e matches. It compares +// the precomputed fields first, so most pairs skip the O(L²) covers call. +func subsumes(other, e *entry) bool { + if !other.hasWild { + return false + } + if other.minLen > e.minLen { + return false + } + if !other.hasGaps && (e.hasGaps || other.minLen != e.minLen) { + return false + } + if other.firstLit != "" && other.firstLit != e.firstLit { + return false + } + if other.lastLit != "" && other.lastLit != e.lastLit { + return false + } + return covers(other.toks, e.toks) +} diff --git a/vendor/github.com/docker/secrets-engine/secrets/pattern.go b/vendor/github.com/docker/secrets-engine/secrets/pattern.go new file mode 100644 index 000000000000..ffce6deede65 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/secrets/pattern.go @@ -0,0 +1,297 @@ +// Copyright 2025-2026 Docker, 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 secrets + +import ( + "errors" + "fmt" + "strings" +) + +// ErrInvalidPattern is returned by [ParsePattern] when a string is not a +// valid [Pattern]. +var ErrInvalidPattern = errors.New("invalid pattern") + +// validPattern reports whether s is a valid pattern: non-empty '/'-separated +// components of A-Z, a-z, 0-9, '.', '-', '_', ':', where a component may +// instead be '*' or '**'. +func validPattern(s string) bool { + if len(s) == 0 { + return false + } + + componentLen := 0 + wildcardLen := 0 + + for _, r := range s { + switch { + case r == '/': + if !isValidComponentMatcher(componentLen, wildcardLen) { + return false + } + componentLen = 0 + wildcardLen = 0 + case isValidPatternRune(r): + componentLen++ + if r == '*' { + wildcardLen++ + } + default: + return false + } + } + // Final component + return isValidComponentMatcher(componentLen, wildcardLen) +} + +func isValidComponentMatcher(componentLen, wildcardLen int) bool { + if wildcardLen > 2 { + // No more than two wildcards per component + return false + } + if wildcardLen > 0 && wildcardLen != componentLen { + // Wildcard can't be mixed with other characters in the same component + return false + } + // Component must not be empty + return componentLen > 0 +} + +func isValidPatternRune(c rune) bool { + return isValidRune(c) || c == '*' +} + +// Pattern matches secret IDs. It follows the ID validation rules, except +// that '*' matches one component and '**' matches zero or more. +// Below, matches(p) denotes the set of IDs a pattern p matches. +type Pattern interface { + // Match reports whether the pattern matches id. + // Complexity: O(n*m^k), where id has n components and the pattern has + // m components and k occurrences of '**'. + Match(id ID) bool + // Contains reports whether every ID that [other] matches can also be + // matched by the pattern: the set of IDs [other] matches is contained + // in the set the pattern matches, i.e., matches(other) ⊆ matches(p). + // + // Examples: + // - docker/** contains docker/*/mcp/*: '**' is more general than + // '*/mcp/*'. + // - docker/proj1/** does not contain docker/*/mcp/*: docker/*/mcp/* + // matches docker/proj2/mcp/x, but docker/proj1/** does not. + // + // Complexity: O(n*m) + Contains(other Pattern) bool + // Overlaps reports whether the pattern and [other] match at least one + // ID in common, i.e., matches(p) ∩ matches(other) ≠ ∅. + // + // Examples: + // - docker/*/mcp/* and docker/proj1/** overlap: both match e.g. docker/proj1/mcp/x. + // - bar/** and foo/** do not overlap: an ID cannot begin with both bar and foo. + // + // Complexity: O(n*m) + Overlaps(other Pattern) bool + // String returns the pattern text. + String() string + + ExpandID(other ID) (ID, error) + ExpandPattern(other Pattern) (Pattern, error) +} + +type pattern string + +func (p pattern) Match(id ID) bool { + pathParts := split(id.String()) + patternParts := split(string(p)) + + return match(patternParts, pathParts) +} + +func (p pattern) Contains(other Pattern) bool { + return covers(canonicalize(string(p)), canonicalize(other.String())) +} + +func (p pattern) Overlaps(other Pattern) bool { + return compatible(canonicalize(string(p)), canonicalize(other.String())) +} + +type tokenKind uint8 + +const ( + tokenLit tokenKind = iota + tokenStar + tokenGap +) + +type token struct { + kind tokenKind + lit string +} + +// canonicalize tokenizes a pattern so that two patterns match the same set +// of IDs exactly when their canonical tokens are equal. Two rewrites give +// that property: +// +// - In a run of consecutive wildcard components, the '*' move to the +// front and the '**' merge into one at the end: order within a run +// does not affect what it matches, and one '**' already matches any +// number of components. +// - A pattern consisting only of '**' becomes "*/**": an ID always has +// at least one component, so both match the same IDs, and the first +// rewrite already turns the equivalent spelling "**/*" into "*/**". +// +// Examples: +// +// a/a/** and a/a/**/** -> [a a **] +// a/**/*/**/b -> [a * ** b] +// ** and **/* -> [* **] +func canonicalize(s string) []token { + parts := split(s) + toks := make([]token, 0, len(parts)) + stars, gap := 0, false + flush := func() { + for range stars { + toks = append(toks, token{kind: tokenStar}) + } + if gap { + toks = append(toks, token{kind: tokenGap}) + } + stars, gap = 0, false + } + for _, part := range parts { + switch part { + case "*": + stars++ + case "**": + gap = true + default: + flush() + toks = append(toks, token{kind: tokenLit, lit: part}) + } + } + flush() + if len(toks) == 1 && toks[0].kind == tokenGap { + toks = []token{{kind: tokenStar}, {kind: tokenGap}} + } + return toks +} + +// covers reports whether p matches every ID q matches, for canonical tokens. +// The component alphabet is unbounded, so a literal in p never covers an '*' +// or '**' in q. +func covers(p, q []token) bool { + np, nq := len(p), len(q) + prev := make([]bool, nq+1) + cur := make([]bool, nq+1) + prev[nq] = true + for i := np - 1; i >= 0; i-- { + cur[nq] = p[i].kind == tokenGap && prev[nq] + for j := nq - 1; j >= 0; j-- { + switch { + case p[i].kind == tokenGap: + cur[j] = prev[j] || cur[j+1] + case q[j].kind == tokenGap: + cur[j] = p[i].kind == tokenStar && cur[j+1] && prev[j] + case p[i].kind == tokenStar: + cur[j] = prev[j+1] + default: + cur[j] = q[j].kind == tokenLit && p[i].lit == q[j].lit && prev[j+1] + } + } + prev, cur = cur, prev + } + return prev[0] +} + +// compatible reports whether p and q match at least one ID in common, for +// canonical tokens. A common ID aligns both token lists over its +// components: wildcards accept anything, so only differing literals or +// mismatched lengths (* vs */foo) rule one out. +func compatible(p, q []token) bool { + np, nq := len(p), len(q) + prev := make([]bool, nq+1) + cur := make([]bool, nq+1) + prev[nq] = true + for j := nq - 1; j >= 0; j-- { + prev[j] = q[j].kind == tokenGap && prev[j+1] + } + for i := np - 1; i >= 0; i-- { + cur[nq] = p[i].kind == tokenGap && prev[nq] + for j := nq - 1; j >= 0; j-- { + switch { + case p[i].kind == tokenGap || q[j].kind == tokenGap: + cur[j] = prev[j] || cur[j+1] + case p[i].kind == tokenLit && q[j].kind == tokenLit && p[i].lit != q[j].lit: + cur[j] = false + default: + cur[j] = prev[j+1] + } + } + prev, cur = cur, prev + } + return prev[0] +} + +func (p pattern) String() string { + return string(p) +} + +// ParsePattern parses s into a [Pattern]: non-empty '/'-separated components +// of A-Z, a-z, 0-9, '.', '-', '_', ':', where a component may instead be '*' +// or '**'. It returns [ErrInvalidPattern] for anything else. +func ParsePattern(s string) (Pattern, error) { + if !validPattern(s) { + return nil, ErrInvalidPattern + } + return pattern(s), nil +} + +// MustParsePattern is like [ParsePattern] but panics on an invalid pattern. +func MustParsePattern(s string) Pattern { + if !validPattern(s) { + panic(ErrInvalidPattern) + } + return pattern(s) +} + +func (p pattern) ExpandID(other ID) (ID, error) { + val, err := replace1(string(p), other.String()) + if err != nil { + return nil, err + } + return ParseID(val) +} + +func (p pattern) ExpandPattern(other Pattern) (Pattern, error) { + val, err := replace1(string(p), other.String()) + if err != nil { + return nil, err + } + return pattern(val), err +} + +func replace1(original, other string) (string, error) { + components := split(original) + var candidates []int + for idx, val := range components { + if val == "**" { + candidates = append(candidates, idx) + } + } + if len(candidates) != 1 { + return "", fmt.Errorf("expand only supports one expansion glob, pattern %s has %d", original, len(candidates)) + } + components[candidates[0]] = other + return strings.Join(components, "/"), nil +} diff --git a/vendor/github.com/docker/secrets-engine/secrets/secrets.go b/vendor/github.com/docker/secrets-engine/secrets/secrets.go new file mode 100644 index 000000000000..c9ea1fff7299 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/secrets/secrets.go @@ -0,0 +1,65 @@ +// Copyright 2025-2026 Docker, 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 secrets + +import ( + "encoding/json" + "errors" + "time" +) + +var ( + // ErrNotFound is returned when no secret exists for the requested ID or + // pattern. + ErrNotFound = errors.New("secret not found") + // ErrAccessDenied is returned when the caller is not allowed to access + // the requested secrets. + ErrAccessDenied = errors.New("access denied") // nuh, uh, uh! + // ErrEmptySecret is returned when a secret with an empty value is saved. + ErrEmptySecret = errors.New("secret value must not be empty") +) + +// Envelope is a resolved secret together with information about where it +// came from and how long it is valid. +// +// An Envelope carries plaintext secret material and cannot be encoded with +// encoding/json; see [Envelope.MarshalJSON]. +type Envelope struct { + // ID identifies the secret. + ID ID `json:"-"` + // Value is the plaintext secret value. + Value []byte `json:"-"` + // Metadata holds non-sensitive key-value data about the secret. + Metadata map[string]string `json:"-"` + // Provider names the provider that resolved the secret. + Provider string `json:"-"` + // Version is the version of the payload format in Value, set by the + // provider. It is independent of the provider's own release version. + Version string `json:"-"` + // CreatedAt is when the secret was created. + CreatedAt time.Time `json:"-"` + // ResolvedAt is when the secret was resolved. + ResolvedAt time.Time `json:"-"` + // ExpiresAt is when the secret stops being valid. + ExpiresAt time.Time `json:"-"` +} + +var _ json.Marshaler = Envelope{} + +// MarshalJSON always panics, so that an Envelope and its plaintext value are +// never written out by encoding/json by accident. +func (e Envelope) MarshalJSON() ([]byte, error) { + panic("secrets.Envelope does not support json.Marshal") +} diff --git a/vendor/github.com/docker/secrets-engine/secrets/store.go b/vendor/github.com/docker/secrets-engine/secrets/store.go new file mode 100644 index 000000000000..92dfa3d48bf9 --- /dev/null +++ b/vendor/github.com/docker/secrets-engine/secrets/store.go @@ -0,0 +1,98 @@ +// Copyright 2025-2026 Docker, 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 secrets + +import "context" + +// Secret is a generic type that represents the actual secret values +// +// The implementer is responsible for defining the data structure of their secrets. +// +// Example: +// +// type secret struct { +// AccessToken string +// RefreshToken string +// } +// +// func (s *secret) Marshal() ([]byte, error) { +// return []byte(s.AccessToken+":"+s.RefreshToken), nil +// } +// +// func (s *secret) Unmarshal(data []byte) error { +// tokens := bytes.Split(data, []byte(":")) +// if len(tokens) != 2 { +// return errors.New("invalid secret format") +// } +// +// s.AccessToken, s.RefreshToken = string(tokens[0]), string(tokens[1]) +// return nil +// } +type Secret interface { + // Marshal the secret into a slice of bytes + Marshal() ([]byte, error) + // Unmarshal the secret from a slice of bytes into its structured format. + // Implementations must copy any bytes they retain: store backends zero + // the source buffer after Unmarshal returns to avoid leaking plaintext. + Unmarshal(data []byte) error + // Metadata returns a key-value pair of non-sensitive data about the secret + Metadata() map[string]string + // SetMetadata allows the caller to set the secrets non-sensitive data + // A secret may expects certain keys or values from the map and may return + // an error. + SetMetadata(map[string]string) error +} + +// Store defines a strict format for secrets to conform to when interacting +// with the secrets engine +type Store interface { + // Delete removes credentials from the store for a given ID. + Delete(ctx context.Context, id ID) error + // Get retrieves credentials from the store for a given ID. + Get(ctx context.Context, id ID) (Secret, error) + // GetAllMetadata retrieves all the credentials from the store. + // Credentials retrieved will only call [Secret.SetMetadata] so that the + // underlying store does not get queried for each secret's sensitive data. + // This could be very taxing on the underlying store and cause a poor User + // Experience. + GetAllMetadata(ctx context.Context) (map[ID]Secret, error) + // Save persists credentials from the store. + // + // An empty secret value is rejected with [ErrEmptySecret]. + Save(ctx context.Context, id ID, secret Secret) error + // Upsert atomically replaces an existing credential or inserts a new one. + // + // An empty secret value is rejected with [ErrEmptySecret]. + // + // On the macOS Keychain an existing item is updated in place, keeping the + // applications the user allowed to access it. Another store instance or + // process can still write the same item concurrently, in which case Upsert + // returns a backend-specific duplicate item error. + Upsert(ctx context.Context, id ID, secret Secret) error + // Filter returns a map of secrets based on a [Pattern]. + // + // A pattern matching nothing is a valid empty result: implementations + // return an empty (non-nil) map with a nil error, not ErrNotFound. + // + // Secrets returned will have both [Secret.SetMetadata] and [Secret.Unmarshal] + // called; in that order. Any error produced by any of them would result in + // an early return with a nil secrets map. + Filter(ctx context.Context, pattern Pattern) (map[ID]Secret, error) +} + +// Factory returns a new, empty [Secret] for the given ID. Store backends call +// it for every secret they read, then fill it in with [Secret.SetMetadata] +// and, when the value is read too, [Secret.Unmarshal]. +type Factory[T Secret] func(context.Context, ID) T diff --git a/vendor/modules.txt b/vendor/modules.txt index 622cc56e974c..0db9077ca973 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -87,6 +87,24 @@ github.com/docker/go-metrics github.com/docker/go-units # github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 ## explicit +# github.com/docker/secrets-engine/client v1.0.0 +## explicit; go 1.26.11 +github.com/docker/secrets-engine/client +github.com/docker/secrets-engine/client/api/health/v1 +github.com/docker/secrets-engine/client/api/health/v1/healthv1rpc +github.com/docker/secrets-engine/client/api/plugins/v1 +github.com/docker/secrets-engine/client/api/plugins/v1/pluginsv1rpc +github.com/docker/secrets-engine/client/api/resolver +github.com/docker/secrets-engine/client/api/resolver/v1 +github.com/docker/secrets-engine/client/api/resolver/v1/resolverv1rpc +github.com/docker/secrets-engine/client/config +github.com/docker/secrets-engine/client/dockerhub +github.com/docker/secrets-engine/client/realms +github.com/docker/secrets-engine/client/rpc +github.com/docker/secrets-engine/client/version +# github.com/docker/secrets-engine/secrets v1.0.0 +## explicit; go 1.26.0 +github.com/docker/secrets-engine/secrets # github.com/felixge/httpsnoop v1.1.0 ## explicit; go 1.25 github.com/felixge/httpsnoop From 71a8042b42f929a23eabfbf4eb8bb930bbb0ec5d Mon Sep 17 00:00:00 2001 From: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:03:05 +0100 Subject: [PATCH 2/3] internal/secretsengine: read the Docker Hub session from Docker Desktop Add an auth provider that reads the Docker Desktop session from the secrets engine and returns it as the credentials for Docker Hub (docker.io) and Docker Hardened Images (dhi.io), keeping the production and staging sessions apart. The session is cached until it expires. When no session is usable (no socket, nothing listening, signed out, or no answer within 5 seconds), the provider falls back to the given provider and retries after a minute. Add registry.DefaultRegistryHost, so the Docker Hub registry host is defined once. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> --- internal/registry/config.go | 5 +- internal/secretsengine/secretsengine.go | 199 +++++++++ internal/secretsengine/secretsengine_test.go | 429 +++++++++++++++++++ 3 files changed, 631 insertions(+), 2 deletions(-) create mode 100644 internal/secretsengine/secretsengine.go create mode 100644 internal/secretsengine/secretsengine_test.go diff --git a/internal/registry/config.go b/internal/registry/config.go index 24b5eedfe3d6..aab0b7ae2896 100644 --- a/internal/registry/config.go +++ b/internal/registry/config.go @@ -51,7 +51,8 @@ const ( // IndexServer is used for user auth and image search IndexServer = "https://index.docker.io/v1/" // IndexName is the name of the index - IndexName = "docker.io" + IndexName = "docker.io" + DefaultRegistryHost = "registry-1.docker.io" ) var ( @@ -61,7 +62,7 @@ var ( // or "ubuntu:latest"), as well as references using the "docker.io" domain // name, which is used as canonical reference for images on Docker Hub, but // does not match the domain-name of Docker Hub's registry. - DefaultV2Registry = &url.URL{Scheme: "https", Host: "registry-1.docker.io"} + DefaultV2Registry = &url.URL{Scheme: "https", Host: DefaultRegistryHost} validHostPortRegex = sync.OnceValue(func() *regexp.Regexp { return regexp.MustCompile(`^` + reference.DomainRegexp.String() + `$`) diff --git a/internal/secretsengine/secretsengine.go b/internal/secretsengine/secretsengine.go new file mode 100644 index 000000000000..125fcfa2ff57 --- /dev/null +++ b/internal/secretsengine/secretsengine.go @@ -0,0 +1,199 @@ +//go:build go1.26 + +package secretsengine + +import ( + "context" + "errors" + "fmt" + "io/fs" + "os" + "sync" + "time" + + "github.com/docker/cli/cli/config/credentials" + "github.com/docker/cli/cli/config/types" + "github.com/docker/cli/internal/registry" + seclient "github.com/docker/secrets-engine/client" + seconfig "github.com/docker/secrets-engine/client/config" + "github.com/docker/secrets-engine/client/dockerhub" + "github.com/sirupsen/logrus" +) + +const ( + lookupTimeout = 5 * time.Second + sessionExpirySkew = 30 * time.Second + sessionTTL = time.Minute + retryInterval = time.Minute + + stagingRegistryHost = "registry-1-stage.docker.io" + dhiRegistryHost = "dhi.io" +) + +var errSessionExpired = errors.New("the session has expired (not signed in to Docker Desktop?)") + +type hubClient interface { + GetDefaultSession(ctx context.Context) (dockerhub.UserSession, error) + GetDefaultProfile(ctx context.Context) (dockerhub.Profile, error) +} + +var _ hubClient = dockerhub.ClientAuth(nil) + +type AuthProvider interface { + GetAuthConfig(registryHostname string) (types.AuthConfig, error) +} + +type provider struct { + fallback AuthProvider + hub *session + staging *session +} + +func NewDesktop(fallback AuthProvider) AuthProvider { + return &provider{ + fallback: fallback, + hub: newDesktopSession("Docker Hub"), + staging: newDesktopSession("Docker Hub staging", dockerhub.Staging()), + } +} + +func (p *provider) GetAuthConfig(registryHostname string) (types.AuthConfig, error) { + if s, serverAddress := p.sessionFor(registryHostname); s != nil { + if auth, ok := s.auth(); ok { + auth.ServerAddress = serverAddress + return auth, nil + } + } + return p.fallback.GetAuthConfig(registryHostname) +} + +func (p *provider) sessionFor(registryHostname string) (*session, string) { + switch credentials.ConvertToHostname(registryHostname) { + case registry.IndexName, registry.IndexHostname, registry.DefaultRegistryHost: + return p.hub, registry.IndexServer + case dhiRegistryHost: + return p.hub, dhiRegistryHost + case stagingRegistryHost: + return p.staging, stagingRegistryHost + default: + return nil, "" + } +} + +type session struct { + name string + connect func() (hubClient, error) + + mu sync.Mutex + hub hubClient + retryAt time.Time + cached *types.AuthConfig + validUntil time.Time +} + +func newDesktopSession(name string, opts ...dockerhub.Option) *session { + return &session{ + name: name, + connect: func() (hubClient, error) { + return connect(seconfig.DesktopSocketPath(), opts...) + }, + } +} + +func connect(socketPath string, opts ...dockerhub.Option) (hubClient, error) { + if _, err := os.Lstat(socketPath); errors.Is(err, fs.ErrNotExist) { + return nil, err + } + c, err := seclient.New( + seclient.WithSocketPath(socketPath), + seclient.WithTimeout(lookupTimeout), + ) + if err != nil { + return nil, err + } + return c.HubAuth(opts...), nil +} + +func (s *session) auth() (types.AuthConfig, bool) { + s.mu.Lock() + defer s.mu.Unlock() + + now := time.Now() + if now.Before(s.retryAt) { + return types.AuthConfig{}, false + } + if s.cached != nil && now.Before(s.validUntil) { + return *s.cached, true + } + auth, validUntil, err := s.fetch() + if err != nil { + s.retryAt = time.Now().Add(retryInterval) + s.cached = nil + logFallback(s.name, err) + return types.AuthConfig{}, false + } + logrus.Debugf("using the %s session of %q from Docker Desktop", s.name, auth.Username) + s.cached, s.validUntil = &auth, validUntil + return auth, true +} + +func (s *session) fetch() (types.AuthConfig, time.Time, error) { + if s.hub == nil { + hub, err := s.connect() + if err != nil { + return types.AuthConfig{}, time.Time{}, err + } + s.hub = hub + } + + ctx, cancel := context.WithTimeout(context.Background(), lookupTimeout) + defer cancel() + + userSession, err := s.hub.GetDefaultSession(ctx) + if err != nil { + return types.AuthConfig{}, time.Time{}, err + } + + username := userSession.Claims.Username + if username == "" { + profile, err := s.hub.GetDefaultProfile(ctx) + if err != nil { + return types.AuthConfig{}, time.Time{}, fmt.Errorf("resolving the Docker Hub username: %w", err) + } + username = profile.Username + } + if username == "" { + return types.AuthConfig{}, time.Time{}, errors.New("no username for the session") + } + + now := time.Now() + validUntil := now.Add(sessionTTL) + if exp := userSession.Claims.ExpiresAt; exp != nil { + validUntil = exp.Add(-sessionExpirySkew) + if !now.Before(validUntil) { + return types.AuthConfig{}, time.Time{}, errSessionExpired + } + } + + return types.AuthConfig{ + Username: username, + Password: userSession.AccessToken, + }, validUntil, nil +} + +func logFallback(name string, err error) { + if isSessionUnavailable(err) { + logrus.Debugf("no %s session available from Docker Desktop, using Docker CLI credentials: %v", name, err) + return + } + logrus.Warnf("could not use the %s session from Docker Desktop, using Docker CLI credentials instead: %v", name, err) +} + +func isSessionUnavailable(err error) bool { + if _, ok := errors.AsType[*seclient.ConnectError](err); ok { + return true + } + return errors.Is(err, fs.ErrNotExist) || + errors.Is(err, dockerhub.ErrNoSession) || + errors.Is(err, errSessionExpired) +} diff --git a/internal/secretsengine/secretsengine_test.go b/internal/secretsengine/secretsengine_test.go new file mode 100644 index 000000000000..c6f0a71eb04f --- /dev/null +++ b/internal/secretsengine/secretsengine_test.go @@ -0,0 +1,429 @@ +//go:build go1.26 + +package secretsengine + +import ( + "context" + "errors" + "fmt" + "io/fs" + "path/filepath" + "sync" + "sync/atomic" + "testing" + "testing/synctest" + "time" + + "github.com/docker/cli/cli/config/types" + "github.com/docker/cli/internal/registry" + seclient "github.com/docker/secrets-engine/client" + "github.com/docker/secrets-engine/client/dockerhub" + "gotest.tools/v3/assert" +) + +type fakeHub struct { + session dockerhub.UserSession + sessionErr error + profile dockerhub.Profile + profileErr error + sessionCalls atomic.Int32 +} + +func (f *fakeHub) GetDefaultSession(context.Context) (dockerhub.UserSession, error) { + f.sessionCalls.Add(1) + return f.session, f.sessionErr +} + +func (f *fakeHub) GetDefaultProfile(context.Context) (dockerhub.Profile, error) { + return f.profile, f.profileErr +} + +func hubSession(username string, expiresAt time.Time) dockerhub.UserSession { + s := dockerhub.UserSession{AccessToken: "desktop-oauth-token"} + s.Claims.Username = username + if !expiresAt.IsZero() { + s.Claims.ExpiresAt = &dockerhub.NumericDate{Time: expiresAt} + } + return s +} + +func inAnHour() time.Time { + return time.Now().Add(time.Hour) +} + +type recordingFallback struct { + mu sync.Mutex + hosts []string +} + +func (f *recordingFallback) GetAuthConfig(registryHostname string) (types.AuthConfig, error) { + f.mu.Lock() + defer f.mu.Unlock() + f.hosts = append(f.hosts, registryHostname) + return cliCredentials(registryHostname), nil +} + +func cliCredentials(registryHostname string) types.AuthConfig { + return types.AuthConfig{Username: "cli-user", Password: "cli-password", ServerAddress: registryHostname} +} + +func desktopCredentials() types.AuthConfig { + return types.AuthConfig{Username: "hubuser", Password: "desktop-oauth-token", ServerAddress: registry.IndexServer} +} + +func stagingCredentials() types.AuthConfig { + return types.AuthConfig{Username: "stageuser", Password: "staging-oauth-token", ServerAddress: stagingRegistryHost} +} + +type testProvider struct { + *provider + fallback *recordingFallback + staging *fakeHub +} + +func newTestProvider(hub hubClient) *testProvider { + tp := &testProvider{ + fallback: &recordingFallback{}, + staging: &fakeHub{sessionErr: dockerhub.ErrNoDefaultProfile}, + } + tp.provider = &provider{ + fallback: tp.fallback, + hub: &session{name: "Docker Hub", hub: hub}, + staging: &session{name: "Docker Hub staging", hub: tp.staging}, + } + return tp +} + +func (tp *testProvider) signInToStaging() { + tp.staging.sessionErr = nil + tp.staging.session = hubSession("stageuser", inAnHour()) + tp.staging.session.AccessToken = "staging-oauth-token" +} + +func connectError(reason seclient.ConnectReason) error { + return &seclient.ConnectError{ + Reason: reason, + SocketPath: "/run/engine.sock", + Err: errors.New("dial unix /run/engine.sock"), + } +} + +func TestNewDesktopUsesSeparateSessions(t *testing.T) { + t.Parallel() + p := NewDesktop(&recordingFallback{}).(*provider) + assert.Assert(t, p.hub != p.staging, "production and staging sessions must be separate") +} + +func TestDockerHubUsesDesktopSession(t *testing.T) { + t.Parallel() + for _, host := range []string{"docker.io", "index.docker.io", "registry-1.docker.io", registry.IndexServer} { + t.Run(host, func(t *testing.T) { + t.Parallel() + hub := &fakeHub{session: hubSession("hubuser", inAnHour())} + p := newTestProvider(hub) + + got, err := p.GetAuthConfig(host) + assert.NilError(t, err) + assert.DeepEqual(t, got, desktopCredentials()) + assert.Equal(t, got.IdentityToken, "", "an IdentityToken is sent as a refresh token") + assert.Equal(t, len(p.fallback.hosts), 0) + }) + } +} + +func TestOtherRegistriesUseFallback(t *testing.T) { + t.Parallel() + hosts := []string{ + "ghcr.io", "localhost:5000", "registry.example.com", "", + stagingRegistryHost + ".example.com", "example.com/" + stagingRegistryHost, + dhiRegistryHost + ".example.com", "example.com/" + dhiRegistryHost, "registry." + dhiRegistryHost, + "docker.io.example.com", + } + for _, host := range hosts { + t.Run(host, func(t *testing.T) { + t.Parallel() + hub := &fakeHub{session: hubSession("hubuser", inAnHour())} + p := newTestProvider(hub) + p.signInToStaging() + + got, err := p.GetAuthConfig(host) + assert.NilError(t, err) + assert.DeepEqual(t, got, cliCredentials(host)) + assert.DeepEqual(t, p.fallback.hosts, []string{host}) + assert.Equal(t, hub.sessionCalls.Load(), int32(0), "Docker Desktop must only be contacted for Docker Hub") + assert.Equal(t, p.staging.sessionCalls.Load(), int32(0), "Docker Desktop must only be contacted for Docker Hub") + }) + } +} + +func TestDHIUsesDockerHubSession(t *testing.T) { + t.Parallel() + for _, host := range []string{dhiRegistryHost, "https://" + dhiRegistryHost, "https://" + dhiRegistryHost + "/"} { + t.Run(host, func(t *testing.T) { + t.Parallel() + hub := &fakeHub{session: hubSession("hubuser", inAnHour())} + p := newTestProvider(hub) + p.signInToStaging() + + want := desktopCredentials() + want.ServerAddress = dhiRegistryHost + got, err := p.GetAuthConfig(host) + assert.NilError(t, err) + assert.DeepEqual(t, got, want) + assert.Equal(t, p.staging.sessionCalls.Load(), int32(0), "the staging session must not be read for DHI") + + got, err = p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, desktopCredentials()) + assert.Equal(t, hub.sessionCalls.Load(), int32(1)) + }) + } +} + +func TestStagingRegistryUsesStagingSession(t *testing.T) { + t.Parallel() + for _, host := range []string{stagingRegistryHost, "https://" + stagingRegistryHost + "/"} { + t.Run(host, func(t *testing.T) { + t.Parallel() + hub := &fakeHub{session: hubSession("hubuser", inAnHour())} + p := newTestProvider(hub) + p.signInToStaging() + + got, err := p.GetAuthConfig(host) + assert.NilError(t, err) + assert.DeepEqual(t, got, stagingCredentials()) + assert.Equal(t, hub.sessionCalls.Load(), int32(0), "the production session must not be read for the staging registry") + }) + } +} + +func TestEnvironmentsDoNotMix(t *testing.T) { + t.Parallel() + t.Run("staging session is not used for docker.io", func(t *testing.T) { + t.Parallel() + p := newTestProvider(&fakeHub{sessionErr: dockerhub.ErrNoDefaultProfile}) + p.signInToStaging() + + got, err := p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, cliCredentials("docker.io")) + + got, err = p.GetAuthConfig(stagingRegistryHost) + assert.NilError(t, err) + assert.DeepEqual(t, got, stagingCredentials()) + }) + + t.Run("production session is not used for the staging registry", func(t *testing.T) { + t.Parallel() + p := newTestProvider(&fakeHub{session: hubSession("hubuser", inAnHour())}) + + got, err := p.GetAuthConfig(stagingRegistryHost) + assert.NilError(t, err) + assert.DeepEqual(t, got, cliCredentials(stagingRegistryHost)) + + got, err = p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, desktopCredentials()) + }) +} + +func TestUsernameFromProfile(t *testing.T) { + t.Parallel() + hub := &fakeHub{ + session: hubSession("", inAnHour()), + profile: dockerhub.Profile{Username: "hubuser"}, + } + p := newTestProvider(hub) + + got, err := p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, desktopCredentials()) +} + +func TestFallsBackWithoutUsableSession(t *testing.T) { + t.Parallel() + tests := []struct { + name string + hub func() *fakeHub + }{ + {name: "secrets engine not running", hub: func() *fakeHub { return &fakeHub{sessionErr: connectError(seclient.ReasonNotRunning)} }}, + {name: "secrets engine socket not accessible", hub: func() *fakeHub { return &fakeHub{sessionErr: connectError(seclient.ReasonPermissionDenied)} }}, + {name: "nobody signed in", hub: func() *fakeHub { return &fakeHub{sessionErr: dockerhub.ErrNoDefaultProfile} }}, + {name: "access denied", hub: func() *fakeHub { return &fakeHub{sessionErr: seclient.ErrAccessDenied} }}, + {name: "no username", hub: func() *fakeHub { return &fakeHub{session: hubSession("", inAnHour())} }}, + {name: "profile lookup fails", hub: func() *fakeHub { + return &fakeHub{session: hubSession("", inAnHour()), profileErr: errors.New("boom")} + }}, + {name: "expired", hub: func() *fakeHub { return &fakeHub{session: hubSession("hubuser", time.Now().Add(-time.Minute))} }}, + {name: "expires within the skew", hub: func() *fakeHub { + return &fakeHub{session: hubSession("hubuser", time.Now().Add(sessionExpirySkew/2))} + }}, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + synctest.Test(t, func(t *testing.T) { + hub := tc.hub() + p := newTestProvider(hub) + + for range 2 { + got, err := p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, cliCredentials("docker.io")) + } + assert.Equal(t, hub.sessionCalls.Load(), int32(1), "Desktop must not be asked again within retryInterval") + }) + }) + } +} + +func TestDesktopFallsBackWhenClientCannotBeCreated(t *testing.T) { + t.Parallel() + var connects atomic.Int32 + s := &session{ + name: "Docker Hub", + connect: func() (hubClient, error) { + connects.Add(1) + return nil, errors.New("no socket path") + }, + } + p := &provider{fallback: &recordingFallback{}, hub: s} + + for range 2 { + got, err := p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, cliCredentials("docker.io")) + } + assert.Equal(t, connects.Load(), int32(1)) +} + +func TestRetriesAfterInterval(t *testing.T) { + t.Parallel() + synctest.Test(t, func(t *testing.T) { + hub := &fakeHub{sessionErr: dockerhub.ErrNoDefaultProfile} + p := newTestProvider(hub) + + got, err := p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, cliCredentials("docker.io")) + + hub.sessionErr = nil + hub.session = hubSession("hubuser", inAnHour()) + + time.Sleep(retryInterval - time.Second) + got, err = p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, cliCredentials("docker.io")) + assert.Equal(t, hub.sessionCalls.Load(), int32(1)) + + time.Sleep(time.Second) + got, err = p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, desktopCredentials()) + assert.Equal(t, hub.sessionCalls.Load(), int32(2)) + }) +} + +func TestReusesSessionUntilExpiry(t *testing.T) { + t.Parallel() + synctest.Test(t, func(t *testing.T) { + expiresAt := time.Now().Add(10 * time.Minute) + hub := &fakeHub{session: hubSession("hubuser", expiresAt)} + p := newTestProvider(hub) + + got, err := p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, desktopCredentials()) + time.Sleep(5 * time.Minute) + got, err = p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, desktopCredentials()) + assert.Equal(t, hub.sessionCalls.Load(), int32(1)) + + hub.session = hubSession("hubuser", expiresAt.Add(time.Hour)) + hub.session.AccessToken = "refreshed-token" + time.Sleep(5*time.Minute - sessionExpirySkew) + + got, err = p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.Equal(t, got.Password, "refreshed-token") + assert.Equal(t, hub.sessionCalls.Load(), int32(2)) + }) +} + +func TestRefetchesSessionWithoutExpiry(t *testing.T) { + t.Parallel() + synctest.Test(t, func(t *testing.T) { + hub := &fakeHub{session: hubSession("hubuser", time.Time{})} + p := newTestProvider(hub) + + got, err := p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, desktopCredentials()) + time.Sleep(sessionTTL - time.Second) + got, err = p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, desktopCredentials()) + assert.Equal(t, hub.sessionCalls.Load(), int32(1)) + + time.Sleep(time.Second) + got, err = p.GetAuthConfig("docker.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, desktopCredentials()) + assert.Equal(t, hub.sessionCalls.Load(), int32(2)) + }) +} + +func TestConcurrentLookupsShareOneFetch(t *testing.T) { + t.Parallel() + hub := &fakeHub{session: hubSession("hubuser", inAnHour())} + p := newTestProvider(hub) + + const lookups = 20 + results := make([]types.AuthConfig, lookups) + var wg sync.WaitGroup + for i := range lookups { + wg.Go(func() { + auth, err := p.GetAuthConfig("docker.io") + assert.Check(t, err) + results[i] = auth + }) + } + wg.Wait() + + for _, auth := range results { + assert.DeepEqual(t, auth, desktopCredentials()) + } + assert.Equal(t, hub.sessionCalls.Load(), int32(1)) +} + +func TestConnectSkipsMissingSocket(t *testing.T) { + t.Parallel() + _, err := connect(filepath.Join(t.TempDir(), "engine.sock")) + assert.Assert(t, errors.Is(err, fs.ErrNotExist), err) + assert.Assert(t, isSessionUnavailable(err)) +} + +func TestIsSessionUnavailable(t *testing.T) { + t.Parallel() + for _, err := range []error{ + connectError(seclient.ReasonNotRunning), + fmt.Errorf("get session: %w", connectError(seclient.ReasonNotRunning)), + connectError(seclient.ReasonPermissionDenied), + connectError(seclient.ReasonTimeout), + connectError(seclient.ReasonUnknown), + dockerhub.ErrNoSession, + dockerhub.ErrNoDefaultProfile, + errSessionExpired, + fs.ErrNotExist, + } { + assert.Assert(t, isSessionUnavailable(err), err) + } + for _, err := range []error{ + seclient.ErrAccessDenied, + errors.New("no username for the session"), + context.DeadlineExceeded, + } { + assert.Assert(t, !isSessionUnavailable(err), err) + } +} From 5e1a6554f0b14e13921a4ae25265ed3b290a9f29 Mon Sep 17 00:00:00 2001 From: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:03:10 +0100 Subject: [PATCH 3/3] cli/command: use the Docker Desktop session for Docker Hub When Docker Desktop is running and signed in, send its Docker Hub session as the registry credentials for Docker Hub (docker.io) and Docker Hardened Images (dhi.io) when pulling or pushing images through the daemon: docker pull, push, run, create, plugin install and push, service create and update, and stack deploy. The lookup goes through the new internal/registryauth package. Credentials in DOCKER_AUTH_CONFIG take precedence for the registries they cover. Without a usable Docker Desktop session, the CLI uses its credential store, credential helpers, and configuration file as before. docker login and stored credentials are not changed. FakeCli returns its configuration file as the auth provider, so tests never reach the Docker Desktop of the machine they run on. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> --- cli/command/cli.go | 19 +++ cli/command/cli_test.go | 15 +++ cli/command/container/create.go | 3 +- cli/command/image/pull.go | 3 +- cli/command/image/push.go | 3 +- cli/command/plugin/install.go | 3 +- cli/command/plugin/push.go | 3 +- cli/command/service/create.go | 3 +- cli/command/service/update.go | 3 +- cli/command/stack/deploy_composefile.go | 3 +- docs/reference/commandline/login.md | 12 ++ internal/registryauth/registryauth.go | 62 ++++++++++ internal/registryauth/registryauth_test.go | 131 +++++++++++++++++++++ internal/test/cli.go | 5 + 14 files changed, 260 insertions(+), 8 deletions(-) create mode 100644 internal/registryauth/registryauth.go create mode 100644 internal/registryauth/registryauth_test.go diff --git a/cli/command/cli.go b/cli/command/cli.go index 0d2f4b506f63..308cbbd18b6e 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -16,6 +16,7 @@ import ( "github.com/docker/cli/cli/config" "github.com/docker/cli/cli/config/configfile" + configtypes "github.com/docker/cli/cli/config/types" dcontext "github.com/docker/cli/cli/context" "github.com/docker/cli/cli/context/docker" "github.com/docker/cli/cli/context/store" @@ -23,6 +24,7 @@ import ( cliflags "github.com/docker/cli/cli/flags" "github.com/docker/cli/cli/streams" "github.com/docker/cli/cli/version" + "github.com/docker/cli/internal/secretsengine" dopts "github.com/docker/cli/opts" "github.com/moby/moby/api/types/build" "github.com/moby/moby/client" @@ -75,6 +77,8 @@ type DockerCli struct { contextStoreConfig *store.Config initTimeout time.Duration res telemetryResource + registryAuthOnce sync.Once + registryAuth secretsengine.AuthProvider // baseCtx is the base context used for internal operations. In the future // this may be replaced by explicitly passing a context to functions that @@ -141,6 +145,21 @@ func (cli *DockerCli) ConfigFile() *configfile.ConfigFile { return cli.configFile } +func (cli *DockerCli) RegistryAuthProvider() secretsengine.AuthProvider { + cli.registryAuthOnce.Do(func() { + cli.registryAuth = secretsengine.NewDesktop(configFileAuth{cli}) + }) + return cli.registryAuth +} + +type configFileAuth struct { + cli *DockerCli +} + +func (c configFileAuth) GetAuthConfig(registryHostname string) (configtypes.AuthConfig, error) { + return c.cli.ConfigFile().GetAuthConfig(registryHostname) +} + // ServerInfo returns the server version details for the host this client is // connected to func (cli *DockerCli) ServerInfo() ServerInfo { diff --git a/cli/command/cli_test.go b/cli/command/cli_test.go index 09c093d5ddef..fc0413f50d20 100644 --- a/cli/command/cli_test.go +++ b/cli/command/cli_test.go @@ -18,6 +18,7 @@ import ( "github.com/docker/cli/cli/config" "github.com/docker/cli/cli/config/configfile" + configtypes "github.com/docker/cli/cli/config/types" "github.com/docker/cli/cli/context/store" "github.com/docker/cli/cli/flags" "github.com/moby/moby/client" @@ -501,3 +502,17 @@ func TestNewDockerCliWithAPIClientOptions(t *testing.T) { assert.NilError(t, err) assert.DeepEqual(t, received, "fake-agent/0.0.1") } + +func TestRegistryAuthProvider(t *testing.T) { + t.Parallel() + cli := &DockerCli{configFile: &configfile.ConfigFile{}} + p := cli.RegistryAuthProvider() + assert.Assert(t, p == cli.RegistryAuthProvider(), "the provider must be created once per DockerCli") + + cli.configFile = &configfile.ConfigFile{AuthConfigs: map[string]configtypes.AuthConfig{ + "ghcr.io": {Username: "user", Password: "pass"}, + }} + got, err := p.GetAuthConfig("ghcr.io") + assert.NilError(t, err) + assert.DeepEqual(t, got, configtypes.AuthConfig{Username: "user", Password: "pass"}) +} diff --git a/cli/command/container/create.go b/cli/command/container/create.go index 122d15e2e149..14ab92d5737f 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -21,6 +21,7 @@ import ( "github.com/docker/cli/cli/config/types" "github.com/docker/cli/cli/streams" "github.com/docker/cli/internal/jsonstream" + "github.com/docker/cli/internal/registryauth" "github.com/docker/cli/opts" "github.com/moby/moby/api/types/mount" "github.com/moby/moby/client" @@ -133,7 +134,7 @@ func runCreate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, } func pullImage(ctx context.Context, dockerCLI command.Cli, img string, options *createOptions) error { - encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), img) + encodedAuth, err := registryauth.EncodedAuth(dockerCLI, img) if err != nil { return err } diff --git a/cli/command/image/pull.go b/cli/command/image/pull.go index 7485d21a6880..27aca9e75af7 100644 --- a/cli/command/image/pull.go +++ b/cli/command/image/pull.go @@ -14,6 +14,7 @@ import ( "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/streams" "github.com/docker/cli/internal/jsonstream" + "github.com/docker/cli/internal/registryauth" "github.com/moby/moby/client" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/spf13/cobra" @@ -90,7 +91,7 @@ func runPull(ctx context.Context, dockerCLI command.Cli, opts pullOptions) error ociPlatforms = append(ociPlatforms, p) } - encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), distributionRef.String()) + encodedAuth, err := registryauth.EncodedAuth(dockerCLI, distributionRef.String()) if err != nil { return err } diff --git a/cli/command/image/push.go b/cli/command/image/push.go index 87e2f7dea4c4..fdd1f52f47cf 100644 --- a/cli/command/image/push.go +++ b/cli/command/image/push.go @@ -17,6 +17,7 @@ import ( "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/streams" "github.com/docker/cli/internal/jsonstream" + "github.com/docker/cli/internal/registryauth" "github.com/docker/cli/internal/tui" "github.com/moby/moby/api/types/auxprogress" "github.com/moby/moby/client" @@ -108,7 +109,7 @@ To push the complete multi-platform image, remove the --platform flag. } // Resolve the Auth config relevant for this server - encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCli.ConfigFile(), ref.String()) + encodedAuth, err := registryauth.EncodedAuth(dockerCli, ref.String()) if err != nil { return err } diff --git a/cli/command/plugin/install.go b/cli/command/plugin/install.go index 7d2d9aafaeb0..eaffc5eae9ff 100644 --- a/cli/command/plugin/install.go +++ b/cli/command/plugin/install.go @@ -9,6 +9,7 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/cli/internal/jsonstream" "github.com/docker/cli/internal/prompt" + "github.com/docker/cli/internal/registryauth" "github.com/moby/moby/api/types/plugin" "github.com/moby/moby/client" "github.com/spf13/cobra" @@ -60,7 +61,7 @@ func buildPullConfig(dockerCLI command.Cli, opts pluginOptions) (client.PluginIn return client.PluginInstallOptions{}, err } - encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), ref.String()) + encodedAuth, err := registryauth.EncodedAuth(dockerCLI, ref.String()) if err != nil { return client.PluginInstallOptions{}, err } diff --git a/cli/command/plugin/push.go b/cli/command/plugin/push.go index af76db49ebef..ca7f7139faee 100644 --- a/cli/command/plugin/push.go +++ b/cli/command/plugin/push.go @@ -8,6 +8,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/internal/jsonstream" + "github.com/docker/cli/internal/registryauth" "github.com/moby/moby/client" "github.com/spf13/cobra" ) @@ -42,7 +43,7 @@ func runPush(ctx context.Context, dockerCli command.Cli, name string) error { } named = reference.TagNameOnly(named) - encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCli.ConfigFile(), named.String()) + encodedAuth, err := registryauth.EncodedAuth(dockerCli, named.String()) if err != nil { return err } diff --git a/cli/command/service/create.go b/cli/command/service/create.go index 45406d7b2633..d2c1e0ee688c 100644 --- a/cli/command/service/create.go +++ b/cli/command/service/create.go @@ -7,6 +7,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/completion" + "github.com/docker/cli/internal/registryauth" cliopts "github.com/docker/cli/opts" "github.com/moby/moby/api/types/swarm" "github.com/moby/moby/client" @@ -120,7 +121,7 @@ func runCreate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, if opts.registryAuth { // Retrieve encoded auth token from the image reference var err error - encodedAuth, err = command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), opts.image) + encodedAuth, err = registryauth.EncodedAuth(dockerCLI, opts.image) if err != nil { return err } diff --git a/cli/command/service/update.go b/cli/command/service/update.go index 2e7a0ee25fce..7da58245aacb 100644 --- a/cli/command/service/update.go +++ b/cli/command/service/update.go @@ -17,6 +17,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/completion" + "github.com/docker/cli/internal/registryauth" "github.com/docker/cli/opts" "github.com/docker/cli/opts/swarmopts" "github.com/moby/moby/api/types/container" @@ -223,7 +224,7 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, // Retrieve encoded auth token from the image reference // This would be the old image if it didn't change in this update var err error - encodedAuth, err = command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), spec.TaskTemplate.ContainerSpec.Image) + encodedAuth, err = registryauth.EncodedAuth(dockerCLI, spec.TaskTemplate.ContainerSpec.Image) if err != nil { return err } diff --git a/cli/command/stack/deploy_composefile.go b/cli/command/stack/deploy_composefile.go index ad85765133cb..82f8c740736d 100644 --- a/cli/command/stack/deploy_composefile.go +++ b/cli/command/stack/deploy_composefile.go @@ -10,6 +10,7 @@ import ( "github.com/docker/cli/cli/command/service" "github.com/docker/cli/cli/compose/convert" composetypes "github.com/docker/cli/cli/compose/types" + "github.com/docker/cli/internal/registryauth" "github.com/moby/moby/api/types/container" "github.com/moby/moby/api/types/network" "github.com/moby/moby/api/types/swarm" @@ -224,7 +225,7 @@ func deployServices(ctx context.Context, dockerCLI command.Cli, services map[str if sendAuth { // Retrieve encoded auth token from the image reference - encodedAuth, err = command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), image) + encodedAuth, err = registryauth.EncodedAuth(dockerCLI, image) if err != nil { return nil, err } diff --git a/docs/reference/commandline/login.md b/docs/reference/commandline/login.md index 458edd7b91b0..660e9258352f 100644 --- a/docs/reference/commandline/login.md +++ b/docs/reference/commandline/login.md @@ -70,6 +70,18 @@ With Docker Desktop, the credential store is already installed and configured for you. Unless you want to change the credential store used by Docker Desktop, you can skip the following steps. +#### Docker Desktop sign-in + +When Docker Desktop is running and you are signed in, commands that pull or +push images through the Docker Engine, such as `docker pull`, `docker push`, +`docker run`, and `docker service create`, use the Docker Desktop session for +Docker Hub (`docker.io`) and Docker Hardened Images (`dhi.io`). The session is +used before the credential store, credential helpers, and the configuration +file. Credentials set in the `DOCKER_AUTH_CONFIG` environment variable take +precedence over the Docker Desktop session. If Docker Desktop is not installed +or not running, or you are not signed in, the Docker CLI uses its own +credentials. + #### Configure the credential store You need to specify the credential store in `$HOME/.docker/config.json` diff --git a/internal/registryauth/registryauth.go b/internal/registryauth/registryauth.go new file mode 100644 index 000000000000..657387492aa1 --- /dev/null +++ b/internal/registryauth/registryauth.go @@ -0,0 +1,62 @@ +package registryauth + +import ( + "os" + + "github.com/distribution/reference" + "github.com/docker/cli/cli/config/configfile" + configtypes "github.com/docker/cli/cli/config/types" + "github.com/docker/cli/internal/secretsengine" + "github.com/moby/moby/api/pkg/authconfig" + registrytypes "github.com/moby/moby/api/types/registry" +) + +type configProvider interface { + ConfigFile() *configfile.ConfigFile +} + +type authProvider interface { + RegistryAuthProvider() secretsengine.AuthProvider +} + +type envAuthFunc func(registryHostname string) (configtypes.AuthConfig, bool) + +func EncodedAuth(dockerCLI configProvider, image string) (string, error) { + var auth secretsengine.AuthProvider = dockerCLI.ConfigFile() + if p, ok := dockerCLI.(authProvider); ok { + auth = p.RegistryAuthProvider() + } + return encodedAuth(envAuthConfig, auth, image) +} + +func encodedAuth(envAuth envAuthFunc, auth secretsengine.AuthProvider, image string) (string, error) { + registryRef, err := reference.ParseNormalizedNamed(image) + if err != nil { + return "", err + } + domain := reference.Domain(registryRef) + authConfig, ok := envAuth(domain) + if !ok { + authConfig, err = auth.GetAuthConfig(domain) + if err != nil { + return "", err + } + } + + return authconfig.Encode(registrytypes.AuthConfig{ + Username: authConfig.Username, + Password: authConfig.Password, + ServerAddress: authConfig.ServerAddress, + Auth: authConfig.Auth, + IdentityToken: authConfig.IdentityToken, + RegistryToken: authConfig.RegistryToken, + }) +} + +func envAuthConfig(registryHostname string) (configtypes.AuthConfig, bool) { + if os.Getenv(configfile.DockerEnvConfigKey) == "" { + return configtypes.AuthConfig{}, false + } + authConfig, err := configfile.New("").GetAuthConfig(registryHostname) + return authConfig, err == nil && authConfig.Username != "" +} diff --git a/internal/registryauth/registryauth_test.go b/internal/registryauth/registryauth_test.go new file mode 100644 index 000000000000..941fc9de5cad --- /dev/null +++ b/internal/registryauth/registryauth_test.go @@ -0,0 +1,131 @@ +package registryauth + +import ( + "bytes" + "sync" + "testing" + + "github.com/docker/cli/cli/config/configfile" + configtypes "github.com/docker/cli/cli/config/types" + "github.com/docker/cli/internal/secretsengine" + "github.com/moby/moby/api/pkg/authconfig" + registrytypes "github.com/moby/moby/api/types/registry" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +type recordingAuthProvider struct { + mu sync.Mutex + hosts []string +} + +func (p *recordingAuthProvider) GetAuthConfig(registryHostname string) (configtypes.AuthConfig, error) { + p.mu.Lock() + defer p.mu.Unlock() + p.hosts = append(p.hosts, registryHostname) + return configtypes.AuthConfig{Username: "hubuser", Password: "desktop-token", ServerAddress: registryHostname}, nil +} + +type configOnlyCli struct { + cfg *configfile.ConfigFile +} + +func (c *configOnlyCli) ConfigFile() *configfile.ConfigFile { + return c.cfg +} + +type fakeCli struct { + configOnlyCli + auth *recordingAuthProvider +} + +func (c *fakeCli) RegistryAuthProvider() secretsengine.AuthProvider { + return c.auth +} + +func noEnvAuth(string) (configtypes.AuthConfig, bool) { + return configtypes.AuthConfig{}, false +} + +func loadConfig(t *testing.T) *configfile.ConfigFile { + t.Helper() + const configFileContent = `{"auths": { + "https://index.docker.io/v1/": {"auth": "dXNlcm5hbWU6cGFzc3dvcmQ="}, + "localhost:5000": {"auth": "dXNlcm5hbWU6cGFzc3dvcmQ="} + } +}` + cfg := &configfile.ConfigFile{} + assert.NilError(t, cfg.LoadFromReader(bytes.NewReader([]byte(configFileContent)))) + return cfg +} + +func TestEncodedAuthUsesCLIAuthProvider(t *testing.T) { + t.Parallel() + dockerCLI := &fakeCli{configOnlyCli: configOnlyCli{cfg: configfile.New("")}, auth: &recordingAuthProvider{}} + + actual, err := EncodedAuth(dockerCLI, "dhi.io/python") + assert.NilError(t, err) + expected, err := authconfig.Encode(registrytypes.AuthConfig{Username: "hubuser", Password: "desktop-token", ServerAddress: "dhi.io"}) + assert.NilError(t, err) + assert.Check(t, is.Equal(actual, expected)) + assert.Check(t, is.DeepEqual(dockerCLI.auth.hosts, []string{"dhi.io"})) +} + +func TestEncodedAuthWithoutAuthProviderUsesConfigFile(t *testing.T) { + t.Parallel() + actual, err := EncodedAuth(&configOnlyCli{cfg: loadConfig(t)}, "ubuntu") + assert.NilError(t, err) + expected, err := authconfig.Encode(registrytypes.AuthConfig{Username: "username", Password: "password", ServerAddress: "https://index.docker.io/v1/"}) + assert.NilError(t, err) + assert.Check(t, is.Equal(actual, expected)) +} + +func TestEncodedAuthEnvTakesPrecedence(t *testing.T) { + t.Parallel() + envAuth := func(registryHostname string) (configtypes.AuthConfig, bool) { + return configtypes.AuthConfig{Username: "envuser", Password: "envpass", ServerAddress: registryHostname}, true + } + auth := &recordingAuthProvider{} + + actual, err := encodedAuth(envAuth, auth, "ubuntu") + assert.NilError(t, err) + expected, err := authconfig.Encode(registrytypes.AuthConfig{Username: "envuser", Password: "envpass", ServerAddress: "docker.io"}) + assert.NilError(t, err) + assert.Check(t, is.Equal(actual, expected)) + assert.Check(t, is.Len(auth.hosts, 0), "the auth provider must not be asked for a registry in DOCKER_AUTH_CONFIG") +} + +func TestEnvAuthConfig(t *testing.T) { + t.Setenv(configfile.DockerEnvConfigKey, `{"auths":{"https://index.docker.io/v1/":{"auth":"ZW52dXNlcjplbnZwYXNz"}}}`) + + got, ok := envAuthConfig("docker.io") + assert.Check(t, ok) + assert.Check(t, is.DeepEqual(got, configtypes.AuthConfig{Username: "envuser", Password: "envpass", ServerAddress: "https://index.docker.io/v1/"})) + + _, ok = envAuthConfig("ghcr.io") + assert.Check(t, !ok) +} + +func TestEncodedAuthFromConfigFile(t *testing.T) { + t.Parallel() + cfg := loadConfig(t) + + tests := []struct { + image string + expected registrytypes.AuthConfig + }{ + {image: "ubuntu", expected: registrytypes.AuthConfig{Username: "username", Password: "password", ServerAddress: "https://index.docker.io/v1/"}}, + {image: "localhost:5000/ubuntu", expected: registrytypes.AuthConfig{Username: "username", Password: "password", ServerAddress: "localhost:5000"}}, + {image: "no-auth.example.com/ubuntu", expected: registrytypes.AuthConfig{}}, + } + for _, tc := range tests { + t.Run(tc.image, func(t *testing.T) { + t.Parallel() + actual, err := encodedAuth(noEnvAuth, cfg, tc.image) + assert.NilError(t, err) + expected, err := authconfig.Encode(tc.expected) + assert.NilError(t, err) + assert.Check(t, is.Equal(actual, expected)) + }) + } +} diff --git a/internal/test/cli.go b/internal/test/cli.go index 4a5b0bf9a0fc..5b431437b719 100644 --- a/internal/test/cli.go +++ b/internal/test/cli.go @@ -12,6 +12,7 @@ import ( manifeststore "github.com/docker/cli/cli/manifest/store" "github.com/docker/cli/cli/streams" "github.com/docker/cli/internal/registryclient" + "github.com/docker/cli/internal/secretsengine" "github.com/moby/moby/client" ) @@ -176,6 +177,10 @@ func (c *FakeCli) SetRegistryClient(registryClient registryclient.RegistryClient c.registryClient = registryClient } +func (c *FakeCli) RegistryAuthProvider() secretsengine.AuthProvider { + return c.configfile +} + // BuildKitEnabled on the fake cli func (*FakeCli) BuildKitEnabled() (bool, error) { return true, nil