diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 3395226cc0c4..3d4f7fb900e2 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -119,6 +119,26 @@ "ImportPath": "github.com/GeertJohan/go.rice/embedded", "Rev": "c02ca9a983da5807ddf7d796784928f5be4afd09" }, + { + "ImportPath": "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud", + "Comment": "1.2.0", + "Rev": "773c7a284e1399960745d0e2c501f577a20d4947" + }, + { + "ImportPath": "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter", + "Comment": "1.2.0", + "Rev": "773c7a284e1399960745d0e2c501f577a20d4947" + }, + { + "ImportPath": "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta", + "Comment": "1.2.0", + "Rev": "773c7a284e1399960745d0e2c501f577a20d4947" + }, + { + "ImportPath": "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock", + "Comment": "1.2.0", + "Rev": "773c7a284e1399960745d0e2c501f577a20d4947" + }, { "ImportPath": "github.com/JeffAshton/win_pdh", "Rev": "76bb4ee9f0ab50f77826f2a2ee7fb9d3880d6ec2" diff --git a/Godeps/LICENSES b/Godeps/LICENSES index 8ae1fb3a178a..80b0e76adfdd 100644 --- a/Godeps/LICENSES +++ b/Godeps/LICENSES @@ -61242,6 +61242,846 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================================================ +================================================================================ += vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud licensed under: = + + + 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. + += vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/LICENSE 3b83ef96387f14655fc854ddc3c6bd57 +================================================================================ + + +================================================================================ += vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter licensed under: = + + + 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. + += vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/LICENSE 3b83ef96387f14655fc854ddc3c6bd57 +================================================================================ + + +================================================================================ += vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta licensed under: = + + + 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. + += vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/LICENSE 3b83ef96387f14655fc854ddc3c6bd57 +================================================================================ + + +================================================================================ += vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock licensed under: = + + + 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. + += vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/LICENSE 3b83ef96387f14655fc854ddc3c6bd57 +================================================================================ + + ================================================================================ = vendor/github.com/gophercloud/gophercloud licensed under: = diff --git a/hack/.golint_failures b/hack/.golint_failures index a918ef88f02b..4000805f41ef 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -87,7 +87,6 @@ pkg/apis/storage/v1beta1/util pkg/auth/authorizer/abac pkg/capabilities pkg/cloudprovider/providers/fake -pkg/cloudprovider/providers/gce/cloud pkg/cloudprovider/providers/photon pkg/cloudprovider/providers/vsphere pkg/cloudprovider/providers/vsphere/vclib diff --git a/hack/update-cloudprovider-gce.sh b/hack/update-cloudprovider-gce.sh deleted file mode 100755 index b35c429f8a9b..000000000000 --- a/hack/update-cloudprovider-gce.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2018 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. -source "${KUBE_ROOT}/hack/lib/init.sh" -GENERATOR="${KUBE_ROOT}/pkg/cloudprovider/providers/gce/cloud/gen/main.go" - -GEN_GO="${KUBE_ROOT}/pkg/cloudprovider/providers/gce/cloud/gen.go" -GEN_TEST_GO="${KUBE_ROOT}/pkg/cloudprovider/providers/gce/cloud/gen_test.go" - -kube::golang::setup_env - -TMPFILE=$(mktemp verify-cloudprovider-gce-XXXX) -trap "{ rm -f ${TMPFILE}; }" EXIT - -go run "${GENERATOR}" > ${TMPFILE} -mv "${TMPFILE}" "${GEN_GO}" -go run "${GENERATOR}" -mode test > ${TMPFILE} -mv "${TMPFILE}" "${GEN_TEST_GO}" - -exit 0 diff --git a/hack/verify-cloudprovider-gce.sh b/hack/verify-cloudprovider-gce.sh deleted file mode 100755 index c6b3bd89af78..000000000000 --- a/hack/verify-cloudprovider-gce.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2018 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. -source "${KUBE_ROOT}/hack/lib/init.sh" -GENERATOR="${KUBE_ROOT}/pkg/cloudprovider/providers/gce/cloud/gen/main.go" - -GEN_GO="${KUBE_ROOT}/pkg/cloudprovider/providers/gce/cloud/gen.go" -GEN_TEST_GO="${KUBE_ROOT}/pkg/cloudprovider/providers/gce/cloud/gen_test.go" - -kube::golang::setup_env - -TMPFILE=$(mktemp verify-cloudprovider-gce-XXXX) -trap "{ rm -f ${TMPFILE}; }" EXIT - -go run "${GENERATOR}" > ${TMPFILE} -if ! diff "${TMPFILE}" "${GEN_GO}"; then - echo "Generated file ${GEN_GO} needs to be updated (run hack/update-cloudprovider-gce.sh)" - echo - diff -u "${TMPFILE}" "${GEN_GO}" || true - exit 1 -fi - -go run "${GENERATOR}" -mode test > ${TMPFILE} -if ! diff "${TMPFILE}" "${GEN_TEST_GO}"; then - echo "Generated file ${GEN_TEST_GO} needs to be updated (run hack/update-cloudprovider-gce.sh)" - echo - diff -u "${TMPFILE}" "${GEN_TEST_GO}" || true - exit 1 -fi - -exit 0 diff --git a/pkg/cloudprovider/providers/gce/BUILD b/pkg/cloudprovider/providers/gce/BUILD index 0e5905647074..92fcfc2cfaae 100644 --- a/pkg/cloudprovider/providers/gce/BUILD +++ b/pkg/cloudprovider/providers/gce/BUILD @@ -47,10 +47,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/gce", deps = [ "//pkg/api/v1/service:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud/filter:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud/meta:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud/mock:go_default_library", "//pkg/controller:go_default_library", "//pkg/features:go_default_library", "//pkg/kubelet/apis:go_default_library", @@ -80,6 +76,10 @@ go_library( "//staging/src/k8s.io/client-go/util/flowcontrol:go_default_library", "//staging/src/k8s.io/cloud-provider:go_default_library", "//vendor/cloud.google.com/go/compute/metadata:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/golang.org/x/oauth2:go_default_library", "//vendor/golang.org/x/oauth2/google:go_default_library", @@ -112,9 +112,6 @@ go_test( embed = [":go_default_library"], deps = [ "//pkg/api/v1/service:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud/meta:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud/mock:go_default_library", "//pkg/kubelet/apis:go_default_library", "//pkg/util/net/sets:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -123,6 +120,9 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", "//staging/src/k8s.io/cloud-provider:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/github.com/stretchr/testify/require:go_default_library", "//vendor/golang.org/x/oauth2/google:go_default_library", @@ -142,9 +142,6 @@ filegroup( filegroup( name = "all-srcs", - srcs = [ - ":package-srcs", - "//pkg/cloudprovider/providers/gce/cloud:all-srcs", - ], + srcs = [":package-srcs"], tags = ["automanaged"], ) diff --git a/pkg/cloudprovider/providers/gce/cloud/BUILD b/pkg/cloudprovider/providers/gce/cloud/BUILD deleted file mode 100644 index e3c289daa6fa..000000000000 --- a/pkg/cloudprovider/providers/gce/cloud/BUILD +++ /dev/null @@ -1,67 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "constants.go", - "context.go", - "doc.go", - "gce_projects.go", - "gen.go", - "op.go", - "project.go", - "ratelimit.go", - "service.go", - "utils.go", - ], - importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud", - visibility = ["//visibility:public"], - deps = [ - "//pkg/cloudprovider/providers/gce/cloud/filter:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud/meta:go_default_library", - "//vendor/google.golang.org/api/compute/v0.alpha:go_default_library", - "//vendor/google.golang.org/api/compute/v0.beta:go_default_library", - "//vendor/google.golang.org/api/compute/v1:go_default_library", - "//vendor/google.golang.org/api/googleapi:go_default_library", - "//vendor/k8s.io/klog:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "gen_test.go", - "mock_test.go", - "ratelimit_test.go", - "service_test.go", - "utils_test.go", - ], - embed = [":go_default_library"], - deps = [ - "//pkg/cloudprovider/providers/gce/cloud/filter:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud/meta:go_default_library", - "//vendor/google.golang.org/api/compute/v0.alpha:go_default_library", - "//vendor/google.golang.org/api/compute/v0.beta:go_default_library", - "//vendor/google.golang.org/api/compute/v1:go_default_library", - ], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [ - ":package-srcs", - "//pkg/cloudprovider/providers/gce/cloud/filter:all-srcs", - "//pkg/cloudprovider/providers/gce/cloud/gen:all-srcs", - "//pkg/cloudprovider/providers/gce/cloud/meta:all-srcs", - "//pkg/cloudprovider/providers/gce/cloud/mock:all-srcs", - ], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/pkg/cloudprovider/providers/gce/cloud/filter/filter_test.go b/pkg/cloudprovider/providers/gce/cloud/filter/filter_test.go deleted file mode 100644 index 46b3c279a477..000000000000 --- a/pkg/cloudprovider/providers/gce/cloud/filter/filter_test.go +++ /dev/null @@ -1,176 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package filter - -import ( - "reflect" - "testing" -) - -func TestFilterToString(t *testing.T) { - t.Parallel() - - for _, tc := range []struct { - f *F - want string - }{ - {Regexp("field1", "abc"), `field1 eq abc`}, - {NotRegexp("field1", "abc"), `field1 ne abc`}, - {EqualInt("field1", 13), "field1 eq 13"}, - {NotEqualInt("field1", 13), "field1 ne 13"}, - {EqualBool("field1", true), "field1 eq true"}, - {NotEqualBool("field1", true), "field1 ne true"}, - {Regexp("field1", "abc").AndRegexp("field2", "def"), `(field1 eq abc) (field2 eq def)`}, - {Regexp("field1", "abc").AndNotEqualInt("field2", 17), `(field1 eq abc) (field2 ne 17)`}, - {Regexp("field1", "abc").And(EqualInt("field2", 17)), `(field1 eq abc) (field2 eq 17)`}, - } { - if tc.f.String() != tc.want { - t.Errorf("filter %#v String() = %q, want %q", tc.f, tc.f.String(), tc.want) - } - } -} - -func TestFilterMatch(t *testing.T) { - t.Parallel() - - type inner struct { - X string - } - type S struct { - S string - I int - B bool - Unhandled struct{} - NestedField *inner - } - - for _, tc := range []struct { - f *F - o interface{} - want bool - }{ - {f: None, o: &S{}, want: true}, - {f: Regexp("s", "abc"), o: &S{}}, - {f: EqualInt("i", 10), o: &S{}}, - {f: EqualBool("b", true), o: &S{}}, - {f: NotRegexp("s", "abc"), o: &S{}, want: true}, - {f: NotEqualInt("i", 10), o: &S{}, want: true}, - {f: NotEqualBool("b", true), o: &S{}, want: true}, - {f: Regexp("s", "abc").AndEqualBool("b", true), o: &S{}}, - {f: Regexp("s", "abc"), o: &S{S: "abc"}, want: true}, - {f: Regexp("s", "a.*"), o: &S{S: "abc"}, want: true}, - {f: Regexp("s", "a((("), o: &S{S: "abc"}}, - {f: NotRegexp("s", "abc"), o: &S{S: "abc"}}, - {f: EqualInt("i", 10), o: &S{I: 11}}, - {f: EqualInt("i", 10), o: &S{I: 10}, want: true}, - {f: Regexp("s", "abc").AndEqualBool("b", true), o: &S{S: "abc"}}, - {f: Regexp("s", "abcd").AndEqualBool("b", true), o: &S{S: "abc"}}, - {f: Regexp("s", "abc").AndEqualBool("b", true), o: &S{S: "abc", B: true}, want: true}, - {f: Regexp("s", "abc").And(EqualBool("b", true)), o: &S{S: "abc", B: true}, want: true}, - {f: Regexp("unhandled", "xyz"), o: &S{}}, - {f: Regexp("nested_field.x", "xyz"), o: &S{}}, - {f: Regexp("nested_field.x", "xyz"), o: &S{NestedField: &inner{"xyz"}}, want: true}, - {f: NotRegexp("nested_field.x", "xyz"), o: &S{NestedField: &inner{"xyz"}}}, - {f: Regexp("nested_field.y", "xyz"), o: &S{NestedField: &inner{"xyz"}}}, - {f: Regexp("nested_field", "xyz"), o: &S{NestedField: &inner{"xyz"}}}, - } { - got := tc.f.Match(tc.o) - if got != tc.want { - t.Errorf("%v: Match(%+v) = %v, want %v", tc.f, tc.o, got, tc.want) - } - } -} - -func TestFilterSnakeToCamelCase(t *testing.T) { - t.Parallel() - - for _, tc := range []struct { - s string - want string - }{ - {"", ""}, - {"abc", "Abc"}, - {"_foo", "Foo"}, - {"a_b_c", "ABC"}, - {"a_BC_def", "ABCDef"}, - {"a_Bc_def", "ABcDef"}, - } { - got := snakeToCamelCase(tc.s) - if got != tc.want { - t.Errorf("snakeToCamelCase(%q) = %q, want %q", tc.s, got, tc.want) - } - } -} - -func TestFilterExtractValue(t *testing.T) { - t.Parallel() - - type nest2 struct { - Y string - } - type nest struct { - X string - Nest2 nest2 - } - st := &struct { - S string - I int - F bool - Nest nest - NestPtr *nest - - Unhandled float64 - }{ - "abc", - 13, - true, - nest{"xyz", nest2{"zzz"}}, - &nest{"yyy", nest2{}}, - 0.0, - } - - for _, tc := range []struct { - path string - o interface{} - want interface{} - wantErr bool - }{ - {path: "s", o: st, want: "abc"}, - {path: "i", o: st, want: 13}, - {path: "f", o: st, want: true}, - {path: "nest.x", o: st, want: "xyz"}, - {path: "nest_ptr.x", o: st, want: "yyy"}, - // Error cases. - {path: "", o: st, wantErr: true}, - {path: "no_such_field", o: st, wantErr: true}, - {path: "s.invalid_type", o: st, wantErr: true}, - {path: "unhandled", o: st, wantErr: true}, - {path: "nest.x", o: &struct{ Nest *nest }{}, wantErr: true}, - } { - o, err := extractValue(tc.path, tc.o) - gotErr := err != nil - if gotErr != tc.wantErr { - t.Errorf("extractValue(%v, %+v) = %v, %v; gotErr = %v, tc.wantErr = %v", tc.path, tc.o, o, err, gotErr, tc.wantErr) - } - if err != nil { - continue - } - if !reflect.DeepEqual(o, tc.want) { - t.Errorf("extractValue(%v, %+v) = %v, nil; want %v, nil", tc.path, tc.o, o, tc.want) - } - } -} diff --git a/pkg/cloudprovider/providers/gce/cloud/gen/BUILD b/pkg/cloudprovider/providers/gce/cloud/gen/BUILD deleted file mode 100644 index b51f9c80db1d..000000000000 --- a/pkg/cloudprovider/providers/gce/cloud/gen/BUILD +++ /dev/null @@ -1,29 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") - -go_library( - name = "go_default_library", - srcs = ["main.go"], - importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/gen", - visibility = ["//visibility:private"], - deps = ["//pkg/cloudprovider/providers/gce/cloud/meta:go_default_library"], -) - -go_binary( - name = "gen", - embed = [":go_default_library"], - visibility = ["//visibility:public"], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/pkg/cloudprovider/providers/gce/cloud/gen/main.go b/pkg/cloudprovider/providers/gce/cloud/gen/main.go deleted file mode 100644 index ff45ccb3e11d..000000000000 --- a/pkg/cloudprovider/providers/gce/cloud/gen/main.go +++ /dev/null @@ -1,1376 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Generator for GCE compute wrapper code. You must regenerate the code after -// modifying this file: -// -// $ go run gen/main.go > gen.go -package main - -import ( - "bytes" - "flag" - "fmt" - "io" - "log" - "os" - "os/exec" - "text/template" - "time" - - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" -) - -const ( - gofmt = "gofmt" - packageRoot = "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - - // readOnly specifies that the given resource is read-only and should not - // have insert() or delete() methods generated for the wrapper. - readOnly = iota -) - -var flags = struct { - gofmt bool - mode string -}{} - -func init() { - flag.BoolVar(&flags.gofmt, "gofmt", true, "run output through gofmt") - flag.StringVar(&flags.mode, "mode", "src", "content to generate: src, test, dummy") -} - -// gofmtContent runs "gofmt" on the given contents. -func gofmtContent(r io.Reader) string { - cmd := exec.Command(gofmt, "-s") - out := &bytes.Buffer{} - cmd.Stdin = r - cmd.Stdout = out - cmdErr := &bytes.Buffer{} - cmd.Stderr = cmdErr - - if err := cmd.Run(); err != nil { - fmt.Fprintf(os.Stderr, cmdErr.String()) - panic(err) - } - return out.String() -} - -// genHeader generate the header for the file. -func genHeader(wr io.Writer) { - const text = `/* -Copyright {{.Year}} The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// This file was generated by "go run gen/main.go > gen.go". Do not edit -// directly. - -package cloud - -import ( - "context" - "fmt" - "net/http" - "sync" - - "google.golang.org/api/googleapi" - "k8s.io/klog" - - "{{.PackageRoot}}/filter" - "{{.PackageRoot}}/meta" - -` - tmpl := template.Must(template.New("header").Parse(text)) - values := map[string]string{ - "Year": fmt.Sprintf("%v", time.Now().Year()), - "PackageRoot": packageRoot, - } - if err := tmpl.Execute(wr, values); err != nil { - panic(err) - } - - var hasGA, hasAlpha, hasBeta bool - for _, s := range meta.AllServices { - switch s.Version() { - case meta.VersionGA: - hasGA = true - case meta.VersionAlpha: - hasAlpha = true - case meta.VersionBeta: - hasBeta = true - } - } - if hasAlpha { - fmt.Fprintln(wr, ` alpha "google.golang.org/api/compute/v0.alpha"`) - } - if hasBeta { - fmt.Fprintln(wr, ` beta "google.golang.org/api/compute/v0.beta"`) - } - if hasGA { - fmt.Fprintln(wr, ` ga "google.golang.org/api/compute/v1"`) - } - fmt.Fprintf(wr, ")\n\n") -} - -// genStubs generates the interface and wrapper stubs. -func genStubs(wr io.Writer) { - const text = `// Cloud is an interface for the GCE compute API. -type Cloud interface { -{{- range .All}} - {{.WrapType}}() {{.WrapType}} -{{- end}} -} - -// NewGCE returns a GCE. -func NewGCE(s *Service) *GCE { - g := &GCE{ - {{- range .All}} - {{.Field}}: &{{.GCEWrapType}}{s}, - {{- end}} - } - return g -} - -// GCE implements Cloud. -var _ Cloud = (*GCE)(nil) - -// GCE is the golang adapter for the compute APIs. -type GCE struct { -{{- range .All}} - {{.Field}} *{{.GCEWrapType}} -{{- end}} -} - -{{range .All}} -// {{.WrapType}} returns the interface for the {{.Version}} {{.Service}}. -func (gce *GCE) {{.WrapType}}() {{.WrapType}} { - return gce.{{.Field}} -} -{{- end}} - -// NewMockGCE returns a new mock for GCE. -func NewMockGCE(projectRouter ProjectRouter) *MockGCE { - {{- range .Groups}} - mock{{.Service}}Objs := map[meta.Key]*Mock{{.Service}}Obj{} - {{- end}} - - mock := &MockGCE{ - {{- range .All}} - {{.MockField}}: New{{.MockWrapType}}(projectRouter, mock{{.Service}}Objs), - {{- end}} - } - return mock -} - -// MockGCE implements Cloud. -var _ Cloud = (*MockGCE)(nil) - -// MockGCE is the mock for the compute API. -type MockGCE struct { -{{- range .All}} - {{.MockField}} *{{.MockWrapType}} -{{- end}} -} -{{range .All}} -// {{.WrapType}} returns the interface for the {{.Version}} {{.Service}}. -func (mock *MockGCE) {{.WrapType}}() {{.WrapType}} { - return mock.{{.MockField}} -} -{{end}} - -{{range .Groups}} -// Mock{{.Service}}Obj is used to store the various object versions in the shared -// map of mocked objects. This allows for multiple API versions to co-exist and -// share the same "view" of the objects in the backend. -type Mock{{.Service}}Obj struct { - Obj interface{} -} -{{- if .HasAlpha}} -// ToAlpha retrieves the given version of the object. -func (m *Mock{{.Service}}Obj) ToAlpha() *{{.Alpha.FQObjectType}} { - if ret, ok := m.Obj.(*{{.Alpha.FQObjectType}}); ok { - return ret - } - // Convert the object via JSON copying to the type that was requested. - ret := &{{.Alpha.FQObjectType}}{} - if err := copyViaJSON(ret, m.Obj); err != nil { - klog.Errorf("Could not convert %T to *{{.Alpha.FQObjectType}} via JSON: %v", m.Obj, err) - } - return ret -} -{{- end}} -{{- if .HasBeta}} -// ToBeta retrieves the given version of the object. -func (m *Mock{{.Service}}Obj) ToBeta() *{{.Beta.FQObjectType}} { - if ret, ok := m.Obj.(*{{.Beta.FQObjectType}}); ok { - return ret - } - // Convert the object via JSON copying to the type that was requested. - ret := &{{.Beta.FQObjectType}}{} - if err := copyViaJSON(ret, m.Obj); err != nil { - klog.Errorf("Could not convert %T to *{{.Beta.FQObjectType}} via JSON: %v", m.Obj, err) - } - return ret -} -{{- end}} -{{- if .HasGA}} -// ToGA retrieves the given version of the object. -func (m *Mock{{.Service}}Obj) ToGA() *{{.GA.FQObjectType}} { - if ret, ok := m.Obj.(*{{.GA.FQObjectType}}); ok { - return ret - } - // Convert the object via JSON copying to the type that was requested. - ret := &{{.GA.FQObjectType}}{} - if err := copyViaJSON(ret, m.Obj); err != nil { - klog.Errorf("Could not convert %T to *{{.GA.FQObjectType}} via JSON: %v", m.Obj, err) - } - return ret -} -{{- end}} -{{- end}} -` - data := struct { - All []*meta.ServiceInfo - Groups map[string]*meta.ServiceGroup - }{meta.AllServices, meta.AllServicesByGroup} - - tmpl := template.Must(template.New("interface").Parse(text)) - if err := tmpl.Execute(wr, data); err != nil { - panic(err) - } -} - -// genTypes generates the type wrappers. -func genTypes(wr io.Writer) { - const text = `// {{.WrapType}} is an interface that allows for mocking of {{.Service}}. -type {{.WrapType}} interface { -{{- if .GenerateCustomOps}} - // {{.WrapTypeOps}} is an interface with additional non-CRUD type methods. - // This interface is expected to be implemented by hand (non-autogenerated). - {{.WrapTypeOps}} -{{- end}} -{{- if .GenerateGet}} - Get(ctx context.Context, key *meta.Key) (*{{.FQObjectType}}, error) -{{- end -}} -{{- if .GenerateList}} -{{- if .KeyIsGlobal}} - List(ctx context.Context, fl *filter.F) ([]*{{.FQObjectType}}, error) -{{- end -}} -{{- if .KeyIsRegional}} - List(ctx context.Context, region string, fl *filter.F) ([]*{{.FQObjectType}}, error) -{{- end -}} -{{- if .KeyIsZonal}} - List(ctx context.Context, zone string, fl *filter.F) ([]*{{.FQObjectType}}, error) -{{- end -}} -{{- end -}} -{{- if .GenerateInsert}} - Insert(ctx context.Context, key *meta.Key, obj *{{.FQObjectType}}) error -{{- end -}} -{{- if .GenerateDelete}} - Delete(ctx context.Context, key *meta.Key) error -{{- end -}} -{{- if .AggregatedList}} - AggregatedList(ctx context.Context, fl *filter.F) (map[string][]*{{.FQObjectType}}, error) -{{- end}} -{{- with .Methods -}} -{{- range .}} - {{.InterfaceFunc}} -{{- end -}} -{{- end}} -} - -// New{{.MockWrapType}} returns a new mock for {{.Service}}. -func New{{.MockWrapType}}(pr ProjectRouter, objs map[meta.Key]*Mock{{.Service}}Obj) *{{.MockWrapType}} { - mock := &{{.MockWrapType}}{ - ProjectRouter: pr, - - Objects: objs, - {{- if .GenerateGet}} - GetError: map[meta.Key]error{}, - {{- end -}} - {{- if .GenerateInsert}} - InsertError: map[meta.Key]error{}, - {{- end -}} - {{- if .GenerateDelete}} - DeleteError: map[meta.Key]error{}, - {{- end}} - } - return mock -} - -// {{.MockWrapType}} is the mock for {{.Service}}. -type {{.MockWrapType}} struct { - Lock sync.Mutex - - ProjectRouter ProjectRouter - - // Objects maintained by the mock. - Objects map[meta.Key]*Mock{{.Service}}Obj - - // If an entry exists for the given key and operation, then the error - // will be returned instead of the operation. - {{- if .GenerateGet}} - GetError map[meta.Key]error - {{- end -}} - {{- if .GenerateList}} - ListError *error - {{- end -}} - {{- if .GenerateInsert}} - InsertError map[meta.Key]error - {{- end -}} - {{- if .GenerateDelete}} - DeleteError map[meta.Key]error - {{- end -}} - {{- if .AggregatedList}} - AggregatedListError *error - {{- end}} - - // xxxHook allow you to intercept the standard processing of the mock in - // order to add your own logic. Return (true, _, _) to prevent the normal - // execution flow of the mock. Return (false, nil, nil) to continue with - // normal mock behavior/ after the hook function executes. - {{- if .GenerateGet}} - GetHook func(ctx context.Context, key *meta.Key, m *{{.MockWrapType}}) (bool, *{{.FQObjectType}}, error) - {{- end -}} - {{- if .GenerateList}} - {{- if .KeyIsGlobal}} - ListHook func(ctx context.Context, fl *filter.F, m *{{.MockWrapType}}) (bool, []*{{.FQObjectType}}, error) - {{- end -}} - {{- if .KeyIsRegional}} - ListHook func(ctx context.Context, region string, fl *filter.F, m *{{.MockWrapType}}) (bool, []*{{.FQObjectType}}, error) - {{- end -}} - {{- if .KeyIsZonal}} - ListHook func(ctx context.Context, zone string, fl *filter.F, m *{{.MockWrapType}}) (bool, []*{{.FQObjectType}}, error) - {{- end}} - {{- end -}} - {{- if .GenerateInsert}} - InsertHook func(ctx context.Context, key *meta.Key, obj *{{.FQObjectType}}, m *{{.MockWrapType}}) (bool, error) - {{- end -}} - {{- if .GenerateDelete}} - DeleteHook func(ctx context.Context, key *meta.Key, m *{{.MockWrapType}}) (bool, error) - {{- end -}} - {{- if .AggregatedList}} - AggregatedListHook func(ctx context.Context, fl *filter.F, m *{{.MockWrapType}}) (bool, map[string][]*{{.FQObjectType}}, error) - {{- end}} - -{{- with .Methods -}} -{{- range .}} - {{.MockHook}} -{{- end -}} -{{- end}} - - // X is extra state that can be used as part of the mock. Generated code - // will not use this field. - X interface{} -} - -{{- if .GenerateGet}} -// Get returns the object from the mock. -func (m *{{.MockWrapType}}) Get(ctx context.Context, key *meta.Key) (*{{.FQObjectType}}, error) { - if m.GetHook != nil { - if intercept, obj, err := m.GetHook(ctx, key, m); intercept { - klog.V(5).Infof("{{.MockWrapType}}.Get(%v, %s) = %+v, %v", ctx, key, obj ,err) - return obj, err - } - } - if !key.Valid() { - return nil, fmt.Errorf("invalid GCE key (%+v)", key) - } - - m.Lock.Lock() - defer m.Lock.Unlock() - - if err, ok := m.GetError[*key]; ok { - klog.V(5).Infof("{{.MockWrapType}}.Get(%v, %s) = nil, %v", ctx, key, err) - return nil, err - } - if obj, ok := m.Objects[*key]; ok { - typedObj := obj.To{{.VersionTitle}}() - klog.V(5).Infof("{{.MockWrapType}}.Get(%v, %s) = %+v, nil", ctx, key, typedObj) - return typedObj, nil - } - - err := &googleapi.Error{ - Code: http.StatusNotFound, - Message: fmt.Sprintf("{{.MockWrapType}} %v not found", key), - } - klog.V(5).Infof("{{.MockWrapType}}.Get(%v, %s) = nil, %v", ctx, key, err) - return nil, err -} -{{- end}} - -{{- if .GenerateList}} -{{if .KeyIsGlobal -}} -// List all of the objects in the mock. -func (m *{{.MockWrapType}}) List(ctx context.Context, fl *filter.F) ([]*{{.FQObjectType}}, error) { -{{- end -}} -{{- if .KeyIsRegional -}} -// List all of the objects in the mock in the given region. -func (m *{{.MockWrapType}}) List(ctx context.Context, region string, fl *filter.F) ([]*{{.FQObjectType}}, error) { -{{- end -}} -{{- if .KeyIsZonal -}} -// List all of the objects in the mock in the given zone. -func (m *{{.MockWrapType}}) List(ctx context.Context, zone string, fl *filter.F) ([]*{{.FQObjectType}}, error) { -{{- end}} - if m.ListHook != nil { - {{if .KeyIsGlobal -}} - if intercept, objs, err := m.ListHook(ctx, fl, m); intercept { - klog.V(5).Infof("{{.MockWrapType}}.List(%v, %v) = [%v items], %v", ctx, fl, len(objs), err) - {{- end -}} - {{- if .KeyIsRegional -}} - if intercept, objs, err := m.ListHook(ctx, region, fl, m); intercept { - klog.V(5).Infof("{{.MockWrapType}}.List(%v, %q, %v) = [%v items], %v", ctx, region, fl, len(objs), err) - {{- end -}} - {{- if .KeyIsZonal -}} - if intercept, objs, err := m.ListHook(ctx, zone, fl, m); intercept { - klog.V(5).Infof("{{.MockWrapType}}.List(%v, %q, %v) = [%v items], %v", ctx, zone, fl, len(objs), err) - {{- end}} - return objs, err - } - } - - m.Lock.Lock() - defer m.Lock.Unlock() - - if m.ListError != nil { - err := *m.ListError - {{if .KeyIsGlobal -}} - klog.V(5).Infof("{{.MockWrapType}}.List(%v, %v) = nil, %v", ctx, fl, err) - {{- end -}} - {{- if .KeyIsRegional -}} - klog.V(5).Infof("{{.MockWrapType}}.List(%v, %q, %v) = nil, %v", ctx, region, fl, err) - {{- end -}} - {{- if .KeyIsZonal -}} - klog.V(5).Infof("{{.MockWrapType}}.List(%v, %q, %v) = nil, %v", ctx, zone, fl, err) - {{- end}} - - return nil, *m.ListError - } - - var objs []*{{.FQObjectType}} -{{- if .KeyIsGlobal}} - for _, obj := range m.Objects { -{{- else}} - for key, obj := range m.Objects { -{{- end -}} -{{- if .KeyIsRegional}} - if key.Region != region { - continue - } -{{- end -}} -{{- if .KeyIsZonal}} - if key.Zone != zone { - continue - } -{{- end}} - if !fl.Match(obj.To{{.VersionTitle}}()) { - continue - } - objs = append(objs, obj.To{{.VersionTitle}}()) - } - - {{if .KeyIsGlobal -}} - klog.V(5).Infof("{{.MockWrapType}}.List(%v, %v) = [%v items], nil", ctx, fl, len(objs)) - {{- end -}} - {{- if .KeyIsRegional -}} - klog.V(5).Infof("{{.MockWrapType}}.List(%v, %q, %v) = [%v items], nil", ctx, region, fl, len(objs)) - {{- end -}} - {{- if .KeyIsZonal -}} - klog.V(5).Infof("{{.MockWrapType}}.List(%v, %q, %v) = [%v items], nil", ctx, zone, fl, len(objs)) - {{- end}} - return objs, nil -} -{{- end}} - -{{- if .GenerateInsert}} -// Insert is a mock for inserting/creating a new object. -func (m *{{.MockWrapType}}) Insert(ctx context.Context, key *meta.Key, obj *{{.FQObjectType}}) error { - if m.InsertHook != nil { - if intercept, err := m.InsertHook(ctx, key, obj, m); intercept { - klog.V(5).Infof("{{.MockWrapType}}.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) - return err - } - } - if !key.Valid() { - return fmt.Errorf("invalid GCE key (%+v)", key) - } - - m.Lock.Lock() - defer m.Lock.Unlock() - - if err, ok := m.InsertError[*key]; ok { - klog.V(5).Infof("{{.MockWrapType}}.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) - return err - } - if _, ok := m.Objects[*key]; ok { - err := &googleapi.Error{ - Code: http.StatusConflict, - Message: fmt.Sprintf("{{.MockWrapType}} %v exists", key), - } - klog.V(5).Infof("{{.MockWrapType}}.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) - return err - } - - obj.Name = key.Name - projectID := m.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Resource}}") - obj.SelfLink = SelfLink(meta.Version{{.VersionTitle}}, projectID, "{{.Resource}}", key) - - m.Objects[*key] = &Mock{{.Service}}Obj{obj} - klog.V(5).Infof("{{.MockWrapType}}.Insert(%v, %v, %+v) = nil", ctx, key, obj) - return nil -} -{{- end}} - -{{- if .GenerateDelete}} -// Delete is a mock for deleting the object. -func (m *{{.MockWrapType}}) Delete(ctx context.Context, key *meta.Key) error { - if m.DeleteHook != nil { - if intercept, err := m.DeleteHook(ctx, key, m); intercept { - klog.V(5).Infof("{{.MockWrapType}}.Delete(%v, %v) = %v", ctx, key, err) - return err - } - } - if !key.Valid() { - return fmt.Errorf("invalid GCE key (%+v)", key) - } - - m.Lock.Lock() - defer m.Lock.Unlock() - - if err, ok := m.DeleteError[*key]; ok { - klog.V(5).Infof("{{.MockWrapType}}.Delete(%v, %v) = %v", ctx, key, err) - return err - } - if _, ok := m.Objects[*key]; !ok { - err := &googleapi.Error{ - Code: http.StatusNotFound, - Message: fmt.Sprintf("{{.MockWrapType}} %v not found", key), - } - klog.V(5).Infof("{{.MockWrapType}}.Delete(%v, %v) = %v", ctx, key, err) - return err - } - - delete(m.Objects, *key) - klog.V(5).Infof("{{.MockWrapType}}.Delete(%v, %v) = nil", ctx, key) - return nil -} -{{- end}} - -{{- if .AggregatedList}} -// AggregatedList is a mock for AggregatedList. -func (m *{{.MockWrapType}}) AggregatedList(ctx context.Context, fl *filter.F) (map[string][]*{{.FQObjectType}}, error) { - if m.AggregatedListHook != nil { - if intercept, objs, err := m.AggregatedListHook(ctx, fl, m); intercept { - klog.V(5).Infof("{{.MockWrapType}}.AggregatedList(%v, %v) = [%v items], %v", ctx, fl, len(objs), err) - return objs, err - } - } - - m.Lock.Lock() - defer m.Lock.Unlock() - - if m.AggregatedListError != nil { - err := *m.AggregatedListError - klog.V(5).Infof("{{.MockWrapType}}.AggregatedList(%v, %v) = nil, %v", ctx, fl, err) - return nil, err - } - - objs := map[string][]*{{.FQObjectType}}{} - for _, obj := range m.Objects { - res, err := ParseResourceURL(obj.To{{.VersionTitle}}().SelfLink) - {{- if .KeyIsRegional}} - location := res.Key.Region - {{- end -}} - {{- if .KeyIsZonal}} - location := res.Key.Zone - {{- end}} - if err != nil { - klog.V(5).Infof("{{.MockWrapType}}.AggregatedList(%v, %v) = nil, %v", ctx, fl, err) - return nil, err - } - if !fl.Match(obj.To{{.VersionTitle}}()) { - continue - } - objs[location] = append(objs[location], obj.To{{.VersionTitle}}()) - } - klog.V(5).Infof("{{.MockWrapType}}.AggregatedList(%v, %v) = [%v items], nil", ctx, fl, len(objs)) - return objs, nil -} -{{- end}} - -// Obj wraps the object for use in the mock. -func (m *{{.MockWrapType}}) Obj(o *{{.FQObjectType}}) *Mock{{.Service}}Obj { - return &Mock{{.Service}}Obj{o} -} - -{{with .Methods -}} -{{- range .}} -// {{.Name}} is a mock for the corresponding method. -func (m *{{.MockWrapType}}) {{.FcnArgs}} { -{{- if .IsOperation }} - if m.{{.MockHookName}} != nil { - return m.{{.MockHookName}}(ctx, key {{.CallArgs}}, m) - } - return nil -{{- else if .IsGet}} - if m.{{.MockHookName}} != nil { - return m.{{.MockHookName}}(ctx, key {{.CallArgs}}, m) - } - return nil, fmt.Errorf("{{.MockHookName}} must be set") -{{- else if .IsPaged}} - if m.{{.MockHookName}} != nil { - return m.{{.MockHookName}}(ctx, key {{.CallArgs}}, fl, m) - } - return nil, nil -{{- end}} -} -{{end -}} -{{- end}} -// {{.GCEWrapType}} is a simplifying adapter for the GCE {{.Service}}. -type {{.GCEWrapType}} struct { - s *Service -} - -{{- if .GenerateGet}} -// Get the {{.Object}} named by key. -func (g *{{.GCEWrapType}}) Get(ctx context.Context, key *meta.Key) (*{{.FQObjectType}}, error) { - klog.V(5).Infof("{{.GCEWrapType}}.Get(%v, %v): called", ctx, key) - - if !key.Valid() { - klog.V(2).Infof("{{.GCEWrapType}}.Get(%v, %v): key is invalid (%#v)", ctx, key, key) - return nil, fmt.Errorf("invalid GCE key (%#v)", key) - } - projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}") - rk := &RateLimitKey{ - ProjectID: projectID, - Operation: "Get", - Version: meta.Version("{{.Version}}"), - Service: "{{.Service}}", - } - klog.V(5).Infof("{{.GCEWrapType}}.Get(%v, %v): projectID = %v, rk = %+v", ctx, key, projectID, rk) - if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("{{.GCEWrapType}}.Get(%v, %v): RateLimiter error: %v", ctx, key, err) - return nil, err - } -{{- if .KeyIsGlobal}} - call := g.s.{{.VersionTitle}}.{{.Service}}.Get(projectID, key.Name) -{{- end -}} -{{- if .KeyIsRegional}} - call := g.s.{{.VersionTitle}}.{{.Service}}.Get(projectID, key.Region, key.Name) -{{- end -}} -{{- if .KeyIsZonal}} - call := g.s.{{.VersionTitle}}.{{.Service}}.Get(projectID, key.Zone, key.Name) -{{- end}} - call.Context(ctx) - v, err := call.Do() - klog.V(4).Infof("{{.GCEWrapType}}.Get(%v, %v) = %+v, %v", ctx, key, v, err) - return v, err -} -{{- end}} - -{{- if .GenerateList}} -// List all {{.Object}} objects. -{{- if .KeyIsGlobal}} -func (g *{{.GCEWrapType}}) List(ctx context.Context, fl *filter.F) ([]*{{.FQObjectType}}, error) { - klog.V(5).Infof("{{.GCEWrapType}}.List(%v, %v) called", ctx, fl) -{{- end -}} -{{- if .KeyIsRegional}} -func (g *{{.GCEWrapType}}) List(ctx context.Context, region string, fl *filter.F) ([]*{{.FQObjectType}}, error) { - klog.V(5).Infof("{{.GCEWrapType}}.List(%v, %v, %v) called", ctx, region, fl) -{{- end -}} -{{- if .KeyIsZonal}} -func (g *{{.GCEWrapType}}) List(ctx context.Context, zone string, fl *filter.F) ([]*{{.FQObjectType}}, error) { - klog.V(5).Infof("{{.GCEWrapType}}.List(%v, %v, %v) called", ctx, zone, fl) -{{- end}} - projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}") - rk := &RateLimitKey{ - ProjectID: projectID, - Operation: "List", - Version: meta.Version("{{.Version}}"), - Service: "{{.Service}}", - } - if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - return nil, err - } -{{- if .KeyIsGlobal}} - klog.V(5).Infof("{{.GCEWrapType}}.List(%v, %v): projectID = %v, rk = %+v", ctx, fl, projectID, rk) - call := g.s.{{.VersionTitle}}.{{.Service}}.List(projectID) -{{- end -}} -{{- if .KeyIsRegional}} - klog.V(5).Infof("{{.GCEWrapType}}.List(%v, %v, %v): projectID = %v, rk = %+v", ctx, region, fl, projectID, rk) - call := g.s.{{.VersionTitle}}.{{.Service}}.List(projectID, region) -{{- end -}} -{{- if .KeyIsZonal}} - klog.V(5).Infof("{{.GCEWrapType}}.List(%v, %v, %v): projectID = %v, rk = %+v", ctx, zone, fl, projectID, rk) - call := g.s.{{.VersionTitle}}.{{.Service}}.List(projectID, zone) -{{- end}} - if fl != filter.None { - call.Filter(fl.String()) - } - var all []*{{.FQObjectType}} - f := func(l *{{.ObjectListType}}) error { - klog.V(5).Infof("{{.GCEWrapType}}.List(%v, ..., %v): page %+v", ctx, fl, l) - all = append(all, l.Items...) - return nil - } - if err := call.Pages(ctx, f); err != nil { - klog.V(4).Infof("{{.GCEWrapType}}.List(%v, ..., %v) = %v, %v", ctx, fl, nil, err) - return nil, err - } - - if klog.V(4) { - klog.V(4).Infof("{{.GCEWrapType}}.List(%v, ..., %v) = [%v items], %v", ctx, fl, len(all), nil) - } else if klog.V(5) { - var asStr []string - for _, o := range all { - asStr = append(asStr, fmt.Sprintf("%+v", o)) - } - klog.V(5).Infof("{{.GCEWrapType}}.List(%v, ..., %v) = %v, %v", ctx, fl, asStr, nil) - } - - return all, nil -} -{{- end}} - -{{- if .GenerateInsert}} -// Insert {{.Object}} with key of value obj. -func (g *{{.GCEWrapType}}) Insert(ctx context.Context, key *meta.Key, obj *{{.FQObjectType}}) error { - klog.V(5).Infof("{{.GCEWrapType}}.Insert(%v, %v, %+v): called", ctx, key, obj) - if !key.Valid() { - klog.V(2).Infof("{{.GCEWrapType}}.Insert(%v, %v, ...): key is invalid (%#v)", ctx, key, key) - return fmt.Errorf("invalid GCE key (%+v)", key) - } - projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}") - rk := &RateLimitKey{ - ProjectID: projectID, - Operation: "Insert", - Version: meta.Version("{{.Version}}"), - Service: "{{.Service}}", - } - klog.V(5).Infof("{{.GCEWrapType}}.Insert(%v, %v, ...): projectID = %v, rk = %+v", ctx, key, projectID, rk) - if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("{{.GCEWrapType}}.Insert(%v, %v, ...): RateLimiter error: %v", ctx, key, err) - return err - } - obj.Name = key.Name -{{- if .KeyIsGlobal}} - call := g.s.{{.VersionTitle}}.{{.Service}}.Insert(projectID, obj) -{{- end -}} -{{- if .KeyIsRegional}} - call := g.s.{{.VersionTitle}}.{{.Service}}.Insert(projectID, key.Region, obj) -{{- end -}} -{{- if .KeyIsZonal}} - call := g.s.{{.VersionTitle}}.{{.Service}}.Insert(projectID, key.Zone, obj) -{{- end}} - call.Context(ctx) - - op, err := call.Do() - if err != nil { - klog.V(4).Infof("{{.GCEWrapType}}.Insert(%v, %v, ...) = %+v", ctx, key, err) - return err - } - - err = g.s.WaitForCompletion(ctx, op) - klog.V(4).Infof("{{.GCEWrapType}}.Insert(%v, %v, %+v) = %+v", ctx, key, obj, err) - return err -} -{{- end}} - -{{- if .GenerateDelete}} -// Delete the {{.Object}} referenced by key. -func (g *{{.GCEWrapType}}) Delete(ctx context.Context, key *meta.Key) error { - klog.V(5).Infof("{{.GCEWrapType}}.Delete(%v, %v): called", ctx, key) - if !key.Valid() { - klog.V(2).Infof("{{.GCEWrapType}}.Delete(%v, %v): key is invalid (%#v)", ctx, key, key) - return fmt.Errorf("invalid GCE key (%+v)", key) - } - projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}") - rk := &RateLimitKey{ - ProjectID: projectID, - Operation: "Delete", - Version: meta.Version("{{.Version}}"), - Service: "{{.Service}}", - } - klog.V(5).Infof("{{.GCEWrapType}}.Delete(%v, %v): projectID = %v, rk = %+v", ctx, key, projectID, rk) - if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("{{.GCEWrapType}}.Delete(%v, %v): RateLimiter error: %v", ctx, key, err) - return err - } -{{- if .KeyIsGlobal}} - call := g.s.{{.VersionTitle}}.{{.Service}}.Delete(projectID, key.Name) -{{end -}} -{{- if .KeyIsRegional}} - call := g.s.{{.VersionTitle}}.{{.Service}}.Delete(projectID, key.Region, key.Name) -{{- end -}} -{{- if .KeyIsZonal}} - call := g.s.{{.VersionTitle}}.{{.Service}}.Delete(projectID, key.Zone, key.Name) -{{- end}} - call.Context(ctx) - - op, err := call.Do() - if err != nil { - klog.V(4).Infof("{{.GCEWrapType}}.Delete(%v, %v) = %v", ctx, key, err) - return err - } - - err = g.s.WaitForCompletion(ctx, op) - klog.V(4).Infof("{{.GCEWrapType}}.Delete(%v, %v) = %v", ctx, key, err) - return err -} -{{end -}} - -{{- if .AggregatedList}} -// AggregatedList lists all resources of the given type across all locations. -func (g *{{.GCEWrapType}}) AggregatedList(ctx context.Context, fl *filter.F) (map[string][]*{{.FQObjectType}}, error) { - klog.V(5).Infof("{{.GCEWrapType}}.AggregatedList(%v, %v) called", ctx, fl) - - projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}") - rk := &RateLimitKey{ - ProjectID: projectID, - Operation: "AggregatedList", - Version: meta.Version("{{.Version}}"), - Service: "{{.Service}}", - } - - klog.V(5).Infof("{{.GCEWrapType}}.AggregatedList(%v, %v): projectID = %v, rk = %+v", ctx, fl, projectID, rk) - if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(5).Infof("{{.GCEWrapType}}.AggregatedList(%v, %v): RateLimiter error: %v", ctx, fl, err) - return nil, err - } - - call := g.s.{{.VersionTitle}}.{{.Service}}.AggregatedList(projectID) - call.Context(ctx) - if fl != filter.None { - call.Filter(fl.String()) - } - - all := map[string][]*{{.FQObjectType}}{} - f := func(l *{{.ObjectAggregatedListType}}) error { - for k, v := range l.Items { - klog.V(5).Infof("{{.GCEWrapType}}.AggregatedList(%v, %v): page[%v]%+v", ctx, fl, k, v) - all[k] = append(all[k], v.{{.AggregatedListField}}...) - } - return nil - } - if err := call.Pages(ctx, f); err != nil { - klog.V(4).Infof("{{.GCEWrapType}}.AggregatedList(%v, %v) = %v, %v", ctx, fl, nil, err) - return nil, err - } - if klog.V(4) { - klog.V(4).Infof("{{.GCEWrapType}}.AggregatedList(%v, %v) = [%v items], %v", ctx, fl, len(all), nil) - } else if klog.V(5) { - var asStr []string - for _, o := range all { - asStr = append(asStr, fmt.Sprintf("%+v", o)) - } - klog.V(5).Infof("{{.GCEWrapType}}.AggregatedList(%v, %v) = %v, %v", ctx, fl, asStr, nil) - } - return all, nil -} -{{- end}} - -{{- with .Methods -}} -{{- range .}} -// {{.Name}} is a method on {{.GCEWrapType}}. -func (g *{{.GCEWrapType}}) {{.FcnArgs}} { - klog.V(5).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...): called", ctx, key) - - if !key.Valid() { - klog.V(2).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...): key is invalid (%#v)", ctx, key, key) -{{- if .IsOperation}} - return fmt.Errorf("invalid GCE key (%+v)", key) -{{- else if .IsGet}} - return nil, fmt.Errorf("invalid GCE key (%+v)", key) -{{- else if .IsPaged}} - return nil, fmt.Errorf("invalid GCE key (%+v)", key) -{{- end}} - } - projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}") - rk := &RateLimitKey{ - ProjectID: projectID, - Operation: "{{.Name}}", - Version: meta.Version("{{.Version}}"), - Service: "{{.Service}}", - } - klog.V(5).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...): projectID = %v, rk = %+v", ctx, key, projectID, rk) - - if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...): RateLimiter error: %v", ctx, key, err) - {{- if .IsOperation}} - return err - {{- else}} - return nil, err - {{- end}} - } -{{- if .KeyIsGlobal}} - call := g.s.{{.VersionTitle}}.{{.Service}}.{{.Name}}(projectID, key.Name {{.CallArgs}}) -{{- end -}} -{{- if .KeyIsRegional}} - call := g.s.{{.VersionTitle}}.{{.Service}}.{{.Name}}(projectID, key.Region, key.Name {{.CallArgs}}) -{{- end -}} -{{- if .KeyIsZonal}} - call := g.s.{{.VersionTitle}}.{{.Service}}.{{.Name}}(projectID, key.Zone, key.Name {{.CallArgs}}) -{{- end}} -{{- if .IsOperation}} - call.Context(ctx) - op, err := call.Do() - if err != nil { - klog.V(4).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...) = %+v", ctx, key, err) - return err - } - err = g.s.WaitForCompletion(ctx, op) - klog.V(4).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...) = %+v", ctx, key, err) - return err -{{- else if .IsGet}} - call.Context(ctx) - v, err := call.Do() - klog.V(4).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...) = %+v, %v", ctx, key, v, err) - return v, err -{{- else if .IsPaged}} - var all []*{{.Version}}.{{.ItemType}} - f := func(l *{{.Version}}.{{.ReturnType}}) error { - klog.V(5).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...): page %+v", ctx, key, l) - all = append(all, l.Items...) - return nil - } - if err := call.Pages(ctx, f); err != nil { - klog.V(4).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...) = %v, %v", ctx, key, nil, err) - return nil, err - } - if klog.V(4) { - klog.V(4).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...) = [%v items], %v", ctx, key, len(all), nil) - } else if klog.V(5) { - var asStr []string - for _, o := range all { - asStr = append(asStr, fmt.Sprintf("%+v", o)) - } - klog.V(5).Infof("{{.GCEWrapType}}.{{.Name}}(%v, %v, ...) = %v, %v", ctx, key, asStr, nil) - } - return all, nil -{{- end}} -} -{{end -}} -{{- end}} -` - tmpl := template.Must(template.New("interface").Parse(text)) - for _, s := range meta.AllServices { - if err := tmpl.Execute(wr, s); err != nil { - panic(err) - } - } -} - -// genTypes generates the type wrappers. -func genResourceIDs(wr io.Writer) { - const text = ` -// New{{.Service}}ResourceID creates a ResourceID for the {{.Service}} resource. -{{- if .KeyIsProject}} -func New{{.Service}}ResourceID(project string) *ResourceID { - var key *meta.Key -{{- else}} -{{- if .KeyIsGlobal}} -func New{{.Service}}ResourceID(project, name string) *ResourceID { - key := meta.GlobalKey(name) -{{- end}} -{{- if .KeyIsRegional}} -func New{{.Service}}ResourceID(project, region, name string) *ResourceID { - key := meta.RegionalKey(name, region) -{{- end}} -{{- if .KeyIsZonal}} -func New{{.Service}}ResourceID(project, zone, name string) *ResourceID { - key := meta.ZonalKey(name, zone) -{{- end -}} -{{end}} - return &ResourceID{project, "{{.Resource}}", key} -} -` - tmpl := template.Must(template.New("resourceIDs").Parse(text)) - for _, sg := range meta.SortedServicesGroups { - if err := tmpl.Execute(wr, sg.ServiceInfo()); err != nil { - panic(err) - } - } -} - -func genUnitTestHeader(wr io.Writer) { - const text = `/* -Copyright {{.Year}} The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// This file was generated by "go run gen/main.go -mode test > gen_test.go". Do not edit -// directly. - -package cloud - -import ( - "context" - "reflect" - "testing" - - alpha "google.golang.org/api/compute/v0.alpha" - beta "google.golang.org/api/compute/v0.beta" - ga "google.golang.org/api/compute/v1" - - "{{.PackageRoot}}/filter" - "{{.PackageRoot}}/meta" -) - -const location = "location" -` - tmpl := template.Must(template.New("header").Parse(text)) - values := map[string]string{ - "Year": fmt.Sprintf("%v", time.Now().Year()), - "PackageRoot": packageRoot, - } - if err := tmpl.Execute(wr, values); err != nil { - panic(err) - } -} - -func genUnitTestServices(wr io.Writer) { - const text = ` -func Test{{.Service}}Group(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key -{{- if .HasAlpha}} - keyAlpha := meta.{{.Alpha.MakeKey "key-alpha" "location"}} - key = keyAlpha -{{- end}} -{{- if .HasBeta}} - keyBeta := meta.{{.Beta.MakeKey "key-beta" "location"}} - key = keyBeta -{{- end}} -{{- if .HasGA}} - keyGA := meta.{{.GA.MakeKey "key-ga" "location"}} - key = keyGA -{{- end}} - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. -{{- if .HasAlpha}}{{- if .Alpha.GenerateGet}} - if _, err := mock.Alpha{{.Service}}().Get(ctx, key); err == nil { - t.Errorf("Alpha{{.Service}}().Get(%v, %v) = _, nil; want error", ctx, key) - } -{{- end}}{{- end}} -{{- if .HasBeta}}{{- if .Beta.GenerateGet}} - if _, err := mock.Beta{{.Service}}().Get(ctx, key); err == nil { - t.Errorf("Beta{{.Service}}().Get(%v, %v) = _, nil; want error", ctx, key) - } -{{- end}}{{- end}} -{{- if .HasGA}}{{- if .GA.GenerateGet}} - if _, err := mock.{{.Service}}().Get(ctx, key); err == nil { - t.Errorf("{{.Service}}().Get(%v, %v) = _, nil; want error", ctx, key) - } -{{- end}}{{- end}} - - // Insert. -{{- if .HasAlpha}}{{- if .Alpha.GenerateInsert}} - { - obj := &alpha.{{.Alpha.Object}}{} - if err := mock.Alpha{{.Service}}().Insert(ctx, keyAlpha, obj); err != nil { - t.Errorf("Alpha{{.Service}}().Insert(%v, %v, %v) = %v; want nil", ctx, keyAlpha, obj, err) - } - } -{{- end}}{{- end}} -{{- if .HasBeta}}{{- if .Beta.GenerateInsert}} - { - obj := &beta.{{.Beta.Object}}{} - if err := mock.Beta{{.Service}}().Insert(ctx, keyBeta, obj); err != nil { - t.Errorf("Beta{{.Service}}().Insert(%v, %v, %v) = %v; want nil", ctx, keyBeta, obj, err) - } - } -{{- end}}{{- end}} -{{- if .HasGA}}{{- if .GA.GenerateInsert}} - { - obj := &ga.{{.GA.Object}}{} - if err := mock.{{.Service}}().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("{{.Service}}().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } -{{- end}}{{- end}} - - // Get across versions. -{{- if .HasAlpha}}{{- if .Alpha.GenerateInsert}} - if obj, err := mock.Alpha{{.Service}}().Get(ctx, key); err != nil { - t.Errorf("Alpha{{.Service}}().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } -{{- end}}{{- end}} -{{- if .HasBeta}}{{- if .Beta.GenerateInsert}} - if obj, err := mock.Beta{{.Service}}().Get(ctx, key); err != nil { - t.Errorf("Beta{{.Service}}().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } -{{- end}}{{- end}} -{{- if .HasGA}}{{- if .GA.GenerateInsert}} - if obj, err := mock.{{.Service}}().Get(ctx, key); err != nil { - t.Errorf("{{.Service}}().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } -{{- end}}{{- end}} - - // List. -{{- if .HasAlpha}} - mock.MockAlpha{{.Service}}.Objects[*keyAlpha] = mock.MockAlpha{{.Service}}.Obj(&alpha.{{.Alpha.Object}}{Name: keyAlpha.Name}) -{{- end}} -{{- if .HasBeta}} - mock.MockBeta{{.Service}}.Objects[*keyBeta] = mock.MockBeta{{.Service}}.Obj(&beta.{{.Beta.Object}}{Name: keyBeta.Name}) -{{- end}} -{{- if .HasGA}} - mock.Mock{{.Service}}.Objects[*keyGA] = mock.Mock{{.Service}}.Obj(&ga.{{.GA.Object}}{Name: keyGA.Name}) -{{- end}} - want := map[string]bool{ -{{- if .HasAlpha}} - "key-alpha": true, -{{- end}} -{{- if .HasBeta}} - "key-beta": true, -{{- end}} -{{- if .HasGA}} - "key-ga": true, -{{- end}} - } - _ = want // ignore unused variables. - -{{- if .HasAlpha}}{{- if .Alpha.GenerateList}} - { - {{- if .Alpha.KeyIsGlobal }} - objs, err := mock.Alpha{{.Service}}().List(ctx, filter.None) - {{- else}} - objs, err := mock.Alpha{{.Service}}().List(ctx, location, filter.None) - {{- end}} - if err != nil { - t.Errorf("Alpha{{.Service}}().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("Alpha{{.Service}}().List(); got %+v, want %+v", got, want) - } - } - } -{{- end}}{{- end}} -{{- if .HasBeta}}{{- if .Beta.GenerateList}} - { - {{- if .Beta.KeyIsGlobal }} - objs, err := mock.Beta{{.Service}}().List(ctx, filter.None) - {{- else}} - objs, err := mock.Beta{{.Service}}().List(ctx, location, filter.None) - {{- end}} - if err != nil { - t.Errorf("Beta{{.Service}}().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("Beta{{.Service}}().List(); got %+v, want %+v", got, want) - } - } - } -{{- end}}{{- end}} -{{- if .HasGA}}{{- if .GA.GenerateList}} - { - {{- if .GA.KeyIsGlobal }} - objs, err := mock.{{.Service}}().List(ctx, filter.None) - {{- else}} - objs, err := mock.{{.Service}}().List(ctx, location, filter.None) - {{- end}} - if err != nil { - t.Errorf("{{.Service}}().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("{{.Service}}().List(); got %+v, want %+v", got, want) - } - } - } -{{- end}}{{- end}} - - // Delete across versions. -{{- if .HasAlpha}}{{- if .Alpha.GenerateDelete}} - if err := mock.Alpha{{.Service}}().Delete(ctx, keyAlpha); err != nil { - t.Errorf("Alpha{{.Service}}().Delete(%v, %v) = %v; want nil", ctx, keyAlpha, err) - } -{{- end}}{{- end}} -{{- if .HasBeta}}{{- if .Beta.GenerateDelete}} - if err := mock.Beta{{.Service}}().Delete(ctx, keyBeta); err != nil { - t.Errorf("Beta{{.Service}}().Delete(%v, %v) = %v; want nil", ctx, keyBeta, err) - } -{{- end}}{{- end}} -{{- if .HasGA}}{{- if .GA.GenerateDelete}} - if err := mock.{{.Service}}().Delete(ctx, keyGA); err != nil { - t.Errorf("{{.Service}}().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } -{{- end}}{{- end}} - - // Delete not found. -{{- if .HasAlpha}}{{- if .Alpha.GenerateDelete}} - if err := mock.Alpha{{.Service}}().Delete(ctx, keyAlpha); err == nil { - t.Errorf("Alpha{{.Service}}().Delete(%v, %v) = nil; want error", ctx, keyAlpha) - } -{{- end}}{{- end}} -{{- if .HasBeta}}{{- if .Beta.GenerateDelete}} - if err := mock.Beta{{.Service}}().Delete(ctx, keyBeta); err == nil { - t.Errorf("Beta{{.Service}}().Delete(%v, %v) = nil; want error", ctx, keyBeta) - } -{{- end}}{{- end}} -{{- if .HasGA}}{{- if .GA.GenerateDelete}} - if err := mock.{{.Service}}().Delete(ctx, keyGA); err == nil { - t.Errorf("{{.Service}}().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -{{- end}}{{- end}} -} -` - tmpl := template.Must(template.New("unittest").Parse(text)) - for _, sg := range meta.SortedServicesGroups { - if err := tmpl.Execute(wr, sg); err != nil { - panic(err) - } - } -} - -func genUnitTestResourceIDConversion(wr io.Writer) { - const text = ` -func TestResourceIDConversion(t *testing.T) { - t.Parallel() - - for _, id := range []*ResourceID{ - {{- range .Groups}} - {{- with .ServiceInfo}} - {{- if .KeyIsProject}} - New{{.Service}}ResourceID("my-{{.Resource}}-resource"), - {{- else}} - {{- if .KeyIsGlobal}} - New{{.Service}}ResourceID("some-project", "my-{{.Resource}}-resource"), - {{- end}} - {{- if .KeyIsRegional}} - New{{.Service}}ResourceID("some-project", "us-central1", "my-{{.Resource}}-resource"), - {{- end}} - {{- if .KeyIsZonal}} - New{{.Service}}ResourceID("some-project", "us-east1-b", "my-{{.Resource}}-resource"), - {{- end -}} - {{end -}} - {{end -}} - {{end}} - } { - t.Run(id.Resource, func(t *testing.T) { - // Test conversion to and from full URL. - fullURL := id.SelfLink(meta.VersionGA) - parsedID, err := ParseResourceURL(fullURL) - if err != nil { - t.Errorf("ParseResourceURL(%s) = _, %v, want nil", fullURL, err) - } - if !reflect.DeepEqual(id, parsedID) { - t.Errorf("SelfLink(%+v) -> ParseResourceURL(%s) = %+v, want original ID", id, fullURL, parsedID) - } - - // Test conversion to and from relative resource name. - relativeName := id.RelativeResourceName() - parsedID, err = ParseResourceURL(relativeName) - if err != nil { - t.Errorf("ParseResourceURL(%s) = _, %v, want nil", relativeName, err) - } - if !reflect.DeepEqual(id, parsedID) { - t.Errorf("RelativeResourceName(%+v) -> ParseResourceURL(%s) = %+v, want original ID", id, relativeName, parsedID) - } - - // Do not test ResourcePath for projects. - if id.Resource == "projects" { - return - } - - // Test conversion to and from resource path. - resourcePath := id.ResourcePath() - parsedID, err = ParseResourceURL(resourcePath) - if err != nil { - t.Errorf("ParseResourceURL(%s) = _, %v, want nil", resourcePath, err) - } - id.ProjectID = "" - if !reflect.DeepEqual(id, parsedID) { - t.Errorf("ResourcePath(%+v) -> ParseResourceURL(%s) = %+v, want %+v", id, resourcePath, parsedID, id) - } - }) - } -} -` - data := struct { - Groups []*meta.ServiceGroup - }{meta.SortedServicesGroups} - tmpl := template.Must(template.New("unittest-resourceIDs").Parse(text)) - if err := tmpl.Execute(wr, data); err != nil { - panic(err) - } -} - -func main() { - flag.Parse() - - out := &bytes.Buffer{} - - switch flags.mode { - case "src": - genHeader(out) - genStubs(out) - genTypes(out) - genResourceIDs(out) - case "test": - genUnitTestHeader(out) - genUnitTestServices(out) - genUnitTestResourceIDConversion(out) - default: - log.Fatalf("Invalid -mode: %q", flags.mode) - } - - if flags.gofmt { - fmt.Print(gofmtContent(out)) - } else { - fmt.Print(out.String()) - } -} diff --git a/pkg/cloudprovider/providers/gce/cloud/gen_test.go b/pkg/cloudprovider/providers/gce/cloud/gen_test.go deleted file mode 100644 index 902b4ee780d8..000000000000 --- a/pkg/cloudprovider/providers/gce/cloud/gen_test.go +++ /dev/null @@ -1,2014 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// This file was generated by "go run gen/main.go -mode test > gen_test.go". Do not edit -// directly. - -package cloud - -import ( - "context" - "reflect" - "testing" - - alpha "google.golang.org/api/compute/v0.alpha" - beta "google.golang.org/api/compute/v0.beta" - ga "google.golang.org/api/compute/v1" - - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" -) - -const location = "location" - -func TestAddressesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyAlpha := meta.RegionalKey("key-alpha", "location") - key = keyAlpha - keyBeta := meta.RegionalKey("key-beta", "location") - key = keyBeta - keyGA := meta.RegionalKey("key-ga", "location") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.AlphaAddresses().Get(ctx, key); err == nil { - t.Errorf("AlphaAddresses().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.BetaAddresses().Get(ctx, key); err == nil { - t.Errorf("BetaAddresses().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.Addresses().Get(ctx, key); err == nil { - t.Errorf("Addresses().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &alpha.Address{} - if err := mock.AlphaAddresses().Insert(ctx, keyAlpha, obj); err != nil { - t.Errorf("AlphaAddresses().Insert(%v, %v, %v) = %v; want nil", ctx, keyAlpha, obj, err) - } - } - { - obj := &beta.Address{} - if err := mock.BetaAddresses().Insert(ctx, keyBeta, obj); err != nil { - t.Errorf("BetaAddresses().Insert(%v, %v, %v) = %v; want nil", ctx, keyBeta, obj, err) - } - } - { - obj := &ga.Address{} - if err := mock.Addresses().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("Addresses().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.AlphaAddresses().Get(ctx, key); err != nil { - t.Errorf("AlphaAddresses().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.BetaAddresses().Get(ctx, key); err != nil { - t.Errorf("BetaAddresses().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.Addresses().Get(ctx, key); err != nil { - t.Errorf("Addresses().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockAlphaAddresses.Objects[*keyAlpha] = mock.MockAlphaAddresses.Obj(&alpha.Address{Name: keyAlpha.Name}) - mock.MockBetaAddresses.Objects[*keyBeta] = mock.MockBetaAddresses.Obj(&beta.Address{Name: keyBeta.Name}) - mock.MockAddresses.Objects[*keyGA] = mock.MockAddresses.Obj(&ga.Address{Name: keyGA.Name}) - want := map[string]bool{ - "key-alpha": true, - "key-beta": true, - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.AlphaAddresses().List(ctx, location, filter.None) - if err != nil { - t.Errorf("AlphaAddresses().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("AlphaAddresses().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.BetaAddresses().List(ctx, location, filter.None) - if err != nil { - t.Errorf("BetaAddresses().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("BetaAddresses().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.Addresses().List(ctx, location, filter.None) - if err != nil { - t.Errorf("Addresses().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("Addresses().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.AlphaAddresses().Delete(ctx, keyAlpha); err != nil { - t.Errorf("AlphaAddresses().Delete(%v, %v) = %v; want nil", ctx, keyAlpha, err) - } - if err := mock.BetaAddresses().Delete(ctx, keyBeta); err != nil { - t.Errorf("BetaAddresses().Delete(%v, %v) = %v; want nil", ctx, keyBeta, err) - } - if err := mock.Addresses().Delete(ctx, keyGA); err != nil { - t.Errorf("Addresses().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.AlphaAddresses().Delete(ctx, keyAlpha); err == nil { - t.Errorf("AlphaAddresses().Delete(%v, %v) = nil; want error", ctx, keyAlpha) - } - if err := mock.BetaAddresses().Delete(ctx, keyBeta); err == nil { - t.Errorf("BetaAddresses().Delete(%v, %v) = nil; want error", ctx, keyBeta) - } - if err := mock.Addresses().Delete(ctx, keyGA); err == nil { - t.Errorf("Addresses().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestBackendServicesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyAlpha := meta.GlobalKey("key-alpha") - key = keyAlpha - keyBeta := meta.GlobalKey("key-beta") - key = keyBeta - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.AlphaBackendServices().Get(ctx, key); err == nil { - t.Errorf("AlphaBackendServices().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.BetaBackendServices().Get(ctx, key); err == nil { - t.Errorf("BetaBackendServices().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.BackendServices().Get(ctx, key); err == nil { - t.Errorf("BackendServices().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &alpha.BackendService{} - if err := mock.AlphaBackendServices().Insert(ctx, keyAlpha, obj); err != nil { - t.Errorf("AlphaBackendServices().Insert(%v, %v, %v) = %v; want nil", ctx, keyAlpha, obj, err) - } - } - { - obj := &beta.BackendService{} - if err := mock.BetaBackendServices().Insert(ctx, keyBeta, obj); err != nil { - t.Errorf("BetaBackendServices().Insert(%v, %v, %v) = %v; want nil", ctx, keyBeta, obj, err) - } - } - { - obj := &ga.BackendService{} - if err := mock.BackendServices().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("BackendServices().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.AlphaBackendServices().Get(ctx, key); err != nil { - t.Errorf("AlphaBackendServices().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.BetaBackendServices().Get(ctx, key); err != nil { - t.Errorf("BetaBackendServices().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.BackendServices().Get(ctx, key); err != nil { - t.Errorf("BackendServices().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockAlphaBackendServices.Objects[*keyAlpha] = mock.MockAlphaBackendServices.Obj(&alpha.BackendService{Name: keyAlpha.Name}) - mock.MockBetaBackendServices.Objects[*keyBeta] = mock.MockBetaBackendServices.Obj(&beta.BackendService{Name: keyBeta.Name}) - mock.MockBackendServices.Objects[*keyGA] = mock.MockBackendServices.Obj(&ga.BackendService{Name: keyGA.Name}) - want := map[string]bool{ - "key-alpha": true, - "key-beta": true, - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.AlphaBackendServices().List(ctx, filter.None) - if err != nil { - t.Errorf("AlphaBackendServices().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("AlphaBackendServices().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.BetaBackendServices().List(ctx, filter.None) - if err != nil { - t.Errorf("BetaBackendServices().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("BetaBackendServices().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.BackendServices().List(ctx, filter.None) - if err != nil { - t.Errorf("BackendServices().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("BackendServices().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.AlphaBackendServices().Delete(ctx, keyAlpha); err != nil { - t.Errorf("AlphaBackendServices().Delete(%v, %v) = %v; want nil", ctx, keyAlpha, err) - } - if err := mock.BetaBackendServices().Delete(ctx, keyBeta); err != nil { - t.Errorf("BetaBackendServices().Delete(%v, %v) = %v; want nil", ctx, keyBeta, err) - } - if err := mock.BackendServices().Delete(ctx, keyGA); err != nil { - t.Errorf("BackendServices().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.AlphaBackendServices().Delete(ctx, keyAlpha); err == nil { - t.Errorf("AlphaBackendServices().Delete(%v, %v) = nil; want error", ctx, keyAlpha) - } - if err := mock.BetaBackendServices().Delete(ctx, keyBeta); err == nil { - t.Errorf("BetaBackendServices().Delete(%v, %v) = nil; want error", ctx, keyBeta) - } - if err := mock.BackendServices().Delete(ctx, keyGA); err == nil { - t.Errorf("BackendServices().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestDisksGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.ZonalKey("key-ga", "location") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.Disks().Get(ctx, key); err == nil { - t.Errorf("Disks().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.Disk{} - if err := mock.Disks().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("Disks().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.Disks().Get(ctx, key); err != nil { - t.Errorf("Disks().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockDisks.Objects[*keyGA] = mock.MockDisks.Obj(&ga.Disk{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.Disks().List(ctx, location, filter.None) - if err != nil { - t.Errorf("Disks().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("Disks().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.Disks().Delete(ctx, keyGA); err != nil { - t.Errorf("Disks().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.Disks().Delete(ctx, keyGA); err == nil { - t.Errorf("Disks().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestFirewallsGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.Firewalls().Get(ctx, key); err == nil { - t.Errorf("Firewalls().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.Firewall{} - if err := mock.Firewalls().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("Firewalls().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.Firewalls().Get(ctx, key); err != nil { - t.Errorf("Firewalls().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockFirewalls.Objects[*keyGA] = mock.MockFirewalls.Obj(&ga.Firewall{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.Firewalls().List(ctx, filter.None) - if err != nil { - t.Errorf("Firewalls().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("Firewalls().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.Firewalls().Delete(ctx, keyGA); err != nil { - t.Errorf("Firewalls().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.Firewalls().Delete(ctx, keyGA); err == nil { - t.Errorf("Firewalls().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestForwardingRulesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyAlpha := meta.RegionalKey("key-alpha", "location") - key = keyAlpha - keyGA := meta.RegionalKey("key-ga", "location") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.AlphaForwardingRules().Get(ctx, key); err == nil { - t.Errorf("AlphaForwardingRules().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.ForwardingRules().Get(ctx, key); err == nil { - t.Errorf("ForwardingRules().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &alpha.ForwardingRule{} - if err := mock.AlphaForwardingRules().Insert(ctx, keyAlpha, obj); err != nil { - t.Errorf("AlphaForwardingRules().Insert(%v, %v, %v) = %v; want nil", ctx, keyAlpha, obj, err) - } - } - { - obj := &ga.ForwardingRule{} - if err := mock.ForwardingRules().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("ForwardingRules().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.AlphaForwardingRules().Get(ctx, key); err != nil { - t.Errorf("AlphaForwardingRules().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.ForwardingRules().Get(ctx, key); err != nil { - t.Errorf("ForwardingRules().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockAlphaForwardingRules.Objects[*keyAlpha] = mock.MockAlphaForwardingRules.Obj(&alpha.ForwardingRule{Name: keyAlpha.Name}) - mock.MockForwardingRules.Objects[*keyGA] = mock.MockForwardingRules.Obj(&ga.ForwardingRule{Name: keyGA.Name}) - want := map[string]bool{ - "key-alpha": true, - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.AlphaForwardingRules().List(ctx, location, filter.None) - if err != nil { - t.Errorf("AlphaForwardingRules().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("AlphaForwardingRules().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.ForwardingRules().List(ctx, location, filter.None) - if err != nil { - t.Errorf("ForwardingRules().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("ForwardingRules().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.AlphaForwardingRules().Delete(ctx, keyAlpha); err != nil { - t.Errorf("AlphaForwardingRules().Delete(%v, %v) = %v; want nil", ctx, keyAlpha, err) - } - if err := mock.ForwardingRules().Delete(ctx, keyGA); err != nil { - t.Errorf("ForwardingRules().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.AlphaForwardingRules().Delete(ctx, keyAlpha); err == nil { - t.Errorf("AlphaForwardingRules().Delete(%v, %v) = nil; want error", ctx, keyAlpha) - } - if err := mock.ForwardingRules().Delete(ctx, keyGA); err == nil { - t.Errorf("ForwardingRules().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestGlobalAddressesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.GlobalAddresses().Get(ctx, key); err == nil { - t.Errorf("GlobalAddresses().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.Address{} - if err := mock.GlobalAddresses().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("GlobalAddresses().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.GlobalAddresses().Get(ctx, key); err != nil { - t.Errorf("GlobalAddresses().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockGlobalAddresses.Objects[*keyGA] = mock.MockGlobalAddresses.Obj(&ga.Address{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.GlobalAddresses().List(ctx, filter.None) - if err != nil { - t.Errorf("GlobalAddresses().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("GlobalAddresses().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.GlobalAddresses().Delete(ctx, keyGA); err != nil { - t.Errorf("GlobalAddresses().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.GlobalAddresses().Delete(ctx, keyGA); err == nil { - t.Errorf("GlobalAddresses().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestGlobalForwardingRulesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.GlobalForwardingRules().Get(ctx, key); err == nil { - t.Errorf("GlobalForwardingRules().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.ForwardingRule{} - if err := mock.GlobalForwardingRules().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("GlobalForwardingRules().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.GlobalForwardingRules().Get(ctx, key); err != nil { - t.Errorf("GlobalForwardingRules().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockGlobalForwardingRules.Objects[*keyGA] = mock.MockGlobalForwardingRules.Obj(&ga.ForwardingRule{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.GlobalForwardingRules().List(ctx, filter.None) - if err != nil { - t.Errorf("GlobalForwardingRules().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("GlobalForwardingRules().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.GlobalForwardingRules().Delete(ctx, keyGA); err != nil { - t.Errorf("GlobalForwardingRules().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.GlobalForwardingRules().Delete(ctx, keyGA); err == nil { - t.Errorf("GlobalForwardingRules().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestHealthChecksGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyAlpha := meta.GlobalKey("key-alpha") - key = keyAlpha - keyBeta := meta.GlobalKey("key-beta") - key = keyBeta - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.AlphaHealthChecks().Get(ctx, key); err == nil { - t.Errorf("AlphaHealthChecks().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.BetaHealthChecks().Get(ctx, key); err == nil { - t.Errorf("BetaHealthChecks().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.HealthChecks().Get(ctx, key); err == nil { - t.Errorf("HealthChecks().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &alpha.HealthCheck{} - if err := mock.AlphaHealthChecks().Insert(ctx, keyAlpha, obj); err != nil { - t.Errorf("AlphaHealthChecks().Insert(%v, %v, %v) = %v; want nil", ctx, keyAlpha, obj, err) - } - } - { - obj := &beta.HealthCheck{} - if err := mock.BetaHealthChecks().Insert(ctx, keyBeta, obj); err != nil { - t.Errorf("BetaHealthChecks().Insert(%v, %v, %v) = %v; want nil", ctx, keyBeta, obj, err) - } - } - { - obj := &ga.HealthCheck{} - if err := mock.HealthChecks().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("HealthChecks().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.AlphaHealthChecks().Get(ctx, key); err != nil { - t.Errorf("AlphaHealthChecks().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.BetaHealthChecks().Get(ctx, key); err != nil { - t.Errorf("BetaHealthChecks().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.HealthChecks().Get(ctx, key); err != nil { - t.Errorf("HealthChecks().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockAlphaHealthChecks.Objects[*keyAlpha] = mock.MockAlphaHealthChecks.Obj(&alpha.HealthCheck{Name: keyAlpha.Name}) - mock.MockBetaHealthChecks.Objects[*keyBeta] = mock.MockBetaHealthChecks.Obj(&beta.HealthCheck{Name: keyBeta.Name}) - mock.MockHealthChecks.Objects[*keyGA] = mock.MockHealthChecks.Obj(&ga.HealthCheck{Name: keyGA.Name}) - want := map[string]bool{ - "key-alpha": true, - "key-beta": true, - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.AlphaHealthChecks().List(ctx, filter.None) - if err != nil { - t.Errorf("AlphaHealthChecks().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("AlphaHealthChecks().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.BetaHealthChecks().List(ctx, filter.None) - if err != nil { - t.Errorf("BetaHealthChecks().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("BetaHealthChecks().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.HealthChecks().List(ctx, filter.None) - if err != nil { - t.Errorf("HealthChecks().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("HealthChecks().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.AlphaHealthChecks().Delete(ctx, keyAlpha); err != nil { - t.Errorf("AlphaHealthChecks().Delete(%v, %v) = %v; want nil", ctx, keyAlpha, err) - } - if err := mock.BetaHealthChecks().Delete(ctx, keyBeta); err != nil { - t.Errorf("BetaHealthChecks().Delete(%v, %v) = %v; want nil", ctx, keyBeta, err) - } - if err := mock.HealthChecks().Delete(ctx, keyGA); err != nil { - t.Errorf("HealthChecks().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.AlphaHealthChecks().Delete(ctx, keyAlpha); err == nil { - t.Errorf("AlphaHealthChecks().Delete(%v, %v) = nil; want error", ctx, keyAlpha) - } - if err := mock.BetaHealthChecks().Delete(ctx, keyBeta); err == nil { - t.Errorf("BetaHealthChecks().Delete(%v, %v) = nil; want error", ctx, keyBeta) - } - if err := mock.HealthChecks().Delete(ctx, keyGA); err == nil { - t.Errorf("HealthChecks().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestHttpHealthChecksGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.HttpHealthChecks().Get(ctx, key); err == nil { - t.Errorf("HttpHealthChecks().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.HttpHealthCheck{} - if err := mock.HttpHealthChecks().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("HttpHealthChecks().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.HttpHealthChecks().Get(ctx, key); err != nil { - t.Errorf("HttpHealthChecks().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockHttpHealthChecks.Objects[*keyGA] = mock.MockHttpHealthChecks.Obj(&ga.HttpHealthCheck{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.HttpHealthChecks().List(ctx, filter.None) - if err != nil { - t.Errorf("HttpHealthChecks().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("HttpHealthChecks().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.HttpHealthChecks().Delete(ctx, keyGA); err != nil { - t.Errorf("HttpHealthChecks().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.HttpHealthChecks().Delete(ctx, keyGA); err == nil { - t.Errorf("HttpHealthChecks().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestHttpsHealthChecksGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.HttpsHealthChecks().Get(ctx, key); err == nil { - t.Errorf("HttpsHealthChecks().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.HttpsHealthCheck{} - if err := mock.HttpsHealthChecks().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("HttpsHealthChecks().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.HttpsHealthChecks().Get(ctx, key); err != nil { - t.Errorf("HttpsHealthChecks().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockHttpsHealthChecks.Objects[*keyGA] = mock.MockHttpsHealthChecks.Obj(&ga.HttpsHealthCheck{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.HttpsHealthChecks().List(ctx, filter.None) - if err != nil { - t.Errorf("HttpsHealthChecks().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("HttpsHealthChecks().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.HttpsHealthChecks().Delete(ctx, keyGA); err != nil { - t.Errorf("HttpsHealthChecks().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.HttpsHealthChecks().Delete(ctx, keyGA); err == nil { - t.Errorf("HttpsHealthChecks().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestInstanceGroupsGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.ZonalKey("key-ga", "location") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.InstanceGroups().Get(ctx, key); err == nil { - t.Errorf("InstanceGroups().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.InstanceGroup{} - if err := mock.InstanceGroups().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("InstanceGroups().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.InstanceGroups().Get(ctx, key); err != nil { - t.Errorf("InstanceGroups().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockInstanceGroups.Objects[*keyGA] = mock.MockInstanceGroups.Obj(&ga.InstanceGroup{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.InstanceGroups().List(ctx, location, filter.None) - if err != nil { - t.Errorf("InstanceGroups().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("InstanceGroups().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.InstanceGroups().Delete(ctx, keyGA); err != nil { - t.Errorf("InstanceGroups().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.InstanceGroups().Delete(ctx, keyGA); err == nil { - t.Errorf("InstanceGroups().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestInstancesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyAlpha := meta.ZonalKey("key-alpha", "location") - key = keyAlpha - keyBeta := meta.ZonalKey("key-beta", "location") - key = keyBeta - keyGA := meta.ZonalKey("key-ga", "location") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.AlphaInstances().Get(ctx, key); err == nil { - t.Errorf("AlphaInstances().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.BetaInstances().Get(ctx, key); err == nil { - t.Errorf("BetaInstances().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.Instances().Get(ctx, key); err == nil { - t.Errorf("Instances().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &alpha.Instance{} - if err := mock.AlphaInstances().Insert(ctx, keyAlpha, obj); err != nil { - t.Errorf("AlphaInstances().Insert(%v, %v, %v) = %v; want nil", ctx, keyAlpha, obj, err) - } - } - { - obj := &beta.Instance{} - if err := mock.BetaInstances().Insert(ctx, keyBeta, obj); err != nil { - t.Errorf("BetaInstances().Insert(%v, %v, %v) = %v; want nil", ctx, keyBeta, obj, err) - } - } - { - obj := &ga.Instance{} - if err := mock.Instances().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("Instances().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.AlphaInstances().Get(ctx, key); err != nil { - t.Errorf("AlphaInstances().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.BetaInstances().Get(ctx, key); err != nil { - t.Errorf("BetaInstances().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.Instances().Get(ctx, key); err != nil { - t.Errorf("Instances().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockAlphaInstances.Objects[*keyAlpha] = mock.MockAlphaInstances.Obj(&alpha.Instance{Name: keyAlpha.Name}) - mock.MockBetaInstances.Objects[*keyBeta] = mock.MockBetaInstances.Obj(&beta.Instance{Name: keyBeta.Name}) - mock.MockInstances.Objects[*keyGA] = mock.MockInstances.Obj(&ga.Instance{Name: keyGA.Name}) - want := map[string]bool{ - "key-alpha": true, - "key-beta": true, - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.AlphaInstances().List(ctx, location, filter.None) - if err != nil { - t.Errorf("AlphaInstances().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("AlphaInstances().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.BetaInstances().List(ctx, location, filter.None) - if err != nil { - t.Errorf("BetaInstances().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("BetaInstances().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.Instances().List(ctx, location, filter.None) - if err != nil { - t.Errorf("Instances().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("Instances().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.AlphaInstances().Delete(ctx, keyAlpha); err != nil { - t.Errorf("AlphaInstances().Delete(%v, %v) = %v; want nil", ctx, keyAlpha, err) - } - if err := mock.BetaInstances().Delete(ctx, keyBeta); err != nil { - t.Errorf("BetaInstances().Delete(%v, %v) = %v; want nil", ctx, keyBeta, err) - } - if err := mock.Instances().Delete(ctx, keyGA); err != nil { - t.Errorf("Instances().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.AlphaInstances().Delete(ctx, keyAlpha); err == nil { - t.Errorf("AlphaInstances().Delete(%v, %v) = nil; want error", ctx, keyAlpha) - } - if err := mock.BetaInstances().Delete(ctx, keyBeta); err == nil { - t.Errorf("BetaInstances().Delete(%v, %v) = nil; want error", ctx, keyBeta) - } - if err := mock.Instances().Delete(ctx, keyGA); err == nil { - t.Errorf("Instances().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestNetworkEndpointGroupsGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyAlpha := meta.ZonalKey("key-alpha", "location") - key = keyAlpha - keyBeta := meta.ZonalKey("key-beta", "location") - key = keyBeta - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.AlphaNetworkEndpointGroups().Get(ctx, key); err == nil { - t.Errorf("AlphaNetworkEndpointGroups().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.BetaNetworkEndpointGroups().Get(ctx, key); err == nil { - t.Errorf("BetaNetworkEndpointGroups().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &alpha.NetworkEndpointGroup{} - if err := mock.AlphaNetworkEndpointGroups().Insert(ctx, keyAlpha, obj); err != nil { - t.Errorf("AlphaNetworkEndpointGroups().Insert(%v, %v, %v) = %v; want nil", ctx, keyAlpha, obj, err) - } - } - { - obj := &beta.NetworkEndpointGroup{} - if err := mock.BetaNetworkEndpointGroups().Insert(ctx, keyBeta, obj); err != nil { - t.Errorf("BetaNetworkEndpointGroups().Insert(%v, %v, %v) = %v; want nil", ctx, keyBeta, obj, err) - } - } - - // Get across versions. - if obj, err := mock.AlphaNetworkEndpointGroups().Get(ctx, key); err != nil { - t.Errorf("AlphaNetworkEndpointGroups().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.BetaNetworkEndpointGroups().Get(ctx, key); err != nil { - t.Errorf("BetaNetworkEndpointGroups().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockAlphaNetworkEndpointGroups.Objects[*keyAlpha] = mock.MockAlphaNetworkEndpointGroups.Obj(&alpha.NetworkEndpointGroup{Name: keyAlpha.Name}) - mock.MockBetaNetworkEndpointGroups.Objects[*keyBeta] = mock.MockBetaNetworkEndpointGroups.Obj(&beta.NetworkEndpointGroup{Name: keyBeta.Name}) - want := map[string]bool{ - "key-alpha": true, - "key-beta": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.AlphaNetworkEndpointGroups().List(ctx, location, filter.None) - if err != nil { - t.Errorf("AlphaNetworkEndpointGroups().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("AlphaNetworkEndpointGroups().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.BetaNetworkEndpointGroups().List(ctx, location, filter.None) - if err != nil { - t.Errorf("BetaNetworkEndpointGroups().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("BetaNetworkEndpointGroups().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.AlphaNetworkEndpointGroups().Delete(ctx, keyAlpha); err != nil { - t.Errorf("AlphaNetworkEndpointGroups().Delete(%v, %v) = %v; want nil", ctx, keyAlpha, err) - } - if err := mock.BetaNetworkEndpointGroups().Delete(ctx, keyBeta); err != nil { - t.Errorf("BetaNetworkEndpointGroups().Delete(%v, %v) = %v; want nil", ctx, keyBeta, err) - } - - // Delete not found. - if err := mock.AlphaNetworkEndpointGroups().Delete(ctx, keyAlpha); err == nil { - t.Errorf("AlphaNetworkEndpointGroups().Delete(%v, %v) = nil; want error", ctx, keyAlpha) - } - if err := mock.BetaNetworkEndpointGroups().Delete(ctx, keyBeta); err == nil { - t.Errorf("BetaNetworkEndpointGroups().Delete(%v, %v) = nil; want error", ctx, keyBeta) - } -} - -func TestProjectsGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - - // Insert. - - // Get across versions. - - // List. - mock.MockProjects.Objects[*keyGA] = mock.MockProjects.Obj(&ga.Project{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - - // Delete across versions. - - // Delete not found. -} - -func TestRegionBackendServicesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyAlpha := meta.RegionalKey("key-alpha", "location") - key = keyAlpha - keyGA := meta.RegionalKey("key-ga", "location") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.AlphaRegionBackendServices().Get(ctx, key); err == nil { - t.Errorf("AlphaRegionBackendServices().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.RegionBackendServices().Get(ctx, key); err == nil { - t.Errorf("RegionBackendServices().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &alpha.BackendService{} - if err := mock.AlphaRegionBackendServices().Insert(ctx, keyAlpha, obj); err != nil { - t.Errorf("AlphaRegionBackendServices().Insert(%v, %v, %v) = %v; want nil", ctx, keyAlpha, obj, err) - } - } - { - obj := &ga.BackendService{} - if err := mock.RegionBackendServices().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("RegionBackendServices().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.AlphaRegionBackendServices().Get(ctx, key); err != nil { - t.Errorf("AlphaRegionBackendServices().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.RegionBackendServices().Get(ctx, key); err != nil { - t.Errorf("RegionBackendServices().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockAlphaRegionBackendServices.Objects[*keyAlpha] = mock.MockAlphaRegionBackendServices.Obj(&alpha.BackendService{Name: keyAlpha.Name}) - mock.MockRegionBackendServices.Objects[*keyGA] = mock.MockRegionBackendServices.Obj(&ga.BackendService{Name: keyGA.Name}) - want := map[string]bool{ - "key-alpha": true, - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.AlphaRegionBackendServices().List(ctx, location, filter.None) - if err != nil { - t.Errorf("AlphaRegionBackendServices().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("AlphaRegionBackendServices().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.RegionBackendServices().List(ctx, location, filter.None) - if err != nil { - t.Errorf("RegionBackendServices().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("RegionBackendServices().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.AlphaRegionBackendServices().Delete(ctx, keyAlpha); err != nil { - t.Errorf("AlphaRegionBackendServices().Delete(%v, %v) = %v; want nil", ctx, keyAlpha, err) - } - if err := mock.RegionBackendServices().Delete(ctx, keyGA); err != nil { - t.Errorf("RegionBackendServices().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.AlphaRegionBackendServices().Delete(ctx, keyAlpha); err == nil { - t.Errorf("AlphaRegionBackendServices().Delete(%v, %v) = nil; want error", ctx, keyAlpha) - } - if err := mock.RegionBackendServices().Delete(ctx, keyGA); err == nil { - t.Errorf("RegionBackendServices().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestRegionDisksGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.RegionalKey("key-ga", "location") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.RegionDisks().Get(ctx, key); err == nil { - t.Errorf("RegionDisks().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.Disk{} - if err := mock.RegionDisks().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("RegionDisks().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.RegionDisks().Get(ctx, key); err != nil { - t.Errorf("RegionDisks().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockRegionDisks.Objects[*keyGA] = mock.MockRegionDisks.Obj(&ga.Disk{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.RegionDisks().List(ctx, location, filter.None) - if err != nil { - t.Errorf("RegionDisks().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("RegionDisks().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.RegionDisks().Delete(ctx, keyGA); err != nil { - t.Errorf("RegionDisks().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.RegionDisks().Delete(ctx, keyGA); err == nil { - t.Errorf("RegionDisks().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestRegionsGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.Regions().Get(ctx, key); err == nil { - t.Errorf("Regions().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - - // Get across versions. - - // List. - mock.MockRegions.Objects[*keyGA] = mock.MockRegions.Obj(&ga.Region{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.Regions().List(ctx, filter.None) - if err != nil { - t.Errorf("Regions().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("Regions().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - - // Delete not found. -} - -func TestRoutesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.Routes().Get(ctx, key); err == nil { - t.Errorf("Routes().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.Route{} - if err := mock.Routes().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("Routes().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.Routes().Get(ctx, key); err != nil { - t.Errorf("Routes().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockRoutes.Objects[*keyGA] = mock.MockRoutes.Obj(&ga.Route{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.Routes().List(ctx, filter.None) - if err != nil { - t.Errorf("Routes().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("Routes().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.Routes().Delete(ctx, keyGA); err != nil { - t.Errorf("Routes().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.Routes().Delete(ctx, keyGA); err == nil { - t.Errorf("Routes().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestSecurityPoliciesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyBeta := meta.GlobalKey("key-beta") - key = keyBeta - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.BetaSecurityPolicies().Get(ctx, key); err == nil { - t.Errorf("BetaSecurityPolicies().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &beta.SecurityPolicy{} - if err := mock.BetaSecurityPolicies().Insert(ctx, keyBeta, obj); err != nil { - t.Errorf("BetaSecurityPolicies().Insert(%v, %v, %v) = %v; want nil", ctx, keyBeta, obj, err) - } - } - - // Get across versions. - if obj, err := mock.BetaSecurityPolicies().Get(ctx, key); err != nil { - t.Errorf("BetaSecurityPolicies().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockBetaSecurityPolicies.Objects[*keyBeta] = mock.MockBetaSecurityPolicies.Obj(&beta.SecurityPolicy{Name: keyBeta.Name}) - want := map[string]bool{ - "key-beta": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.BetaSecurityPolicies().List(ctx, filter.None) - if err != nil { - t.Errorf("BetaSecurityPolicies().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("BetaSecurityPolicies().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.BetaSecurityPolicies().Delete(ctx, keyBeta); err != nil { - t.Errorf("BetaSecurityPolicies().Delete(%v, %v) = %v; want nil", ctx, keyBeta, err) - } - - // Delete not found. - if err := mock.BetaSecurityPolicies().Delete(ctx, keyBeta); err == nil { - t.Errorf("BetaSecurityPolicies().Delete(%v, %v) = nil; want error", ctx, keyBeta) - } -} - -func TestSslCertificatesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.SslCertificates().Get(ctx, key); err == nil { - t.Errorf("SslCertificates().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.SslCertificate{} - if err := mock.SslCertificates().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("SslCertificates().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.SslCertificates().Get(ctx, key); err != nil { - t.Errorf("SslCertificates().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockSslCertificates.Objects[*keyGA] = mock.MockSslCertificates.Obj(&ga.SslCertificate{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.SslCertificates().List(ctx, filter.None) - if err != nil { - t.Errorf("SslCertificates().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("SslCertificates().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.SslCertificates().Delete(ctx, keyGA); err != nil { - t.Errorf("SslCertificates().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.SslCertificates().Delete(ctx, keyGA); err == nil { - t.Errorf("SslCertificates().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestTargetHttpProxiesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.TargetHttpProxies().Get(ctx, key); err == nil { - t.Errorf("TargetHttpProxies().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.TargetHttpProxy{} - if err := mock.TargetHttpProxies().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("TargetHttpProxies().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.TargetHttpProxies().Get(ctx, key); err != nil { - t.Errorf("TargetHttpProxies().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockTargetHttpProxies.Objects[*keyGA] = mock.MockTargetHttpProxies.Obj(&ga.TargetHttpProxy{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.TargetHttpProxies().List(ctx, filter.None) - if err != nil { - t.Errorf("TargetHttpProxies().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("TargetHttpProxies().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.TargetHttpProxies().Delete(ctx, keyGA); err != nil { - t.Errorf("TargetHttpProxies().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.TargetHttpProxies().Delete(ctx, keyGA); err == nil { - t.Errorf("TargetHttpProxies().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestTargetHttpsProxiesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.TargetHttpsProxies().Get(ctx, key); err == nil { - t.Errorf("TargetHttpsProxies().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.TargetHttpsProxy{} - if err := mock.TargetHttpsProxies().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("TargetHttpsProxies().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.TargetHttpsProxies().Get(ctx, key); err != nil { - t.Errorf("TargetHttpsProxies().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockTargetHttpsProxies.Objects[*keyGA] = mock.MockTargetHttpsProxies.Obj(&ga.TargetHttpsProxy{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.TargetHttpsProxies().List(ctx, filter.None) - if err != nil { - t.Errorf("TargetHttpsProxies().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("TargetHttpsProxies().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.TargetHttpsProxies().Delete(ctx, keyGA); err != nil { - t.Errorf("TargetHttpsProxies().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.TargetHttpsProxies().Delete(ctx, keyGA); err == nil { - t.Errorf("TargetHttpsProxies().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestTargetPoolsGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.RegionalKey("key-ga", "location") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.TargetPools().Get(ctx, key); err == nil { - t.Errorf("TargetPools().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.TargetPool{} - if err := mock.TargetPools().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("TargetPools().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.TargetPools().Get(ctx, key); err != nil { - t.Errorf("TargetPools().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockTargetPools.Objects[*keyGA] = mock.MockTargetPools.Obj(&ga.TargetPool{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.TargetPools().List(ctx, location, filter.None) - if err != nil { - t.Errorf("TargetPools().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("TargetPools().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.TargetPools().Delete(ctx, keyGA); err != nil { - t.Errorf("TargetPools().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.TargetPools().Delete(ctx, keyGA); err == nil { - t.Errorf("TargetPools().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestUrlMapsGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.UrlMaps().Get(ctx, key); err == nil { - t.Errorf("UrlMaps().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - { - obj := &ga.UrlMap{} - if err := mock.UrlMaps().Insert(ctx, keyGA, obj); err != nil { - t.Errorf("UrlMaps().Insert(%v, %v, %v) = %v; want nil", ctx, keyGA, obj, err) - } - } - - // Get across versions. - if obj, err := mock.UrlMaps().Get(ctx, key); err != nil { - t.Errorf("UrlMaps().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - - // List. - mock.MockUrlMaps.Objects[*keyGA] = mock.MockUrlMaps.Obj(&ga.UrlMap{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.UrlMaps().List(ctx, filter.None) - if err != nil { - t.Errorf("UrlMaps().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("UrlMaps().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - if err := mock.UrlMaps().Delete(ctx, keyGA); err != nil { - t.Errorf("UrlMaps().Delete(%v, %v) = %v; want nil", ctx, keyGA, err) - } - - // Delete not found. - if err := mock.UrlMaps().Delete(ctx, keyGA); err == nil { - t.Errorf("UrlMaps().Delete(%v, %v) = nil; want error", ctx, keyGA) - } -} - -func TestZonesGroup(t *testing.T) { - t.Parallel() - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - var key *meta.Key - keyGA := meta.GlobalKey("key-ga") - key = keyGA - // Ignore unused variables. - _, _, _ = ctx, mock, key - - // Get not found. - if _, err := mock.Zones().Get(ctx, key); err == nil { - t.Errorf("Zones().Get(%v, %v) = _, nil; want error", ctx, key) - } - - // Insert. - - // Get across versions. - - // List. - mock.MockZones.Objects[*keyGA] = mock.MockZones.Obj(&ga.Zone{Name: keyGA.Name}) - want := map[string]bool{ - "key-ga": true, - } - _ = want // ignore unused variables. - { - objs, err := mock.Zones().List(ctx, filter.None) - if err != nil { - t.Errorf("Zones().List(%v, %v, %v) = %v, %v; want _, nil", ctx, location, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("Zones().List(); got %+v, want %+v", got, want) - } - } - } - - // Delete across versions. - - // Delete not found. -} - -func TestResourceIDConversion(t *testing.T) { - t.Parallel() - - for _, id := range []*ResourceID{ - NewAddressesResourceID("some-project", "us-central1", "my-addresses-resource"), - NewBackendServicesResourceID("some-project", "my-backendServices-resource"), - NewDisksResourceID("some-project", "us-east1-b", "my-disks-resource"), - NewFirewallsResourceID("some-project", "my-firewalls-resource"), - NewForwardingRulesResourceID("some-project", "us-central1", "my-forwardingRules-resource"), - NewGlobalAddressesResourceID("some-project", "my-addresses-resource"), - NewGlobalForwardingRulesResourceID("some-project", "my-forwardingRules-resource"), - NewHealthChecksResourceID("some-project", "my-healthChecks-resource"), - NewHttpHealthChecksResourceID("some-project", "my-httpHealthChecks-resource"), - NewHttpsHealthChecksResourceID("some-project", "my-httpsHealthChecks-resource"), - NewInstanceGroupsResourceID("some-project", "us-east1-b", "my-instanceGroups-resource"), - NewInstancesResourceID("some-project", "us-east1-b", "my-instances-resource"), - NewNetworkEndpointGroupsResourceID("some-project", "us-east1-b", "my-networkEndpointGroups-resource"), - NewProjectsResourceID("my-projects-resource"), - NewRegionBackendServicesResourceID("some-project", "us-central1", "my-backendServices-resource"), - NewRegionDisksResourceID("some-project", "us-central1", "my-disks-resource"), - NewRegionsResourceID("some-project", "my-regions-resource"), - NewRoutesResourceID("some-project", "my-routes-resource"), - NewSecurityPoliciesResourceID("some-project", "my-securityPolicies-resource"), - NewSslCertificatesResourceID("some-project", "my-sslCertificates-resource"), - NewTargetHttpProxiesResourceID("some-project", "my-targetHttpProxies-resource"), - NewTargetHttpsProxiesResourceID("some-project", "my-targetHttpsProxies-resource"), - NewTargetPoolsResourceID("some-project", "us-central1", "my-targetPools-resource"), - NewUrlMapsResourceID("some-project", "my-urlMaps-resource"), - NewZonesResourceID("some-project", "my-zones-resource"), - } { - t.Run(id.Resource, func(t *testing.T) { - // Test conversion to and from full URL. - fullURL := id.SelfLink(meta.VersionGA) - parsedID, err := ParseResourceURL(fullURL) - if err != nil { - t.Errorf("ParseResourceURL(%s) = _, %v, want nil", fullURL, err) - } - if !reflect.DeepEqual(id, parsedID) { - t.Errorf("SelfLink(%+v) -> ParseResourceURL(%s) = %+v, want original ID", id, fullURL, parsedID) - } - - // Test conversion to and from relative resource name. - relativeName := id.RelativeResourceName() - parsedID, err = ParseResourceURL(relativeName) - if err != nil { - t.Errorf("ParseResourceURL(%s) = _, %v, want nil", relativeName, err) - } - if !reflect.DeepEqual(id, parsedID) { - t.Errorf("RelativeResourceName(%+v) -> ParseResourceURL(%s) = %+v, want original ID", id, relativeName, parsedID) - } - - // Do not test ResourcePath for projects. - if id.Resource == "projects" { - return - } - - // Test conversion to and from resource path. - resourcePath := id.ResourcePath() - parsedID, err = ParseResourceURL(resourcePath) - if err != nil { - t.Errorf("ParseResourceURL(%s) = _, %v, want nil", resourcePath, err) - } - id.ProjectID = "" - if !reflect.DeepEqual(id, parsedID) { - t.Errorf("ResourcePath(%+v) -> ParseResourceURL(%s) = %+v, want %+v", id, resourcePath, parsedID, id) - } - }) - } -} diff --git a/pkg/cloudprovider/providers/gce/cloud/meta/key_test.go b/pkg/cloudprovider/providers/gce/cloud/meta/key_test.go deleted file mode 100644 index e661bb8f76b2..000000000000 --- a/pkg/cloudprovider/providers/gce/cloud/meta/key_test.go +++ /dev/null @@ -1,76 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package meta - -import ( - "testing" -) - -func TestKeyType(t *testing.T) { - t.Parallel() - - for _, tc := range []struct { - key *Key - want KeyType - }{ - {GlobalKey("abc"), Global}, - {ZonalKey("abc", "us-central1-b"), Zonal}, - {RegionalKey("abc", "us-central1"), Regional}, - } { - if tc.key.Type() != tc.want { - t.Errorf("key.Type() == %v, want %v", tc.key.Type(), tc.want) - } - } -} - -func TestKeyString(t *testing.T) { - t.Parallel() - - for _, k := range []*Key{ - GlobalKey("abc"), - RegionalKey("abc", "us-central1"), - ZonalKey("abc", "us-central1-b"), - } { - if k.String() == "" { - t.Errorf(`k.String() = "", want non-empty`) - } - } -} - -func TestKeyValid(t *testing.T) { - t.Parallel() - - region := "us-central1" - zone := "us-central1-b" - - for _, tc := range []struct { - key *Key - want bool - }{ - {GlobalKey("abc"), true}, - {RegionalKey("abc", region), true}, - {ZonalKey("abc", zone), true}, - {RegionalKey("abc", "/invalid/"), false}, - {ZonalKey("abc", "/invalid/"), false}, - {&Key{"abc", zone, region}, false}, - } { - got := tc.key.Valid() - if got != tc.want { - t.Errorf("key %+v; key.Valid() = %v, want %v", tc.key, got, tc.want) - } - } -} diff --git a/pkg/cloudprovider/providers/gce/cloud/mock_test.go b/pkg/cloudprovider/providers/gce/cloud/mock_test.go deleted file mode 100644 index 4736f3a31cb1..000000000000 --- a/pkg/cloudprovider/providers/gce/cloud/mock_test.go +++ /dev/null @@ -1,151 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloud - -import ( - "context" - "reflect" - "testing" - - alpha "google.golang.org/api/compute/v0.alpha" - beta "google.golang.org/api/compute/v0.beta" - ga "google.golang.org/api/compute/v1" - - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" -) - -func TestMocks(t *testing.T) { - t.Parallel() - - // This test uses Addresses, but the logic that is generated is the same for - // other basic objects. - const region = "us-central1" - - ctx := context.Background() - pr := &SingleProjectRouter{"mock-project"} - mock := NewMockGCE(pr) - - keyAlpha := meta.RegionalKey("key-alpha", region) - keyBeta := meta.RegionalKey("key-beta", region) - keyGA := meta.RegionalKey("key-ga", region) - key := keyAlpha - - // Get not found. - if _, err := mock.AlphaAddresses().Get(ctx, key); err == nil { - t.Errorf("AlphaAddresses().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.BetaAddresses().Get(ctx, key); err == nil { - t.Errorf("BetaAddresses().Get(%v, %v) = _, nil; want error", ctx, key) - } - if _, err := mock.Addresses().Get(ctx, key); err == nil { - t.Errorf("Addresses().Get(%v, %v) = _, nil; want error", ctx, key) - } - // Insert. - { - obj := &alpha.Address{} - if err := mock.AlphaAddresses().Insert(ctx, keyAlpha, obj); err != nil { - t.Errorf("AlphaAddresses().Insert(%v, %v, %v) = %v; want nil", ctx, key, obj, err) - } - } - { - obj := &beta.Address{} - if err := mock.BetaAddresses().Insert(ctx, keyBeta, obj); err != nil { - t.Errorf("BetaAddresses().Insert(%v, %v, %v) = %v; want nil", ctx, key, obj, err) - } - } - { - obj := &ga.Address{} - if err := mock.Addresses().Insert(ctx, keyGA, &ga.Address{Name: "ga"}); err != nil { - t.Errorf("Addresses().Insert(%v, %v, %v) = %v; want nil", ctx, key, obj, err) - } - } - // Get across versions. - if obj, err := mock.AlphaAddresses().Get(ctx, key); err != nil { - t.Errorf("AlphaAddresses().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.BetaAddresses().Get(ctx, key); err != nil { - t.Errorf("BetaAddresses().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - if obj, err := mock.Addresses().Get(ctx, key); err != nil { - t.Errorf("Addresses().Get(%v, %v) = %v, %v; want nil", ctx, key, obj, err) - } - // List across versions. - want := map[string]bool{"key-alpha": true, "key-beta": true, "key-ga": true} - { - objs, err := mock.AlphaAddresses().List(ctx, region, filter.None) - if err != nil { - t.Errorf("AlphaAddresses().List(%v, %v, %v) = %v, %v; want _, nil", ctx, region, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("AlphaAddresses().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.BetaAddresses().List(ctx, region, filter.None) - if err != nil { - t.Errorf("BetaAddresses().List(%v, %v, %v) = %v, %v; want _, nil", ctx, region, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("AlphaAddresses().List(); got %+v, want %+v", got, want) - } - } - } - { - objs, err := mock.Addresses().List(ctx, region, filter.None) - if err != nil { - t.Errorf("Addresses().List(%v, %v, %v) = %v, %v; want _, nil", ctx, region, filter.None, objs, err) - } else { - got := map[string]bool{} - for _, obj := range objs { - got[obj.Name] = true - } - if !reflect.DeepEqual(got, want) { - t.Errorf("AlphaAddresses().List(); got %+v, want %+v", got, want) - } - } - } - // Delete across versions. - if err := mock.AlphaAddresses().Delete(ctx, keyAlpha); err != nil { - t.Errorf("AlphaAddresses().Delete(%v, %v) = %v; want nil", ctx, key, err) - } - if err := mock.BetaAddresses().Delete(ctx, keyBeta); err != nil { - t.Errorf("BetaAddresses().Delete(%v, %v) = %v; want nil", ctx, key, err) - } - if err := mock.Addresses().Delete(ctx, keyGA); err != nil { - t.Errorf("Addresses().Delete(%v, %v) = %v; want nil", ctx, key, err) - } - // Delete not found. - if err := mock.AlphaAddresses().Delete(ctx, keyAlpha); err == nil { - t.Errorf("AlphaAddresses().Delete(%v, %v) = nil; want error", ctx, key) - } - if err := mock.BetaAddresses().Delete(ctx, keyBeta); err == nil { - t.Errorf("BetaAddresses().Delete(%v, %v) = nil; want error", ctx, key) - } - if err := mock.Addresses().Delete(ctx, keyGA); err == nil { - t.Errorf("Addresses().Delete(%v, %v) = nil; want error", ctx, key) - } -} diff --git a/pkg/cloudprovider/providers/gce/cloud/ratelimit_test.go b/pkg/cloudprovider/providers/gce/cloud/ratelimit_test.go deleted file mode 100644 index 4bb4512e1337..000000000000 --- a/pkg/cloudprovider/providers/gce/cloud/ratelimit_test.go +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloud - -import ( - "context" - "testing" - "time" -) - -type FakeAcceptor struct{ accept func() } - -func (f *FakeAcceptor) Accept() { - f.accept() -} - -func TestAcceptRateLimiter(t *testing.T) { - fa := &FakeAcceptor{accept: func() {}} - arl := &AcceptRateLimiter{fa} - err := arl.Accept(context.Background(), nil) - if err != nil { - t.Errorf("AcceptRateLimiter.Accept() = %v, want nil", err) - } - - // Use context that has been cancelled and expect a context error returned. - ctxCancelled, cancelled := context.WithCancel(context.Background()) - cancelled() - // Verify context is cancelled by now. - <-ctxCancelled.Done() - - fa.accept = func() { time.Sleep(1 * time.Second) } - err = arl.Accept(ctxCancelled, nil) - if err != ctxCancelled.Err() { - t.Errorf("AcceptRateLimiter.Accept() = %v, want %v", err, ctxCancelled.Err()) - } -} - -func TestMinimumRateLimiter(t *testing.T) { - fa := &FakeAcceptor{accept: func() {}} - arl := &AcceptRateLimiter{fa} - var called bool - fa.accept = func() { called = true } - m := &MinimumRateLimiter{RateLimiter: arl, Minimum: 10 * time.Millisecond} - - err := m.Accept(context.Background(), nil) - if err != nil { - t.Errorf("MinimumRateLimiter.Accept = %v, want nil", err) - } - if !called { - t.Errorf("`called` = false, want true") - } - - // Use context that has been cancelled and expect a context error returned. - ctxCancelled, cancelled := context.WithCancel(context.Background()) - cancelled() - // Verify context is cancelled by now. - <-ctxCancelled.Done() - called = false - err = m.Accept(ctxCancelled, nil) - if err != ctxCancelled.Err() { - t.Errorf("AcceptRateLimiter.Accept() = %v, want %v", err, ctxCancelled.Err()) - } - if called { - t.Errorf("`called` = true, want false") - } -} diff --git a/pkg/cloudprovider/providers/gce/cloud/service_test.go b/pkg/cloudprovider/providers/gce/cloud/service_test.go deleted file mode 100644 index fc6fbb51d899..000000000000 --- a/pkg/cloudprovider/providers/gce/cloud/service_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloud - -import ( - "context" - "fmt" - "testing" -) - -func TestPollOperation(t *testing.T) { - const totalAttempts = 10 - var attempts int - fo := &fakeOperation{isDoneFunc: func(ctx context.Context) (bool, error) { - attempts++ - if attempts < totalAttempts { - return false, nil - } - return true, nil - }} - s := Service{RateLimiter: &NopRateLimiter{}} - // Check that pollOperation will retry the operation multiple times. - err := s.pollOperation(context.Background(), fo) - if err != nil { - t.Errorf("pollOperation() = %v, want nil", err) - } - if attempts != totalAttempts { - t.Errorf("`attempts` = %d, want %d", attempts, totalAttempts) - } - - // Check that the operation's error is returned. - fo.err = fmt.Errorf("test operation failed") - err = s.pollOperation(context.Background(), fo) - if err != fo.err { - t.Errorf("pollOperation() = %v, want %v", err, fo.err) - } - fo.err = nil - - fo.isDoneFunc = func(ctx context.Context) (bool, error) { - return false, nil - } - // Use context that has been cancelled and expect a context error returned. - ctxCancelled, cancelled := context.WithCancel(context.Background()) - cancelled() - // Verify context is cancelled by now. - <-ctxCancelled.Done() - // Check that pollOperation returns because the context is cancelled. - err = s.pollOperation(ctxCancelled, fo) - if err == nil { - t.Errorf("pollOperation() = nil, want: %v", ctxCancelled.Err()) - } -} - -type fakeOperation struct { - isDoneFunc func(ctx context.Context) (bool, error) - err error - rateKey *RateLimitKey -} - -func (f *fakeOperation) isDone(ctx context.Context) (bool, error) { - return f.isDoneFunc(ctx) -} - -func (f *fakeOperation) error() error { - return f.err -} - -func (f *fakeOperation) rateLimitKey() *RateLimitKey { - return f.rateKey -} diff --git a/pkg/cloudprovider/providers/gce/cloud/utils_test.go b/pkg/cloudprovider/providers/gce/cloud/utils_test.go deleted file mode 100644 index 0565638ccee5..000000000000 --- a/pkg/cloudprovider/providers/gce/cloud/utils_test.go +++ /dev/null @@ -1,291 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cloud - -import ( - "errors" - "testing" - - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" -) - -func TestEqualResourceID(t *testing.T) { - t.Parallel() - - for _, tc := range []struct { - a *ResourceID - b *ResourceID - }{ - { - a: &ResourceID{"some-gce-project", "projects", nil}, - b: &ResourceID{"some-gce-project", "projects", nil}, - }, - { - a: &ResourceID{"", "networks", meta.GlobalKey("my-net")}, - b: &ResourceID{"", "networks", meta.GlobalKey("my-net")}, - }, - { - a: &ResourceID{"some-gce-project", "projects", meta.GlobalKey("us-central1")}, - b: &ResourceID{"some-gce-project", "projects", meta.GlobalKey("us-central1")}, - }, - } { - if !tc.a.Equal(tc.b) { - t.Errorf("%v.Equal(%v) = false, want true", tc.a, tc.b) - } - } - - for _, tc := range []struct { - a *ResourceID - b *ResourceID - }{ - { - a: &ResourceID{"some-gce-project", "projects", nil}, - b: &ResourceID{"some-other-project", "projects", nil}, - }, - { - a: &ResourceID{"some-gce-project", "projects", nil}, - b: &ResourceID{"some-gce-project", "projects", meta.GlobalKey("us-central1")}, - }, - { - a: &ResourceID{"some-gce-project", "networks", meta.GlobalKey("us-central1")}, - b: &ResourceID{"some-gce-project", "projects", meta.GlobalKey("us-central1")}, - }, - } { - if tc.a.Equal(tc.b) { - t.Errorf("%v.Equal(%v) = true, want false", tc.a, tc.b) - } - } -} - -func TestParseResourceURL(t *testing.T) { - t.Parallel() - - for _, tc := range []struct { - in string - r *ResourceID - }{ - { - "https://www.googleapis.com/compute/v1/projects/some-gce-project", - &ResourceID{"some-gce-project", "projects", nil}, - }, - { - "https://www.googleapis.com/compute/v1/projects/some-gce-project/regions/us-central1", - &ResourceID{"some-gce-project", "regions", meta.GlobalKey("us-central1")}, - }, - { - "https://www.googleapis.com/compute/v1/projects/some-gce-project/zones/us-central1-b", - &ResourceID{"some-gce-project", "zones", meta.GlobalKey("us-central1-b")}, - }, - { - "https://www.googleapis.com/compute/v1/projects/some-gce-project/global/operations/operation-1513289952196-56054460af5a0-b1dae0c3-9bbf9dbf", - &ResourceID{"some-gce-project", "operations", meta.GlobalKey("operation-1513289952196-56054460af5a0-b1dae0c3-9bbf9dbf")}, - }, - { - "https://www.googleapis.com/compute/alpha/projects/some-gce-project/regions/us-central1/addresses/my-address", - &ResourceID{"some-gce-project", "addresses", meta.RegionalKey("my-address", "us-central1")}, - }, - { - "https://www.googleapis.com/compute/v1/projects/some-gce-project/zones/us-central1-c/instances/instance-1", - &ResourceID{"some-gce-project", "instances", meta.ZonalKey("instance-1", "us-central1-c")}, - }, - { - "http://localhost:3990/compute/beta/projects/some-gce-project/global/operations/operation-1513289952196-56054460af5a0-b1dae0c3-9bbf9dbf", - &ResourceID{"some-gce-project", "operations", meta.GlobalKey("operation-1513289952196-56054460af5a0-b1dae0c3-9bbf9dbf")}, - }, - { - "http://localhost:3990/compute/alpha/projects/some-gce-project/regions/dev-central1/addresses/my-address", - &ResourceID{"some-gce-project", "addresses", meta.RegionalKey("my-address", "dev-central1")}, - }, - { - "http://localhost:3990/compute/v1/projects/some-gce-project/zones/dev-central1-std/instances/instance-1", - &ResourceID{"some-gce-project", "instances", meta.ZonalKey("instance-1", "dev-central1-std")}, - }, - { - "projects/some-gce-project", - &ResourceID{"some-gce-project", "projects", nil}, - }, - { - "projects/some-gce-project/regions/us-central1", - &ResourceID{"some-gce-project", "regions", meta.GlobalKey("us-central1")}, - }, - { - "projects/some-gce-project/zones/us-central1-b", - &ResourceID{"some-gce-project", "zones", meta.GlobalKey("us-central1-b")}, - }, - { - "projects/some-gce-project/global/operations/operation-1513289952196-56054460af5a0-b1dae0c3-9bbf9dbf", - &ResourceID{"some-gce-project", "operations", meta.GlobalKey("operation-1513289952196-56054460af5a0-b1dae0c3-9bbf9dbf")}, - }, - { - "projects/some-gce-project/regions/us-central1/addresses/my-address", - &ResourceID{"some-gce-project", "addresses", meta.RegionalKey("my-address", "us-central1")}, - }, - { - "projects/some-gce-project/zones/us-central1-c/instances/instance-1", - &ResourceID{"some-gce-project", "instances", meta.ZonalKey("instance-1", "us-central1-c")}, - }, - { - "global/networks/my-network", - &ResourceID{"", "networks", meta.GlobalKey("my-network")}, - }, - { - "regions/us-central1/subnetworks/my-subnet", - &ResourceID{"", "subnetworks", meta.RegionalKey("my-subnet", "us-central1")}, - }, - { - "zones/us-central1-c/instances/instance-1", - &ResourceID{"", "instances", meta.ZonalKey("instance-1", "us-central1-c")}, - }, - } { - r, err := ParseResourceURL(tc.in) - if err != nil { - t.Errorf("ParseResourceURL(%q) = %+v, %v; want _, nil", tc.in, r, err) - continue - } - if !r.Equal(tc.r) { - t.Errorf("ParseResourceURL(%q) = %+v, nil; want %+v, nil", tc.in, r, tc.r) - } - } - // Malformed URLs. - for _, tc := range []string{ - "", - "/", - "/a", - "/a/b", - "/a/b/c", - "/a/b/c/d", - "/a/b/c/d/e", - "/a/b/c/d/e/f", - "https://www.googleapis.com/compute/v1/projects/some-gce-project/global", - "projects/some-gce-project/global", - "projects/some-gce-project/global/foo", - "projects/some-gce-project/global/foo/bar/baz", - "projects/some-gce-project/regions/us-central1/res", - "projects/some-gce-project/zones/us-central1-c/res", - "projects/some-gce-project/zones/us-central1-c/res/name/extra", - } { - r, err := ParseResourceURL(tc) - if err == nil { - t.Errorf("ParseResourceURL(%q) = %+v, %v, want _, error", tc, r, err) - } - } -} - -type A struct { - A, B, C string -} - -type B struct { - A, B, D string -} - -type E struct{} - -func (*E) MarshalJSON() ([]byte, error) { - return nil, errors.New("injected error") -} - -func TestCopyVisJSON(t *testing.T) { - t.Parallel() - - var b B - srcA := &A{"aa", "bb", "cc"} - err := copyViaJSON(&b, srcA) - if err != nil { - t.Errorf(`copyViaJSON(&b, %+v) = %v, want nil`, srcA, err) - } else { - expectedB := B{"aa", "bb", ""} - if b != expectedB { - t.Errorf("b == %+v, want %+v", b, expectedB) - } - } - - var a A - srcB := &B{"aaa", "bbb", "ccc"} - err = copyViaJSON(&a, srcB) - if err != nil { - t.Errorf(`copyViaJSON(&a, %+v) = %v, want nil`, srcB, err) - } else { - expectedA := A{"aaa", "bbb", ""} - if a != expectedA { - t.Errorf("a == %+v, want %+v", a, expectedA) - } - } - - if err := copyViaJSON(&a, &E{}); err == nil { - t.Errorf("copyViaJSON(&a, &E{}) = nil, want error") - } -} - -func TestSelfLink(t *testing.T) { - t.Parallel() - - for _, tc := range []struct { - ver meta.Version - project string - resource string - key *meta.Key - want string - }{ - { - meta.VersionAlpha, - "proj1", - "addresses", - meta.RegionalKey("key1", "us-central1"), - "https://www.googleapis.com/compute/alpha/projects/proj1/regions/us-central1/addresses/key1", - }, - { - meta.VersionBeta, - "proj3", - "disks", - meta.ZonalKey("key2", "us-central1-b"), - "https://www.googleapis.com/compute/beta/projects/proj3/zones/us-central1-b/disks/key2", - }, - { - meta.VersionGA, - "proj4", - "urlMaps", - meta.GlobalKey("key3"), - "https://www.googleapis.com/compute/v1/projects/proj4/global/urlMaps/key3", - }, - { - meta.VersionGA, - "proj4", - "projects", - nil, - "https://www.googleapis.com/compute/v1/projects/proj4", - }, - { - meta.VersionGA, - "proj4", - "regions", - meta.GlobalKey("us-central1"), - "https://www.googleapis.com/compute/v1/projects/proj4/regions/us-central1", - }, - { - meta.VersionGA, - "proj4", - "zones", - meta.GlobalKey("us-central1-a"), - "https://www.googleapis.com/compute/v1/projects/proj4/zones/us-central1-a", - }, - } { - if link := SelfLink(tc.ver, tc.project, tc.resource, tc.key); link != tc.want { - t.Errorf("SelfLink(%v, %q, %q, %v) = %v, want %q", tc.ver, tc.project, tc.resource, tc.key, link, tc.want) - } - } -} diff --git a/pkg/cloudprovider/providers/gce/gce.go b/pkg/cloudprovider/providers/gce/gce.go index 3e13930197e3..239e515efdf5 100644 --- a/pkg/cloudprovider/providers/gce/gce.go +++ b/pkg/cloudprovider/providers/gce/gce.go @@ -49,8 +49,8 @@ import ( "k8s.io/client-go/tools/record" "k8s.io/client-go/util/flowcontrol" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" cloudprovider "k8s.io/cloud-provider" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" "k8s.io/kubernetes/pkg/controller" kubeletapis "k8s.io/kubernetes/pkg/kubelet/apis" "k8s.io/kubernetes/pkg/version" diff --git a/pkg/cloudprovider/providers/gce/gce_address_manager.go b/pkg/cloudprovider/providers/gce/gce_address_manager.go index 51b9bc5e718f..7674e36df60d 100644 --- a/pkg/cloudprovider/providers/gce/gce_address_manager.go +++ b/pkg/cloudprovider/providers/gce/gce_address_manager.go @@ -22,8 +22,8 @@ import ( compute "google.golang.org/api/compute/v1" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "k8s.io/klog" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" ) type addressManager struct { diff --git a/pkg/cloudprovider/providers/gce/gce_address_manager_test.go b/pkg/cloudprovider/providers/gce/gce_address_manager_test.go index 3b7409c6c194..48a5fcedd961 100644 --- a/pkg/cloudprovider/providers/gce/gce_address_manager_test.go +++ b/pkg/cloudprovider/providers/gce/gce_address_manager_test.go @@ -19,10 +19,10 @@ package gce import ( "testing" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" compute "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" ) const testSvcName = "my-service" diff --git a/pkg/cloudprovider/providers/gce/gce_addresses.go b/pkg/cloudprovider/providers/gce/gce_addresses.go index 044258f1b4e3..08ef981157e4 100644 --- a/pkg/cloudprovider/providers/gce/gce_addresses.go +++ b/pkg/cloudprovider/providers/gce/gce_addresses.go @@ -25,9 +25,9 @@ import ( computebeta "google.golang.org/api/compute/v0.beta" compute "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) func newAddressMetricContext(request, region string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_annotations.go b/pkg/cloudprovider/providers/gce/gce_annotations.go index 39e632e0795f..a9cab8f366f4 100644 --- a/pkg/cloudprovider/providers/gce/gce_annotations.go +++ b/pkg/cloudprovider/providers/gce/gce_annotations.go @@ -21,8 +21,8 @@ import ( "k8s.io/klog" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "k8s.io/api/core/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" ) // LoadBalancerType defines a specific type for holding load balancer types (eg. Internal) diff --git a/pkg/cloudprovider/providers/gce/gce_annotations_test.go b/pkg/cloudprovider/providers/gce/gce_annotations_test.go index a3b2dfb86bfb..049b2bd545d4 100644 --- a/pkg/cloudprovider/providers/gce/gce_annotations_test.go +++ b/pkg/cloudprovider/providers/gce/gce_annotations_test.go @@ -19,9 +19,9 @@ package gce import ( "testing" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" "github.com/stretchr/testify/assert" ) diff --git a/pkg/cloudprovider/providers/gce/gce_backendservice.go b/pkg/cloudprovider/providers/gce/gce_backendservice.go index 6560c9126068..aa0f52d212be 100644 --- a/pkg/cloudprovider/providers/gce/gce_backendservice.go +++ b/pkg/cloudprovider/providers/gce/gce_backendservice.go @@ -21,9 +21,9 @@ import ( computebeta "google.golang.org/api/compute/v0.beta" compute "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) func newBackendServiceMetricContext(request, region string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_cert.go b/pkg/cloudprovider/providers/gce/gce_cert.go index 5153f067e8a1..8d9481945c02 100644 --- a/pkg/cloudprovider/providers/gce/gce_cert.go +++ b/pkg/cloudprovider/providers/gce/gce_cert.go @@ -19,9 +19,9 @@ package gce import ( compute "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) func newCertMetricContext(request string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_disks.go b/pkg/cloudprovider/providers/gce/gce_disks.go index 7e10e50c32bb..1c3bda8dd87e 100644 --- a/pkg/cloudprovider/providers/gce/gce_disks.go +++ b/pkg/cloudprovider/providers/gce/gce_disks.go @@ -33,12 +33,12 @@ import ( "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" compute "google.golang.org/api/compute/v1" "google.golang.org/api/googleapi" utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/klog" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" "k8s.io/kubernetes/pkg/features" ) diff --git a/pkg/cloudprovider/providers/gce/gce_fake.go b/pkg/cloudprovider/providers/gce/gce_fake.go index 73a724d74ae0..2394cb47333b 100644 --- a/pkg/cloudprovider/providers/gce/gce_fake.go +++ b/pkg/cloudprovider/providers/gce/gce_fake.go @@ -20,9 +20,9 @@ import ( "fmt" "net/http" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" compute "google.golang.org/api/compute/v1" "k8s.io/client-go/tools/cache" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" ) // TestClusterValues holds the config values for the fake/test gce cloud object. diff --git a/pkg/cloudprovider/providers/gce/gce_firewall.go b/pkg/cloudprovider/providers/gce/gce_firewall.go index 4aea49709562..d8b2ae749f30 100644 --- a/pkg/cloudprovider/providers/gce/gce_firewall.go +++ b/pkg/cloudprovider/providers/gce/gce_firewall.go @@ -19,8 +19,8 @@ package gce import ( compute "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) func newFirewallMetricContext(request string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_forwardingrule.go b/pkg/cloudprovider/providers/gce/gce_forwardingrule.go index 5689cfd32eaa..af12aa47c2b3 100644 --- a/pkg/cloudprovider/providers/gce/gce_forwardingrule.go +++ b/pkg/cloudprovider/providers/gce/gce_forwardingrule.go @@ -17,11 +17,11 @@ limitations under the License. package gce import ( + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" computealpha "google.golang.org/api/compute/v0.alpha" compute "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" ) func newForwardingRuleMetricContext(request, region string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_healthchecks.go b/pkg/cloudprovider/providers/gce/gce_healthchecks.go index d314376db121..a545b49f9e54 100644 --- a/pkg/cloudprovider/providers/gce/gce_healthchecks.go +++ b/pkg/cloudprovider/providers/gce/gce_healthchecks.go @@ -23,11 +23,11 @@ import ( computebeta "google.golang.org/api/compute/v0.beta" compute "google.golang.org/api/compute/v1" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "k8s.io/api/core/v1" utilversion "k8s.io/apimachinery/pkg/util/version" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" "k8s.io/kubernetes/pkg/master/ports" ) diff --git a/pkg/cloudprovider/providers/gce/gce_instancegroup.go b/pkg/cloudprovider/providers/gce/gce_instancegroup.go index edc5f093339b..8fbdf8ae55d5 100644 --- a/pkg/cloudprovider/providers/gce/gce_instancegroup.go +++ b/pkg/cloudprovider/providers/gce/gce_instancegroup.go @@ -19,9 +19,9 @@ package gce import ( compute "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) func newInstanceGroupMetricContext(request string, zone string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_instances.go b/pkg/cloudprovider/providers/gce/gce_instances.go index e8345abfae56..f93e0fff006d 100644 --- a/pkg/cloudprovider/providers/gce/gce_instances.go +++ b/pkg/cloudprovider/providers/gce/gce_instances.go @@ -29,14 +29,14 @@ import ( compute "google.golang.org/api/compute/v1" "k8s.io/klog" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/wait" cloudprovider "k8s.io/cloud-provider" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" kubeletapis "k8s.io/kubernetes/pkg/kubelet/apis" ) diff --git a/pkg/cloudprovider/providers/gce/gce_loadbalancer.go b/pkg/cloudprovider/providers/gce/gce_loadbalancer.go index 35a2c6952f4a..5c9dbb027ed8 100644 --- a/pkg/cloudprovider/providers/gce/gce_loadbalancer.go +++ b/pkg/cloudprovider/providers/gce/gce_loadbalancer.go @@ -26,9 +26,9 @@ import ( "k8s.io/klog" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "k8s.io/api/core/v1" cloudprovider "k8s.io/cloud-provider" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" netsets "k8s.io/kubernetes/pkg/util/net/sets" ) diff --git a/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go b/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go index 6b92e71ef77f..5606467586d8 100644 --- a/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go +++ b/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go @@ -23,12 +23,12 @@ import ( "strconv" "strings" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/sets" apiservice "k8s.io/kubernetes/pkg/api/v1/service" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" netsets "k8s.io/kubernetes/pkg/util/net/sets" computealpha "google.golang.org/api/compute/v0.alpha" diff --git a/pkg/cloudprovider/providers/gce/gce_loadbalancer_external_test.go b/pkg/cloudprovider/providers/gce/gce_loadbalancer_external_test.go index a238d888db8a..cc5c90cae627 100644 --- a/pkg/cloudprovider/providers/gce/gce_loadbalancer_external_test.go +++ b/pkg/cloudprovider/providers/gce/gce_loadbalancer_external_test.go @@ -27,13 +27,13 @@ import ( computealpha "google.golang.org/api/compute/v0.alpha" compute "google.golang.org/api/compute/v1" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock" ga "google.golang.org/api/compute/v1" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/mock" netsets "k8s.io/kubernetes/pkg/util/net/sets" ) diff --git a/pkg/cloudprovider/providers/gce/gce_loadbalancer_internal.go b/pkg/cloudprovider/providers/gce/gce_loadbalancer_internal.go index 87d1be64b49e..69bbd8530639 100644 --- a/pkg/cloudprovider/providers/gce/gce_loadbalancer_internal.go +++ b/pkg/cloudprovider/providers/gce/gce_loadbalancer_internal.go @@ -22,13 +22,13 @@ import ( "strconv" "strings" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" compute "google.golang.org/api/compute/v1" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/klog" v1_service "k8s.io/kubernetes/pkg/api/v1/service" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" ) const ( diff --git a/pkg/cloudprovider/providers/gce/gce_loadbalancer_internal_test.go b/pkg/cloudprovider/providers/gce/gce_loadbalancer_internal_test.go index 8b08ce378e80..6480b8b11ca0 100644 --- a/pkg/cloudprovider/providers/gce/gce_loadbalancer_internal_test.go +++ b/pkg/cloudprovider/providers/gce/gce_loadbalancer_internal_test.go @@ -25,13 +25,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock" compute "google.golang.org/api/compute/v1" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" v1_service "k8s.io/kubernetes/pkg/api/v1/service" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/mock" ) func createInternalLoadBalancer(gce *Cloud, svc *v1.Service, existingFwdRule *compute.ForwardingRule, nodeNames []string, clusterName, clusterID, zoneName string) (*v1.LoadBalancerStatus, error) { diff --git a/pkg/cloudprovider/providers/gce/gce_loadbalancer_naming.go b/pkg/cloudprovider/providers/gce/gce_loadbalancer_naming.go index 63b11eb11416..f7c2e0ce289b 100644 --- a/pkg/cloudprovider/providers/gce/gce_loadbalancer_naming.go +++ b/pkg/cloudprovider/providers/gce/gce_loadbalancer_naming.go @@ -22,9 +22,9 @@ import ( "fmt" "strings" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" ) // Internal Load Balancer diff --git a/pkg/cloudprovider/providers/gce/gce_loadbalancer_utils_test.go b/pkg/cloudprovider/providers/gce/gce_loadbalancer_utils_test.go index 7c133c7c9a22..7c460809ea8e 100644 --- a/pkg/cloudprovider/providers/gce/gce_loadbalancer_utils_test.go +++ b/pkg/cloudprovider/providers/gce/gce_loadbalancer_utils_test.go @@ -31,11 +31,11 @@ import ( "github.com/stretchr/testify/require" compute "google.golang.org/api/compute/v1" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/record" v1_service "k8s.io/kubernetes/pkg/api/v1/service" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" kubeletapis "k8s.io/kubernetes/pkg/kubelet/apis" ) diff --git a/pkg/cloudprovider/providers/gce/gce_networkendpointgroup.go b/pkg/cloudprovider/providers/gce/gce_networkendpointgroup.go index b7aa998cc34e..23503d2e007e 100644 --- a/pkg/cloudprovider/providers/gce/gce_networkendpointgroup.go +++ b/pkg/cloudprovider/providers/gce/gce_networkendpointgroup.go @@ -22,9 +22,9 @@ import ( computebeta "google.golang.org/api/compute/v0.beta" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) func newNetworkEndpointGroupMetricContext(request string, zone string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_routes.go b/pkg/cloudprovider/providers/gce/gce_routes.go index cc3cbfc53a04..62d9b0995f7c 100644 --- a/pkg/cloudprovider/providers/gce/gce_routes.go +++ b/pkg/cloudprovider/providers/gce/gce_routes.go @@ -26,10 +26,10 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/klog" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" cloudprovider "k8s.io/cloud-provider" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" ) func newRoutesMetricContext(request string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_securitypolicy.go b/pkg/cloudprovider/providers/gce/gce_securitypolicy.go index 3ce2f71fa540..bfb2cb96ebe2 100644 --- a/pkg/cloudprovider/providers/gce/gce_securitypolicy.go +++ b/pkg/cloudprovider/providers/gce/gce_securitypolicy.go @@ -19,9 +19,9 @@ package gce import ( computebeta "google.golang.org/api/compute/v0.beta" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) func newSecurityPolicyMetricContextWithVersion(request, version string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_targetpool.go b/pkg/cloudprovider/providers/gce/gce_targetpool.go index 65388b44980a..8f2f2cdff1b1 100644 --- a/pkg/cloudprovider/providers/gce/gce_targetpool.go +++ b/pkg/cloudprovider/providers/gce/gce_targetpool.go @@ -19,8 +19,8 @@ package gce import ( compute "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) func newTargetPoolMetricContext(request, region string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_targetproxy.go b/pkg/cloudprovider/providers/gce/gce_targetproxy.go index 64a4190628ea..1744e88e86a4 100644 --- a/pkg/cloudprovider/providers/gce/gce_targetproxy.go +++ b/pkg/cloudprovider/providers/gce/gce_targetproxy.go @@ -19,9 +19,9 @@ package gce import ( compute "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) func newTargetProxyMetricContext(request string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_urlmap.go b/pkg/cloudprovider/providers/gce/gce_urlmap.go index 7ee8b8213271..2ea04e4a2c40 100644 --- a/pkg/cloudprovider/providers/gce/gce_urlmap.go +++ b/pkg/cloudprovider/providers/gce/gce_urlmap.go @@ -19,9 +19,9 @@ package gce import ( compute "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) func newURLMapMetricContext(request string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/gce_util.go b/pkg/cloudprovider/providers/gce/gce_util.go index d66029a1df6c..328b9204f56a 100644 --- a/pkg/cloudprovider/providers/gce/gce_util.go +++ b/pkg/cloudprovider/providers/gce/gce_util.go @@ -26,12 +26,12 @@ import ( "strings" "sync" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/mock" "cloud.google.com/go/compute/metadata" compute "google.golang.org/api/compute/v1" diff --git a/pkg/cloudprovider/providers/gce/gce_zones.go b/pkg/cloudprovider/providers/gce/gce_zones.go index 3e4bb059bd64..0862d6dea9f6 100644 --- a/pkg/cloudprovider/providers/gce/gce_zones.go +++ b/pkg/cloudprovider/providers/gce/gce_zones.go @@ -22,10 +22,10 @@ import ( compute "google.golang.org/api/compute/v1" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" "k8s.io/apimachinery/pkg/types" cloudprovider "k8s.io/cloud-provider" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" ) func newZonesMetricContext(request, region string) *metricContext { diff --git a/pkg/cloudprovider/providers/gce/support.go b/pkg/cloudprovider/providers/gce/support.go index e6c471855fe6..9ad04439780d 100644 --- a/pkg/cloudprovider/providers/gce/support.go +++ b/pkg/cloudprovider/providers/gce/support.go @@ -19,8 +19,8 @@ package gce import ( "context" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) // gceProjectRouter sends requests to the appropriate project ID. diff --git a/pkg/controller/.import-restrictions b/pkg/controller/.import-restrictions index e7e62c875ede..c96ccd7dce0e 100644 --- a/pkg/controller/.import-restrictions +++ b/pkg/controller/.import-restrictions @@ -103,15 +103,16 @@ "github.com/cloudflare/cfssl/signer", "github.com/cloudflare/cfssl/signer/local", "github.com/davecgh/go-spew/spew", + "github.com/docker/distribution/reference", "github.com/evanphx/json-patch", "github.com/golang/groupcache/lru", + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud", + "github.com/google/gofuzz", "github.com/prometheus/client_golang/prometheus", "github.com/robfig/cron", "github.com/spf13/pflag", "github.com/stretchr/testify/assert", - "github.com/stretchr/testify/require", - "github.com/docker/distribution/reference", - "github.com/google/gofuzz" + "github.com/stretchr/testify/require" ] }, { diff --git a/test/e2e/network/BUILD b/test/e2e/network/BUILD index 663a2e5d6e9a..a1987d8644c5 100644 --- a/test/e2e/network/BUILD +++ b/test/e2e/network/BUILD @@ -34,7 +34,6 @@ go_library( "//pkg/apis/core:go_default_library", "//pkg/client/clientset_generated/internalclientset:go_default_library", "//pkg/cloudprovider/providers/gce:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud:go_default_library", "//pkg/controller/endpoint:go_default_library", "//pkg/kubelet/apis:go_default_library", "//pkg/master/ports:go_default_library", @@ -68,6 +67,7 @@ go_library( "//test/images/net/nat:go_default_library", "//test/utils:go_default_library", "//test/utils/image:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud:go_default_library", "//vendor/github.com/onsi/ginkgo:go_default_library", "//vendor/github.com/onsi/gomega:go_default_library", "//vendor/google.golang.org/api/compute/v0.alpha:go_default_library", diff --git a/test/e2e/network/network_tiers.go b/test/e2e/network/network_tiers.go index c102d52e3d30..459be2b2cf42 100644 --- a/test/e2e/network/network_tiers.go +++ b/test/e2e/network/network_tiers.go @@ -23,12 +23,12 @@ import ( computealpha "google.golang.org/api/compute/v0.alpha" - "k8s.io/api/core/v1" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/wait" clientset "k8s.io/client-go/kubernetes" cloudprovider "k8s.io/cloud-provider" gcecloud "k8s.io/kubernetes/pkg/cloudprovider/providers/gce" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" "k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework/providers/gce" diff --git a/test/integration/ipamperf/BUILD b/test/integration/ipamperf/BUILD index 52b0889b6a70..e26a4c4e076d 100644 --- a/test/integration/ipamperf/BUILD +++ b/test/integration/ipamperf/BUILD @@ -47,8 +47,6 @@ go_library( ], importpath = "k8s.io/kubernetes/test/integration/ipamperf", deps = [ - "//pkg/cloudprovider/providers/gce/cloud:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud/meta:go_default_library", "//pkg/controller/nodeipam/ipam:go_default_library", "//pkg/controller/nodeipam/ipam/cidrset:go_default_library", "//pkg/controller/util/node:go_default_library", @@ -63,6 +61,8 @@ go_library( "//staging/src/k8s.io/client-go/tools/cache:go_default_library", "//staging/src/k8s.io/cloud-provider:go_default_library", "//test/integration/util:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta:go_default_library", "//vendor/google.golang.org/api/compute/v0.beta:go_default_library", "//vendor/google.golang.org/api/compute/v1:go_default_library", "//vendor/k8s.io/klog:go_default_library", diff --git a/test/integration/ipamperf/cloud.go b/test/integration/ipamperf/cloud.go index c7cb10ec10fa..63c4681ee1bc 100644 --- a/test/integration/ipamperf/cloud.go +++ b/test/integration/ipamperf/cloud.go @@ -21,10 +21,10 @@ import ( "net" "sync" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" beta "google.golang.org/api/compute/v0.beta" ga "google.golang.org/api/compute/v1" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" "k8s.io/kubernetes/pkg/controller/nodeipam/ipam/cidrset" "k8s.io/kubernetes/test/integration/util" ) diff --git a/test/integration/util/BUILD b/test/integration/util/BUILD index e4cc884cc8b4..add700c8058b 100644 --- a/test/integration/util/BUILD +++ b/test/integration/util/BUILD @@ -15,7 +15,6 @@ go_library( deps = [ "//pkg/api/legacyscheme:go_default_library", "//pkg/cloudprovider/providers/gce:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud:go_default_library", "//pkg/scheduler:go_default_library", "//pkg/scheduler/api:go_default_library", "//pkg/scheduler/factory:go_default_library", @@ -25,6 +24,7 @@ go_library( "//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library", "//staging/src/k8s.io/client-go/tools/record:go_default_library", "//test/integration/framework:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud:go_default_library", "//vendor/golang.org/x/oauth2:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], diff --git a/test/integration/util/cloud.go b/test/integration/util/cloud.go index 0d018a4e96f9..c701a5410b3e 100644 --- a/test/integration/util/cloud.go +++ b/test/integration/util/cloud.go @@ -19,9 +19,9 @@ package util import ( "time" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "golang.org/x/oauth2" "k8s.io/kubernetes/pkg/cloudprovider/providers/gce" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" ) const ( diff --git a/vendor/BUILD b/vendor/BUILD index a7dbf6304c09..ce159d32a541 100644 --- a/vendor/BUILD +++ b/vendor/BUILD @@ -26,6 +26,7 @@ filegroup( "//vendor/github.com/Azure/go-autorest/logger:all-srcs", "//vendor/github.com/Azure/go-autorest/version:all-srcs", "//vendor/github.com/GeertJohan/go.rice:all-srcs", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud:all-srcs", "//vendor/github.com/JeffAshton/win_pdh:all-srcs", "//vendor/github.com/MakeNowJust/heredoc:all-srcs", "//vendor/github.com/Microsoft/go-winio:all-srcs", diff --git a/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/LICENSE b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/BUILD b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/BUILD new file mode 100644 index 000000000000..def5ab66418a --- /dev/null +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/BUILD @@ -0,0 +1,49 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "constants.go", + "context.go", + "doc.go", + "gce_projects.go", + "gen.go", + "op.go", + "project.go", + "ratelimit.go", + "service.go", + "utils.go", + ], + importmap = "k8s.io/kubernetes/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud", + importpath = "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud", + visibility = ["//visibility:public"], + deps = [ + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta:go_default_library", + "//vendor/google.golang.org/api/compute/v0.alpha:go_default_library", + "//vendor/google.golang.org/api/compute/v0.beta:go_default_library", + "//vendor/google.golang.org/api/compute/v1:go_default_library", + "//vendor/google.golang.org/api/googleapi:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter:all-srcs", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gen:all-srcs", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta:all-srcs", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock:all-srcs", + ], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/cloudprovider/providers/gce/cloud/constants.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/constants.go similarity index 94% rename from pkg/cloudprovider/providers/gce/cloud/constants.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/constants.go index 8d09c8bead8b..a1f433bb0af9 100644 --- a/pkg/cloudprovider/providers/gce/cloud/constants.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/constants.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/cloudprovider/providers/gce/cloud/context.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/context.go similarity index 90% rename from pkg/cloudprovider/providers/gce/cloud/context.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/context.go index 307a0a7a4799..d0b6b0a9143a 100644 --- a/pkg/cloudprovider/providers/gce/cloud/context.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/context.go @@ -1,11 +1,11 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/cloudprovider/providers/gce/cloud/doc.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/doc.go similarity index 98% rename from pkg/cloudprovider/providers/gce/cloud/doc.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/doc.go index 23b4ae838b80..1e52f6331ee8 100644 --- a/pkg/cloudprovider/providers/gce/cloud/doc.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/doc.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/cloudprovider/providers/gce/cloud/filter/BUILD b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter/BUILD similarity index 63% rename from pkg/cloudprovider/providers/gce/cloud/filter/BUILD rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter/BUILD index 0932666c50bd..22f1f88777a0 100644 --- a/pkg/cloudprovider/providers/gce/cloud/filter/BUILD +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter/BUILD @@ -1,19 +1,14 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = ["filter.go"], - importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter", + importmap = "k8s.io/kubernetes/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter", + importpath = "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter", visibility = ["//visibility:public"], deps = ["//vendor/k8s.io/klog:go_default_library"], ) -go_test( - name = "go_default_test", - srcs = ["filter_test.go"], - embed = [":go_default_library"], -) - filegroup( name = "package-srcs", srcs = glob(["**"]), diff --git a/pkg/cloudprovider/providers/gce/cloud/filter/filter.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter/filter.go similarity index 98% rename from pkg/cloudprovider/providers/gce/cloud/filter/filter.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter/filter.go index b65ab6391a7d..2a58b9c14be4 100644 --- a/pkg/cloudprovider/providers/gce/cloud/filter/filter.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter/filter.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/cloudprovider/providers/gce/cloud/gce_projects.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gce_projects.go similarity index 94% rename from pkg/cloudprovider/providers/gce/cloud/gce_projects.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gce_projects.go index c531881a94ac..d7f73fdca6d6 100644 --- a/pkg/cloudprovider/providers/gce/cloud/gce_projects.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gce_projects.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -21,9 +21,9 @@ import ( "fmt" "net/http" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" compute "google.golang.org/api/compute/v1" "google.golang.org/api/googleapi" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" ) // ProjectsOps is the manually implemented methods for the Projects service. diff --git a/pkg/cloudprovider/providers/gce/cloud/gen.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gen.go similarity index 99% rename from pkg/cloudprovider/providers/gce/cloud/gen.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gen.go index a3e7cd2c657a..9c34936ffe95 100644 --- a/pkg/cloudprovider/providers/gce/cloud/gen.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gen.go @@ -1,11 +1,11 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -28,8 +28,8 @@ import ( "google.golang.org/api/googleapi" "k8s.io/klog" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" alpha "google.golang.org/api/compute/v0.alpha" beta "google.golang.org/api/compute/v0.beta" @@ -54,8 +54,8 @@ type Cloud interface { AlphaForwardingRules() AlphaForwardingRules GlobalForwardingRules() GlobalForwardingRules HealthChecks() HealthChecks - BetaHealthChecks() BetaHealthChecks AlphaHealthChecks() AlphaHealthChecks + BetaHealthChecks() BetaHealthChecks HttpHealthChecks() HttpHealthChecks HttpsHealthChecks() HttpsHealthChecks InstanceGroups() InstanceGroups @@ -95,8 +95,8 @@ func NewGCE(s *Service) *GCE { gceAlphaForwardingRules: &GCEAlphaForwardingRules{s}, gceGlobalForwardingRules: &GCEGlobalForwardingRules{s}, gceHealthChecks: &GCEHealthChecks{s}, - gceBetaHealthChecks: &GCEBetaHealthChecks{s}, gceAlphaHealthChecks: &GCEAlphaHealthChecks{s}, + gceBetaHealthChecks: &GCEBetaHealthChecks{s}, gceHttpHealthChecks: &GCEHttpHealthChecks{s}, gceHttpsHealthChecks: &GCEHttpsHealthChecks{s}, gceInstanceGroups: &GCEInstanceGroups{s}, @@ -140,8 +140,8 @@ type GCE struct { gceAlphaForwardingRules *GCEAlphaForwardingRules gceGlobalForwardingRules *GCEGlobalForwardingRules gceHealthChecks *GCEHealthChecks - gceBetaHealthChecks *GCEBetaHealthChecks gceAlphaHealthChecks *GCEAlphaHealthChecks + gceBetaHealthChecks *GCEBetaHealthChecks gceHttpHealthChecks *GCEHttpHealthChecks gceHttpsHealthChecks *GCEHttpsHealthChecks gceInstanceGroups *GCEInstanceGroups @@ -242,16 +242,16 @@ func (gce *GCE) HealthChecks() HealthChecks { return gce.gceHealthChecks } -// BetaHealthChecks returns the interface for the beta HealthChecks. -func (gce *GCE) BetaHealthChecks() BetaHealthChecks { - return gce.gceBetaHealthChecks -} - // AlphaHealthChecks returns the interface for the alpha HealthChecks. func (gce *GCE) AlphaHealthChecks() AlphaHealthChecks { return gce.gceAlphaHealthChecks } +// BetaHealthChecks returns the interface for the beta HealthChecks. +func (gce *GCE) BetaHealthChecks() BetaHealthChecks { + return gce.gceBetaHealthChecks +} + // HttpHealthChecks returns the interface for the ga HttpHealthChecks. func (gce *GCE) HttpHealthChecks() HttpHealthChecks { return gce.gceHttpHealthChecks @@ -387,8 +387,8 @@ func NewMockGCE(projectRouter ProjectRouter) *MockGCE { MockAlphaForwardingRules: NewMockAlphaForwardingRules(projectRouter, mockForwardingRulesObjs), MockGlobalForwardingRules: NewMockGlobalForwardingRules(projectRouter, mockGlobalForwardingRulesObjs), MockHealthChecks: NewMockHealthChecks(projectRouter, mockHealthChecksObjs), - MockBetaHealthChecks: NewMockBetaHealthChecks(projectRouter, mockHealthChecksObjs), MockAlphaHealthChecks: NewMockAlphaHealthChecks(projectRouter, mockHealthChecksObjs), + MockBetaHealthChecks: NewMockBetaHealthChecks(projectRouter, mockHealthChecksObjs), MockHttpHealthChecks: NewMockHttpHealthChecks(projectRouter, mockHttpHealthChecksObjs), MockHttpsHealthChecks: NewMockHttpsHealthChecks(projectRouter, mockHttpsHealthChecksObjs), MockInstanceGroups: NewMockInstanceGroups(projectRouter, mockInstanceGroupsObjs), @@ -432,8 +432,8 @@ type MockGCE struct { MockAlphaForwardingRules *MockAlphaForwardingRules MockGlobalForwardingRules *MockGlobalForwardingRules MockHealthChecks *MockHealthChecks - MockBetaHealthChecks *MockBetaHealthChecks MockAlphaHealthChecks *MockAlphaHealthChecks + MockBetaHealthChecks *MockBetaHealthChecks MockHttpHealthChecks *MockHttpHealthChecks MockHttpsHealthChecks *MockHttpsHealthChecks MockInstanceGroups *MockInstanceGroups @@ -534,16 +534,16 @@ func (mock *MockGCE) HealthChecks() HealthChecks { return mock.MockHealthChecks } -// BetaHealthChecks returns the interface for the beta HealthChecks. -func (mock *MockGCE) BetaHealthChecks() BetaHealthChecks { - return mock.MockBetaHealthChecks -} - // AlphaHealthChecks returns the interface for the alpha HealthChecks. func (mock *MockGCE) AlphaHealthChecks() AlphaHealthChecks { return mock.MockAlphaHealthChecks } +// BetaHealthChecks returns the interface for the beta HealthChecks. +func (mock *MockGCE) BetaHealthChecks() BetaHealthChecks { + return mock.MockBetaHealthChecks +} + // HttpHealthChecks returns the interface for the ga HttpHealthChecks. func (mock *MockGCE) HttpHealthChecks() HttpHealthChecks { return mock.MockHttpHealthChecks @@ -7280,18 +7280,18 @@ func (g *GCEHealthChecks) Update(ctx context.Context, key *meta.Key, arg0 *ga.He return err } -// BetaHealthChecks is an interface that allows for mocking of HealthChecks. -type BetaHealthChecks interface { - Get(ctx context.Context, key *meta.Key) (*beta.HealthCheck, error) - List(ctx context.Context, fl *filter.F) ([]*beta.HealthCheck, error) - Insert(ctx context.Context, key *meta.Key, obj *beta.HealthCheck) error +// AlphaHealthChecks is an interface that allows for mocking of HealthChecks. +type AlphaHealthChecks interface { + Get(ctx context.Context, key *meta.Key) (*alpha.HealthCheck, error) + List(ctx context.Context, fl *filter.F) ([]*alpha.HealthCheck, error) + Insert(ctx context.Context, key *meta.Key, obj *alpha.HealthCheck) error Delete(ctx context.Context, key *meta.Key) error - Update(context.Context, *meta.Key, *beta.HealthCheck) error + Update(context.Context, *meta.Key, *alpha.HealthCheck) error } -// NewMockBetaHealthChecks returns a new mock for HealthChecks. -func NewMockBetaHealthChecks(pr ProjectRouter, objs map[meta.Key]*MockHealthChecksObj) *MockBetaHealthChecks { - mock := &MockBetaHealthChecks{ +// NewMockAlphaHealthChecks returns a new mock for HealthChecks. +func NewMockAlphaHealthChecks(pr ProjectRouter, objs map[meta.Key]*MockHealthChecksObj) *MockAlphaHealthChecks { + mock := &MockAlphaHealthChecks{ ProjectRouter: pr, Objects: objs, @@ -7302,8 +7302,8 @@ func NewMockBetaHealthChecks(pr ProjectRouter, objs map[meta.Key]*MockHealthChec return mock } -// MockBetaHealthChecks is the mock for HealthChecks. -type MockBetaHealthChecks struct { +// MockAlphaHealthChecks is the mock for HealthChecks. +type MockAlphaHealthChecks struct { Lock sync.Mutex ProjectRouter ProjectRouter @@ -7322,11 +7322,11 @@ type MockBetaHealthChecks struct { // order to add your own logic. Return (true, _, _) to prevent the normal // execution flow of the mock. Return (false, nil, nil) to continue with // normal mock behavior/ after the hook function executes. - GetHook func(ctx context.Context, key *meta.Key, m *MockBetaHealthChecks) (bool, *beta.HealthCheck, error) - ListHook func(ctx context.Context, fl *filter.F, m *MockBetaHealthChecks) (bool, []*beta.HealthCheck, error) - InsertHook func(ctx context.Context, key *meta.Key, obj *beta.HealthCheck, m *MockBetaHealthChecks) (bool, error) - DeleteHook func(ctx context.Context, key *meta.Key, m *MockBetaHealthChecks) (bool, error) - UpdateHook func(context.Context, *meta.Key, *beta.HealthCheck, *MockBetaHealthChecks) error + GetHook func(ctx context.Context, key *meta.Key, m *MockAlphaHealthChecks) (bool, *alpha.HealthCheck, error) + ListHook func(ctx context.Context, fl *filter.F, m *MockAlphaHealthChecks) (bool, []*alpha.HealthCheck, error) + InsertHook func(ctx context.Context, key *meta.Key, obj *alpha.HealthCheck, m *MockAlphaHealthChecks) (bool, error) + DeleteHook func(ctx context.Context, key *meta.Key, m *MockAlphaHealthChecks) (bool, error) + UpdateHook func(context.Context, *meta.Key, *alpha.HealthCheck, *MockAlphaHealthChecks) error // X is extra state that can be used as part of the mock. Generated code // will not use this field. @@ -7334,10 +7334,10 @@ type MockBetaHealthChecks struct { } // Get returns the object from the mock. -func (m *MockBetaHealthChecks) Get(ctx context.Context, key *meta.Key) (*beta.HealthCheck, error) { +func (m *MockAlphaHealthChecks) Get(ctx context.Context, key *meta.Key) (*alpha.HealthCheck, error) { if m.GetHook != nil { if intercept, obj, err := m.GetHook(ctx, key, m); intercept { - klog.V(5).Infof("MockBetaHealthChecks.Get(%v, %s) = %+v, %v", ctx, key, obj, err) + klog.V(5).Infof("MockAlphaHealthChecks.Get(%v, %s) = %+v, %v", ctx, key, obj, err) return obj, err } } @@ -7349,28 +7349,28 @@ func (m *MockBetaHealthChecks) Get(ctx context.Context, key *meta.Key) (*beta.He defer m.Lock.Unlock() if err, ok := m.GetError[*key]; ok { - klog.V(5).Infof("MockBetaHealthChecks.Get(%v, %s) = nil, %v", ctx, key, err) + klog.V(5).Infof("MockAlphaHealthChecks.Get(%v, %s) = nil, %v", ctx, key, err) return nil, err } if obj, ok := m.Objects[*key]; ok { - typedObj := obj.ToBeta() - klog.V(5).Infof("MockBetaHealthChecks.Get(%v, %s) = %+v, nil", ctx, key, typedObj) + typedObj := obj.ToAlpha() + klog.V(5).Infof("MockAlphaHealthChecks.Get(%v, %s) = %+v, nil", ctx, key, typedObj) return typedObj, nil } err := &googleapi.Error{ Code: http.StatusNotFound, - Message: fmt.Sprintf("MockBetaHealthChecks %v not found", key), + Message: fmt.Sprintf("MockAlphaHealthChecks %v not found", key), } - klog.V(5).Infof("MockBetaHealthChecks.Get(%v, %s) = nil, %v", ctx, key, err) + klog.V(5).Infof("MockAlphaHealthChecks.Get(%v, %s) = nil, %v", ctx, key, err) return nil, err } // List all of the objects in the mock. -func (m *MockBetaHealthChecks) List(ctx context.Context, fl *filter.F) ([]*beta.HealthCheck, error) { +func (m *MockAlphaHealthChecks) List(ctx context.Context, fl *filter.F) ([]*alpha.HealthCheck, error) { if m.ListHook != nil { if intercept, objs, err := m.ListHook(ctx, fl, m); intercept { - klog.V(5).Infof("MockBetaHealthChecks.List(%v, %v) = [%v items], %v", ctx, fl, len(objs), err) + klog.V(5).Infof("MockAlphaHealthChecks.List(%v, %v) = [%v items], %v", ctx, fl, len(objs), err) return objs, err } } @@ -7380,28 +7380,28 @@ func (m *MockBetaHealthChecks) List(ctx context.Context, fl *filter.F) ([]*beta. if m.ListError != nil { err := *m.ListError - klog.V(5).Infof("MockBetaHealthChecks.List(%v, %v) = nil, %v", ctx, fl, err) + klog.V(5).Infof("MockAlphaHealthChecks.List(%v, %v) = nil, %v", ctx, fl, err) return nil, *m.ListError } - var objs []*beta.HealthCheck + var objs []*alpha.HealthCheck for _, obj := range m.Objects { - if !fl.Match(obj.ToBeta()) { + if !fl.Match(obj.ToAlpha()) { continue } - objs = append(objs, obj.ToBeta()) + objs = append(objs, obj.ToAlpha()) } - klog.V(5).Infof("MockBetaHealthChecks.List(%v, %v) = [%v items], nil", ctx, fl, len(objs)) + klog.V(5).Infof("MockAlphaHealthChecks.List(%v, %v) = [%v items], nil", ctx, fl, len(objs)) return objs, nil } // Insert is a mock for inserting/creating a new object. -func (m *MockBetaHealthChecks) Insert(ctx context.Context, key *meta.Key, obj *beta.HealthCheck) error { +func (m *MockAlphaHealthChecks) Insert(ctx context.Context, key *meta.Key, obj *alpha.HealthCheck) error { if m.InsertHook != nil { if intercept, err := m.InsertHook(ctx, key, obj, m); intercept { - klog.V(5).Infof("MockBetaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) + klog.V(5).Infof("MockAlphaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) return err } } @@ -7413,32 +7413,32 @@ func (m *MockBetaHealthChecks) Insert(ctx context.Context, key *meta.Key, obj *b defer m.Lock.Unlock() if err, ok := m.InsertError[*key]; ok { - klog.V(5).Infof("MockBetaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) + klog.V(5).Infof("MockAlphaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) return err } if _, ok := m.Objects[*key]; ok { err := &googleapi.Error{ Code: http.StatusConflict, - Message: fmt.Sprintf("MockBetaHealthChecks %v exists", key), + Message: fmt.Sprintf("MockAlphaHealthChecks %v exists", key), } - klog.V(5).Infof("MockBetaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) + klog.V(5).Infof("MockAlphaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) return err } obj.Name = key.Name - projectID := m.ProjectRouter.ProjectID(ctx, "beta", "healthChecks") - obj.SelfLink = SelfLink(meta.VersionBeta, projectID, "healthChecks", key) + projectID := m.ProjectRouter.ProjectID(ctx, "alpha", "healthChecks") + obj.SelfLink = SelfLink(meta.VersionAlpha, projectID, "healthChecks", key) m.Objects[*key] = &MockHealthChecksObj{obj} - klog.V(5).Infof("MockBetaHealthChecks.Insert(%v, %v, %+v) = nil", ctx, key, obj) + klog.V(5).Infof("MockAlphaHealthChecks.Insert(%v, %v, %+v) = nil", ctx, key, obj) return nil } // Delete is a mock for deleting the object. -func (m *MockBetaHealthChecks) Delete(ctx context.Context, key *meta.Key) error { +func (m *MockAlphaHealthChecks) Delete(ctx context.Context, key *meta.Key) error { if m.DeleteHook != nil { if intercept, err := m.DeleteHook(ctx, key, m); intercept { - klog.V(5).Infof("MockBetaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) + klog.V(5).Infof("MockAlphaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) return err } } @@ -7450,223 +7450,223 @@ func (m *MockBetaHealthChecks) Delete(ctx context.Context, key *meta.Key) error defer m.Lock.Unlock() if err, ok := m.DeleteError[*key]; ok { - klog.V(5).Infof("MockBetaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) + klog.V(5).Infof("MockAlphaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) return err } if _, ok := m.Objects[*key]; !ok { err := &googleapi.Error{ Code: http.StatusNotFound, - Message: fmt.Sprintf("MockBetaHealthChecks %v not found", key), + Message: fmt.Sprintf("MockAlphaHealthChecks %v not found", key), } - klog.V(5).Infof("MockBetaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) + klog.V(5).Infof("MockAlphaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) return err } delete(m.Objects, *key) - klog.V(5).Infof("MockBetaHealthChecks.Delete(%v, %v) = nil", ctx, key) + klog.V(5).Infof("MockAlphaHealthChecks.Delete(%v, %v) = nil", ctx, key) return nil } // Obj wraps the object for use in the mock. -func (m *MockBetaHealthChecks) Obj(o *beta.HealthCheck) *MockHealthChecksObj { +func (m *MockAlphaHealthChecks) Obj(o *alpha.HealthCheck) *MockHealthChecksObj { return &MockHealthChecksObj{o} } // Update is a mock for the corresponding method. -func (m *MockBetaHealthChecks) Update(ctx context.Context, key *meta.Key, arg0 *beta.HealthCheck) error { +func (m *MockAlphaHealthChecks) Update(ctx context.Context, key *meta.Key, arg0 *alpha.HealthCheck) error { if m.UpdateHook != nil { return m.UpdateHook(ctx, key, arg0, m) } return nil } -// GCEBetaHealthChecks is a simplifying adapter for the GCE HealthChecks. -type GCEBetaHealthChecks struct { +// GCEAlphaHealthChecks is a simplifying adapter for the GCE HealthChecks. +type GCEAlphaHealthChecks struct { s *Service } // Get the HealthCheck named by key. -func (g *GCEBetaHealthChecks) Get(ctx context.Context, key *meta.Key) (*beta.HealthCheck, error) { - klog.V(5).Infof("GCEBetaHealthChecks.Get(%v, %v): called", ctx, key) +func (g *GCEAlphaHealthChecks) Get(ctx context.Context, key *meta.Key) (*alpha.HealthCheck, error) { + klog.V(5).Infof("GCEAlphaHealthChecks.Get(%v, %v): called", ctx, key) if !key.Valid() { - klog.V(2).Infof("GCEBetaHealthChecks.Get(%v, %v): key is invalid (%#v)", ctx, key, key) + klog.V(2).Infof("GCEAlphaHealthChecks.Get(%v, %v): key is invalid (%#v)", ctx, key, key) return nil, fmt.Errorf("invalid GCE key (%#v)", key) } - projectID := g.s.ProjectRouter.ProjectID(ctx, "beta", "HealthChecks") + projectID := g.s.ProjectRouter.ProjectID(ctx, "alpha", "HealthChecks") rk := &RateLimitKey{ ProjectID: projectID, Operation: "Get", - Version: meta.Version("beta"), + Version: meta.Version("alpha"), Service: "HealthChecks", } - klog.V(5).Infof("GCEBetaHealthChecks.Get(%v, %v): projectID = %v, rk = %+v", ctx, key, projectID, rk) + klog.V(5).Infof("GCEAlphaHealthChecks.Get(%v, %v): projectID = %v, rk = %+v", ctx, key, projectID, rk) if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("GCEBetaHealthChecks.Get(%v, %v): RateLimiter error: %v", ctx, key, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Get(%v, %v): RateLimiter error: %v", ctx, key, err) return nil, err } - call := g.s.Beta.HealthChecks.Get(projectID, key.Name) + call := g.s.Alpha.HealthChecks.Get(projectID, key.Name) call.Context(ctx) v, err := call.Do() - klog.V(4).Infof("GCEBetaHealthChecks.Get(%v, %v) = %+v, %v", ctx, key, v, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Get(%v, %v) = %+v, %v", ctx, key, v, err) return v, err } // List all HealthCheck objects. -func (g *GCEBetaHealthChecks) List(ctx context.Context, fl *filter.F) ([]*beta.HealthCheck, error) { - klog.V(5).Infof("GCEBetaHealthChecks.List(%v, %v) called", ctx, fl) - projectID := g.s.ProjectRouter.ProjectID(ctx, "beta", "HealthChecks") +func (g *GCEAlphaHealthChecks) List(ctx context.Context, fl *filter.F) ([]*alpha.HealthCheck, error) { + klog.V(5).Infof("GCEAlphaHealthChecks.List(%v, %v) called", ctx, fl) + projectID := g.s.ProjectRouter.ProjectID(ctx, "alpha", "HealthChecks") rk := &RateLimitKey{ ProjectID: projectID, Operation: "List", - Version: meta.Version("beta"), + Version: meta.Version("alpha"), Service: "HealthChecks", } if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { return nil, err } - klog.V(5).Infof("GCEBetaHealthChecks.List(%v, %v): projectID = %v, rk = %+v", ctx, fl, projectID, rk) - call := g.s.Beta.HealthChecks.List(projectID) + klog.V(5).Infof("GCEAlphaHealthChecks.List(%v, %v): projectID = %v, rk = %+v", ctx, fl, projectID, rk) + call := g.s.Alpha.HealthChecks.List(projectID) if fl != filter.None { call.Filter(fl.String()) } - var all []*beta.HealthCheck - f := func(l *beta.HealthCheckList) error { - klog.V(5).Infof("GCEBetaHealthChecks.List(%v, ..., %v): page %+v", ctx, fl, l) + var all []*alpha.HealthCheck + f := func(l *alpha.HealthCheckList) error { + klog.V(5).Infof("GCEAlphaHealthChecks.List(%v, ..., %v): page %+v", ctx, fl, l) all = append(all, l.Items...) return nil } if err := call.Pages(ctx, f); err != nil { - klog.V(4).Infof("GCEBetaHealthChecks.List(%v, ..., %v) = %v, %v", ctx, fl, nil, err) + klog.V(4).Infof("GCEAlphaHealthChecks.List(%v, ..., %v) = %v, %v", ctx, fl, nil, err) return nil, err } if klog.V(4) { - klog.V(4).Infof("GCEBetaHealthChecks.List(%v, ..., %v) = [%v items], %v", ctx, fl, len(all), nil) + klog.V(4).Infof("GCEAlphaHealthChecks.List(%v, ..., %v) = [%v items], %v", ctx, fl, len(all), nil) } else if klog.V(5) { var asStr []string for _, o := range all { asStr = append(asStr, fmt.Sprintf("%+v", o)) } - klog.V(5).Infof("GCEBetaHealthChecks.List(%v, ..., %v) = %v, %v", ctx, fl, asStr, nil) + klog.V(5).Infof("GCEAlphaHealthChecks.List(%v, ..., %v) = %v, %v", ctx, fl, asStr, nil) } return all, nil } // Insert HealthCheck with key of value obj. -func (g *GCEBetaHealthChecks) Insert(ctx context.Context, key *meta.Key, obj *beta.HealthCheck) error { - klog.V(5).Infof("GCEBetaHealthChecks.Insert(%v, %v, %+v): called", ctx, key, obj) +func (g *GCEAlphaHealthChecks) Insert(ctx context.Context, key *meta.Key, obj *alpha.HealthCheck) error { + klog.V(5).Infof("GCEAlphaHealthChecks.Insert(%v, %v, %+v): called", ctx, key, obj) if !key.Valid() { - klog.V(2).Infof("GCEBetaHealthChecks.Insert(%v, %v, ...): key is invalid (%#v)", ctx, key, key) + klog.V(2).Infof("GCEAlphaHealthChecks.Insert(%v, %v, ...): key is invalid (%#v)", ctx, key, key) return fmt.Errorf("invalid GCE key (%+v)", key) } - projectID := g.s.ProjectRouter.ProjectID(ctx, "beta", "HealthChecks") + projectID := g.s.ProjectRouter.ProjectID(ctx, "alpha", "HealthChecks") rk := &RateLimitKey{ ProjectID: projectID, Operation: "Insert", - Version: meta.Version("beta"), + Version: meta.Version("alpha"), Service: "HealthChecks", } - klog.V(5).Infof("GCEBetaHealthChecks.Insert(%v, %v, ...): projectID = %v, rk = %+v", ctx, key, projectID, rk) + klog.V(5).Infof("GCEAlphaHealthChecks.Insert(%v, %v, ...): projectID = %v, rk = %+v", ctx, key, projectID, rk) if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("GCEBetaHealthChecks.Insert(%v, %v, ...): RateLimiter error: %v", ctx, key, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Insert(%v, %v, ...): RateLimiter error: %v", ctx, key, err) return err } obj.Name = key.Name - call := g.s.Beta.HealthChecks.Insert(projectID, obj) + call := g.s.Alpha.HealthChecks.Insert(projectID, obj) call.Context(ctx) op, err := call.Do() if err != nil { - klog.V(4).Infof("GCEBetaHealthChecks.Insert(%v, %v, ...) = %+v", ctx, key, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Insert(%v, %v, ...) = %+v", ctx, key, err) return err } err = g.s.WaitForCompletion(ctx, op) - klog.V(4).Infof("GCEBetaHealthChecks.Insert(%v, %v, %+v) = %+v", ctx, key, obj, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Insert(%v, %v, %+v) = %+v", ctx, key, obj, err) return err } // Delete the HealthCheck referenced by key. -func (g *GCEBetaHealthChecks) Delete(ctx context.Context, key *meta.Key) error { - klog.V(5).Infof("GCEBetaHealthChecks.Delete(%v, %v): called", ctx, key) +func (g *GCEAlphaHealthChecks) Delete(ctx context.Context, key *meta.Key) error { + klog.V(5).Infof("GCEAlphaHealthChecks.Delete(%v, %v): called", ctx, key) if !key.Valid() { - klog.V(2).Infof("GCEBetaHealthChecks.Delete(%v, %v): key is invalid (%#v)", ctx, key, key) + klog.V(2).Infof("GCEAlphaHealthChecks.Delete(%v, %v): key is invalid (%#v)", ctx, key, key) return fmt.Errorf("invalid GCE key (%+v)", key) } - projectID := g.s.ProjectRouter.ProjectID(ctx, "beta", "HealthChecks") + projectID := g.s.ProjectRouter.ProjectID(ctx, "alpha", "HealthChecks") rk := &RateLimitKey{ ProjectID: projectID, Operation: "Delete", - Version: meta.Version("beta"), + Version: meta.Version("alpha"), Service: "HealthChecks", } - klog.V(5).Infof("GCEBetaHealthChecks.Delete(%v, %v): projectID = %v, rk = %+v", ctx, key, projectID, rk) + klog.V(5).Infof("GCEAlphaHealthChecks.Delete(%v, %v): projectID = %v, rk = %+v", ctx, key, projectID, rk) if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("GCEBetaHealthChecks.Delete(%v, %v): RateLimiter error: %v", ctx, key, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Delete(%v, %v): RateLimiter error: %v", ctx, key, err) return err } - call := g.s.Beta.HealthChecks.Delete(projectID, key.Name) + call := g.s.Alpha.HealthChecks.Delete(projectID, key.Name) call.Context(ctx) op, err := call.Do() if err != nil { - klog.V(4).Infof("GCEBetaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) return err } err = g.s.WaitForCompletion(ctx, op) - klog.V(4).Infof("GCEBetaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) return err } -// Update is a method on GCEBetaHealthChecks. -func (g *GCEBetaHealthChecks) Update(ctx context.Context, key *meta.Key, arg0 *beta.HealthCheck) error { - klog.V(5).Infof("GCEBetaHealthChecks.Update(%v, %v, ...): called", ctx, key) +// Update is a method on GCEAlphaHealthChecks. +func (g *GCEAlphaHealthChecks) Update(ctx context.Context, key *meta.Key, arg0 *alpha.HealthCheck) error { + klog.V(5).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...): called", ctx, key) if !key.Valid() { - klog.V(2).Infof("GCEBetaHealthChecks.Update(%v, %v, ...): key is invalid (%#v)", ctx, key, key) + klog.V(2).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...): key is invalid (%#v)", ctx, key, key) return fmt.Errorf("invalid GCE key (%+v)", key) } - projectID := g.s.ProjectRouter.ProjectID(ctx, "beta", "HealthChecks") + projectID := g.s.ProjectRouter.ProjectID(ctx, "alpha", "HealthChecks") rk := &RateLimitKey{ ProjectID: projectID, Operation: "Update", - Version: meta.Version("beta"), + Version: meta.Version("alpha"), Service: "HealthChecks", } - klog.V(5).Infof("GCEBetaHealthChecks.Update(%v, %v, ...): projectID = %v, rk = %+v", ctx, key, projectID, rk) + klog.V(5).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...): projectID = %v, rk = %+v", ctx, key, projectID, rk) if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("GCEBetaHealthChecks.Update(%v, %v, ...): RateLimiter error: %v", ctx, key, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...): RateLimiter error: %v", ctx, key, err) return err } - call := g.s.Beta.HealthChecks.Update(projectID, key.Name, arg0) + call := g.s.Alpha.HealthChecks.Update(projectID, key.Name, arg0) call.Context(ctx) op, err := call.Do() if err != nil { - klog.V(4).Infof("GCEBetaHealthChecks.Update(%v, %v, ...) = %+v", ctx, key, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...) = %+v", ctx, key, err) return err } err = g.s.WaitForCompletion(ctx, op) - klog.V(4).Infof("GCEBetaHealthChecks.Update(%v, %v, ...) = %+v", ctx, key, err) + klog.V(4).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...) = %+v", ctx, key, err) return err } -// AlphaHealthChecks is an interface that allows for mocking of HealthChecks. -type AlphaHealthChecks interface { - Get(ctx context.Context, key *meta.Key) (*alpha.HealthCheck, error) - List(ctx context.Context, fl *filter.F) ([]*alpha.HealthCheck, error) - Insert(ctx context.Context, key *meta.Key, obj *alpha.HealthCheck) error +// BetaHealthChecks is an interface that allows for mocking of HealthChecks. +type BetaHealthChecks interface { + Get(ctx context.Context, key *meta.Key) (*beta.HealthCheck, error) + List(ctx context.Context, fl *filter.F) ([]*beta.HealthCheck, error) + Insert(ctx context.Context, key *meta.Key, obj *beta.HealthCheck) error Delete(ctx context.Context, key *meta.Key) error - Update(context.Context, *meta.Key, *alpha.HealthCheck) error + Update(context.Context, *meta.Key, *beta.HealthCheck) error } -// NewMockAlphaHealthChecks returns a new mock for HealthChecks. -func NewMockAlphaHealthChecks(pr ProjectRouter, objs map[meta.Key]*MockHealthChecksObj) *MockAlphaHealthChecks { - mock := &MockAlphaHealthChecks{ +// NewMockBetaHealthChecks returns a new mock for HealthChecks. +func NewMockBetaHealthChecks(pr ProjectRouter, objs map[meta.Key]*MockHealthChecksObj) *MockBetaHealthChecks { + mock := &MockBetaHealthChecks{ ProjectRouter: pr, Objects: objs, @@ -7677,8 +7677,8 @@ func NewMockAlphaHealthChecks(pr ProjectRouter, objs map[meta.Key]*MockHealthChe return mock } -// MockAlphaHealthChecks is the mock for HealthChecks. -type MockAlphaHealthChecks struct { +// MockBetaHealthChecks is the mock for HealthChecks. +type MockBetaHealthChecks struct { Lock sync.Mutex ProjectRouter ProjectRouter @@ -7697,11 +7697,11 @@ type MockAlphaHealthChecks struct { // order to add your own logic. Return (true, _, _) to prevent the normal // execution flow of the mock. Return (false, nil, nil) to continue with // normal mock behavior/ after the hook function executes. - GetHook func(ctx context.Context, key *meta.Key, m *MockAlphaHealthChecks) (bool, *alpha.HealthCheck, error) - ListHook func(ctx context.Context, fl *filter.F, m *MockAlphaHealthChecks) (bool, []*alpha.HealthCheck, error) - InsertHook func(ctx context.Context, key *meta.Key, obj *alpha.HealthCheck, m *MockAlphaHealthChecks) (bool, error) - DeleteHook func(ctx context.Context, key *meta.Key, m *MockAlphaHealthChecks) (bool, error) - UpdateHook func(context.Context, *meta.Key, *alpha.HealthCheck, *MockAlphaHealthChecks) error + GetHook func(ctx context.Context, key *meta.Key, m *MockBetaHealthChecks) (bool, *beta.HealthCheck, error) + ListHook func(ctx context.Context, fl *filter.F, m *MockBetaHealthChecks) (bool, []*beta.HealthCheck, error) + InsertHook func(ctx context.Context, key *meta.Key, obj *beta.HealthCheck, m *MockBetaHealthChecks) (bool, error) + DeleteHook func(ctx context.Context, key *meta.Key, m *MockBetaHealthChecks) (bool, error) + UpdateHook func(context.Context, *meta.Key, *beta.HealthCheck, *MockBetaHealthChecks) error // X is extra state that can be used as part of the mock. Generated code // will not use this field. @@ -7709,10 +7709,10 @@ type MockAlphaHealthChecks struct { } // Get returns the object from the mock. -func (m *MockAlphaHealthChecks) Get(ctx context.Context, key *meta.Key) (*alpha.HealthCheck, error) { +func (m *MockBetaHealthChecks) Get(ctx context.Context, key *meta.Key) (*beta.HealthCheck, error) { if m.GetHook != nil { if intercept, obj, err := m.GetHook(ctx, key, m); intercept { - klog.V(5).Infof("MockAlphaHealthChecks.Get(%v, %s) = %+v, %v", ctx, key, obj, err) + klog.V(5).Infof("MockBetaHealthChecks.Get(%v, %s) = %+v, %v", ctx, key, obj, err) return obj, err } } @@ -7724,28 +7724,28 @@ func (m *MockAlphaHealthChecks) Get(ctx context.Context, key *meta.Key) (*alpha. defer m.Lock.Unlock() if err, ok := m.GetError[*key]; ok { - klog.V(5).Infof("MockAlphaHealthChecks.Get(%v, %s) = nil, %v", ctx, key, err) + klog.V(5).Infof("MockBetaHealthChecks.Get(%v, %s) = nil, %v", ctx, key, err) return nil, err } if obj, ok := m.Objects[*key]; ok { - typedObj := obj.ToAlpha() - klog.V(5).Infof("MockAlphaHealthChecks.Get(%v, %s) = %+v, nil", ctx, key, typedObj) + typedObj := obj.ToBeta() + klog.V(5).Infof("MockBetaHealthChecks.Get(%v, %s) = %+v, nil", ctx, key, typedObj) return typedObj, nil } err := &googleapi.Error{ Code: http.StatusNotFound, - Message: fmt.Sprintf("MockAlphaHealthChecks %v not found", key), + Message: fmt.Sprintf("MockBetaHealthChecks %v not found", key), } - klog.V(5).Infof("MockAlphaHealthChecks.Get(%v, %s) = nil, %v", ctx, key, err) + klog.V(5).Infof("MockBetaHealthChecks.Get(%v, %s) = nil, %v", ctx, key, err) return nil, err } // List all of the objects in the mock. -func (m *MockAlphaHealthChecks) List(ctx context.Context, fl *filter.F) ([]*alpha.HealthCheck, error) { +func (m *MockBetaHealthChecks) List(ctx context.Context, fl *filter.F) ([]*beta.HealthCheck, error) { if m.ListHook != nil { if intercept, objs, err := m.ListHook(ctx, fl, m); intercept { - klog.V(5).Infof("MockAlphaHealthChecks.List(%v, %v) = [%v items], %v", ctx, fl, len(objs), err) + klog.V(5).Infof("MockBetaHealthChecks.List(%v, %v) = [%v items], %v", ctx, fl, len(objs), err) return objs, err } } @@ -7755,28 +7755,28 @@ func (m *MockAlphaHealthChecks) List(ctx context.Context, fl *filter.F) ([]*alph if m.ListError != nil { err := *m.ListError - klog.V(5).Infof("MockAlphaHealthChecks.List(%v, %v) = nil, %v", ctx, fl, err) + klog.V(5).Infof("MockBetaHealthChecks.List(%v, %v) = nil, %v", ctx, fl, err) return nil, *m.ListError } - var objs []*alpha.HealthCheck + var objs []*beta.HealthCheck for _, obj := range m.Objects { - if !fl.Match(obj.ToAlpha()) { + if !fl.Match(obj.ToBeta()) { continue } - objs = append(objs, obj.ToAlpha()) + objs = append(objs, obj.ToBeta()) } - klog.V(5).Infof("MockAlphaHealthChecks.List(%v, %v) = [%v items], nil", ctx, fl, len(objs)) + klog.V(5).Infof("MockBetaHealthChecks.List(%v, %v) = [%v items], nil", ctx, fl, len(objs)) return objs, nil } // Insert is a mock for inserting/creating a new object. -func (m *MockAlphaHealthChecks) Insert(ctx context.Context, key *meta.Key, obj *alpha.HealthCheck) error { +func (m *MockBetaHealthChecks) Insert(ctx context.Context, key *meta.Key, obj *beta.HealthCheck) error { if m.InsertHook != nil { if intercept, err := m.InsertHook(ctx, key, obj, m); intercept { - klog.V(5).Infof("MockAlphaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) + klog.V(5).Infof("MockBetaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) return err } } @@ -7788,32 +7788,32 @@ func (m *MockAlphaHealthChecks) Insert(ctx context.Context, key *meta.Key, obj * defer m.Lock.Unlock() if err, ok := m.InsertError[*key]; ok { - klog.V(5).Infof("MockAlphaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) + klog.V(5).Infof("MockBetaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) return err } if _, ok := m.Objects[*key]; ok { err := &googleapi.Error{ Code: http.StatusConflict, - Message: fmt.Sprintf("MockAlphaHealthChecks %v exists", key), + Message: fmt.Sprintf("MockBetaHealthChecks %v exists", key), } - klog.V(5).Infof("MockAlphaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) + klog.V(5).Infof("MockBetaHealthChecks.Insert(%v, %v, %+v) = %v", ctx, key, obj, err) return err } obj.Name = key.Name - projectID := m.ProjectRouter.ProjectID(ctx, "alpha", "healthChecks") - obj.SelfLink = SelfLink(meta.VersionAlpha, projectID, "healthChecks", key) + projectID := m.ProjectRouter.ProjectID(ctx, "beta", "healthChecks") + obj.SelfLink = SelfLink(meta.VersionBeta, projectID, "healthChecks", key) m.Objects[*key] = &MockHealthChecksObj{obj} - klog.V(5).Infof("MockAlphaHealthChecks.Insert(%v, %v, %+v) = nil", ctx, key, obj) + klog.V(5).Infof("MockBetaHealthChecks.Insert(%v, %v, %+v) = nil", ctx, key, obj) return nil } // Delete is a mock for deleting the object. -func (m *MockAlphaHealthChecks) Delete(ctx context.Context, key *meta.Key) error { +func (m *MockBetaHealthChecks) Delete(ctx context.Context, key *meta.Key) error { if m.DeleteHook != nil { if intercept, err := m.DeleteHook(ctx, key, m); intercept { - klog.V(5).Infof("MockAlphaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) + klog.V(5).Infof("MockBetaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) return err } } @@ -7825,208 +7825,208 @@ func (m *MockAlphaHealthChecks) Delete(ctx context.Context, key *meta.Key) error defer m.Lock.Unlock() if err, ok := m.DeleteError[*key]; ok { - klog.V(5).Infof("MockAlphaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) + klog.V(5).Infof("MockBetaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) return err } if _, ok := m.Objects[*key]; !ok { err := &googleapi.Error{ Code: http.StatusNotFound, - Message: fmt.Sprintf("MockAlphaHealthChecks %v not found", key), + Message: fmt.Sprintf("MockBetaHealthChecks %v not found", key), } - klog.V(5).Infof("MockAlphaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) + klog.V(5).Infof("MockBetaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) return err } delete(m.Objects, *key) - klog.V(5).Infof("MockAlphaHealthChecks.Delete(%v, %v) = nil", ctx, key) + klog.V(5).Infof("MockBetaHealthChecks.Delete(%v, %v) = nil", ctx, key) return nil } // Obj wraps the object for use in the mock. -func (m *MockAlphaHealthChecks) Obj(o *alpha.HealthCheck) *MockHealthChecksObj { +func (m *MockBetaHealthChecks) Obj(o *beta.HealthCheck) *MockHealthChecksObj { return &MockHealthChecksObj{o} } // Update is a mock for the corresponding method. -func (m *MockAlphaHealthChecks) Update(ctx context.Context, key *meta.Key, arg0 *alpha.HealthCheck) error { +func (m *MockBetaHealthChecks) Update(ctx context.Context, key *meta.Key, arg0 *beta.HealthCheck) error { if m.UpdateHook != nil { return m.UpdateHook(ctx, key, arg0, m) } return nil } -// GCEAlphaHealthChecks is a simplifying adapter for the GCE HealthChecks. -type GCEAlphaHealthChecks struct { +// GCEBetaHealthChecks is a simplifying adapter for the GCE HealthChecks. +type GCEBetaHealthChecks struct { s *Service } // Get the HealthCheck named by key. -func (g *GCEAlphaHealthChecks) Get(ctx context.Context, key *meta.Key) (*alpha.HealthCheck, error) { - klog.V(5).Infof("GCEAlphaHealthChecks.Get(%v, %v): called", ctx, key) +func (g *GCEBetaHealthChecks) Get(ctx context.Context, key *meta.Key) (*beta.HealthCheck, error) { + klog.V(5).Infof("GCEBetaHealthChecks.Get(%v, %v): called", ctx, key) if !key.Valid() { - klog.V(2).Infof("GCEAlphaHealthChecks.Get(%v, %v): key is invalid (%#v)", ctx, key, key) + klog.V(2).Infof("GCEBetaHealthChecks.Get(%v, %v): key is invalid (%#v)", ctx, key, key) return nil, fmt.Errorf("invalid GCE key (%#v)", key) } - projectID := g.s.ProjectRouter.ProjectID(ctx, "alpha", "HealthChecks") + projectID := g.s.ProjectRouter.ProjectID(ctx, "beta", "HealthChecks") rk := &RateLimitKey{ ProjectID: projectID, Operation: "Get", - Version: meta.Version("alpha"), + Version: meta.Version("beta"), Service: "HealthChecks", } - klog.V(5).Infof("GCEAlphaHealthChecks.Get(%v, %v): projectID = %v, rk = %+v", ctx, key, projectID, rk) + klog.V(5).Infof("GCEBetaHealthChecks.Get(%v, %v): projectID = %v, rk = %+v", ctx, key, projectID, rk) if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("GCEAlphaHealthChecks.Get(%v, %v): RateLimiter error: %v", ctx, key, err) + klog.V(4).Infof("GCEBetaHealthChecks.Get(%v, %v): RateLimiter error: %v", ctx, key, err) return nil, err } - call := g.s.Alpha.HealthChecks.Get(projectID, key.Name) + call := g.s.Beta.HealthChecks.Get(projectID, key.Name) call.Context(ctx) v, err := call.Do() - klog.V(4).Infof("GCEAlphaHealthChecks.Get(%v, %v) = %+v, %v", ctx, key, v, err) + klog.V(4).Infof("GCEBetaHealthChecks.Get(%v, %v) = %+v, %v", ctx, key, v, err) return v, err } // List all HealthCheck objects. -func (g *GCEAlphaHealthChecks) List(ctx context.Context, fl *filter.F) ([]*alpha.HealthCheck, error) { - klog.V(5).Infof("GCEAlphaHealthChecks.List(%v, %v) called", ctx, fl) - projectID := g.s.ProjectRouter.ProjectID(ctx, "alpha", "HealthChecks") +func (g *GCEBetaHealthChecks) List(ctx context.Context, fl *filter.F) ([]*beta.HealthCheck, error) { + klog.V(5).Infof("GCEBetaHealthChecks.List(%v, %v) called", ctx, fl) + projectID := g.s.ProjectRouter.ProjectID(ctx, "beta", "HealthChecks") rk := &RateLimitKey{ ProjectID: projectID, Operation: "List", - Version: meta.Version("alpha"), + Version: meta.Version("beta"), Service: "HealthChecks", } if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { return nil, err } - klog.V(5).Infof("GCEAlphaHealthChecks.List(%v, %v): projectID = %v, rk = %+v", ctx, fl, projectID, rk) - call := g.s.Alpha.HealthChecks.List(projectID) + klog.V(5).Infof("GCEBetaHealthChecks.List(%v, %v): projectID = %v, rk = %+v", ctx, fl, projectID, rk) + call := g.s.Beta.HealthChecks.List(projectID) if fl != filter.None { call.Filter(fl.String()) } - var all []*alpha.HealthCheck - f := func(l *alpha.HealthCheckList) error { - klog.V(5).Infof("GCEAlphaHealthChecks.List(%v, ..., %v): page %+v", ctx, fl, l) + var all []*beta.HealthCheck + f := func(l *beta.HealthCheckList) error { + klog.V(5).Infof("GCEBetaHealthChecks.List(%v, ..., %v): page %+v", ctx, fl, l) all = append(all, l.Items...) return nil } if err := call.Pages(ctx, f); err != nil { - klog.V(4).Infof("GCEAlphaHealthChecks.List(%v, ..., %v) = %v, %v", ctx, fl, nil, err) + klog.V(4).Infof("GCEBetaHealthChecks.List(%v, ..., %v) = %v, %v", ctx, fl, nil, err) return nil, err } if klog.V(4) { - klog.V(4).Infof("GCEAlphaHealthChecks.List(%v, ..., %v) = [%v items], %v", ctx, fl, len(all), nil) + klog.V(4).Infof("GCEBetaHealthChecks.List(%v, ..., %v) = [%v items], %v", ctx, fl, len(all), nil) } else if klog.V(5) { var asStr []string for _, o := range all { asStr = append(asStr, fmt.Sprintf("%+v", o)) } - klog.V(5).Infof("GCEAlphaHealthChecks.List(%v, ..., %v) = %v, %v", ctx, fl, asStr, nil) + klog.V(5).Infof("GCEBetaHealthChecks.List(%v, ..., %v) = %v, %v", ctx, fl, asStr, nil) } return all, nil } // Insert HealthCheck with key of value obj. -func (g *GCEAlphaHealthChecks) Insert(ctx context.Context, key *meta.Key, obj *alpha.HealthCheck) error { - klog.V(5).Infof("GCEAlphaHealthChecks.Insert(%v, %v, %+v): called", ctx, key, obj) +func (g *GCEBetaHealthChecks) Insert(ctx context.Context, key *meta.Key, obj *beta.HealthCheck) error { + klog.V(5).Infof("GCEBetaHealthChecks.Insert(%v, %v, %+v): called", ctx, key, obj) if !key.Valid() { - klog.V(2).Infof("GCEAlphaHealthChecks.Insert(%v, %v, ...): key is invalid (%#v)", ctx, key, key) + klog.V(2).Infof("GCEBetaHealthChecks.Insert(%v, %v, ...): key is invalid (%#v)", ctx, key, key) return fmt.Errorf("invalid GCE key (%+v)", key) } - projectID := g.s.ProjectRouter.ProjectID(ctx, "alpha", "HealthChecks") + projectID := g.s.ProjectRouter.ProjectID(ctx, "beta", "HealthChecks") rk := &RateLimitKey{ ProjectID: projectID, Operation: "Insert", - Version: meta.Version("alpha"), + Version: meta.Version("beta"), Service: "HealthChecks", } - klog.V(5).Infof("GCEAlphaHealthChecks.Insert(%v, %v, ...): projectID = %v, rk = %+v", ctx, key, projectID, rk) + klog.V(5).Infof("GCEBetaHealthChecks.Insert(%v, %v, ...): projectID = %v, rk = %+v", ctx, key, projectID, rk) if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("GCEAlphaHealthChecks.Insert(%v, %v, ...): RateLimiter error: %v", ctx, key, err) + klog.V(4).Infof("GCEBetaHealthChecks.Insert(%v, %v, ...): RateLimiter error: %v", ctx, key, err) return err } obj.Name = key.Name - call := g.s.Alpha.HealthChecks.Insert(projectID, obj) + call := g.s.Beta.HealthChecks.Insert(projectID, obj) call.Context(ctx) op, err := call.Do() if err != nil { - klog.V(4).Infof("GCEAlphaHealthChecks.Insert(%v, %v, ...) = %+v", ctx, key, err) + klog.V(4).Infof("GCEBetaHealthChecks.Insert(%v, %v, ...) = %+v", ctx, key, err) return err } err = g.s.WaitForCompletion(ctx, op) - klog.V(4).Infof("GCEAlphaHealthChecks.Insert(%v, %v, %+v) = %+v", ctx, key, obj, err) + klog.V(4).Infof("GCEBetaHealthChecks.Insert(%v, %v, %+v) = %+v", ctx, key, obj, err) return err } // Delete the HealthCheck referenced by key. -func (g *GCEAlphaHealthChecks) Delete(ctx context.Context, key *meta.Key) error { - klog.V(5).Infof("GCEAlphaHealthChecks.Delete(%v, %v): called", ctx, key) +func (g *GCEBetaHealthChecks) Delete(ctx context.Context, key *meta.Key) error { + klog.V(5).Infof("GCEBetaHealthChecks.Delete(%v, %v): called", ctx, key) if !key.Valid() { - klog.V(2).Infof("GCEAlphaHealthChecks.Delete(%v, %v): key is invalid (%#v)", ctx, key, key) + klog.V(2).Infof("GCEBetaHealthChecks.Delete(%v, %v): key is invalid (%#v)", ctx, key, key) return fmt.Errorf("invalid GCE key (%+v)", key) } - projectID := g.s.ProjectRouter.ProjectID(ctx, "alpha", "HealthChecks") + projectID := g.s.ProjectRouter.ProjectID(ctx, "beta", "HealthChecks") rk := &RateLimitKey{ ProjectID: projectID, Operation: "Delete", - Version: meta.Version("alpha"), + Version: meta.Version("beta"), Service: "HealthChecks", } - klog.V(5).Infof("GCEAlphaHealthChecks.Delete(%v, %v): projectID = %v, rk = %+v", ctx, key, projectID, rk) + klog.V(5).Infof("GCEBetaHealthChecks.Delete(%v, %v): projectID = %v, rk = %+v", ctx, key, projectID, rk) if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("GCEAlphaHealthChecks.Delete(%v, %v): RateLimiter error: %v", ctx, key, err) + klog.V(4).Infof("GCEBetaHealthChecks.Delete(%v, %v): RateLimiter error: %v", ctx, key, err) return err } - call := g.s.Alpha.HealthChecks.Delete(projectID, key.Name) + call := g.s.Beta.HealthChecks.Delete(projectID, key.Name) call.Context(ctx) op, err := call.Do() if err != nil { - klog.V(4).Infof("GCEAlphaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) + klog.V(4).Infof("GCEBetaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) return err } err = g.s.WaitForCompletion(ctx, op) - klog.V(4).Infof("GCEAlphaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) + klog.V(4).Infof("GCEBetaHealthChecks.Delete(%v, %v) = %v", ctx, key, err) return err } -// Update is a method on GCEAlphaHealthChecks. -func (g *GCEAlphaHealthChecks) Update(ctx context.Context, key *meta.Key, arg0 *alpha.HealthCheck) error { - klog.V(5).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...): called", ctx, key) +// Update is a method on GCEBetaHealthChecks. +func (g *GCEBetaHealthChecks) Update(ctx context.Context, key *meta.Key, arg0 *beta.HealthCheck) error { + klog.V(5).Infof("GCEBetaHealthChecks.Update(%v, %v, ...): called", ctx, key) if !key.Valid() { - klog.V(2).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...): key is invalid (%#v)", ctx, key, key) + klog.V(2).Infof("GCEBetaHealthChecks.Update(%v, %v, ...): key is invalid (%#v)", ctx, key, key) return fmt.Errorf("invalid GCE key (%+v)", key) } - projectID := g.s.ProjectRouter.ProjectID(ctx, "alpha", "HealthChecks") + projectID := g.s.ProjectRouter.ProjectID(ctx, "beta", "HealthChecks") rk := &RateLimitKey{ ProjectID: projectID, Operation: "Update", - Version: meta.Version("alpha"), + Version: meta.Version("beta"), Service: "HealthChecks", } - klog.V(5).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...): projectID = %v, rk = %+v", ctx, key, projectID, rk) + klog.V(5).Infof("GCEBetaHealthChecks.Update(%v, %v, ...): projectID = %v, rk = %+v", ctx, key, projectID, rk) if err := g.s.RateLimiter.Accept(ctx, rk); err != nil { - klog.V(4).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...): RateLimiter error: %v", ctx, key, err) + klog.V(4).Infof("GCEBetaHealthChecks.Update(%v, %v, ...): RateLimiter error: %v", ctx, key, err) return err } - call := g.s.Alpha.HealthChecks.Update(projectID, key.Name, arg0) + call := g.s.Beta.HealthChecks.Update(projectID, key.Name, arg0) call.Context(ctx) op, err := call.Do() if err != nil { - klog.V(4).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...) = %+v", ctx, key, err) + klog.V(4).Infof("GCEBetaHealthChecks.Update(%v, %v, ...) = %+v", ctx, key, err) return err } err = g.s.WaitForCompletion(ctx, op) - klog.V(4).Infof("GCEAlphaHealthChecks.Update(%v, %v, ...) = %+v", ctx, key, err) + klog.V(4).Infof("GCEBetaHealthChecks.Update(%v, %v, ...) = %+v", ctx, key, err) return err } diff --git a/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gen/BUILD b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gen/BUILD new file mode 100644 index 000000000000..6df04e38cd75 --- /dev/null +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/gen/BUILD @@ -0,0 +1,13 @@ +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/cloudprovider/providers/gce/cloud/meta/BUILD b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/BUILD similarity index 74% rename from pkg/cloudprovider/providers/gce/cloud/meta/BUILD rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/BUILD index 591e6f22be54..6c7222619125 100644 --- a/pkg/cloudprovider/providers/gce/cloud/meta/BUILD +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/BUILD @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -9,7 +9,8 @@ go_library( "method.go", "service.go", ], - importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta", + importmap = "k8s.io/kubernetes/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta", + importpath = "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta", visibility = ["//visibility:public"], deps = [ "//vendor/google.golang.org/api/compute/v0.alpha:go_default_library", @@ -18,12 +19,6 @@ go_library( ], ) -go_test( - name = "go_default_test", - srcs = ["key_test.go"], - embed = [":go_default_library"], -) - filegroup( name = "package-srcs", srcs = glob(["**"]), diff --git a/pkg/cloudprovider/providers/gce/cloud/meta/doc.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/doc.go similarity index 87% rename from pkg/cloudprovider/providers/gce/cloud/meta/doc.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/doc.go index 7aa24e063792..7633da38a059 100644 --- a/pkg/cloudprovider/providers/gce/cloud/meta/doc.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/doc.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/cloudprovider/providers/gce/cloud/meta/key.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/key.go similarity index 96% rename from pkg/cloudprovider/providers/gce/cloud/meta/key.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/key.go index 4b6241d2b907..b6a94ba062c7 100644 --- a/pkg/cloudprovider/providers/gce/cloud/meta/key.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/key.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/cloudprovider/providers/gce/cloud/meta/meta.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/meta.go similarity index 99% rename from pkg/cloudprovider/providers/gce/cloud/meta/meta.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/meta.go index 04d13e0bfd29..1be6e1df57d2 100644 --- a/pkg/cloudprovider/providers/gce/cloud/meta/meta.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/meta.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -225,9 +225,9 @@ var AllServices = []*ServiceInfo{ Object: "HealthCheck", Service: "HealthChecks", Resource: "healthChecks", - version: VersionBeta, + version: VersionAlpha, keyType: Global, - serviceType: reflect.TypeOf(&beta.HealthChecksService{}), + serviceType: reflect.TypeOf(&alpha.HealthChecksService{}), additionalMethods: []string{ "Update", }, @@ -236,9 +236,9 @@ var AllServices = []*ServiceInfo{ Object: "HealthCheck", Service: "HealthChecks", Resource: "healthChecks", - version: VersionAlpha, + version: VersionBeta, keyType: Global, - serviceType: reflect.TypeOf(&alpha.HealthChecksService{}), + serviceType: reflect.TypeOf(&beta.HealthChecksService{}), additionalMethods: []string{ "Update", }, diff --git a/pkg/cloudprovider/providers/gce/cloud/meta/method.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/method.go similarity index 99% rename from pkg/cloudprovider/providers/gce/cloud/meta/method.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/method.go index b37258705a2b..f7e62dd3cd2d 100644 --- a/pkg/cloudprovider/providers/gce/cloud/meta/method.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/method.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/cloudprovider/providers/gce/cloud/meta/service.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/service.go similarity index 98% rename from pkg/cloudprovider/providers/gce/cloud/meta/service.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/service.go index c18de2a59427..e7659e4916be 100644 --- a/pkg/cloudprovider/providers/gce/cloud/meta/service.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta/service.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/cloudprovider/providers/gce/cloud/mock/BUILD b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock/BUILD similarity index 60% rename from pkg/cloudprovider/providers/gce/cloud/mock/BUILD rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock/BUILD index e6e359278c43..2da95097b2c7 100644 --- a/pkg/cloudprovider/providers/gce/cloud/mock/BUILD +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock/BUILD @@ -3,12 +3,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = ["mock.go"], - importpath = "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/mock", + importmap = "k8s.io/kubernetes/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock", + importpath = "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock", visibility = ["//visibility:public"], deps = [ - "//pkg/cloudprovider/providers/gce/cloud:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud/filter:go_default_library", - "//pkg/cloudprovider/providers/gce/cloud/meta:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter:go_default_library", + "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta:go_default_library", "//vendor/google.golang.org/api/compute/v0.alpha:go_default_library", "//vendor/google.golang.org/api/compute/v0.beta:go_default_library", "//vendor/google.golang.org/api/compute/v1:go_default_library", diff --git a/pkg/cloudprovider/providers/gce/cloud/mock/mock.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock/mock.go similarity index 98% rename from pkg/cloudprovider/providers/gce/cloud/mock/mock.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock/mock.go index 0489bf8d4a31..fb908dfaa32c 100644 --- a/pkg/cloudprovider/providers/gce/cloud/mock/mock.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock/mock.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -30,13 +30,13 @@ import ( "net/http" "sync" + cloud "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" alpha "google.golang.org/api/compute/v0.alpha" beta "google.golang.org/api/compute/v0.beta" ga "google.golang.org/api/compute/v1" "google.golang.org/api/googleapi" - cloud "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" ) var ( diff --git a/pkg/cloudprovider/providers/gce/cloud/op.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/op.go similarity index 97% rename from pkg/cloudprovider/providers/gce/cloud/op.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/op.go index eb45c769e461..e0caf5f315eb 100644 --- a/pkg/cloudprovider/providers/gce/cloud/op.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/op.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -27,7 +27,7 @@ import ( ga "google.golang.org/api/compute/v1" "google.golang.org/api/googleapi" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) const ( diff --git a/pkg/cloudprovider/providers/gce/cloud/project.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/project.go similarity index 90% rename from pkg/cloudprovider/providers/gce/cloud/project.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/project.go index 231e7cf916a8..eb5d920c360b 100644 --- a/pkg/cloudprovider/providers/gce/cloud/project.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/project.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -19,7 +19,7 @@ package cloud import ( "context" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) // ProjectRouter routes service calls to the appropriate GCE project. diff --git a/pkg/cloudprovider/providers/gce/cloud/ratelimit.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/ratelimit.go similarity index 95% rename from pkg/cloudprovider/providers/gce/cloud/ratelimit.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/ratelimit.go index ca1278a008d0..090db2abfa5f 100644 --- a/pkg/cloudprovider/providers/gce/cloud/ratelimit.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/ratelimit.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -20,7 +20,7 @@ import ( "context" "time" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) // RateLimitKey is a key identifying the operation to be rate limited. The rate limit diff --git a/pkg/cloudprovider/providers/gce/cloud/service.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/service.go similarity index 97% rename from pkg/cloudprovider/providers/gce/cloud/service.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/service.go index 4d7b4c557f2a..839eb15f8d1f 100644 --- a/pkg/cloudprovider/providers/gce/cloud/service.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/service.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/pkg/cloudprovider/providers/gce/cloud/utils.go b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/utils.go similarity index 97% rename from pkg/cloudprovider/providers/gce/cloud/utils.go rename to vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/utils.go index 0affadc96d2d..71b60ab818ae 100644 --- a/pkg/cloudprovider/providers/gce/cloud/utils.go +++ b/vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/utils.go @@ -1,11 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -21,7 +21,7 @@ import ( "fmt" "strings" - "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta" + "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" ) const (