From 85f3a9f3b033b3bc1b4cc006462765f94a20c852 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 27 Feb 2022 14:54:37 -0800 Subject: [PATCH] Remove Azure gateway implementation (#14418) refer #14331 --- CREDITS | 816 +++++++------ cmd/gateway-interface.go | 8 +- cmd/gateway-startup-msg_test.go | 2 +- cmd/gateway/azure/gateway-azure.go | 1449 ----------------------- cmd/gateway/azure/gateway-azure_test.go | 273 ----- cmd/gateway/gateway.go | 3 - cmd/globals.go | 2 +- cmd/metrics.go | 2 +- docs/compression/README.md | 2 +- docs/disk-caching/README.md | 2 +- docs/gateway/README.md | 1 - docs/gateway/azure.md | 79 -- go.mod | 2 +- 13 files changed, 430 insertions(+), 2211 deletions(-) delete mode 100644 cmd/gateway/azure/gateway-azure.go delete mode 100644 cmd/gateway/azure/gateway-azure_test.go delete mode 100644 docs/gateway/azure.md diff --git a/CREDITS b/CREDITS index e3a3e20db..c867189b5 100644 --- a/CREDITS +++ b/CREDITS @@ -2124,57 +2124,6 @@ SOFTWARE. ================================================================ -github.com/PuerkitoBio/purell -https://github.com/PuerkitoBio/purell ----------------------------------------------------------------- -Copyright (c) 2012, Martin Angers -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -* Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -================================================================ - -github.com/PuerkitoBio/urlesc -https://github.com/PuerkitoBio/urlesc ----------------------------------------------------------------- -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -================================================================ - github.com/Shopify/sarama https://github.com/Shopify/sarama ---------------------------------------------------------------- @@ -2792,6 +2741,186 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================================ +github.com/briandowns/spinner +https://github.com/briandowns/spinner +---------------------------------------------------------------- + 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. + +================================================================ + github.com/buger/jsonparser https://github.com/buger/jsonparser ---------------------------------------------------------------- @@ -2945,34 +3074,6 @@ Redistribution and use in source and binary forms, with or without modification, THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================================ -github.com/colinmarc/hdfs/v2 -https://github.com/colinmarc/hdfs/v2 ----------------------------------------------------------------- -Copyright (c) 2014 Colin Marc (colinmarc@gmail.com) - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -================================================================ - github.com/containerd/console https://github.com/containerd/console ---------------------------------------------------------------- @@ -5140,6 +5241,214 @@ SOFTWARE. ================================================================ +github.com/fraugster/parquet-go +https://github.com/fraugster/parquet-go +---------------------------------------------------------------- + + 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. + +================================================================ + github.com/gdamore/encoding https://github.com/gdamore/encoding ---------------------------------------------------------------- @@ -8191,21 +8500,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -================================================================ - -github.com/golang-jwt/jwt -https://github.com/golang-jwt/jwt ----------------------------------------------------------------- -Copyright (c) 2012 Dave Grijalva -Copyright (c) 2021 golang-jwt maintainers - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - ================================================================ github.com/golang-jwt/jwt/v4 @@ -9634,72 +9928,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================================ -github.com/gorilla/securecookie -https://github.com/gorilla/securecookie ----------------------------------------------------------------- -Copyright (c) 2012 Rodrigo Moraes. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -================================================================ - -github.com/gorilla/sessions -https://github.com/gorilla/sessions ----------------------------------------------------------------- -Copyright (c) 2012-2018 The Gorilla Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -================================================================ - github.com/gorilla/websocket https://github.com/gorilla/websocket ---------------------------------------------------------------- @@ -17719,214 +17947,6 @@ https://github.com/minio/minio-go/v7 ================================================================ -github.com/minio/parquet-go -https://github.com/minio/parquet-go ----------------------------------------------------------------- - - 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. - -================================================================ - github.com/minio/pkg https://github.com/minio/pkg ---------------------------------------------------------------- @@ -23311,6 +23331,39 @@ SOFTWARE. ================================================================ +github.com/rogpeppe/go-internal +https://github.com/rogpeppe/go-internal +---------------------------------------------------------------- +Copyright (c) 2018 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +================================================================ + github.com/rs/cors https://github.com/rs/cors ---------------------------------------------------------------- @@ -23670,33 +23723,6 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -================================================================ - -github.com/tidwall/sjson -https://github.com/tidwall/sjson ----------------------------------------------------------------- -The MIT License (MIT) - -Copyright (c) 2016 Josh Baker - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - ================================================================ github.com/tinylib/msgp diff --git a/cmd/gateway-interface.go b/cmd/gateway-interface.go index 07ce5ac97..621c3fa1b 100644 --- a/cmd/gateway-interface.go +++ b/cmd/gateway-interface.go @@ -19,12 +19,10 @@ package cmd import "github.com/minio/madmin-go" -// GatewayMinioSysTmp prefix is used in Azure gateway for save metadata sent by Initialize Multipart Upload API. +// Gateway name backends const ( - GatewayMinioSysTmp = "minio.sys.tmp/" - AzureBackendGateway = "azure" - NASBackendGateway = "nas" - S3BackendGateway = "s3" + NASBackendGateway = "nas" + S3BackendGateway = "s3" ) // Gateway represents a gateway backend. diff --git a/cmd/gateway-startup-msg_test.go b/cmd/gateway-startup-msg_test.go index c83c1482c..a4c827937 100644 --- a/cmd/gateway-startup-msg_test.go +++ b/cmd/gateway-startup-msg_test.go @@ -49,5 +49,5 @@ func TestPrintGatewayStartupMessage(t *testing.T) { } apiEndpoints := []string{"http://127.0.0.1:9000"} - printGatewayStartupMessage(apiEndpoints, "azure") + printGatewayStartupMessage(apiEndpoints, "s3") } diff --git a/cmd/gateway/azure/gateway-azure.go b/cmd/gateway/azure/gateway-azure.go deleted file mode 100644 index 2c45165b1..000000000 --- a/cmd/gateway/azure/gateway-azure.go +++ /dev/null @@ -1,1449 +0,0 @@ -/* - * MinIO Object Storage (c) 2021 MinIO, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package azure - -import ( - "bytes" - "context" - "crypto/rand" - "crypto/sha256" - "encoding/base64" - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "path" - "sort" - "strconv" - "strings" - "time" - - "github.com/Azure/azure-pipeline-go/pipeline" - "github.com/Azure/azure-storage-blob-go/azblob" - "github.com/dustin/go-humanize" - "github.com/minio/cli" - "github.com/minio/madmin-go" - miniogopolicy "github.com/minio/minio-go/v7/pkg/policy" - minio "github.com/minio/minio/cmd" - "github.com/minio/minio/internal/logger" - "github.com/minio/pkg/bucket/policy" - "github.com/minio/pkg/bucket/policy/condition" - "github.com/minio/pkg/env" -) - -const ( - azureDefaultUploadChunkSizeMB = 25 - azureDownloadRetryAttempts = 5 - azureS3MinPartSize = 5 * humanize.MiByte - metadataObjectNameTemplate = minio.GatewayMinioSysTmp + "multipart/v1/%s.%x/azure.json" - azureMarkerPrefix = "{minio}" - metadataPartNamePrefix = minio.GatewayMinioSysTmp + "multipart/v1/%s.%x" - maxPartsCount = 10000 -) - -var ( - azureUploadChunkSize int - azureUploadConcurrency int -) - -func init() { - const azureGatewayTemplate = `NAME: - {{.HelpName}} - {{.Usage}} - -USAGE: - {{.HelpName}} {{if .VisibleFlags}}[FLAGS]{{end}} [ENDPOINT] -{{if .VisibleFlags}} -FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}}{{end}} -ENDPOINT: - Azure server endpoint. Default ENDPOINT is https://core.windows.net - -EXAMPLES: - 1. Start minio gateway server for Azure Blob Storage backend on custom endpoint. - {{.Prompt}} {{.EnvVarSetCommand}} MINIO_ROOT_USER{{.AssignmentOperator}}azureaccountname - {{.Prompt}} {{.EnvVarSetCommand}} MINIO_ROOT_PASSWORD{{.AssignmentOperator}}azureaccountkey - {{.Prompt}} {{.HelpName}} https://azureaccountname.blob.custom.azure.endpoint - - 2. Start minio gateway server for Azure Blob Storage backend with edge caching enabled. - {{.Prompt}} {{.EnvVarSetCommand}} MINIO_ROOT_USER{{.AssignmentOperator}}azureaccountname - {{.Prompt}} {{.EnvVarSetCommand}} MINIO_ROOT_PASSWORD{{.AssignmentOperator}}azureaccountkey - {{.Prompt}} {{.EnvVarSetCommand}} MINIO_CACHE_DRIVES{{.AssignmentOperator}}"/mnt/drive1,/mnt/drive2,/mnt/drive3,/mnt/drive4" - {{.Prompt}} {{.EnvVarSetCommand}} MINIO_CACHE_EXCLUDE{{.AssignmentOperator}}"bucket1/*,*.png" - {{.Prompt}} {{.EnvVarSetCommand}} MINIO_CACHE_QUOTA{{.AssignmentOperator}}90 - {{.Prompt}} {{.EnvVarSetCommand}} MINIO_CACHE_AFTER{{.AssignmentOperator}}3 - {{.Prompt}} {{.EnvVarSetCommand}} MINIO_CACHE_WATERMARK_LOW{{.AssignmentOperator}}75 - {{.Prompt}} {{.EnvVarSetCommand}} MINIO_CACHE_WATERMARK_HIGH{{.AssignmentOperator}}85 - {{.Prompt}} {{.HelpName}} - -` - - minio.RegisterGatewayCommand(cli.Command{ - Name: minio.AzureBackendGateway, - Usage: "Microsoft Azure Blob Storage", - Action: azureGatewayMain, - CustomHelpTemplate: azureGatewayTemplate, - HideHelpCommand: true, - }) -} - -// Returns true if marker was returned by Azure, i.e prefixed with -// {minio} -func isAzureMarker(marker string) bool { - return strings.HasPrefix(marker, azureMarkerPrefix) -} - -// Handler for 'minio gateway azure' command line. -func azureGatewayMain(ctx *cli.Context) { - // Validate gateway arguments. - host := ctx.Args().First() - - serverAddr := ctx.GlobalString("address") - if serverAddr == "" || serverAddr == ":"+minio.GlobalMinioDefaultPort { - serverAddr = ctx.String("address") - } - // Validate gateway arguments. - logger.FatalIf(minio.ValidateGatewayArguments(serverAddr, host), "Invalid argument") - - minio.StartGateway(ctx, &Azure{host}) -} - -// Azure implements Gateway. -type Azure struct { - host string -} - -// Name implements Gateway interface. -func (g *Azure) Name() string { - return minio.AzureBackendGateway -} - -// NewGatewayLayer initializes azure blob storage client and returns AzureObjects. -func (g *Azure) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, error) { - var err error - - // Override credentials from the Azure storage environment variables if specified - if acc, key := env.Get("AZURE_STORAGE_ACCOUNT", creds.AccessKey), env.Get("AZURE_STORAGE_KEY", creds.SecretKey); acc != "" && key != "" { - creds = madmin.Credentials{ - AccessKey: acc, - SecretKey: key, - } - } - - endpointURL, err := parseStorageEndpoint(g.host, creds.AccessKey) - if err != nil { - return nil, err - } - - azureUploadChunkSize, err = env.GetInt("MINIO_AZURE_CHUNK_SIZE_MB", azureDefaultUploadChunkSizeMB) - if err != nil { - return nil, err - } - azureUploadChunkSize *= humanize.MiByte - if azureUploadChunkSize <= 0 || azureUploadChunkSize > 100*humanize.MiByte { - return nil, fmt.Errorf("MINIO_AZURE_CHUNK_SIZE_MB should be an integer value between 0 and 100") - } - - azureUploadConcurrency, err = env.GetInt("MINIO_AZURE_UPLOAD_CONCURRENCY", 4) - if err != nil { - return nil, err - } - - credential, err := azblob.NewSharedKeyCredential(creds.AccessKey, creds.SecretKey) - if err != nil { - if _, ok := err.(base64.CorruptInputError); ok { - return &azureObjects{}, errors.New("invalid Azure credentials") - } - return &azureObjects{}, err - } - - metrics := minio.NewMetrics() - - t := &minio.MetricsTransport{ - Transport: minio.NewGatewayHTTPTransport(), - Metrics: metrics, - } - - httpClient := &http.Client{Transport: t} - userAgent := fmt.Sprintf("APN/1.0 MinIO/1.0 MinIO/%s", minio.Version) - - pipeline := azblob.NewPipeline(credential, azblob.PipelineOptions{ - Retry: azblob.RetryOptions{ - // Azure SDK recommends to set a timeout of 60 seconds per MB of data so we - // calculate here the timeout for the configured upload chunck size. - TryTimeout: time.Duration(azureUploadChunkSize/humanize.MiByte) * 60 * time.Second, - }, - HTTPSender: pipeline.FactoryFunc(func(next pipeline.Policy, po *pipeline.PolicyOptions) pipeline.PolicyFunc { - return func(ctx context.Context, request pipeline.Request) (pipeline.Response, error) { - request.Header.Set("User-Agent", userAgent) - resp, err := httpClient.Do(request.WithContext(ctx)) - return pipeline.NewHTTPResponse(resp), err - } - }), - }) - - client := azblob.NewServiceURL(*endpointURL, pipeline) - - return &azureObjects{ - endpoint: endpointURL, - httpClient: httpClient, - client: client, - metrics: metrics, - }, nil -} - -func parseStorageEndpoint(host string, accountName string) (*url.URL, error) { - var endpoint string - - // Load the endpoint url if supplied by the user. - if host != "" { - host, secure, err := minio.ParseGatewayEndpoint(host) - if err != nil { - return nil, err - } - - var protocol string - if secure { - protocol = "https" - } else { - protocol = "http" - } - - // for containerized storage deployments like Azurite or IoT Edge Storage, - // account resolution isn't handled via a hostname prefix like - // `http://${account}.host/${path}` but instead via a route prefix like - // `http://host/${account}/${path}` so adjusting for that here - if !strings.HasPrefix(host, fmt.Sprintf("%s.", accountName)) { - host = fmt.Sprintf("%s/%s", host, accountName) - } - - endpoint = fmt.Sprintf("%s://%s", protocol, host) - } else { - endpoint = fmt.Sprintf("https://%s.blob.core.windows.net", accountName) - } - - return url.Parse(endpoint) -} - -// s3MetaToAzureProperties converts metadata meant for S3 PUT/COPY -// object into Azure data structures - BlobMetadata and -// BlobProperties. -// -// BlobMetadata contains user defined key-value pairs and each key is -// automatically prefixed with `X-Ms-Meta-` by the Azure SDK. S3 -// user-metadata is translated to Azure metadata by removing the -// `X-Amz-Meta-` prefix. -// -// BlobProperties contains commonly set metadata for objects such as -// Content-Encoding, etc. Such metadata that is accepted by S3 is -// copied into BlobProperties. -// -// Header names are canonicalized as in http.Header. -func s3MetaToAzureProperties(ctx context.Context, s3Metadata map[string]string) (azblob.Metadata, azblob.BlobHTTPHeaders, error) { - for k := range s3Metadata { - if strings.Contains(k, "--") { - return azblob.Metadata{}, azblob.BlobHTTPHeaders{}, minio.UnsupportedMetadata{} - } - } - - // Encoding technique for each key is used here is as follows - // Each '-' is converted to '_' - // Each '_' is converted to '__' - // With this basic assumption here are some of the expected - // translations for these keys. - // i: 'x-S3cmd_attrs' -> o: 'x_s3cmd__attrs' (mixed) - // i: 'x__test__value' -> o: 'x____test____value' (double '_') - encodeKey := func(key string) string { - tokens := strings.Split(key, "_") - for i := range tokens { - tokens[i] = strings.ReplaceAll(tokens[i], "-", "_") - } - return strings.Join(tokens, "__") - } - var blobMeta azblob.Metadata = make(map[string]string) - var err error - var props azblob.BlobHTTPHeaders - for k, v := range s3Metadata { - k = http.CanonicalHeaderKey(k) - switch { - case strings.HasPrefix(k, "X-Amz-Meta-"): - // Strip header prefix, to let Azure SDK - // handle it for storage. - k = strings.Replace(k, "X-Amz-Meta-", "", 1) - blobMeta[encodeKey(k)] = v - // All cases below, extract common metadata that is - // accepted by S3 into BlobProperties for setting on - // Azure - see - // https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html - case k == "Cache-Control": - props.CacheControl = v - case k == "Content-Disposition": - props.ContentDisposition = v - case k == "Content-Encoding": - props.ContentEncoding = v - case k == "Content-Md5": - props.ContentMD5, err = base64.StdEncoding.DecodeString(v) - case k == "Content-Type": - props.ContentType = v - case k == "Content-Language": - props.ContentLanguage = v - } - } - return blobMeta, props, err -} - -const ( - partMetaVersionV1 = "1" -) - -// partMetadataV1 struct holds the part specific metadata for -// multipart operations. -type partMetadataV1 struct { - Version string `json:"version"` - Size int64 `json:"Size"` - BlockIDs []string `json:"blockIDs"` - ETag string `json:"etag"` -} - -// Returns the initialized part metadata struct -func newPartMetaV1(uploadID string, partID int) (partMeta *partMetadataV1) { - p := &partMetadataV1{} - p.Version = partMetaVersionV1 - return p -} - -func s3StorageClassToAzureTier(sc string) azblob.AccessTierType { - switch sc { - case "REDUCED_REDUNDANCY": - return azblob.AccessTierCool - case "STANDARD": - return azblob.AccessTierHot - } - return azblob.AccessTierHot -} - -func azureTierToS3StorageClass(tierType string) string { - switch azblob.AccessTierType(tierType) { - case azblob.AccessTierCool: - return "REDUCED_REDUNDANCY" - case azblob.AccessTierHot: - return "STANDARD" - default: - return "STANDARD" - } -} - -// azurePropertiesToS3Meta converts Azure metadata/properties to S3 -// metadata. It is the reverse of s3MetaToAzureProperties. Azure's -// `.GetMetadata()` lower-cases all header keys, so this is taken into -// account by this function. -func azurePropertiesToS3Meta(meta azblob.Metadata, props azblob.BlobHTTPHeaders, contentLength int64) map[string]string { - // Decoding technique for each key is used here is as follows - // Each '_' is converted to '-' - // Each '__' is converted to '_' - // With this basic assumption here are some of the expected - // translations for these keys. - // i: 'x_s3cmd__attrs' -> o: 'x-s3cmd_attrs' (mixed) - // i: 'x____test____value' -> o: 'x__test__value' (double '_') - decodeKey := func(key string) string { - tokens := strings.Split(key, "__") - for i := range tokens { - tokens[i] = strings.ReplaceAll(tokens[i], "_", "-") - } - return strings.Join(tokens, "_") - } - - s3Metadata := make(map[string]string) - for k, v := range meta { - // k's `x-ms-meta-` prefix is already stripped by - // Azure SDK, so we add the AMZ prefix. - k = "X-Amz-Meta-" + decodeKey(k) - k = http.CanonicalHeaderKey(k) - s3Metadata[k] = v - } - - // Add each property from BlobProperties that is supported by - // S3 PUT/COPY common metadata. - if props.CacheControl != "" { - s3Metadata["Cache-Control"] = props.CacheControl - } - if props.ContentDisposition != "" { - s3Metadata["Content-Disposition"] = props.ContentDisposition - } - if props.ContentEncoding != "" { - s3Metadata["Content-Encoding"] = props.ContentEncoding - } - if contentLength != 0 { - s3Metadata["Content-Length"] = fmt.Sprintf("%d", contentLength) - } - if len(props.ContentMD5) != 0 { - s3Metadata["Content-MD5"] = base64.StdEncoding.EncodeToString(props.ContentMD5) - } - if props.ContentType != "" { - s3Metadata["Content-Type"] = props.ContentType - } - if props.ContentLanguage != "" { - s3Metadata["Content-Language"] = props.ContentLanguage - } - return s3Metadata -} - -// azureObjects - Implements Object layer for Azure blob storage. -type azureObjects struct { - minio.GatewayUnsupported - endpoint *url.URL - httpClient *http.Client - metrics *minio.BackendMetrics - client azblob.ServiceURL // Azure sdk client -} - -// Convert azure errors to minio object layer errors. -func azureToObjectError(err error, params ...string) error { - if err == nil { - return nil - } - - bucket := "" - object := "" - if len(params) >= 1 { - bucket = params[0] - } - if len(params) == 2 { - object = params[1] - } - - azureErr, ok := err.(azblob.StorageError) - if !ok { - // We don't interpret non Azure errors. As azure errors will - // have StatusCode to help to convert to object errors. - return err - } - - serviceCode := string(azureErr.ServiceCode()) - statusCode := azureErr.Response().StatusCode - - return azureCodesToObjectError(err, serviceCode, statusCode, bucket, object) -} - -func azureCodesToObjectError(err error, serviceCode string, statusCode int, bucket string, object string) error { - switch serviceCode { - case "ContainerNotFound", "ContainerBeingDeleted": - err = minio.BucketNotFound{Bucket: bucket} - case "ContainerAlreadyExists": - err = minio.BucketExists{Bucket: bucket} - case "InvalidResourceName": - err = minio.BucketNameInvalid{Bucket: bucket} - case "RequestBodyTooLarge": - err = minio.PartTooBig{} - case "InvalidMetadata": - err = minio.UnsupportedMetadata{} - case "BlobAccessTierNotSupportedForAccountType": - err = minio.NotImplemented{} - case "OutOfRangeInput": - err = minio.ObjectNameInvalid{ - Bucket: bucket, - Object: object, - } - default: - switch statusCode { - case http.StatusNotFound: - if object != "" { - err = minio.ObjectNotFound{ - Bucket: bucket, - Object: object, - } - } else { - err = minio.BucketNotFound{Bucket: bucket} - } - case http.StatusBadRequest: - err = minio.BucketNameInvalid{Bucket: bucket} - } - } - return err -} - -// getAzureUploadID - returns new upload ID which is hex encoded 8 bytes random value. -// this 8 byte restriction is needed because Azure block id has a restriction of length -// upto 8 bytes. -func getAzureUploadID() (string, error) { - var id [8]byte - - n, err := io.ReadFull(rand.Reader, id[:]) - if err != nil { - return "", err - } - if n != len(id) { - return "", fmt.Errorf("Unexpected random data size. Expected: %d, read: %d)", len(id), n) - } - - return hex.EncodeToString(id[:]), nil -} - -// checkAzureUploadID - returns error in case of given string is upload ID. -func checkAzureUploadID(ctx context.Context, uploadID string) (err error) { - if len(uploadID) != 16 { - return minio.MalformedUploadID{ - UploadID: uploadID, - } - } - - if _, err = hex.DecodeString(uploadID); err != nil { - return minio.MalformedUploadID{ - UploadID: uploadID, - } - } - - return nil -} - -// parses partID from part metadata file name -func parseAzurePart(metaPartFileName, prefix string) (partID int, err error) { - partStr := strings.TrimPrefix(metaPartFileName, prefix+minio.SlashSeparator) - if partID, err = strconv.Atoi(partStr); err != nil || partID <= 0 { - err = fmt.Errorf("invalid part number in block id '%d'", partID) - return - } - return -} - -// GetMetrics returns this gateway's metrics -func (a *azureObjects) GetMetrics(ctx context.Context) (*minio.BackendMetrics, error) { - return a.metrics, nil -} - -// Shutdown - save any gateway metadata to disk -// if necessary and reload upon next restart. -func (a *azureObjects) Shutdown(ctx context.Context) error { - return nil -} - -// StorageInfo - Not relevant to Azure backend. -func (a *azureObjects) StorageInfo(ctx context.Context) (si minio.StorageInfo, _ []error) { - si.Backend.Type = madmin.Gateway - host := a.endpoint.Host - if a.endpoint.Port() == "" { - host = a.endpoint.Host + ":" + a.endpoint.Scheme - } - si.Backend.GatewayOnline = minio.IsBackendOnline(ctx, host) - return si, nil -} - -// MakeBucketWithLocation - Create a new container on azure backend. -func (a *azureObjects) MakeBucketWithLocation(ctx context.Context, bucket string, opts minio.BucketOptions) error { - // Filter out unsupported features in Azure and return immediately with NotImplemented error - if opts.LockEnabled || opts.VersioningEnabled || strings.ContainsAny(bucket, ".") { - return minio.NotImplemented{} - } - - // Verify if bucket (container-name) is valid. - // IsValidBucketName has same restrictions as container names mentioned - // in azure documentation, so we will simply use the same function here. - // Ref - https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata - if !minio.IsValidBucketName(bucket) { - return minio.BucketNameInvalid{Bucket: bucket} - } - - containerURL := a.client.NewContainerURL(bucket) - _, err := containerURL.Create(ctx, azblob.Metadata{}, azblob.PublicAccessNone) - return azureToObjectError(err, bucket) -} - -// GetBucketInfo - Get bucket metadata.. -func (a *azureObjects) GetBucketInfo(ctx context.Context, bucket string) (bi minio.BucketInfo, e error) { - // Azure does not have an equivalent call, hence use - // ListContainers with prefix - - marker := azblob.Marker{} - - for marker.NotDone() { - resp, err := a.client.ListContainersSegment(ctx, marker, azblob.ListContainersSegmentOptions{ - Prefix: bucket, - }) - if err != nil { - return bi, azureToObjectError(err, bucket) - } - - for _, container := range resp.ContainerItems { - if container.Name == bucket { - t := container.Properties.LastModified - return minio.BucketInfo{ - Name: bucket, - Created: t, - }, nil - } // else continue - } - - marker = resp.NextMarker - } - return bi, minio.BucketNotFound{Bucket: bucket} -} - -// ListBuckets - Lists all azure containers, uses Azure equivalent `ServiceURL.ListContainersSegment`. -func (a *azureObjects) ListBuckets(ctx context.Context) (buckets []minio.BucketInfo, err error) { - marker := azblob.Marker{} - - for marker.NotDone() { - resp, err := a.client.ListContainersSegment(ctx, marker, azblob.ListContainersSegmentOptions{}) - if err != nil { - return nil, azureToObjectError(err) - } - - for _, container := range resp.ContainerItems { - t := container.Properties.LastModified - buckets = append(buckets, minio.BucketInfo{ - Name: container.Name, - Created: t, - }) - } - - marker = resp.NextMarker - } - return buckets, nil -} - -// DeleteBucket - delete a container on azure, uses Azure equivalent `ContainerURL.Delete`. -func (a *azureObjects) DeleteBucket(ctx context.Context, bucket string, opts minio.DeleteBucketOptions) error { - if !opts.Force { - // Check if the container is empty before deleting it. - result, err := a.ListObjects(ctx, bucket, "", "", "", 1) - if err != nil { - return azureToObjectError(err, bucket) - } - if len(result.Objects) > 0 { - return minio.BucketNotEmpty{Bucket: bucket} - } - } - - containerURL := a.client.NewContainerURL(bucket) - _, err := containerURL.Delete(ctx, azblob.ContainerAccessConditions{}) - return azureToObjectError(err, bucket) -} - -// ListObjects - lists all blobs on azure with in a container filtered by prefix -// and marker, uses Azure equivalent `ContainerURL.ListBlobsHierarchySegment`. -// To accommodate S3-compatible applications using -// ListObjectsV1 to use object keys as markers to control the -// listing of objects, we use the following encoding scheme to -// distinguish between Azure continuation tokens and application -// supplied markers. -// -// - NextMarker in ListObjectsV1 response is constructed by -// prefixing "{minio}" to the Azure continuation token, -// e.g, "{minio}CgRvYmoz" -// -// - Application supplied markers are used as-is to list -// object keys that appear after it in the lexicographical order. -func (a *azureObjects) ListObjects(ctx context.Context, bucket, prefix, marker, delimiter string, maxKeys int) (result minio.ListObjectsInfo, err error) { - var objects []minio.ObjectInfo - var prefixes []string - - azureListMarker := azblob.Marker{} - if isAzureMarker(marker) { - // If application is using Azure continuation token we should - // strip the azureTokenPrefix we added in the previous list response. - azureMarker := strings.TrimPrefix(marker, azureMarkerPrefix) - azureListMarker.Val = &azureMarker - } - - containerURL := a.client.NewContainerURL(bucket) - for len(objects) == 0 && len(prefixes) == 0 { - resp, err := containerURL.ListBlobsHierarchySegment(ctx, azureListMarker, delimiter, azblob.ListBlobsSegmentOptions{ - Prefix: prefix, - MaxResults: int32(maxKeys), - }) - if err != nil { - return result, azureToObjectError(err, bucket, prefix) - } - - for _, blob := range resp.Segment.BlobItems { - if delimiter == "" && strings.HasPrefix(blob.Name, minio.GatewayMinioSysTmp) { - // We filter out minio.GatewayMinioSysTmp entries in the recursive listing. - continue - } - if !isAzureMarker(marker) && blob.Name <= marker { - // If the application used ListObjectsV1 style marker then we - // skip all the entries till we reach the marker. - continue - } - // Populate correct ETag's if possible, this code primarily exists - // because AWS S3 indicates that - // - // https://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html - // - // Objects created by the PUT Object, POST Object, or Copy operation, - // or through the AWS Management Console, and are encrypted by SSE-S3 - // or plaintext, have ETags that are an MD5 digest of their object data. - // - // Some applications depend on this behavior refer https://github.com/minio/minio/issues/6550 - // So we handle it here and make this consistent. - etag := minio.ToS3ETag(string(blob.Properties.Etag)) - switch { - case len(blob.Properties.ContentMD5) != 0: - etag = hex.EncodeToString(blob.Properties.ContentMD5) - case blob.Metadata["md5sum"] != "": - etag = blob.Metadata["md5sum"] - delete(blob.Metadata, "md5sum") - } - - objects = append(objects, minio.ObjectInfo{ - Bucket: bucket, - Name: blob.Name, - ModTime: blob.Properties.LastModified, - Size: *blob.Properties.ContentLength, - ETag: etag, - ContentType: *blob.Properties.ContentType, - ContentEncoding: *blob.Properties.ContentEncoding, - UserDefined: blob.Metadata, - }) - } - - for _, blobPrefix := range resp.Segment.BlobPrefixes { - if blobPrefix.Name == minio.GatewayMinioSysTmp { - // We don't do strings.HasPrefix(blob.Name, minio.GatewayMinioSysTmp) here so that - // we can use tools like mc to inspect the contents of minio.sys.tmp/ - // It is OK to allow listing of minio.sys.tmp/ in non-recursive mode as it aids in debugging. - continue - } - if !isAzureMarker(marker) && blobPrefix.Name <= marker { - // If the application used ListObjectsV1 style marker then we - // skip all the entries till we reach the marker. - continue - } - prefixes = append(prefixes, blobPrefix.Name) - } - - azureListMarker = resp.NextMarker - if !azureListMarker.NotDone() { - // Reached end of listing. - break - } - } - - result.Objects = objects - result.Prefixes = prefixes - if azureListMarker.NotDone() { - // We add the {minio} prefix so that we know in the subsequent request that this - // marker is a azure continuation token and not ListObjectV1 marker. - result.NextMarker = azureMarkerPrefix + *azureListMarker.Val - result.IsTruncated = true - } - return result, nil -} - -// ListObjectsV2 - list all blobs in Azure bucket filtered by prefix -func (a *azureObjects) ListObjectsV2(ctx context.Context, bucket, prefix, continuationToken, delimiter string, maxKeys int, fetchOwner bool, startAfter string) (result minio.ListObjectsV2Info, err error) { - marker := continuationToken - if marker == "" { - marker = startAfter - } - - var resultV1 minio.ListObjectsInfo - resultV1, err = a.ListObjects(ctx, bucket, prefix, marker, delimiter, maxKeys) - if err != nil { - return result, err - } - - result.Objects = resultV1.Objects - result.Prefixes = resultV1.Prefixes - result.ContinuationToken = continuationToken - result.NextContinuationToken = resultV1.NextMarker - result.IsTruncated = (resultV1.NextMarker != "") - return result, nil -} - -// GetObjectNInfo - returns object info and locked object ReadCloser -func (a *azureObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType, opts minio.ObjectOptions) (gr *minio.GetObjectReader, err error) { - var objInfo minio.ObjectInfo - objInfo, err = a.GetObjectInfo(ctx, bucket, object, opts) - if err != nil { - return nil, err - } - - var startOffset, length int64 - startOffset, length, err = rs.GetOffsetLength(objInfo.Size) - if err != nil { - return nil, err - } - - if startOffset != 0 || length != objInfo.Size { - delete(objInfo.UserDefined, "Content-MD5") - } - - pr, pw := io.Pipe() - go func() { - err := a.getObject(ctx, bucket, object, startOffset, length, pw, objInfo.InnerETag, opts) - pw.CloseWithError(err) - }() - // Setup cleanup function to cause the above go-routine to - // exit in case of partial read - pipeCloser := func() { pr.Close() } - return minio.NewGetObjectReaderFromReader(pr, objInfo, opts, pipeCloser) -} - -// GetObject - reads an object from azure. Supports additional -// parameters like offset and length which are synonymous with -// HTTP Range requests. -// -// startOffset indicates the starting read location of the object. -// length indicates the total length of the object. -func (a *azureObjects) getObject(ctx context.Context, bucket, object string, startOffset int64, length int64, writer io.Writer, etag string, opts minio.ObjectOptions) error { - // startOffset cannot be negative. - if startOffset < 0 { - return azureToObjectError(minio.InvalidRange{}, bucket, object) - } - - accessCond := azblob.BlobAccessConditions{} - if etag != "" { - accessCond.ModifiedAccessConditions.IfMatch = azblob.ETag(etag) - } - - blobURL := a.client.NewContainerURL(bucket).NewBlobURL(object) - blob, err := blobURL.Download(ctx, startOffset, length, accessCond, false) - if err != nil { - return azureToObjectError(err, bucket, object) - } - - rc := blob.Body(azblob.RetryReaderOptions{MaxRetryRequests: azureDownloadRetryAttempts}) - - _, err = io.Copy(writer, rc) - rc.Close() - return err -} - -// GetObjectInfo - reads blob metadata properties and replies back minio.ObjectInfo, -// uses Azure equivalent `BlobURL.GetProperties`. -func (a *azureObjects) GetObjectInfo(ctx context.Context, bucket, object string, opts minio.ObjectOptions) (objInfo minio.ObjectInfo, err error) { - blobURL := a.client.NewContainerURL(bucket).NewBlobURL(object) - blob, err := blobURL.GetProperties(ctx, azblob.BlobAccessConditions{}) - if err != nil { - return objInfo, azureToObjectError(err, bucket, object) - } - - realETag := string(blob.ETag()) - - // Populate correct ETag's if possible, this code primarily exists - // because AWS S3 indicates that - // - // https://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html - // - // Objects created by the PUT Object, POST Object, or Copy operation, - // or through the AWS Management Console, and are encrypted by SSE-S3 - // or plaintext, have ETags that are an MD5 digest of their object data. - // - // Some applications depend on this behavior refer https://github.com/minio/minio/issues/6550 - // So we handle it here and make this consistent. - etag := minio.ToS3ETag(realETag) - metadata := blob.NewMetadata() - contentMD5 := blob.ContentMD5() - switch { - case len(contentMD5) != 0: - etag = hex.EncodeToString(contentMD5) - case metadata["md5sum"] != "": - etag = metadata["md5sum"] - delete(metadata, "md5sum") - } - - return minio.ObjectInfo{ - Bucket: bucket, - UserDefined: azurePropertiesToS3Meta(metadata, blob.NewHTTPHeaders(), blob.ContentLength()), - ETag: etag, - InnerETag: realETag, - ModTime: blob.LastModified(), - Name: object, - Size: blob.ContentLength(), - ContentType: blob.ContentType(), - ContentEncoding: blob.ContentEncoding(), - StorageClass: azureTierToS3StorageClass(blob.AccessTier()), - }, nil -} - -// PutObject - Create a new blob with the incoming data, -// uses Azure equivalent `UploadStreamToBlockBlob`. -func (a *azureObjects) PutObject(ctx context.Context, bucket, object string, r *minio.PutObjReader, opts minio.ObjectOptions) (objInfo minio.ObjectInfo, err error) { - data := r.Reader - if opts.UserDefined == nil { - opts.UserDefined = map[string]string{} - } - - metadata, properties, err := s3MetaToAzureProperties(ctx, opts.UserDefined) - if err != nil { - return objInfo, azureToObjectError(err, bucket, object) - } - - blobURL := a.client.NewContainerURL(bucket).NewBlockBlobURL(object) - - _, err = azblob.UploadStreamToBlockBlob(ctx, data, blobURL, azblob.UploadStreamToBlockBlobOptions{ - MaxBuffers: azureUploadConcurrency, - BlobHTTPHeaders: properties, - Metadata: metadata, - }) - if err != nil { - return objInfo, azureToObjectError(err, bucket, object) - } - // Query the blob's properties and metadata - get, err := blobURL.GetProperties(ctx, azblob.BlobAccessConditions{}) - if err != nil { - return objInfo, azureToObjectError(err, bucket, object) - } - // Update the blob's metadata with Content-MD5 after the upload - metadata = get.NewMetadata() - metadata["md5sum"] = r.MD5CurrentHexString() - _, err = blobURL.SetMetadata(ctx, metadata, azblob.BlobAccessConditions{}) - if err != nil { - return objInfo, azureToObjectError(err, bucket, object) - } - return a.GetObjectInfo(ctx, bucket, object, opts) -} - -// CopyObject - Copies a blob from source container to destination container. -// Uses Azure equivalent `BlobURL.StartCopyFromURL`. -func (a *azureObjects) CopyObject(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, srcInfo minio.ObjectInfo, srcOpts, dstOpts minio.ObjectOptions) (objInfo minio.ObjectInfo, err error) { - if srcOpts.CheckPrecondFn != nil && srcOpts.CheckPrecondFn(srcInfo) { - return minio.ObjectInfo{}, minio.PreConditionFailed{} - } - srcBlob := a.client.NewContainerURL(srcBucket).NewBlobURL(srcObject) - srcBlobURL := srcBlob.URL() - - srcProps, err := srcBlob.GetProperties(ctx, azblob.BlobAccessConditions{}) - if err != nil { - return objInfo, azureToObjectError(err, srcBucket, srcObject) - } - destBlob := a.client.NewContainerURL(destBucket).NewBlobURL(destObject) - - azureMeta, props, err := s3MetaToAzureProperties(ctx, srcInfo.UserDefined) - if err != nil { - return objInfo, azureToObjectError(err, srcBucket, srcObject) - } - props.ContentMD5 = srcProps.ContentMD5() - azureMeta["md5sum"] = srcInfo.ETag - res, err := destBlob.StartCopyFromURL(ctx, srcBlobURL, azureMeta, azblob.ModifiedAccessConditions{}, azblob.BlobAccessConditions{}) - if err != nil { - return objInfo, azureToObjectError(err, srcBucket, srcObject) - } - // StartCopyFromURL is an asynchronous operation so need to poll for completion, - // see https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob#remarks. - copyStatus := res.CopyStatus() - for copyStatus != azblob.CopyStatusSuccess { - destProps, err := destBlob.GetProperties(ctx, azblob.BlobAccessConditions{}) - if err != nil { - return objInfo, azureToObjectError(err, srcBucket, srcObject) - } - copyStatus = destProps.CopyStatus() - } - - // Azure will copy metadata from the source object when an empty metadata map is provided. - // To handle the case where the source object should be copied without its metadata, - // the metadata must be removed from the dest. object after the copy completes - if len(azureMeta) == 0 { - _, err = destBlob.SetMetadata(ctx, azureMeta, azblob.BlobAccessConditions{}) - if err != nil { - return objInfo, azureToObjectError(err, srcBucket, srcObject) - } - } - - _, err = destBlob.SetHTTPHeaders(ctx, props, azblob.BlobAccessConditions{}) - if err != nil { - return objInfo, azureToObjectError(err, srcBucket, srcObject) - } - - if _, ok := srcInfo.UserDefined["x-amz-storage-class"]; ok { - _, err = destBlob.SetTier(ctx, s3StorageClassToAzureTier(srcInfo.UserDefined["x-amz-storage-class"]), - azblob.LeaseAccessConditions{}) - if err != nil { - return objInfo, azureToObjectError(err, srcBucket, srcObject) - } - } - - return a.GetObjectInfo(ctx, destBucket, destObject, dstOpts) -} - -// DeleteObject - Deletes a blob on azure container, uses Azure -// equivalent `BlobURL.Delete`. -func (a *azureObjects) DeleteObject(ctx context.Context, bucket, object string, opts minio.ObjectOptions) (minio.ObjectInfo, error) { - blob := a.client.NewContainerURL(bucket).NewBlobURL(object) - _, err := blob.Delete(ctx, azblob.DeleteSnapshotsOptionNone, azblob.BlobAccessConditions{}) - if err != nil { - err = azureToObjectError(err, bucket, object) - if !errors.Is(err, minio.ObjectNotFound{Bucket: bucket, Object: object}) { - return minio.ObjectInfo{}, err - } - } - return minio.ObjectInfo{ - Bucket: bucket, - Name: object, - }, nil -} - -func (a *azureObjects) DeleteObjects(ctx context.Context, bucket string, objects []minio.ObjectToDelete, opts minio.ObjectOptions) ([]minio.DeletedObject, []error) { - errs := make([]error, len(objects)) - dobjects := make([]minio.DeletedObject, len(objects)) - for idx, object := range objects { - _, errs[idx] = a.DeleteObject(ctx, bucket, object.ObjectName, opts) - dobjects[idx] = minio.DeletedObject{ - ObjectName: object.ObjectName, - } - } - return dobjects, errs -} - -// ListMultipartUploads - It's decided not to support List Multipart Uploads, hence returning empty result. -func (a *azureObjects) ListMultipartUploads(ctx context.Context, bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (result minio.ListMultipartsInfo, err error) { - // It's decided not to support List Multipart Uploads, hence returning empty result. - return result, nil -} - -type azureMultipartMetadata struct { - Name string `json:"name"` - Metadata map[string]string `json:"metadata"` -} - -func getAzureMetadataObjectName(objectName, uploadID string) string { - return fmt.Sprintf(metadataObjectNameTemplate, uploadID, sha256.Sum256([]byte(objectName))) -} - -// gets the name of part metadata file for multipart upload operations -func getAzureMetadataPartName(objectName, uploadID string, partID int) string { - partMetaPrefix := getAzureMetadataPartPrefix(uploadID, objectName) - return path.Join(partMetaPrefix, fmt.Sprintf("%d", partID)) -} - -// gets the prefix of part metadata file -func getAzureMetadataPartPrefix(uploadID, objectName string) string { - return fmt.Sprintf(metadataPartNamePrefix, uploadID, sha256.Sum256([]byte(objectName))) -} - -func (a *azureObjects) checkUploadIDExists(ctx context.Context, bucketName, objectName, uploadID string) (err error) { - blobURL := a.client.NewContainerURL(bucketName).NewBlobURL( - getAzureMetadataObjectName(objectName, uploadID)) - _, err = blobURL.GetProperties(ctx, azblob.BlobAccessConditions{}) - err = azureToObjectError(err, bucketName, objectName) - oerr := minio.ObjectNotFound{ - Bucket: bucketName, - Object: objectName, - } - if err == oerr { - err = minio.InvalidUploadID{ - UploadID: uploadID, - } - } - return err -} - -// NewMultipartUpload - Use Azure equivalent `BlobURL.Upload`. -func (a *azureObjects) NewMultipartUpload(ctx context.Context, bucket, object string, opts minio.ObjectOptions) (uploadID string, err error) { - uploadID, err = getAzureUploadID() - if err != nil { - logger.LogIf(ctx, err) - return "", err - } - metadataObject := getAzureMetadataObjectName(object, uploadID) - - var jsonData []byte - if jsonData, err = json.Marshal(azureMultipartMetadata{Name: object, Metadata: opts.UserDefined}); err != nil { - logger.LogIf(ctx, err) - return "", err - } - - blobURL := a.client.NewContainerURL(bucket).NewBlockBlobURL(metadataObject) - _, err = blobURL.Upload(ctx, bytes.NewReader(jsonData), azblob.BlobHTTPHeaders{}, azblob.Metadata{}, azblob.BlobAccessConditions{}) - if err != nil { - return "", azureToObjectError(err, bucket, metadataObject) - } - - return uploadID, nil -} - -func (a *azureObjects) CopyObjectPart(ctx context.Context, srcBucket, srcObject, dstBucket, dstObject string, uploadID string, partID int, - startOffset int64, length int64, srcInfo minio.ObjectInfo, srcOpts, dstOpts minio.ObjectOptions, -) (info minio.PartInfo, err error) { - return a.PutObjectPart(ctx, dstBucket, dstObject, uploadID, partID, srcInfo.PutObjReader, dstOpts) -} - -// PutObjectPart - Use Azure equivalent `BlobURL.StageBlock`. -func (a *azureObjects) PutObjectPart(ctx context.Context, bucket, object, uploadID string, partID int, r *minio.PutObjReader, opts minio.ObjectOptions) (info minio.PartInfo, err error) { - data := r.Reader - if err = a.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil { - return info, err - } - - if err = checkAzureUploadID(ctx, uploadID); err != nil { - return info, err - } - - partMetaV1 := newPartMetaV1(uploadID, partID) - subPartSize, subPartNumber := int64(azureUploadChunkSize), 1 - for remainingSize := data.Size(); remainingSize > 0; remainingSize -= subPartSize { - if remainingSize < subPartSize { - subPartSize = remainingSize - } - - id := base64.StdEncoding.EncodeToString([]byte(minio.MustGetUUID())) - blobURL := a.client.NewContainerURL(bucket).NewBlockBlobURL(object) - body, err := ioutil.ReadAll(io.LimitReader(data, subPartSize)) - if err != nil { - return info, azureToObjectError(err, bucket, object) - } - _, err = blobURL.StageBlock(ctx, id, bytes.NewReader(body), azblob.LeaseAccessConditions{}, nil) - if err != nil { - return info, azureToObjectError(err, bucket, object) - } - partMetaV1.BlockIDs = append(partMetaV1.BlockIDs, id) - subPartNumber++ - } - - partMetaV1.ETag = r.MD5CurrentHexString() - partMetaV1.Size = data.Size() - - // maintain per part md5sum in a temporary part metadata file until upload - // is finalized. - metadataObject := getAzureMetadataPartName(object, uploadID, partID) - var jsonData []byte - if jsonData, err = json.Marshal(partMetaV1); err != nil { - logger.LogIf(ctx, err) - return info, err - } - - blobURL := a.client.NewContainerURL(bucket).NewBlockBlobURL(metadataObject) - _, err = blobURL.Upload(ctx, bytes.NewReader(jsonData), azblob.BlobHTTPHeaders{}, azblob.Metadata{}, azblob.BlobAccessConditions{}) - if err != nil { - return info, azureToObjectError(err, bucket, metadataObject) - } - - info.PartNumber = partID - info.ETag = partMetaV1.ETag - info.LastModified = minio.UTCNow() - info.Size = data.Size() - return info, nil -} - -// GetMultipartInfo returns multipart info of the uploadId of the object -func (a *azureObjects) GetMultipartInfo(ctx context.Context, bucket, object, uploadID string, opts minio.ObjectOptions) (result minio.MultipartInfo, err error) { - if err = a.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil { - return result, err - } - - result.Bucket = bucket - result.Object = object - result.UploadID = uploadID - return result, nil -} - -// ListObjectParts - Use Azure equivalent `ContainerURL.ListBlobsHierarchySegment`. -func (a *azureObjects) ListObjectParts(ctx context.Context, bucket, object, uploadID string, partNumberMarker int, maxParts int, opts minio.ObjectOptions) (result minio.ListPartsInfo, err error) { - if err = a.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil { - return result, err - } - - result.Bucket = bucket - result.Object = object - result.UploadID = uploadID - result.MaxParts = maxParts - - azureListMarker := "" - marker := azblob.Marker{Val: &azureListMarker} - - var parts []minio.PartInfo - var delimiter string - maxKeys := maxPartsCount - if partNumberMarker == 0 { - maxKeys = maxParts - } - prefix := getAzureMetadataPartPrefix(uploadID, object) - containerURL := a.client.NewContainerURL(bucket) - resp, err := containerURL.ListBlobsHierarchySegment(ctx, marker, delimiter, azblob.ListBlobsSegmentOptions{ - Prefix: prefix, - MaxResults: int32(maxKeys), - }) - if err != nil { - return result, azureToObjectError(err, bucket, prefix) - } - - for _, blob := range resp.Segment.BlobItems { - if delimiter == "" && !strings.HasPrefix(blob.Name, minio.GatewayMinioSysTmp) { - // We filter out non minio.GatewayMinioSysTmp entries in the recursive listing. - continue - } - // filter temporary metadata file for blob - if strings.HasSuffix(blob.Name, "azure.json") { - continue - } - if !isAzureMarker(*marker.Val) && blob.Name <= *marker.Val { - // If the application used ListObjectsV1 style marker then we - // skip all the entries till we reach the marker. - continue - } - partNumber, err := parseAzurePart(blob.Name, prefix) - if err != nil { - return result, azureToObjectError(fmt.Errorf("Unexpected error"), bucket, object) - } - var metadata partMetadataV1 - blobURL := containerURL.NewBlobURL(blob.Name) - blob, err := blobURL.Download(ctx, 0, azblob.CountToEnd, azblob.BlobAccessConditions{}, false) - if err != nil { - return result, azureToObjectError(fmt.Errorf("Unexpected error"), bucket, object) - } - metadataReader := blob.Body(azblob.RetryReaderOptions{MaxRetryRequests: azureDownloadRetryAttempts}) - if err = json.NewDecoder(metadataReader).Decode(&metadata); err != nil { - logger.LogIf(ctx, err) - return result, azureToObjectError(err, bucket, object) - } - parts = append(parts, minio.PartInfo{ - PartNumber: partNumber, - Size: metadata.Size, - ETag: metadata.ETag, - }) - } - sort.Slice(parts, func(i int, j int) bool { - return parts[i].PartNumber < parts[j].PartNumber - }) - partsCount := 0 - i := 0 - if partNumberMarker != 0 { - // If the marker was set, skip the entries till the marker. - for _, part := range parts { - i++ - if part.PartNumber == partNumberMarker { - break - } - } - } - for partsCount < maxParts && i < len(parts) { - result.Parts = append(result.Parts, parts[i]) - i++ - partsCount++ - } - - if i < len(parts) { - result.IsTruncated = true - if partsCount != 0 { - result.NextPartNumberMarker = result.Parts[partsCount-1].PartNumber - } - } - result.PartNumberMarker = partNumberMarker - return result, nil -} - -// AbortMultipartUpload - Not Implemented. -// There is no corresponding API in azure to abort an incomplete upload. The uncommmitted blocks -// gets deleted after one week. -func (a *azureObjects) AbortMultipartUpload(ctx context.Context, bucket, object, uploadID string, opts minio.ObjectOptions) (err error) { - if err = a.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil { - return err - } - var partNumberMarker int - for { - lpi, err := a.ListObjectParts(ctx, bucket, object, uploadID, partNumberMarker, maxPartsCount, minio.ObjectOptions{}) - if err != nil { - break - } - for _, part := range lpi.Parts { - pblob := a.client.NewContainerURL(bucket).NewBlobURL( - getAzureMetadataPartName(object, uploadID, part.PartNumber)) - pblob.Delete(ctx, azblob.DeleteSnapshotsOptionNone, azblob.BlobAccessConditions{}) - } - partNumberMarker = lpi.NextPartNumberMarker - if !lpi.IsTruncated { - break - } - } - - blobURL := a.client.NewContainerURL(bucket).NewBlobURL( - getAzureMetadataObjectName(object, uploadID)) - _, err = blobURL.Delete(ctx, azblob.DeleteSnapshotsOptionNone, azblob.BlobAccessConditions{}) - return err -} - -// CompleteMultipartUpload - Use Azure equivalent `BlobURL.CommitBlockList`. -func (a *azureObjects) CompleteMultipartUpload(ctx context.Context, bucket, object, uploadID string, uploadedParts []minio.CompletePart, opts minio.ObjectOptions) (objInfo minio.ObjectInfo, err error) { - metadataObject := getAzureMetadataObjectName(object, uploadID) - if err = a.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil { - return objInfo, err - } - - if err = checkAzureUploadID(ctx, uploadID); err != nil { - return objInfo, err - } - - blobURL := a.client.NewContainerURL(bucket).NewBlobURL(metadataObject) - blob, err := blobURL.Download(ctx, 0, azblob.CountToEnd, azblob.BlobAccessConditions{}, false) - if err != nil { - return objInfo, azureToObjectError(err, bucket, metadataObject) - } - - var metadata azureMultipartMetadata - metadataReader := blob.Body(azblob.RetryReaderOptions{MaxRetryRequests: azureDownloadRetryAttempts}) - if err = json.NewDecoder(metadataReader).Decode(&metadata); err != nil { - logger.LogIf(ctx, err) - return objInfo, azureToObjectError(err, bucket, metadataObject) - } - - objBlob := a.client.NewContainerURL(bucket).NewBlockBlobURL(object) - - var allBlocks []string - for i, part := range uploadedParts { - var partMetadata partMetadataV1 - partMetadataObject := getAzureMetadataPartName(object, uploadID, part.PartNumber) - pblobURL := a.client.NewContainerURL(bucket).NewBlobURL(partMetadataObject) - pblob, err := pblobURL.Download(ctx, 0, azblob.CountToEnd, azblob.BlobAccessConditions{}, false) - if err != nil { - return objInfo, azureToObjectError(err, bucket, partMetadataObject) - } - - partMetadataReader := pblob.Body(azblob.RetryReaderOptions{MaxRetryRequests: azureDownloadRetryAttempts}) - if err = json.NewDecoder(partMetadataReader).Decode(&partMetadata); err != nil { - logger.LogIf(ctx, err) - return objInfo, azureToObjectError(err, bucket, partMetadataObject) - } - - if partMetadata.ETag != part.ETag { - return objInfo, minio.InvalidPart{} - } - allBlocks = append(allBlocks, partMetadata.BlockIDs...) - if i < (len(uploadedParts)-1) && partMetadata.Size < azureS3MinPartSize { - return objInfo, minio.PartTooSmall{ - PartNumber: uploadedParts[i].PartNumber, - PartSize: partMetadata.Size, - PartETag: uploadedParts[i].ETag, - } - } - } - - objMetadata, objProperties, err := s3MetaToAzureProperties(ctx, metadata.Metadata) - if err != nil { - return objInfo, azureToObjectError(err, bucket, object) - } - objMetadata["md5sum"] = minio.ComputeCompleteMultipartMD5(uploadedParts) - - _, err = objBlob.CommitBlockList(ctx, allBlocks, objProperties, objMetadata, azblob.BlobAccessConditions{}) - if err != nil { - return objInfo, azureToObjectError(err, bucket, object) - } - var partNumberMarker int - for { - lpi, err := a.ListObjectParts(ctx, bucket, object, uploadID, partNumberMarker, maxPartsCount, minio.ObjectOptions{}) - if err != nil { - break - } - for _, part := range lpi.Parts { - pblob := a.client.NewContainerURL(bucket).NewBlobURL( - getAzureMetadataPartName(object, uploadID, part.PartNumber)) - pblob.Delete(ctx, azblob.DeleteSnapshotsOptionNone, azblob.BlobAccessConditions{}) - } - partNumberMarker = lpi.NextPartNumberMarker - if !lpi.IsTruncated { - break - } - } - - _, derr := blobURL.Delete(ctx, azblob.DeleteSnapshotsOptionNone, azblob.BlobAccessConditions{}) - logger.GetReqInfo(ctx).AppendTags("uploadID", uploadID) - logger.LogIf(ctx, derr) - - return a.GetObjectInfo(ctx, bucket, object, minio.ObjectOptions{}) -} - -// SetBucketPolicy - Azure supports three types of container policies: -// azblob.PublicAccessContainer - readonly in minio terminology -// azblob.PublicAccessBlob - readonly without listing in minio terminology -// azblob.PublicAccessNone - none in minio terminology -// As the common denominator for minio and azure is readonly and none, we support -// these two policies at the bucket level. -func (a *azureObjects) SetBucketPolicy(ctx context.Context, bucket string, bucketPolicy *policy.Policy) error { - policyInfo, err := minio.PolicyToBucketAccessPolicy(bucketPolicy) - if err != nil { - // This should not happen. - logger.LogIf(ctx, err) - return azureToObjectError(err, bucket) - } - - var policies []minio.BucketAccessPolicy - for prefix, policy := range miniogopolicy.GetPolicies(policyInfo.Statements, bucket, "") { - policies = append(policies, minio.BucketAccessPolicy{ - Prefix: prefix, - Policy: policy, - }) - } - prefix := bucket + "/*" // For all objects inside the bucket. - if len(policies) != 1 { - return minio.NotImplemented{} - } - if policies[0].Prefix != prefix { - return minio.NotImplemented{} - } - if policies[0].Policy != miniogopolicy.BucketPolicyReadOnly { - return minio.NotImplemented{} - } - perm := azblob.PublicAccessContainer - container := a.client.NewContainerURL(bucket) - _, err = container.SetAccessPolicy(ctx, perm, nil, azblob.ContainerAccessConditions{}) - return azureToObjectError(err, bucket) -} - -// GetBucketPolicy - Get the container ACL and convert it to canonical []bucketAccessPolicy -func (a *azureObjects) GetBucketPolicy(ctx context.Context, bucket string) (*policy.Policy, error) { - container := a.client.NewContainerURL(bucket) - perm, err := container.GetAccessPolicy(ctx, azblob.LeaseAccessConditions{}) - if err != nil { - return nil, azureToObjectError(err, bucket) - } - - permAccessType := perm.BlobPublicAccess() - - if permAccessType == azblob.PublicAccessNone { - return nil, minio.BucketPolicyNotFound{Bucket: bucket} - } else if permAccessType != azblob.PublicAccessContainer { - return nil, azureToObjectError(minio.NotImplemented{}) - } - - return &policy.Policy{ - Version: policy.DefaultVersion, - Statements: []policy.Statement{ - policy.NewStatement( - "", - policy.Allow, - policy.NewPrincipal("*"), - policy.NewActionSet( - policy.GetBucketLocationAction, - policy.ListBucketAction, - policy.GetObjectAction, - ), - policy.NewResourceSet( - policy.NewResource(bucket, ""), - policy.NewResource(bucket, "*"), - ), - condition.NewFunctions(), - ), - }, - }, nil -} - -// DeleteBucketPolicy - Set the container ACL to "private" -func (a *azureObjects) DeleteBucketPolicy(ctx context.Context, bucket string) error { - perm := azblob.PublicAccessNone - containerURL := a.client.NewContainerURL(bucket) - _, err := containerURL.SetAccessPolicy(ctx, perm, nil, azblob.ContainerAccessConditions{}) - return azureToObjectError(err) -} - -// IsCompressionSupported returns whether compression is applicable for this layer. -func (a *azureObjects) IsCompressionSupported() bool { - return false -} diff --git a/cmd/gateway/azure/gateway-azure_test.go b/cmd/gateway/azure/gateway-azure_test.go deleted file mode 100644 index 706d449b8..000000000 --- a/cmd/gateway/azure/gateway-azure_test.go +++ /dev/null @@ -1,273 +0,0 @@ -/* - * MinIO Object Storage (c) 2021 MinIO, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package azure - -import ( - "encoding/base64" - "fmt" - "net/http" - "reflect" - "testing" - - "github.com/Azure/azure-storage-blob-go/azblob" - minio "github.com/minio/minio/cmd" -) - -func TestParseStorageEndpoint(t *testing.T) { - testCases := []struct { - host string - accountName string - expectedURL string - expectedErr error - }{ - { - "", "myaccount", "https://myaccount.blob.core.windows.net", nil, - }, - { - "myaccount.blob.core.usgovcloudapi.net", "myaccount", "https://myaccount.blob.core.usgovcloudapi.net", nil, - }, - { - "http://localhost:10000", "myaccount", "http://localhost:10000/myaccount", nil, - }, - } - for i, testCase := range testCases { - endpointURL, err := parseStorageEndpoint(testCase.host, testCase.accountName) - if err != testCase.expectedErr { - t.Errorf("Test %d: Expected error %s, got %s", i+1, testCase.expectedErr, err) - } - if endpointURL.String() != testCase.expectedURL { - t.Errorf("Test %d: Expected URL %s, got %s", i+1, testCase.expectedURL, endpointURL.String()) - } - } -} - -// Test canonical metadata. -func TestS3MetaToAzureProperties(t *testing.T) { - headers := map[string]string{ - "accept-encoding": "gzip", - "content-encoding": "gzip", - "cache-control": "age: 3600", - "content-disposition": "dummy", - "content-length": "10", - "content-type": "application/javascript", - "X-Amz-Meta-Hdr": "value", - "X-Amz-Meta-X_test_key": "value", - "X-Amz-Meta-X__test__key": "value", - "X-Amz-Meta-X-Test__key": "value", - "X-Amz-Meta-X-Amz-Key": "hu3ZSqtqwn+aL4V2VhAeov4i+bG3KyCtRMSXQFRHXOk=", - "X-Amz-Meta-X-Amz-Matdesc": "{}", - "X-Amz-Meta-X-Amz-Iv": "eWmyryl8kq+EVnnsE7jpOg==", - } - // Only X-Amz-Meta- prefixed entries will be returned in - // Metadata (without the prefix!) - expectedHeaders := map[string]string{ - "Hdr": "value", - "X__test__key": "value", - "X____test____key": "value", - "X_Test____key": "value", - "X_Amz_Key": "hu3ZSqtqwn+aL4V2VhAeov4i+bG3KyCtRMSXQFRHXOk=", - "X_Amz_Matdesc": "{}", - "X_Amz_Iv": "eWmyryl8kq+EVnnsE7jpOg==", - } - meta, _, err := s3MetaToAzureProperties(minio.GlobalContext, headers) - if err != nil { - t.Fatalf("Test failed, with %s", err) - } - if !reflect.DeepEqual(map[string]string(meta), expectedHeaders) { - t.Fatalf("Test failed, expected %#v, got %#v", expectedHeaders, meta) - } - headers = map[string]string{ - "invalid--meta": "value", - } - _, _, err = s3MetaToAzureProperties(minio.GlobalContext, headers) - if err != nil { - if _, ok := err.(minio.UnsupportedMetadata); !ok { - t.Fatalf("Test failed with unexpected error %s, expected UnsupportedMetadata", err) - } - } - - headers = map[string]string{ - "content-md5": "Dce7bmCX61zvxzP5QmfelQ==", - } - _, props, err := s3MetaToAzureProperties(minio.GlobalContext, headers) - if err != nil { - t.Fatalf("Test failed, with %s", err) - } - if base64.StdEncoding.EncodeToString(props.ContentMD5) != headers["content-md5"] { - t.Fatalf("Test failed, expected %s, got %s", headers["content-md5"], props.ContentMD5) - } -} - -func TestAzurePropertiesToS3Meta(t *testing.T) { - // Just one testcase. Adding more test cases does not add value to the testcase - // as azureToS3Metadata() just adds a prefix. - metadata := map[string]string{ - "first_name": "myname", - "x_test_key": "value", - "x_test__key": "value", - "x__test__key": "value", - "x____test____key": "value", - "x_amz_key": "hu3ZSqtqwn+aL4V2VhAeov4i+bG3KyCtRMSXQFRHXOk=", - "x_amz_matdesc": "{}", - "x_amz_iv": "eWmyryl8kq+EVnnsE7jpOg==", - } - expectedMeta := map[string]string{ - "X-Amz-Meta-First-Name": "myname", - "X-Amz-Meta-X-Test-Key": "value", - "X-Amz-Meta-X-Test_key": "value", - "X-Amz-Meta-X_test_key": "value", - "X-Amz-Meta-X__test__key": "value", - "X-Amz-Meta-X-Amz-Key": "hu3ZSqtqwn+aL4V2VhAeov4i+bG3KyCtRMSXQFRHXOk=", - "X-Amz-Meta-X-Amz-Matdesc": "{}", - "X-Amz-Meta-X-Amz-Iv": "eWmyryl8kq+EVnnsE7jpOg==", - "Cache-Control": "max-age: 3600", - "Content-Disposition": "dummy", - "Content-Encoding": "gzip", - "Content-Length": "10", - "Content-MD5": base64.StdEncoding.EncodeToString([]byte("base64-md5")), - "Content-Type": "application/javascript", - } - actualMeta := azurePropertiesToS3Meta(metadata, azblob.BlobHTTPHeaders{ - CacheControl: "max-age: 3600", - ContentDisposition: "dummy", - ContentEncoding: "gzip", - ContentMD5: []byte("base64-md5"), - ContentType: "application/javascript", - }, 10) - if !reflect.DeepEqual(actualMeta, expectedMeta) { - t.Fatalf("Test failed, expected %#v, got %#v", expectedMeta, actualMeta) - } -} - -// Add tests for azure to object error (top level). -func TestAzureToObjectError(t *testing.T) { - testCases := []struct { - actualErr error - expectedErr error - bucket, object string - }{ - { - nil, nil, "", "", - }, - { - fmt.Errorf("Non azure error"), - fmt.Errorf("Non azure error"), "", "", - }, - } - for i, testCase := range testCases { - if err := azureToObjectError(testCase.actualErr, testCase.bucket, testCase.object); err != nil { - if err.Error() != testCase.expectedErr.Error() { - t.Errorf("Test %d: Expected error %s, got %s", i+1, testCase.expectedErr, err) - } - } else { - if testCase.expectedErr != nil { - t.Errorf("Test %d expected an error but one was not produced", i+1) - } - } - } -} - -// Add tests for azure to object error (internal). -func TestAzureCodesToObjectError(t *testing.T) { - testCases := []struct { - originalErr error - actualServiceCode string - actualStatusCode int - expectedErr error - bucket, object string - }{ - { - nil, "ContainerAlreadyExists", 0, - minio.BucketExists{Bucket: "bucket"}, - "bucket", "", - }, - { - nil, "InvalidResourceName", 0, - minio.BucketNameInvalid{Bucket: "bucket."}, - "bucket.", "", - }, - { - nil, "RequestBodyTooLarge", 0, - minio.PartTooBig{}, - "", "", - }, - { - nil, "InvalidMetadata", 0, - minio.UnsupportedMetadata{}, - "", "", - }, - { - nil, "", http.StatusNotFound, - minio.ObjectNotFound{ - Bucket: "bucket", - Object: "object", - }, - "bucket", "object", - }, - { - nil, "", http.StatusNotFound, - minio.BucketNotFound{Bucket: "bucket"}, - "bucket", "", - }, - { - nil, "", http.StatusBadRequest, - minio.BucketNameInvalid{Bucket: "bucket."}, - "bucket.", "", - }, - { - fmt.Errorf("unhandled azure error"), "", http.StatusForbidden, - fmt.Errorf("unhandled azure error"), "", "", - }, - } - for i, testCase := range testCases { - if err := azureCodesToObjectError(testCase.originalErr, testCase.actualServiceCode, testCase.actualStatusCode, testCase.bucket, testCase.object); err != nil { - if err.Error() != testCase.expectedErr.Error() { - t.Errorf("Test %d: Expected error %s, got %s", i+1, testCase.expectedErr, err) - } - } else { - if testCase.expectedErr != nil { - t.Errorf("Test %d expected an error but one was not produced", i+1) - } - } - } -} - -func TestCheckAzureUploadID(t *testing.T) { - invalidUploadIDs := []string{ - "123456789abcdefg", - "hello world", - "0x1234567890", - "1234567890abcdef1234567890abcdef", - } - - for _, uploadID := range invalidUploadIDs { - if err := checkAzureUploadID(minio.GlobalContext, uploadID); err == nil { - t.Fatalf("%s: expected: , got: ", uploadID) - } - } - - validUploadIDs := []string{ - "1234567890abcdef", - "1122334455667788", - } - - for _, uploadID := range validUploadIDs { - if err := checkAzureUploadID(minio.GlobalContext, uploadID); err != nil { - t.Fatalf("%s: expected: , got: %s", uploadID, err) - } - } -} diff --git a/cmd/gateway/gateway.go b/cmd/gateway/gateway.go index 43c6d2f67..72a382dbd 100644 --- a/cmd/gateway/gateway.go +++ b/cmd/gateway/gateway.go @@ -22,9 +22,6 @@ import ( // NAS _ "github.com/minio/minio/cmd/gateway/nas" - // Azure - _ "github.com/minio/minio/cmd/gateway/azure" - // S3 _ "github.com/minio/minio/cmd/gateway/s3" // gateway functionality is frozen, no new gateways are being implemented diff --git a/cmd/globals.go b/cmd/globals.go index 091cce6cd..3f49f650f 100644 --- a/cmd/globals.go +++ b/cmd/globals.go @@ -139,7 +139,7 @@ var ( // Indicates if the running minio is in gateway mode. globalIsGateway = false - // Name of gateway server, e.g S3, GCS, Azure, etc + // Name of gateway server, e.g S3, NAS etc globalGatewayName = "" // This flag is set to 'true' by default diff --git a/cmd/metrics.go b/cmd/metrics.go index f5f09239f..c287e27b5 100644 --- a/cmd/metrics.go +++ b/cmd/metrics.go @@ -191,7 +191,7 @@ func healingMetricsPrometheus(ch chan<- prometheus.Metric) { // collects gateway specific metrics for MinIO instance in Prometheus specific format // and sends to given channel func gatewayMetricsPrometheus(ch chan<- prometheus.Metric) { - if !globalIsGateway || (globalGatewayName != S3BackendGateway && globalGatewayName != AzureBackendGateway) { + if !globalIsGateway || (globalGatewayName != S3BackendGateway) { return } diff --git a/docs/compression/README.md b/docs/compression/README.md index beaf33b4c..eb08f05aa 100644 --- a/docs/compression/README.md +++ b/docs/compression/README.md @@ -118,7 +118,7 @@ even if compression is enabled for all types. ### 5. Notes -- MinIO does not support compression for Gateway (Azure/GCS/NAS) implementations. +- MinIO does not support compression for Gateway implementations. ## To test the setup diff --git a/docs/disk-caching/README.md b/docs/disk-caching/README.md index 2020d3b5a..02e218d10 100644 --- a/docs/disk-caching/README.md +++ b/docs/disk-caching/README.md @@ -1,6 +1,6 @@ # Disk Cache Quickstart Guide [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io) -Disk caching feature here refers to the use of caching disks to store content closer to the tenants. For instance, if you access an object from a lets say `gateway azure` setup and download the object that gets cached, each subsequent request on the object gets served directly from the cache drives until it expires. This feature allows MinIO users to have +Disk caching feature here refers to the use of caching disks to store content closer to the tenants. For instance, if you access an object from a lets say `gateway s3` setup and download the object that gets cached, each subsequent request on the object gets served directly from the cache drives until it expires. This feature allows MinIO users to have - Object to be delivered with the best possible performance. - Dramatic improvements for time to first byte for any object. diff --git a/docs/gateway/README.md b/docs/gateway/README.md index 7395403a4..9ad8a4152 100644 --- a/docs/gateway/README.md +++ b/docs/gateway/README.md @@ -10,4 +10,3 @@ MinIO Gateway adds Amazon S3 compatibility layer to third party NAS and Cloud St - [NAS](https://github.com/minio/minio/blob/master/docs/gateway/nas.md) - [S3](https://github.com/minio/minio/blob/master/docs/gateway/s3.md) -- [Microsoft Azure Blob Storage](https://github.com/minio/minio/blob/master/docs/gateway/azure.md) diff --git a/docs/gateway/azure.md b/docs/gateway/azure.md deleted file mode 100644 index 671ea9148..000000000 --- a/docs/gateway/azure.md +++ /dev/null @@ -1,79 +0,0 @@ -# MinIO Azure Gateway [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io) - -MinIO Gateway adds Amazon S3 compatibility to Microsoft Azure Blob Storage. - -## Support - -Gateway implementations are frozen and are not accepting any new features. Please reports any bugs at . If you are an existing customer please login to for production support. - -## Run MinIO Gateway for Microsoft Azure Blob Storage - -### Using Docker - -``` -podman run \ - -p 9000:9000 \ - -p 9001:9001 \ - --name azure-s3 \ - -e "MINIO_ROOT_USER=azurestorageaccountname" \ - -e "MINIO_ROOT_PASSWORD=azurestorageaccountkey" \ - quay.io/minio/minio gateway azure --console-address ":9001" -``` - -### Using Binary - -``` -export MINIO_ROOT_USER=azureaccountname -export MINIO_ROOT_PASSWORD=azureaccountkey -minio gateway azure -``` - -## Test using MinIO Console - -MinIO Gateway comes with an embedded web based object browser. Point your web browser to to ensure that your server has started successfully. - -| Dashboard | Creating a bucket | -| ------------- | ------------- | -| ![Dashboard](https://github.com/minio/minio/blob/master/docs/screenshots/pic1.png?raw=true) | ![Dashboard](https://github.com/minio/minio/blob/master/docs/screenshots/pic2.png?raw=true) | - -## Test using MinIO Client `mc` - -`mc` provides a modern alternative to UNIX commands such as ls, cat, cp, mirror, diff etc. It supports filesystems and Amazon S3 compatible cloud storage services. - -### Configure `mc` - -``` -mc alias set myazure http://gateway-ip:9000 azureaccountname azureaccountkey -``` - -### List containers on Microsoft Azure - -``` -mc ls myazure -[2017-02-22 01:50:43 PST] 0B ferenginar/ -[2017-02-26 21:43:51 PST] 0B my-container/ -[2017-02-26 22:10:11 PST] 0B test-container1/ -``` - -### Use custom access/secret keys - -If you do not want to share the credentials of the Azure blob storage with your users/applications, you can set the original credentials in the shell environment using `AZURE_STORAGE_ACCOUNT` and `AZURE_STORAGE_KEY` variables and assign different access/secret keys to `MINIO_ROOT_USER` and `MINIO_ROOT_PASSWORD`. - -### Known limitations - -Gateway inherits the following Azure limitations: - -- Only read-only bucket policy supported at bucket level, all other variations will return API Notimplemented error. -- Bucket names with "." in the bucket name are not supported. -- Non-empty buckets get removed on a DeleteBucket() call. -- _List Multipart Uploads_ always returns empty list. - -Other limitations: - -- Bucket notification APIs are not supported. - -## Explore Further - -- [`mc` command-line interface](https://docs.min.io/docs/minio-client-quickstart-guide) -- [`aws` command-line interface](https://docs.min.io/docs/aws-cli-with-minio) -- [`minio-go` Go SDK](https://docs.min.io/docs/golang-client-quickstart-guide) diff --git a/go.mod b/go.mod index 3c3bea7b0..fb3319261 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.17 require ( cloud.google.com/go/storage v1.10.0 - github.com/Azure/azure-pipeline-go v0.2.2 github.com/Azure/azure-storage-blob-go v0.10.0 github.com/Shopify/sarama v1.30.0 github.com/alecthomas/participle v0.2.1 @@ -96,6 +95,7 @@ require ( cloud.google.com/go v0.100.2 // indirect cloud.google.com/go/compute v0.1.0 // indirect cloud.google.com/go/iam v0.2.0 // indirect + github.com/Azure/azure-pipeline-go v0.2.2 // indirect github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c // indirect github.com/apache/thrift v0.15.0 // indirect github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect