From 3ac1a8e7b831f761e0b97ac97a360be78f4fe81d Mon Sep 17 00:00:00 2001 From: Nicolas Ontiveros Date: Thu, 14 Nov 2024 08:46:31 -0800 Subject: [PATCH] Update to latest dataplane code --- go.mod | 3 +- go.sum | 6 +- .../msi-dataplane/pkg/dataplane/identity.go | 4 + vendor/github.com/golang/mock/AUTHORS | 12 - vendor/github.com/golang/mock/CONTRIBUTORS | 37 -- vendor/github.com/golang/mock/LICENSE | 202 ------- .../golang/mock/mockgen/model/model.go | 495 ------------------ vendor/modules.txt | 5 +- 8 files changed, 8 insertions(+), 756 deletions(-) delete mode 100644 vendor/github.com/golang/mock/AUTHORS delete mode 100644 vendor/github.com/golang/mock/CONTRIBUTORS delete mode 100644 vendor/github.com/golang/mock/LICENSE delete mode 100644 vendor/github.com/golang/mock/mockgen/model/model.go diff --git a/go.mod b/go.mod index 57765752974..7d736f2f86d 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/Azure/go-autorest/autorest/to v0.4.0 github.com/Azure/go-autorest/autorest/validation v0.3.1 github.com/Azure/go-autorest/tracing v0.6.0 - github.com/Azure/msi-dataplane v0.0.8-0.20241113221541-5dcc0d34bca8 + github.com/Azure/msi-dataplane v0.0.8-0.20241114155530-0dd8c166816a github.com/apparentlymart/go-cidr v1.1.0 github.com/codahale/etm v0.0.0-20141003032925-c00c9e6fb4c9 github.com/containers/image/v5 v5.30.1 @@ -38,7 +38,6 @@ require ( github.com/go-test/deep v1.1.0 github.com/gofrs/uuid v4.4.0+incompatible github.com/golang-jwt/jwt/v4 v4.5.0 - github.com/golang/mock v1.6.0 github.com/google/gnostic v0.5.7-v3refs github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum index 09c33db0958..93d579d239e 100644 --- a/go.sum +++ b/go.sum @@ -60,8 +60,8 @@ github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+Z github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= -github.com/Azure/msi-dataplane v0.0.8-0.20241113221541-5dcc0d34bca8 h1:mw91HhsAvqc/qjyHlpq6WlBIh0VXDjqg03SB55A9EmE= -github.com/Azure/msi-dataplane v0.0.8-0.20241113221541-5dcc0d34bca8/go.mod h1:/fXvAsxSogxoT7If0xfaeyaIQ7Q/0xAY9ISn7lOpA4o= +github.com/Azure/msi-dataplane v0.0.8-0.20241114155530-0dd8c166816a h1:b5xpBQDHuLgRqSRTOXsxJhELhgZ/4NAbLmPDxlz7s0Y= +github.com/Azure/msi-dataplane v0.0.8-0.20241114155530-0dd8c166816a/go.mod h1:/fXvAsxSogxoT7If0xfaeyaIQ7Q/0xAY9ISn7lOpA4o= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= @@ -325,8 +325,6 @@ github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= diff --git a/vendor/github.com/Azure/msi-dataplane/pkg/dataplane/identity.go b/vendor/github.com/Azure/msi-dataplane/pkg/dataplane/identity.go index a8f5bb33bdf..47564b82e4e 100644 --- a/vendor/github.com/Azure/msi-dataplane/pkg/dataplane/identity.go +++ b/vendor/github.com/Azure/msi-dataplane/pkg/dataplane/identity.go @@ -95,6 +95,10 @@ func getClientCertificateCredential(identity swagger.NestedCredentialsObject, cl // x5c header required: https://eng.ms/docs/products/arm/rbac/managed_identities/msionboardingrequestingatoken SendCertificateChain: true, + + // Disable instance discovery because MSI credential may have regional AAD endpoint that instance discovery endpoint doesn't support + // e.g. when MSI credential has westus2.login.microsoft.com, it will cause instance discovery to fail with HTTP 400 + DisableInstanceDiscovery: true, } // Set the regional AAD endpoint diff --git a/vendor/github.com/golang/mock/AUTHORS b/vendor/github.com/golang/mock/AUTHORS deleted file mode 100644 index 660b8ccc8ae..00000000000 --- a/vendor/github.com/golang/mock/AUTHORS +++ /dev/null @@ -1,12 +0,0 @@ -# This is the official list of GoMock authors for copyright purposes. -# This file is distinct from the CONTRIBUTORS files. -# See the latter for an explanation. - -# Names should be added to this file as -# Name or Organization -# The email address is not required for organizations. - -# Please keep the list sorted. - -Alex Reece -Google Inc. diff --git a/vendor/github.com/golang/mock/CONTRIBUTORS b/vendor/github.com/golang/mock/CONTRIBUTORS deleted file mode 100644 index def849cab1b..00000000000 --- a/vendor/github.com/golang/mock/CONTRIBUTORS +++ /dev/null @@ -1,37 +0,0 @@ -# This is the official list of people who can contribute (and typically -# have contributed) code to the gomock repository. -# The AUTHORS file lists the copyright holders; this file -# lists people. For example, Google employees are listed here -# but not in AUTHORS, because Google holds the copyright. -# -# The submission process automatically checks to make sure -# that people submitting code are listed in this file (by email address). -# -# Names should be added to this file only after verifying that -# the individual or the individual's organization has agreed to -# the appropriate Contributor License Agreement, found here: -# -# http://code.google.com/legal/individual-cla-v1.0.html -# http://code.google.com/legal/corporate-cla-v1.0.html -# -# The agreement for individuals can be filled out on the web. -# -# When adding J Random Contributor's name to this file, -# either J's name or J's organization's name should be -# added to the AUTHORS file, depending on whether the -# individual or corporate CLA was used. - -# Names should be added to this file like so: -# Name -# -# An entry with two email addresses specifies that the -# first address should be used in the submit logs and -# that the second address should be recognized as the -# same person when interacting with Rietveld. - -# Please keep the list sorted. - -Aaron Jacobs -Alex Reece -David Symonds -Ryan Barrett diff --git a/vendor/github.com/golang/mock/LICENSE b/vendor/github.com/golang/mock/LICENSE deleted file mode 100644 index d6456956733..00000000000 --- a/vendor/github.com/golang/mock/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/golang/mock/mockgen/model/model.go b/vendor/github.com/golang/mock/mockgen/model/model.go deleted file mode 100644 index 2c6a62ceb26..00000000000 --- a/vendor/github.com/golang/mock/mockgen/model/model.go +++ /dev/null @@ -1,495 +0,0 @@ -// Copyright 2012 Google 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 model contains the data model necessary for generating mock implementations. -package model - -import ( - "encoding/gob" - "fmt" - "io" - "reflect" - "strings" -) - -// pkgPath is the importable path for package model -const pkgPath = "github.com/golang/mock/mockgen/model" - -// Package is a Go package. It may be a subset. -type Package struct { - Name string - PkgPath string - Interfaces []*Interface - DotImports []string -} - -// Print writes the package name and its exported interfaces. -func (pkg *Package) Print(w io.Writer) { - _, _ = fmt.Fprintf(w, "package %s\n", pkg.Name) - for _, intf := range pkg.Interfaces { - intf.Print(w) - } -} - -// Imports returns the imports needed by the Package as a set of import paths. -func (pkg *Package) Imports() map[string]bool { - im := make(map[string]bool) - for _, intf := range pkg.Interfaces { - intf.addImports(im) - } - return im -} - -// Interface is a Go interface. -type Interface struct { - Name string - Methods []*Method -} - -// Print writes the interface name and its methods. -func (intf *Interface) Print(w io.Writer) { - _, _ = fmt.Fprintf(w, "interface %s\n", intf.Name) - for _, m := range intf.Methods { - m.Print(w) - } -} - -func (intf *Interface) addImports(im map[string]bool) { - for _, m := range intf.Methods { - m.addImports(im) - } -} - -// AddMethod adds a new method, de-duplicating by method name. -func (intf *Interface) AddMethod(m *Method) { - for _, me := range intf.Methods { - if me.Name == m.Name { - return - } - } - intf.Methods = append(intf.Methods, m) -} - -// Method is a single method of an interface. -type Method struct { - Name string - In, Out []*Parameter - Variadic *Parameter // may be nil -} - -// Print writes the method name and its signature. -func (m *Method) Print(w io.Writer) { - _, _ = fmt.Fprintf(w, " - method %s\n", m.Name) - if len(m.In) > 0 { - _, _ = fmt.Fprintf(w, " in:\n") - for _, p := range m.In { - p.Print(w) - } - } - if m.Variadic != nil { - _, _ = fmt.Fprintf(w, " ...:\n") - m.Variadic.Print(w) - } - if len(m.Out) > 0 { - _, _ = fmt.Fprintf(w, " out:\n") - for _, p := range m.Out { - p.Print(w) - } - } -} - -func (m *Method) addImports(im map[string]bool) { - for _, p := range m.In { - p.Type.addImports(im) - } - if m.Variadic != nil { - m.Variadic.Type.addImports(im) - } - for _, p := range m.Out { - p.Type.addImports(im) - } -} - -// Parameter is an argument or return parameter of a method. -type Parameter struct { - Name string // may be empty - Type Type -} - -// Print writes a method parameter. -func (p *Parameter) Print(w io.Writer) { - n := p.Name - if n == "" { - n = `""` - } - _, _ = fmt.Fprintf(w, " - %v: %v\n", n, p.Type.String(nil, "")) -} - -// Type is a Go type. -type Type interface { - String(pm map[string]string, pkgOverride string) string - addImports(im map[string]bool) -} - -func init() { - gob.Register(&ArrayType{}) - gob.Register(&ChanType{}) - gob.Register(&FuncType{}) - gob.Register(&MapType{}) - gob.Register(&NamedType{}) - gob.Register(&PointerType{}) - - // Call gob.RegisterName to make sure it has the consistent name registered - // for both gob decoder and encoder. - // - // For a non-pointer type, gob.Register will try to get package full path by - // calling rt.PkgPath() for a name to register. If your project has vendor - // directory, it is possible that PkgPath will get a path like this: - // ../../../vendor/github.com/golang/mock/mockgen/model - gob.RegisterName(pkgPath+".PredeclaredType", PredeclaredType("")) -} - -// ArrayType is an array or slice type. -type ArrayType struct { - Len int // -1 for slices, >= 0 for arrays - Type Type -} - -func (at *ArrayType) String(pm map[string]string, pkgOverride string) string { - s := "[]" - if at.Len > -1 { - s = fmt.Sprintf("[%d]", at.Len) - } - return s + at.Type.String(pm, pkgOverride) -} - -func (at *ArrayType) addImports(im map[string]bool) { at.Type.addImports(im) } - -// ChanType is a channel type. -type ChanType struct { - Dir ChanDir // 0, 1 or 2 - Type Type -} - -func (ct *ChanType) String(pm map[string]string, pkgOverride string) string { - s := ct.Type.String(pm, pkgOverride) - if ct.Dir == RecvDir { - return "<-chan " + s - } - if ct.Dir == SendDir { - return "chan<- " + s - } - return "chan " + s -} - -func (ct *ChanType) addImports(im map[string]bool) { ct.Type.addImports(im) } - -// ChanDir is a channel direction. -type ChanDir int - -// Constants for channel directions. -const ( - RecvDir ChanDir = 1 - SendDir ChanDir = 2 -) - -// FuncType is a function type. -type FuncType struct { - In, Out []*Parameter - Variadic *Parameter // may be nil -} - -func (ft *FuncType) String(pm map[string]string, pkgOverride string) string { - args := make([]string, len(ft.In)) - for i, p := range ft.In { - args[i] = p.Type.String(pm, pkgOverride) - } - if ft.Variadic != nil { - args = append(args, "..."+ft.Variadic.Type.String(pm, pkgOverride)) - } - rets := make([]string, len(ft.Out)) - for i, p := range ft.Out { - rets[i] = p.Type.String(pm, pkgOverride) - } - retString := strings.Join(rets, ", ") - if nOut := len(ft.Out); nOut == 1 { - retString = " " + retString - } else if nOut > 1 { - retString = " (" + retString + ")" - } - return "func(" + strings.Join(args, ", ") + ")" + retString -} - -func (ft *FuncType) addImports(im map[string]bool) { - for _, p := range ft.In { - p.Type.addImports(im) - } - if ft.Variadic != nil { - ft.Variadic.Type.addImports(im) - } - for _, p := range ft.Out { - p.Type.addImports(im) - } -} - -// MapType is a map type. -type MapType struct { - Key, Value Type -} - -func (mt *MapType) String(pm map[string]string, pkgOverride string) string { - return "map[" + mt.Key.String(pm, pkgOverride) + "]" + mt.Value.String(pm, pkgOverride) -} - -func (mt *MapType) addImports(im map[string]bool) { - mt.Key.addImports(im) - mt.Value.addImports(im) -} - -// NamedType is an exported type in a package. -type NamedType struct { - Package string // may be empty - Type string -} - -func (nt *NamedType) String(pm map[string]string, pkgOverride string) string { - if pkgOverride == nt.Package { - return nt.Type - } - prefix := pm[nt.Package] - if prefix != "" { - return prefix + "." + nt.Type - } - - return nt.Type -} - -func (nt *NamedType) addImports(im map[string]bool) { - if nt.Package != "" { - im[nt.Package] = true - } -} - -// PointerType is a pointer to another type. -type PointerType struct { - Type Type -} - -func (pt *PointerType) String(pm map[string]string, pkgOverride string) string { - return "*" + pt.Type.String(pm, pkgOverride) -} -func (pt *PointerType) addImports(im map[string]bool) { pt.Type.addImports(im) } - -// PredeclaredType is a predeclared type such as "int". -type PredeclaredType string - -func (pt PredeclaredType) String(map[string]string, string) string { return string(pt) } -func (pt PredeclaredType) addImports(map[string]bool) {} - -// The following code is intended to be called by the program generated by ../reflect.go. - -// InterfaceFromInterfaceType returns a pointer to an interface for the -// given reflection interface type. -func InterfaceFromInterfaceType(it reflect.Type) (*Interface, error) { - if it.Kind() != reflect.Interface { - return nil, fmt.Errorf("%v is not an interface", it) - } - intf := &Interface{} - - for i := 0; i < it.NumMethod(); i++ { - mt := it.Method(i) - // TODO: need to skip unexported methods? or just raise an error? - m := &Method{ - Name: mt.Name, - } - - var err error - m.In, m.Variadic, m.Out, err = funcArgsFromType(mt.Type) - if err != nil { - return nil, err - } - - intf.AddMethod(m) - } - - return intf, nil -} - -// t's Kind must be a reflect.Func. -func funcArgsFromType(t reflect.Type) (in []*Parameter, variadic *Parameter, out []*Parameter, err error) { - nin := t.NumIn() - if t.IsVariadic() { - nin-- - } - var p *Parameter - for i := 0; i < nin; i++ { - p, err = parameterFromType(t.In(i)) - if err != nil { - return - } - in = append(in, p) - } - if t.IsVariadic() { - p, err = parameterFromType(t.In(nin).Elem()) - if err != nil { - return - } - variadic = p - } - for i := 0; i < t.NumOut(); i++ { - p, err = parameterFromType(t.Out(i)) - if err != nil { - return - } - out = append(out, p) - } - return -} - -func parameterFromType(t reflect.Type) (*Parameter, error) { - tt, err := typeFromType(t) - if err != nil { - return nil, err - } - return &Parameter{Type: tt}, nil -} - -var errorType = reflect.TypeOf((*error)(nil)).Elem() - -var byteType = reflect.TypeOf(byte(0)) - -func typeFromType(t reflect.Type) (Type, error) { - // Hack workaround for https://golang.org/issue/3853. - // This explicit check should not be necessary. - if t == byteType { - return PredeclaredType("byte"), nil - } - - if imp := t.PkgPath(); imp != "" { - return &NamedType{ - Package: impPath(imp), - Type: t.Name(), - }, nil - } - - // only unnamed or predeclared types after here - - // Lots of types have element types. Let's do the parsing and error checking for all of them. - var elemType Type - switch t.Kind() { - case reflect.Array, reflect.Chan, reflect.Map, reflect.Ptr, reflect.Slice: - var err error - elemType, err = typeFromType(t.Elem()) - if err != nil { - return nil, err - } - } - - switch t.Kind() { - case reflect.Array: - return &ArrayType{ - Len: t.Len(), - Type: elemType, - }, nil - case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, - reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128, reflect.String: - return PredeclaredType(t.Kind().String()), nil - case reflect.Chan: - var dir ChanDir - switch t.ChanDir() { - case reflect.RecvDir: - dir = RecvDir - case reflect.SendDir: - dir = SendDir - } - return &ChanType{ - Dir: dir, - Type: elemType, - }, nil - case reflect.Func: - in, variadic, out, err := funcArgsFromType(t) - if err != nil { - return nil, err - } - return &FuncType{ - In: in, - Out: out, - Variadic: variadic, - }, nil - case reflect.Interface: - // Two special interfaces. - if t.NumMethod() == 0 { - return PredeclaredType("interface{}"), nil - } - if t == errorType { - return PredeclaredType("error"), nil - } - case reflect.Map: - kt, err := typeFromType(t.Key()) - if err != nil { - return nil, err - } - return &MapType{ - Key: kt, - Value: elemType, - }, nil - case reflect.Ptr: - return &PointerType{ - Type: elemType, - }, nil - case reflect.Slice: - return &ArrayType{ - Len: -1, - Type: elemType, - }, nil - case reflect.Struct: - if t.NumField() == 0 { - return PredeclaredType("struct{}"), nil - } - } - - // TODO: Struct, UnsafePointer - return nil, fmt.Errorf("can't yet turn %v (%v) into a model.Type", t, t.Kind()) -} - -// impPath sanitizes the package path returned by `PkgPath` method of a reflect Type so that -// it is importable. PkgPath might return a path that includes "vendor". These paths do not -// compile, so we need to remove everything up to and including "/vendor/". -// See https://github.com/golang/go/issues/12019. -func impPath(imp string) string { - if strings.HasPrefix(imp, "vendor/") { - imp = "/" + imp - } - if i := strings.LastIndex(imp, "/vendor/"); i != -1 { - imp = imp[i+len("/vendor/"):] - } - return imp -} - -// ErrorInterface represent built-in error interface. -var ErrorInterface = Interface{ - Name: "error", - Methods: []*Method{ - { - Name: "Error", - Out: []*Parameter{ - { - Name: "", - Type: PredeclaredType("string"), - }, - }, - }, - }, -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 9e097432451..b892f6b42a2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -136,7 +136,7 @@ github.com/Azure/go-autorest/logger # github.com/Azure/go-autorest/tracing v0.6.0 ## explicit; go 1.12 github.com/Azure/go-autorest/tracing -# github.com/Azure/msi-dataplane v0.0.8-0.20241113221541-5dcc0d34bca8 +# github.com/Azure/msi-dataplane v0.0.8-0.20241114155530-0dd8c166816a ## explicit; go 1.21 github.com/Azure/msi-dataplane/pkg/dataplane github.com/Azure/msi-dataplane/pkg/dataplane/swagger @@ -693,9 +693,6 @@ github.com/golang-jwt/jwt/v5 # github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da ## explicit github.com/golang/groupcache/lru -# github.com/golang/mock v1.6.0 -## explicit; go 1.11 -github.com/golang/mock/mockgen/model # github.com/golang/protobuf v1.5.4 ## explicit; go 1.17 github.com/golang/protobuf/jsonpb